X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Femails.inc.php;h=ec7946da55b5027bcd9b1c8369485ace9ed308a8;hb=ecf2b474289f94932ff60ab18674610979d0e0db;hp=f285f08858ef8adf46cbe4a91e4d8f2aa41e6743;hpb=805f3d1679a53bb04fff34619c171a1381068612;p=platal.git diff --git a/include/emails.inc.php b/include/emails.inc.php index f285f08..ec7946d 100644 --- a/include/emails.inc.php +++ b/include/emails.inc.php @@ -1,6 +1,6 @@ user = &$user; $this->sufficient = true; - list($this->email, $flags, $this->rewrite, $this->panne, $this->last, $this->panne_level) = $row; + list($this->email, $flags, $this->rewrite, $this->allow_rewrite, $this->hash, $this->panne, $this->last, $this->panne_level) = $row; $this->display_email = $this->email; $this->active = ($flags == 'active'); $this->broken = ($flags == 'panne'); @@ -227,6 +229,22 @@ class EmailRedirection extends Email } XDB::execute('UPDATE emails SET rewrite = {?} WHERE uid = {?} AND email = {?}', $rewrite, $this->user->id(), $this->email); $this->rewrite = $rewrite; + if (!$this->allow_rewrite) { + global $globals; + if (empty($this->hash)) { + $this->hash = rand_url_id(); + XDB::execute("UPDATE emails + SET hash = {?} + WHERE uid = {?} AND email = {?}", $this->hash, $this->user->id(), $this->email); + } + $mail = new PlMailer('emails/rewrite-in.mail.tpl'); + $mail->assign('mail', $this); + $mail->assign('user', $this->user); + $mail->assign('baseurl', $globals->baseurl); + $mail->assign('sitename', $globals->core->sitename); + $mail->assign('to', $this->email); + $mail->send($this->user->isEmailFormatHtml()); + } return; } @@ -388,7 +406,7 @@ class Redirect $this->bogo = new Bogo($user); // Adds third-party email redirections. - $res = XDB::iterRow("SELECT email, flags, rewrite, panne, last, panne_level + $res = XDB::iterRow("SELECT email, flags, rewrite, allow_rewrite, hash, panne, last, panne_level FROM emails WHERE uid = {?} AND flags != 'filter'", $user->id()); $this->emails = Array(); @@ -452,7 +470,7 @@ class Redirect return SUCCESS; } } - $this->emails[] = new EmailRedirection($this->user, array($email, 'active', '', '0000-00-00', '0000-00-00', 0)); + $this->emails[] = new EmailRedirection($this->user, array($email, 'active', '', 0, null, '0000-00-00', '0000-00-00', 0)); // security stuff check_email($email, "Ajout d'une adresse surveillée aux redirections de " . $this->user->login()); @@ -535,7 +553,7 @@ class Redirect { XDB::execute("UPDATE emails SET flags = 'disable' - WHERE flags = 'active' AND uid = {?}", $this->user->id); + WHERE flags = 'active' AND uid = {?}", $this->user->id()); foreach ($this->emails as &$mail) { if ($mail->active && $mail->has_disable()) { $mail->disabled = true; @@ -551,7 +569,7 @@ class Redirect { XDB::execute("UPDATE emails SET flags = 'active' - WHERE flags = 'disable' AND uid = {?}", $this->user->id); + WHERE flags = 'disable' AND uid = {?}", $this->user->id()); foreach ($this->emails as &$mail) { if ($mail->disabled) { $mail->active = true;