Oops
[platal.git] / modules / email.php
index 0e7a1b4..feb1870 100644 (file)
@@ -190,6 +190,8 @@ class EmailModule extends PLModule
         $uid     = S::v('uid');
         $forlife = S::v('forlife');
 
+        $page->assign('eleve', S::i('promo') >= date("Y") - 5);
+
         $redirect = new Redirect(S::v('uid'));
 
         if ($action == 'remove' && $email) {
@@ -370,7 +372,15 @@ L'
                 if ($x = $sel->fetchOneAssoc()) {
                     // on écrit dans la base que l'adresse est cassée
                     if (!$x['panne']) {
-                        XDB::execute("UPDATE emails SET panne=NOW() WHERE email = {?}", $email);
+                        XDB::execute("UPDATE emails
+                                         SET panne=NOW(),
+                                             last=NOW(),
+                                             panne_level = 1
+                                       WHERE email = {?}", $email);
+                    } else {
+                        XDB::execute("UPDATE emails
+                                         SET panne_level = 1
+                                       WHERE email = {?} AND panne_level = 0");
                     }
                     $page->assign_by_ref('x', $x);
                 }
@@ -416,8 +426,8 @@ L'
         if ($action == 'list') {
             $sql = "SELECT  w.email, w.detection, w.state, a.alias AS forlife
                       FROM  emails_watch  AS w
-                INNER JOIN  emails        AS e USING(email)
-                INNER JOIN  aliases       AS a ON (a.id = e.uid AND a.type = 'a_vie')
+                 LEFT JOIN  emails        AS e USING(email)
+                 LEFT JOIN  aliases       AS a ON (a.id = e.uid AND a.type = 'a_vie')
                   ORDER BY  w.state, w.email, a.alias";
             $it = Xdb::iterRow($sql);
 
@@ -444,9 +454,9 @@ L'
             $sql = "SELECT  w.detection, w.state, w.last, w.description,
                             a1.alias AS edit, a2.alias AS forlife
                       FROM  emails_watch AS w
-                INNER JOIN  emails       AS e  USING(email)
-                 LEFT JOIN  aliases      AS a1 ON (a1.id = w.uid AND a1.type = 'a_vie')
-                INNER JOIN  aliases      AS a2 ON (a2.id = e.uid AND a2.type = 'a_vie')
+                 LEFT JOIN  aliases      AS a1 ON (a1.id = w.uid AND a1.type = 'a_vie')     
+                 LEFT JOIN  emails       AS e  ON (w.email = e.email)
+                 LEFT JOIN  aliases      AS a2 ON (a2.id = e.uid AND a2.type = 'a_vie')
                      WHERE  w.email = {?}
                   ORDER BY  a2.alias";
             $it = Xdb::iterRow($sql, $email);