From: scyrma Date: Fri, 21 Dec 2007 08:19:14 +0000 (+0000) Subject: Let the admin choose if a textfield is to be shown as plain text or as a password... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=2803993c02ad4871438300fbed28ce3e555841b1;p=moodle.git Let the admin choose if a textfield is to be shown as plain text or as a password (with '*' in place of normal text) --- diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index 96c92a8cad..003bbaa156 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -527,6 +527,7 @@ $string['profilefieldtypemenu'] = 'Menu of choices'; $string['profilefieldtypetext'] = 'Text input'; $string['profilefieldtypetextarea'] = 'Text area'; $string['profilefieldmaxlength'] = 'Maximum length'; +$string['profilefieldispassword'] = 'Is this a password field?'; $string['profileforceunique'] = 'Should the data be unique?'; $string['profileinvaliddata'] = 'Invalid value'; $string['profilelocked'] = 'Is this field locked?'; diff --git a/user/profile/field/text/define.class.php b/user/profile/field/text/define.class.php index 7de9ec9ff7..74d20770dd 100644 --- a/user/profile/field/text/define.class.php +++ b/user/profile/field/text/define.class.php @@ -16,8 +16,13 @@ class profile_define_text extends profile_define_base { $form->addElement('text', 'param2', get_string('profilefieldmaxlength', 'admin'), 'size="6"'); $form->setDefault('param2', 2048); $form->setType('param2', PARAM_INT); + + /// Param 3 for text type detemines if this is a password field or not + $form->addElement('selectyesno', 'param3', get_string('profilefieldispassword', 'admin')); + $form->setDefault('param3', 0); // defaults to 'no' + $form->setType('param3', PARAM_INT); } } -?> \ No newline at end of file +?> diff --git a/user/profile/field/text/field.class.php b/user/profile/field/text/field.class.php index da7c1636e6..2c0ae1a45a 100644 --- a/user/profile/field/text/field.class.php +++ b/user/profile/field/text/field.class.php @@ -5,9 +5,10 @@ class profile_field_text extends profile_field_base { function edit_field_add(&$mform) { $size = $this->field->param1; $maxlength = $this->field->param2; + $fieldtype = ($this->field->param3 == 1 ? 'password' : 'text'); /// Create the form field - $mform->addElement('text', $this->inputname, format_string($this->field->name), 'maxlength="'.$maxlength.'" size="'.$size.'" '); + $mform->addElement($fieldtype, $this->inputname, format_string($this->field->name), 'maxlength="'.$maxlength.'" size="'.$size.'" '); $mform->setType($this->inputname, PARAM_MULTILANG); }