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()) {
$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;
}
}
}
$_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)
</p>
{/if}
-{if $smarty.session.mx_failures|@count}
+{if $smarty.session.email_is_warning}
<fieldset>
<legend>{icon name=error} Des problèmes sont actuellement recontrés sur tes redirections suivantes</legend>
{foreach from=$smarty.session.mx_failures item=mail}