X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Femails.inc.php;h=e6ae4492f7c68dc2cf4795d6c00ad013dc5de5d8;hb=89cb2025f5f2aed0be3994c89ac473aa11535853;hp=f285f08858ef8adf46cbe4a91e4d8f2aa41e6743;hpb=de14933c384281bfc5571b8b3d7d7ac94b04bc48;p=platal.git diff --git a/include/emails.inc.php b/include/emails.inc.php index f285f08..e6ae449 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; } @@ -281,18 +299,18 @@ class EmailStorage extends Email // Retrieves the current list of actives storages. private function get_storages() { - $res = XDB::query("SELECT mail_storage - FROM auth_user_md5 - WHERE user_id = {?}", $this->user->id()); - return new PlFlagSet($res->fetchOneCell()); + return new PlFlagSet(XDB::fetchOneCell('SELECT storage + FROM email_options + WHERE uid = {?}', + $this->user->id())); } // Updates the list of active storages. private function set_storages($storages) { - XDB::execute("UPDATE auth_user_md5 - SET mail_storage = {?} - WHERE user_id = {?}", $storages, $this->user->id()); + XDB::execute("UPDATE email_options + SET storage = {?} + WHERE uid = {?}", $storages, $this->user->id()); } // Returns the list of allowed storages for the @p user. @@ -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());