]> git.mjollnir.org Git - moodle.git/commitdiff
Let the admin choose if a textfield is to be shown as plain text or as a password...
authorscyrma <scyrma>
Fri, 21 Dec 2007 08:19:14 +0000 (08:19 +0000)
committerscyrma <scyrma>
Fri, 21 Dec 2007 08:19:14 +0000 (08:19 +0000)
lang/en_utf8/admin.php
user/profile/field/text/define.class.php
user/profile/field/text/field.class.php

index 96c92a8cad4d49ca4b7c6854addf4ac2696c9a4c..003bbaa1568a720cac3fc115bbec5b4feca19f78 100644 (file)
@@ -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?';
index 7de9ec9ff7f3ce779dd91d6a5b0022effd8b662c..74d20770ddadd2b6581d0bc8a5029214eb9b77fa 100644 (file)
@@ -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
+?>
index da7c1636e68752eb99c791b1cd3347befb5e23b9..2c0ae1a45a8c38238e0d3d2aaa5226e2130bf3d4 100644 (file)
@@ -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);
     }