X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Femails.inc.php;h=f2f12e034154cc731ff0d8609e66abd65966b21a;hb=3424387cde6c635ff16c3b5459c4caa88bb76e2e;hp=bd24d3ead5bccd6e28aeb301974d52288285e48d;hpb=673e56aa757fce4ea57c27ab2c0d5ce87d713e51;p=platal.git diff --git a/include/emails.inc.php b/include/emails.inc.php index bd24d3e..f2f12e0 100644 --- a/include/emails.inc.php +++ b/include/emails.inc.php @@ -1,6 +1,6 @@ checkPerms(User::PERM_MAIL) && strtolower($new_email) != strtolower($user->forlifeEmail()); + $is_new = !$user->checkPerms(User::PERM_MAIL) && $new_email != strtolower($user->email); + if ($new_email && $is_new) { + $already = XDB::fetchOneCell('SELECT hruid + FROM accounts + WHERE email = {?} AND uid != {?}', + $new_email, $user->id()); + if ($already) { + Platal::page()->trigError("L'email ne peut pas être utilisé pour ce compte car il correspond déjà au compte : " + . $already . ". Si l'utilisateur courant et cette personne ne sont en fait qu'une " + . "seul et même personne, ou en cas de problème, contacter : contact@polytechnique.org"); + return false; + } + } + return $is_new; } function format_email_alias($email) @@ -528,7 +541,7 @@ class Email // Activates the email address as a redirection. public function activate() { - if ($this->inactive) { + if (!$this->active) { if (in_array($this->type, self::get_allowed_storages($this->user))) { self::activate_storage($this->user, $this->type, $this->action); } else { @@ -538,6 +551,8 @@ class Email $this->user->id(), $this->email); } S::logger()->log('email_on', $this->email . ($this->user->id() != S::v('uid') ? "(admin on {$this->user->login()})" : '')); + $this->disabled = false; + $this->broken = false; $this->inactive = false; $this->active = true; } @@ -803,6 +818,10 @@ class Redirect XDB::execute('REPLACE INTO email_redirect_account (uid, redirect, flags, action) VALUES ({?}, {?}, \'active\', {?})', $this->user->id(), $email, $filter); + // Replace this email by forlife email, if present in aliases and MLs. + $listClient = new MMList(S::user()); + $listClient->change_user_email($email, $this->user->forlifeEmail()); + update_alias_user($email, $this->user->forlifeEmail()); if ($logger = S::v('log', null)) { // may be absent --> step4.php S::logger()->log('email_add', $email . ($this->user->id() != S::v('uid') ? " (admin on {$this->user->login()})" : "")); } @@ -994,5 +1013,5 @@ class Redirect } } -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: ?>