Merge commit 'origin/master' into fusionax
[platal.git] / modules / axletter.php
index 8bd7b2d..466dcc2 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  Copyright (C) 2003-2009 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -240,7 +240,7 @@ class AXLetterModule extends PLModule
             return;
         }
 
-        $page->kill("L'envoi de l'annonce {$al->title()} est annulĂ©");
+        $page->killSuccess("L'envoi de l'annonce {$al->title()} est annulĂ©.");
     }
 
     function handler_valid(&$page, $force = null)
@@ -260,7 +260,7 @@ class AXLetterModule extends PLModule
             return;
         }
 
-        $page->kill("L'envoi de l'annonce aura lieu dans l'heure qui vient.");
+        $page->killSuccess("L'envoi de l'annonce aura lieu dans l'heure qui vient.");
     }
 
     function handler_show(&$page, $nid = 'last')
@@ -268,16 +268,20 @@ class AXLetterModule extends PLModule
         $this->load('axletter.inc.php');
         $page->changeTpl('axletter/show.tpl');
 
-        $nl  = new AXLetter($nid);
-        if (Get::has('text')) {
-            $nl->toText($page, S::v('prenom'), S::v('nom'), S::v('femme'));
-        } else {
-            $nl->toHtml($page, S::v('prenom'), S::v('nom'), S::v('femme'));
-        }
-        if (Post::has('send')) {
-            $nl->sendTo(S::user()->login(), S::user()->bestEmail(),
-                        S::v('prenom'), S::v('nom'),
-                        S::v('femme'), S::v('mail_fmt') != 'texte');
+        try {
+            $nl = new AXLetter($nid);
+            if (Get::has('text')) {
+                $nl->toText($page, S::v('prenom'), S::v('nom'), S::v('femme'));
+            } else {
+                $nl->toHtml($page, S::v('prenom'), S::v('nom'), S::v('femme'));
+            }
+            if (Post::has('send')) {
+                $nl->sendTo(S::user()->login(), S::user()->bestEmail(),
+                            S::v('prenom'), S::v('nom'),
+                            S::v('femme'), S::v('mail_fmt') != 'texte');
+            }
+        } catch (MailNotFound $e) {
+            return PL_NOT_FOUND;
         }
     }
 
@@ -309,10 +313,9 @@ class AXLetterModule extends PLModule
 
         $page->changeTpl('axletter/admin.tpl');
         $res = XDB::iterator("SELECT IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom,
-                                     u.prenom, u.promo, a.alias AS forlife
+                                     u.prenom, u.promo, u.hruid
                                 FROM axletter_rights AS ar
-                          INNER JOIN auth_user_md5   AS u USING(user_id)
-                          INNER JOIN aliases         AS a ON (u.user_id = a.id AND a.type = 'a_vie')");
+                          INNER JOIN auth_user_md5   AS u USING(user_id)");
         $page->assign('admins', $res);
 
         $importer = new CSVImporter('axletter_ins');
@@ -366,7 +369,7 @@ class AXLetterModule extends PLModule
         return $id ? $id : '0';
     }
 
-    function createHash($line, $key)
+    function createHash($line, $partial_result, $key)
     {
         $hash = implode(time(), $line) . rand();
         $hash = md5($hash);