Skip to content

Commit

Permalink
MDL-17559 user edit: fixed undefined email property warnings; merged …
Browse files Browse the repository at this point in the history
…from MOODLE_19_STABLE
  • Loading branch information
skodak committed Dec 8, 2008
1 parent 2f5237e commit d0b2acd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion user/edit.php
Expand Up @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions user/edit_form.php
Expand Up @@ -113,17 +113,19 @@ function validation($usernew, $files) {
$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;
Expand Down

0 comments on commit d0b2acd

Please sign in to comment.