MDL-23692 forgotpw:adhere to site autocomp setting
authorPeter Bulmer <peter.bulmer@catalyst.net.nz>
Mon, 7 Oct 2013 10:29:29 +0000 (23:29 +1300)
committerPeter Bulmer <peter.bulmer@catalyst.net.nz>
Mon, 7 Oct 2013 10:29:29 +0000 (23:29 +1300)
login/set_password_form.php

index 8cfb6ab..62e8b5c 100644 (file)
@@ -43,13 +43,19 @@ class login_set_password_form extends moodleform {
      */
     public function definition() {
         global $USER, $CFG;
+        // Prepare a string showing whether the site wants login password autocompletion to be available to user.
+        if (empty($CFG->loginpasswordautocomplete)) {
+            $autocomplete = 'autocomplete="on"';
+        } else {
+            $autocomplete = '';
+        }
 
         $mform = $this->_form;
         $mform->setDisableShortforms(true);
         $mform->addElement('header', 'setpassword', get_string('setpassword'), '');
 
         // Include the username in the form so browsers will recognise that a password is being set.
-        $mform->addElement('text', 'username', '', 'style="display: none;" autocomplete="on"');
+        $mform->addElement('text', 'username', '', 'style="display: none;" ' . $autocomplete);
         $mform->setType('username', PARAM_RAW);
         // Token gives authority to change password.
         $mform->addElement('hidden', 'token', '');
@@ -61,12 +67,12 @@ class login_set_password_form extends moodleform {
         if (!empty($CFG->passwordpolicy)) {
             $mform->addElement('static', 'passwordpolicyinfo', '', print_password_policy());
         }
-        $mform->addElement('password', 'password', get_string('newpassword'), 'autocomplete="on"');
+        $mform->addElement('password', 'password', get_string('newpassword'), $autocomplete);
         $mform->addRule('password', get_string('required'), 'required', null, 'client');
         $mform->setType('password', PARAM_RAW);
 
         $strpasswordagain = get_string('newpassword') . ' (' . get_string('again') . ')';
-        $mform->addElement('password', 'password2', $strpasswordagain, 'autocomplete="on"');
+        $mform->addElement('password', 'password2', $strpasswordagain, $autocomplete);
         $mform->addRule('password2', get_string('required'), 'required', null, 'client');
         $mform->setType('password2', PARAM_RAW);