Add option for checking unknown emails for axletter
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Tue, 18 May 2010 15:42:59 +0000 (17:42 +0200)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Fri, 21 May 2010 18:13:26 +0000 (20:13 +0200)
And fixes a bug in email to uid mapping

Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
include/emails.inc.php
modules/axletter.php
templates/axletter/edit.tpl

index cd7e0a0..c1fd715 100644 (file)
@@ -151,7 +151,7 @@ function ids_from_mails(array $emails)
                             WHERE   email IN ($list)");
         foreach ($res->fetchAllRow() as $row) {
             list ($email, $uid) = $row;
-            $uids[$other_mails[$email]] = $uid;
+            $uids[$email] = $uid;
         }
     }
 
index 9eb253a..a890702 100644 (file)
@@ -153,6 +153,23 @@ class AXLetterModule extends PLModule
             }
 
             switch (@Post::v('valid')) {
+              case 'Vérifier':
+                // Same as 'preview', but performs a test of all provided emails
+                if ($subset) {
+                    require_once 'emails.inc.php';
+                    $ids = ids_from_mails($subset_to);
+                    $has_error = false;
+                    foreach ($subset_to as $e) {
+                        if (!array_key_exists($e, $ids)) {
+                            if (!$has_error) {
+                                $page->trigError("Emails inconnus :");
+                                $has_error = true;
+                            }
+                            $page->trigError($e);
+                        }
+                    }
+                }
+                // XXX : no break here, since Vérifier is a subcase of Aperçu.
               case 'Aperçu':
                 $this->load('axletter.inc.php');
                 $al = new AXLetter(array($id, $short_name, $subject, $title, $body, $signature,
index eeb4f72..914b565 100644 (file)
     <input type="hidden" name="echeance" value="{$echeance}" />
     {/if}
     <input type="submit" name="valid" value="Aperçu" />
+    {if $subset}
+    <input type="submit" name="valid" value="Vérifier" />
+    {/if}
     {if !$new}
     <input type="submit" name="valid" value="Confirmer" />
     {/if}