Merge branch 'w40_MDL-41176_m26_useredit' of https://github.com/skodak/moodle

This commit is contained in:
Sam Hemelryk
2013-09-30 11:55:19 +13:00
3 changed files with 22 additions and 10 deletions
+8 -4
View File
@@ -39,7 +39,7 @@ class core_user {
const NOREPLY_USER = -10;
/**
* Suppport user id.
* Support user id.
*/
const SUPPORT_USER = -20;
@@ -160,9 +160,11 @@ class core_user {
self::$supportuser = self::get_dummy_user_record();
self::$supportuser->id = self::SUPPORT_USER;
self::$supportuser->email = $CFG->supportemail;
self::$supportuser->firstname = $CFG->supportname ? $CFG->supportname : $supportuser->firstname;
if ($CFG->supportname) {
self::$supportuser->firstname = $CFG->supportname;
}
self::$supportuser->username = 'support';
self::$supportuser->maildisplay = true;
self::$supportuser->maildisplay = '1'; // Show to all.
}
// Send support msg to admin user if nothing is set above.
@@ -191,7 +193,7 @@ class core_user {
/**
* Return true is user id is greater than self::NOREPLY_USER and
* alternetely check db.
* alternatively check db.
*
* @param int $userid user id.
* @param bool $checkdb if true userid will be checked in db. By default it's false, and
@@ -199,6 +201,8 @@ class core_user {
* @return bool true is real user else false.
*/
public static function is_real_user($userid, $checkdb = false) {
global $DB;
if ($userid < 0) {
return false;
}
+10 -6
View File
@@ -236,15 +236,15 @@ if ($usernew = $userform->get_data()) {
// save custom profile fields data
profile_save_data($usernew);
// If email was changed and confirmation is required, send confirmation email now
// If email was changed and confirmation is required, send confirmation email now to the new address.
if ($email_changed && $CFG->emailchangeconfirmation) {
$temp_user = fullclone($user);
$temp_user = $DB->get_record('user', array('id'=>$user->id), '*', MUST_EXIST);
$temp_user->email = $usernew->preference_newemail;
$a = new stdClass();
$a->url = $CFG->wwwroot . '/user/emailupdate.php?key=' . $usernew->preference_newemailkey . '&id=' . $user->id;
$a->site = format_string($SITE->fullname, true, array('context' => context_course::instance(SITEID)));
$a->fullname = fullname($user, true);
$a->fullname = fullname($temp_user, true);
$emailupdatemessage = get_string('emailupdatemessage', 'auth', $a);
$emailupdatetitle = get_string('emailupdatetitle', 'auth', $a);
@@ -256,12 +256,16 @@ if ($usernew = $userform->get_data()) {
}
}
// reload from db
$usernew = $DB->get_record('user', array('id'=>$user->id));
// Reload from db, we need new full name on this page if we do not redirect.
$user = $DB->get_record('user', array('id'=>$user->id), '*', MUST_EXIST);
if ($USER->id == $user->id) {
// Override old $USER session variable if needed
foreach ((array)$usernew as $variable => $value) {
foreach ((array)$user as $variable => $value) {
if ($variable === 'description' or $variable === 'password') {
// These are not set for security nad perf reasons.
continue;
}
$USER->$variable = $value;
}
// preload custom fields
+4
View File
@@ -240,6 +240,10 @@ if ($usernew = $userform->get_data()) {
if ($user->id == $USER->id) {
// Override old $USER session variable
foreach ((array)$usernew as $variable => $value) {
if ($variable === 'description' or $variable === 'password') {
// These are not set for security nad perf reasons.
continue;
}
$USER->$variable = $value;
}
// preload custom fields