From: Florent Bruneau Date: Sat, 13 Oct 2007 10:15:58 +0000 (+0200) Subject: Don't show warning mx on the front page if the user has another valid X-Git-Tag: xorg/0.9.16~279 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=8f11b29f7600dfcc825065ce9e89e3c7866de5c6;p=platal.git Don't show warning mx on the front page if the user has another valid redirection Signed-off-by: Florent Bruneau --- diff --git a/include/emails.inc.php b/include/emails.inc.php index 2597086..a8eef27 100644 --- a/include/emails.inc.php +++ b/include/emails.inc.php @@ -372,7 +372,7 @@ class Redirect public function get_broken_mx() { - $res = XDB::query("SELECT host, text + $res = XDB::query("SELECT host, text, state FROM mx_watch WHERE state != 'ok'"); if (!$res->numRows()) { @@ -388,15 +388,17 @@ class Redirect $lcl_mxs = array($domain); } $broken = false; + $state = false; foreach ($mxs as &$mx) { foreach ($lcl_mxs as $lcl) { if (fnmatch($mx['host'], $lcl)) { $broken = $mx['text']; + $state = $mx['state']; break; } } if ($broken) { - $mails[] = array('mail' => $mail->email, 'text' => $broken); + $mails[] = array('mail' => $mail->email, 'text' => $broken, 'state' => $state); break; } } diff --git a/include/xorg.misc.inc.php b/include/xorg.misc.inc.php index 96db292..2ecaab8 100644 --- a/include/xorg.misc.inc.php +++ b/include/xorg.misc.inc.php @@ -287,6 +287,20 @@ function check_redirect($red = null) } $_SESSION['no_redirect'] = !$red->other_active(''); $_SESSION['mx_failures'] = $red->get_broken_mx(); + $warning = 0; + foreach ($red->emails as &$mail) { + if ($mail->active) { + $warning++; + } + } + foreach ($_SESSION['mx_failures'] as &$fail) { + if ($fail['state'] == 'broken') { + $warning -= 99999; + } else if ($fail['state'] == 'warning') { + $warning--; + } + } + $_SESSION['email_is_warning'] = ($warning <= 0 ? true : false); } function send_warning_mail($title) diff --git a/templates/events/index.tpl b/templates/events/index.tpl index 72424d3..37d844e 100644 --- a/templates/events/index.tpl +++ b/templates/events/index.tpl @@ -49,7 +49,7 @@ Bienvenue {$smarty.session.prenom}{if $birthday}

{/if} -{if $smarty.session.mx_failures|@count} +{if $smarty.session.email_is_warning}
{icon name=error} Des problèmes sont actuellement recontrés sur tes redirections suivantes {foreach from=$smarty.session.mx_failures item=mail}