Typos.
[platal.git] / modules / lists.php
index a3224ea..4c5b223 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   *
@@ -31,6 +31,7 @@ class ListsModule extends PLModule
             'lists/create'    => $this->make_hook('create',    AUTH_MDP),
 
             'lists/members'   => $this->make_hook('members',   AUTH_COOKIE),
+            'lists/csv'       => $this->make_hook('csv',       AUTH_COOKIE),
             'lists/annu'      => $this->make_hook('annu',      AUTH_COOKIE),
             'lists/archives'  => $this->make_hook('archives',  AUTH_COOKIE),
             'lists/archives/rss' => $this->make_hook('rss',    AUTH_PUBLIC, 'user', NO_HTTPS),
@@ -46,12 +47,6 @@ class ListsModule extends PLModule
         );
     }
 
-    function on_subscribe($forlife, $uid, $promo, $password)
-    {
-        $this->prepare_client(null);
-        $this->client->subscribe("promo$promo");
-    }
-
     function prepare_client(&$page)
     {
         global $globals;
@@ -343,6 +338,25 @@ class ListsModule extends PLModule
         }
     }
 
+    function handler_csv(PlPage &$page, $liste = null)
+    {
+        if (is_null($liste)) {
+            return PL_NOT_FOUND;
+        }
+        $this->prepare_client($page);
+        $members = $this->client->get_members($liste);
+        $list = list_fetch_names(list_extract_members($members[1]));
+        header('Content-Type: text/x-csv; charset=utf-8;');
+        header('Pragma: ');
+        header('Cache-Control: ');
+
+        echo "email,nom,prenom,promo\n";
+        foreach ($list as $member) {
+            echo @$member['email'] . ',' . @$member['nom'] . ',' . @$member['prenom'] . ',' . @$member['promo'] . "\n";
+        }
+        exit;
+    }
+
     function handler_annu(&$page, $liste = null, $action = null, $subaction = null)
     {
         if (is_null($liste)) {
@@ -812,12 +826,16 @@ class ListsModule extends PLModule
                                  $type, $liste.$app.$domain);
                 }
                 $page->assign('deleted', true);
+                $page->trigSuccess('La liste a été détruite !');
             } else {
                 $page->kill('Une erreur est survenue lors de la suppression de la liste.<br />'
                          . 'Contact les administrateurs du site pour régler le problème : '
                          . '<a href="mailto:support@polytechnique.org">support@polytechnique.org</a>');
             }
         } elseif (list($details,$options) = $this->client->get_owner_options($liste)) {
+            if (!$details['own']) {
+                $page->trigWarning('Tu n\'es pas administrateur de la liste, mais du site.');
+            }
             $page->assign_by_ref('details', $details);
             $page->assign_by_ref('options', $options);
             $page->assign('bogo_level', $this->client->get_bogo_level($liste));