Link to marketing/broken/{forlife} instead of marketing/broken/uid
[platal.git] / modules / lists.php
index c6fb9dc..7111516 100644 (file)
@@ -31,7 +31,7 @@ class ListsModule extends PLModule
             'lists/create'    => $this->make_hook('create',    AUTH_MDP),
 
             'lists/members'   => $this->make_hook('members',   AUTH_COOKIE),
-            'lists/trombi'    => $this->make_hook('trombi',    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),
 
@@ -225,16 +225,6 @@ class ListsModule extends PLModule
         }
     }
 
-    function changeTpl($tpl)
-    {
-        if (!empty($GLOBALS['IS_XNET_SITE'])) {
-            new_group_open_page($tpl);
-        } else {
-            global $page;
-            $page->changeTpl($tpl);
-        }
-    }
-
     function handler_members(&$page, $liste = null)
     {
         if (is_null($liste)) {
@@ -243,7 +233,7 @@ class ListsModule extends PLModule
 
         $this->prepare_client($page);
 
-        $this->changeTpl('lists/members.tpl');
+        $page->changeTpl('lists/members.tpl');
 
         if (Get::has('del')) {
             $this->client->unsubscribe($liste);
@@ -272,42 +262,7 @@ class ListsModule extends PLModule
         }
     }
 
-    function compare($a, $b)
-    {
-        if ($a['promo'] == $b['promo']) {
-            if ($a['nom'] == $b['nom']) {
-                return strcmp($a['prenom'], $b['prenom']);
-            }
-            return strcmp($a['nom'], $b['nom']);
-        }
-        return $a['promo'] - $b['promo'];
-    }
-
-    function _get_list($offset, $limit)
-    {
-        global $platal;
-        list($total, $members) = $this->client->get_members_limit($platal->argv[1], $offset, $limit);
-
-        $membres = Array();
-        foreach ($members as $member) {
-            list($m) = explode('@',$member[1]);
-            $res = XDB::query("SELECT  prenom,if (nom_usage='', nom, nom_usage) AS nom,
-                                                 promo, a.alias AS forlife
-                                           FROM  auth_user_md5 AS u
-                                     INNER JOIN  aliases AS a ON u.user_id = a.id
-                                     INNER JOIN  photo AS p ON p.uid = u.user_id
-                                          WHERE  a.alias = {?}", $m);
-            if ($tmp = $res->fetchOneAssoc()) {
-                $membres[$tmp['nom']] = $tmp;
-            } else {
-                $total--;
-            }
-        }
-        uasort($membres, array($this, 'compare'));
-        return array($total, $membres);
-    }
-
-    function handler_trombi(&$page, $liste = null)
+    function handler_annu(&$page, $liste = null, $action = null, $subaction = null)
     {
         if (is_null($liste)) {
             return PL_NOT_FOUND;
@@ -315,30 +270,42 @@ class ListsModule extends PLModule
 
         $this->prepare_client($page);
 
-        $this->changeTpl('lists/trombi.tpl');
-
         if (Get::has('del')) {
             $this->client->unsubscribe($liste);
-            pl_redirect('lists/trombi/'.$liste);
+            pl_redirect('lists/annu/'.$liste);
         }
         if (Get::has('add')) {
             $this->client->subscribe($liste);
-            pl_redirect('lists/trombi/'.$liste);
+            pl_redirect('lists/annu/'.$liste);
         }
 
         $owners = $this->client->get_owners($liste);
-
-        if (is_array($owners)) {
-            $moderos = list_sort_owners($owners[1]);
-
-            $page->assign_by_ref('details', $owners[0]);
-            $page->assign_by_ref('owners',  $moderos);
-
-            $trombi = new Trombi(array(&$this, '_get_list'));
-            $page->assign('trombi', $trombi);
-        } else {
+        if (!is_array($owners)) {
             $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails");
         }
+
+        global $platal;
+        list(,$members) = $this->client->get_members($liste);
+        $users = array();
+        foreach ($members as $m) {
+            $users[] = $m[1];
+        }
+        require_once 'userset.inc.php';
+        $view = new ArraySet($users);
+        $view->addMod('trombi', 'Trombinoscope', true, array('with_promo' => true));
+        if (empty($GLOBALS['IS_XNET_SITE'])) {
+            $view->addMod('minifiche', 'Minifiches', false);
+        }
+        $view->addMod('geoloc', 'Planisphère');
+        $view->apply("lists/annu/$liste", $page, $action, $subaction);
+        if ($action == 'geoloc' && $subaction) {
+            return;
+        }
+
+        $page->changeTpl('lists/annu.tpl');
+        $moderos = list_sort_owners($owners[1]);
+        $page->assign_by_ref('details', $owners[0]);
+        $page->assign_by_ref('owners',  $moderos);
     }
 
     function handler_archives(&$page, $liste = null, $action = null, $artid = null)
@@ -351,7 +318,7 @@ class ListsModule extends PLModule
 
         $domain = $this->prepare_client($page);
 
-        $this->changeTpl('lists/archives.tpl');
+        $page->changeTpl('lists/archives.tpl');
 
         if (list($det) = $this->client->get_members($liste)) {
             if (substr($liste,0,5) != 'promo' && ($det['ins'] || $det['priv'])
@@ -451,7 +418,7 @@ class ListsModule extends PLModule
 
         $domain = $this->prepare_client($page);
 
-        $this->changeTpl('lists/moderate.tpl');
+        $page->changeTpl('lists/moderate.tpl');
 
         $page->register_modifier('hdc', 'list_header_decode');
 
@@ -513,7 +480,7 @@ class ListsModule extends PLModule
             if (list($subs,$mails) = $this->client->get_pending_ops($liste)) {
                 foreach($subs as $user) {
                     if ($user['id'] == Env::v('sid')) {
-                        $this->changeTpl('lists/moderate_sub.tpl');
+                        $page->changeTpl('lists/moderate_sub.tpl');
                         $page->assign('del_user', $user);
                         return;
                     }
@@ -559,7 +526,7 @@ class ListsModule extends PLModule
 
         $domain = $this->prepare_client($page);
 
-        $this->changeTpl('lists/admin.tpl');
+        $page->changeTpl('lists/admin.tpl');
 
         if (Env::has('send_mark')) {
             $actions = Env::v('mk_action');
@@ -661,7 +628,7 @@ class ListsModule extends PLModule
 
         $this->prepare_client($page);
 
-        $this->changeTpl('lists/options.tpl');
+        $page->changeTpl('lists/options.tpl');
 
         if (Post::has('submit')) {
             $values = $_POST;
@@ -723,7 +690,7 @@ class ListsModule extends PLModule
             $type   = 'list';
         }
 
-        $this->changeTpl('lists/delete.tpl');
+        $page->changeTpl('lists/delete.tpl');
         if (Post::v('valid') == 'OUI') {
             if ($this->client->delete_list($liste, Post::b('del_archive'))) {
                 foreach (array('', '-owner', '-admin', '-bounces') as $app) {
@@ -754,7 +721,7 @@ class ListsModule extends PLModule
 
         $this->prepare_client($page);
 
-        $this->changeTpl('lists/soptions.tpl');
+        $page->changeTpl('lists/soptions.tpl');
 
         if (Post::has('submit')) {
             $values = $_POST;
@@ -781,7 +748,7 @@ class ListsModule extends PLModule
 
         $this->prepare_client($page);
 
-        $this->changeTpl('lists/check.tpl');
+        $page->changeTpl('lists/check.tpl');
 
         if (Post::has('correct')) {
             $this->client->check_options($liste, true);
@@ -796,7 +763,7 @@ class ListsModule extends PLModule
     }
 
     function handler_admin_all(&$page) {
-        $this->changeTpl('lists/admin_all.tpl');
+        $page->changeTpl('lists/admin_all.tpl');
         $page->assign('xorg_title','Polytechnique.org - Administration - Mailing lists');
 
         $client = new MMList(S::v('uid'), S::v('password'));