From d0b2acde4f9fe6c9052cd7c0a7900ba617bb6cf3 Mon Sep 17 00:00:00 2001 From: skodak Date: Mon, 8 Dec 2008 20:16:49 +0000 Subject: [PATCH] MDL-17559 user edit: fixed undefined email property warnings; merged from MOODLE_19_STABLE --- user/edit.php | 2 +- user/edit_form.php | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/user/edit.php b/user/edit.php index 7bf8b327ec..4544635bb2 100644 --- a/user/edit.php +++ b/user/edit.php @@ -116,7 +116,7 @@ if ($CFG->emailchangeconfirmation) { // Handle change of email carefully for non-trusted users - if ($user->email != $usernew->email && !has_capability('moodle/user:update', $systemcontext)) { + if (isset($usernew->email) and $user->email != $usernew->email && !has_capability('moodle/user:update', $systemcontext)) { $a = new stdClass(); $a->newemail = $usernew->preference_newemail = $usernew->email; $usernew->preference_newemailkey = random_string(20); diff --git a/user/edit_form.php b/user/edit_form.php index bc57cea03a..6341317dbf 100644 --- a/user/edit_form.php +++ b/user/edit_form.php @@ -113,17 +113,19 @@ class user_edit_form extends moodleform { $user = $DB->get_record('user', array('id'=>$usernew->id)); // validate email - if (!validate_email($usernew->email)) { + if (!isset($usernew->email)) { + // mail not confirmed yet + } else if (!validate_email($usernew->email)) { $errors['email'] = get_string('invalidemail'); } else if (($usernew->email !== $user->email) and $DB->record_exists('user', array('email'=>$usernew->email, 'mnethostid'=>$CFG->mnet_localhost_id))) { $errors['email'] = get_string('emailexists'); } - if ($usernew->email === $user->email and over_bounce_threshold($user)) { + if (isset($usernew->email) and $usernew->email === $user->email and over_bounce_threshold($user)) { $errors['email'] = get_string('toomanybounces'); } - if (!empty($CFG->verifychangedemail) and !isset($errors['email']) and !has_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM))) { + if (isset($usernew->email) and !empty($CFG->verifychangedemail) and !isset($errors['email']) and !has_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM))) { $errorstr = email_is_not_allowed($usernew->email); if ($errorstr !== false) { $errors['email'] = $errorstr; -- 2.39.5