public static function onSetUserEmail(User $user, $newEmail, &$result, &$info) { $app = F::app(); $oldEmail = $user->getEmail(); $optionNewEmail = $user->getGlobalAttribute('new_email'); if (empty($optionNewEmail) && $newEmail != $oldEmail || !empty($optionNewEmail) && $newEmail != $optionNewEmail) { $user->setGlobalAttribute('new_email', $newEmail); $user->invalidateEmail(); if ($app->wg->EmailAuthentication) { $userLoginHelper = new UserLoginHelper(); $result = $userLoginHelper->sendReconfirmationEmail($user, $newEmail); if ($result->isGood()) { $info = 'eauth'; } } } elseif ($newEmail != $oldEmail) { // if the address is the same, don't change it $user->setEmail($newEmail); } return true; }
/** * Try to set a user's email address. * This does *not* try to validate the address. * Caller is responsible for checking $wgAuth. * @param $user User * @param $newaddr string New email address * @return Array (true on success or Status on failure, info string) */ public static function trySetUserEmail(User $user, $newaddr) { global $wgEnableEmail, $wgEmailAuthentication; $info = ''; // none if ($wgEnableEmail) { #<Wikia> $result = null; wfRunHooks('Preferences::SetUserEmail', array($user, $newaddr, &$result, &$info)); if (empty($result)) { #</Wikia> $oldaddr = $user->getEmail(); if ($newaddr != '' && $newaddr != $oldaddr) { # The user has supplied a new email address on the login page # new behaviour: set this new emailaddr from login-page into user database record $user->setEmail($newaddr); /* Wikia change - begin */ $user->invalidateEmail(); /* Wikia change - end */ if ($wgEmailAuthentication) { # Mail a temporary password to the dirty address. # User can come back through the confirmation URL to re-enable email. $type = $oldaddr != '' ? 'changed' : 'set'; $result = $user->sendConfirmationMail($type); if (!$result->isGood()) { return array($result, 'mailerror'); } $info = 'eauth'; } } elseif ($newaddr != $oldaddr) { // if the address is the same, don't change it $user->setEmail($newaddr); } /* Wikia change - begin */ } else { if (!$result->isGood()) { return array($result, 'mailerror'); } } /* Wikia change - end */ if ($oldaddr != $newaddr) { wfRunHooks('PrefsEmailAudit', array($user, $oldaddr, $newaddr)); } } return array(true, $info); }