| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php //$Id: forgot_password_form.php,v 1.7.2.1 2007/11/23 22:12:35 skodak Exp $ 2 3 require_once $CFG->libdir.'/formslib.php'; 4 5 class login_forgot_password_form extends moodleform { 6 7 function definition() { 8 $mform =& $this->_form; 9 $renderer =& $mform->defaultRenderer(); 10 11 $mform->addElement('header', '', get_string('passwordforgotten'), ''); 12 13 $mform->addElement('text', 'username', get_string('username')); 14 $mform->setType('username', PARAM_RAW); 15 16 $mform->addElement('text', 'email', get_string('email')); 17 $mform->setType('email', PARAM_RAW); 18 19 $this->add_action_buttons(true, get_string('ok')); 20 } 21 22 function validation($data, $files) { 23 global $CFG; 24 25 $errors = parent::validation($data, $files); 26 27 if ((!empty($data['username']) and !empty($data['email'])) or (empty($data['username']) and empty($data['email']))) { 28 $errors['username'] = get_string('usernameoremail'); 29 $errors['email'] = get_string('usernameoremail'); 30 31 } else if (!empty($data['email'])) { 32 if (!validate_email($data['email'])) { 33 $errors['email'] = get_string('invalidemail'); 34 35 } else if (count_records('user', 'email', $data['email']) > 1) { 36 $errors['email'] = get_string('forgottenduplicate'); 37 38 } else { 39 if ($user = get_complete_user_data('email', $data['email'])) { 40 if (empty($user->confirmed)) { 41 $errors['email'] = get_string('confirmednot'); 42 } 43 } 44 if (!$user and empty($CFG->protectusernames)) { 45 $errors['email'] = get_string('emailnotfound'); 46 } 47 } 48 49 } else { 50 if ($user = get_complete_user_data('username', $data['username'])) { 51 if (empty($user->confirmed)) { 52 $errors['email'] = get_string('confirmednot'); 53 } 54 } 55 if (!$user and empty($CFG->protectusernames)) { 56 $errors['username'] = get_string('usernamenotfound'); 57 } 58 } 59 60 return $errors; 61 } 62 63 } 64 65 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |