From: Stéphane Jacob Date: Sun, 6 Mar 2011 19:34:19 +0000 (+0100) Subject: Adapts imap action according to the number of other active reidrection of the user. X-Git-Tag: xorg/1.1.0~61 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=24e8f53b72f100e8ce11b016d8defdb51f9ce9c2;p=platal.git Adapts imap action according to the number of other active reidrection of the user. Signed-off-by: Stéphane Jacob --- diff --git a/bin/cron/emails.check.php b/bin/cron/emails.check.php index 8bab8ab..fb5fdd5 100755 --- a/bin/cron/emails.check.php +++ b/bin/cron/emails.check.php @@ -129,5 +129,15 @@ if ($opt_verbose) { echo "\n"; } +/* + * Updates imap settings for users with no active redirection. Their emails + * must go to imap and bounce. + */ +XDB::execute("UPDATE email_redirect_account AS r + LEFT JOIN email_redirect_account AS a ON (r.uid = a.uid AND a.flags = 'active' AND a.type != 'imap') + SET r.action = 'imap_and_bounce' + WHERE r.type = 'imap' AND a.redirect IS NULL"); + + // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?> diff --git a/include/emails.inc.php b/include/emails.inc.php index c9f35aa..4f0e1ba 100644 --- a/include/emails.inc.php +++ b/include/emails.inc.php @@ -651,6 +651,7 @@ class Redirect } } check_redirect($this); + $this->update_imap(); return SUCCESS; } @@ -696,6 +697,7 @@ class Redirect // security stuff check_email($email, "Ajout d'une adresse surveillée aux redirections de " . $this->user->login()); check_redirect($this); + $this->update_imap(); return SUCCESS; } @@ -710,6 +712,7 @@ class Redirect $email->set_rewrite($emails_rewrite[$email->email]); } check_redirect($this); + $this->update_imap(); return SUCCESS; } @@ -732,6 +735,7 @@ class Redirect $this->emails[$thisone]->deactivate(); } check_redirect($this); + $this->update_imap(); if ($allinactive && !$activate) { return ERROR_INACTIVE_REDIRECTION; } @@ -744,6 +748,7 @@ class Redirect if ($mail->email == $email) { $mail->set_rewrite($redirect); check_redirect($this); + $this->update_imap(); return; } } @@ -754,6 +759,7 @@ class Redirect foreach ($this->emails as &$mail) { if ($mail->email == $email) { check_redirect($this); + $this->update_imap(); return $mail->clean_errors(); } } @@ -772,6 +778,7 @@ class Redirect } } check_redirect($this); + $this->update_imap(); } public function enable() @@ -786,6 +793,7 @@ class Redirect } check_redirect($this); } + $this->update_imap(); } public function get_broken_mx() @@ -838,6 +846,22 @@ class Redirect { return $this->user->id(); } + + private function update_imap() + { + // Imaps must bounce if and only if the user has no active redirection. + if (!$this->other_active('')) { + XDB::execute('UPDATE email_redirect_account + SET action = \'imap_and_bounce\' + WHERE type = \'imap\' AND uid = {?}', + $this->user->id()); + } else { + XDB::execute('UPDATE email_redirect_account + SET action = \'let_spams\' + WHERE type = \'imap\' AND uid = {?}', + $this->user->id()); + } + } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: