From cb8de1ba2171fda35bf5ca6f41e3942344a22a84 Mon Sep 17 00:00:00 2001 From: Sesostris Vieira Date: Mon, 7 Jul 2014 11:20:05 -0300 Subject: [PATCH] =?UTF-8?q?Corre=C3=A7=C3=A3o=20de=20bug=20para=20CPFs=20c?= =?UTF-8?q?ome=C3=A7ados=20com=20d=C3=ADgito=20zero?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- field.class.php | 24 +++++------------------- lang/en/profilefield_cpf.php | 1 + 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/field.class.php b/field.class.php index f761b96..7932001 100644 --- a/field.class.php +++ b/field.class.php @@ -1,38 +1,23 @@ field->param4) and !empty($data)) { - - /// Define the target - if (! empty($this->field->param5)) { - $target = 'target="'.$this->field->param5.'"'; - } else { - $target = ''; - } - - /// Create the link - $data = ''.htmlspecialchars($data).''; - } -*/ return $data; } function edit_field_add($mform) { /// Create the form field $mform->addElement('text', $this->inputname, format_string($this->field->name), 'maxlength="11" size="11"'); - $mform->setType($this->inputname, PARAM_INT); + $mform->setType($this->inputname, PARAM_TEXT); } function edit_validate_field($usernew) { @@ -40,6 +25,9 @@ class profile_field_cpf extends profile_field_base { $errors = array(); if (isset($usernew->{$this->inputname})) { $cpf = $usernew->{$this->inputname}; + if (ctype_digit($cpf)) { + return array($this->inputname => get_string('cpf_digits', 'profilefield_cpf')); + } if (strlen($cpf) != 11) { return array($this->inputname => get_string('cpf_size', 'profilefield_cpf')); } @@ -62,5 +50,3 @@ class profile_field_cpf extends profile_field_base { } } - - diff --git a/lang/en/profilefield_cpf.php b/lang/en/profilefield_cpf.php index 155f114..73853af 100644 --- a/lang/en/profilefield_cpf.php +++ b/lang/en/profilefield_cpf.php @@ -24,5 +24,6 @@ */ $string['pluginname'] = 'Brazilian CPF'; +$string['cpf_digits'] = 'CPF must have only numeric digits'; $string['cpf_size'] = 'CPF must have 11 digits'; $string['cpf_invalid'] = 'Invalid CPF';