$message = get_string('usercannotchangepassword', 'mnet'); if ($idprovider = $DB->get_record('mnet_host', array('id' => $USER->mnethostid))) { $message .= get_string('userchangepasswordlink', 'mnet', $idprovider); } print_error('userchangepasswordlink', 'mnet', '', $message); } // load the appropriate auth plugin $userauth = get_auth_plugin($USER->auth); if (!$userauth->can_change_password()) { print_error('nopasswordchange', 'auth'); } if ($changeurl = $userauth->change_password_url()) { // this internal scrip not used redirect($changeurl); } $mform = new login_change_password_form(); $mform->set_data(array('id' => $course->id)); $navlinks = array(); $navlinks[] = array('name' => $strparticipants, 'link' => "{$CFG->wwwroot}/user/index.php?id={$course->id}", 'type' => 'misc'); if ($mform->is_cancelled()) { redirect($CFG->wwwroot . '/user/view.php?id=' . $USER->id . '&course=' . $course->id); } else { if ($data = $mform->get_data()) { if (!$userauth->user_update_password($USER, $data->newpassword1)) { print_error('errorpasswordupdate', 'auth'); } // register success changing password unset_user_preference('auth_forcepasswordchange', $USER->id); $strpasswordchanged = get_string('passwordchanged'); add_to_log($course->id, 'user', 'change password', "view.php?id={$USER->id}&course={$course->id}", "{$USER->id}"); $fullname = fullname($USER, true);
print_error('userchangepasswordlink', 'mnet', '', $message); } // load the appropriate auth plugin $userauth = get_auth_plugin($USER->auth); if (!$userauth->can_change_password()) { print_error('nopasswordchange', 'auth'); } if ($changeurl = $userauth->change_password_url()) { // this internal scrip not used redirect($changeurl); } $mform = new login_change_password_form(); if ($mform->is_cancelled()) { redirect($CFG->wwwroot); } else if ($data = $mform->get_data()) { if (!$userauth->user_update_password($USER, $data->newpassword1)) { print_error('errorpasswordupdate', 'auth'); } else { $conf = new object(); $conf->username = $DB->get_field('user', 'username', array('id' => $USER->id)); $messages = get_string('msg_pwd_change', 'local_users', $conf); $userfrom = $DB->get_record('user', array('id' => $USER->id)); $userto = $DB->get_record('user', array('id' => $USER->id)); $message_post_message = message_post_message($userfrom, $userto, $messages, FORMAT_HTML); $message = get_string('passwordchange', 'local_users');