Add geoloc for ML by porting ML trombi to PlSet
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 2 Apr 2007 20:19:17 +0000 (20:19 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 2 Apr 2007 20:19:17 +0000 (20:19 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1658 839d8a87-29fc-0310-9880-83ba4fa771e5

include/user.func.inc.php
include/userset.inc.php
modules/lists.php
modules/xnetlists.php
templates/core/plset.tpl
templates/lists/annu.tpl [moved from templates/lists/trombi.tpl with 90% similarity]
templates/lists/header_listes.tpl

index e1b3b88..ae26305 100644 (file)
@@ -84,6 +84,11 @@ function _default_user_callback($login)
     return;
 }
 
+function _silent_user_callback($login)
+{
+    return;
+}
+
 function get_user_login($data, $get_forlife = false, $callback = '_default_user_callback')
 {
     global $globals, $page;
@@ -181,10 +186,12 @@ function get_user_forlife($data, $callback = '_default_user_callback')
 
 function get_users_forlife_list($members, $strict = false, $callback = '_default_user_callback')
 {
-    if (strlen(trim($members)) == 0) {
-        return null;
+    if (!is_array($members)) {
+        if (strlen(trim($members)) == 0) {
+            return null;
+        }
+        $members = explode(' ', $members);
     }
-    $members = explode(' ', $members);
     if ($members) {
         $list = array();
         foreach ($members as $i => $alias) {
index bdfb90a..f96ccfb 100644 (file)
@@ -121,6 +121,29 @@ class SearchSet extends UserSet
     }
 }
 
+class ArraySet extends UserSet
+{
+    public function __construct(array $users)
+    {
+        $where = $this->getUids($users);
+        if ($where) {
+            $where = "a.alias IN ($where)";
+        } else {
+            $where = " 0 ";
+        }
+        parent::__construct('', $where);
+    }
+
+    private function getUids(array $users)
+    {
+        $users = get_users_forlife_list($users, true, '_silent_user_callback');
+        if (is_null($users)) {
+            return '';
+        }
+        return '\'' . implode('\', \'', $users) . '\'';
+    }
+}
+
 class MinificheView extends MultipageView
 {
     public function __construct(PlSet &$set, $data, array $params)
@@ -192,7 +215,6 @@ class TrombiView extends MultipageView
         }
         $this->addSortKey('name', array('nom', 'prenom'), 'nom');
         $this->addSortKey('promo', array('-promo', 'nom', 'prenom'), 'promotion');
-        $this->addSortKey('date', array('-watch_last', '-promo', 'nom', 'prenom'), 'dernière modification');
         parent::__construct($set, $data, $params);
     }
 
index 8dbf769..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),
 
@@ -262,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;
@@ -305,30 +270,42 @@ class ListsModule extends PLModule
 
         $this->prepare_client($page);
 
-        $page->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)
index 31ac9c3..a892132 100644 (file)
@@ -32,7 +32,7 @@ class XnetListsModule extends ListsModule
             '%grp/lists/create'    => $this->make_hook('create',    AUTH_MDP, 'groupmember'),
 
             '%grp/lists/members'   => $this->make_hook('members',   AUTH_COOKIE),
-            '%grp/lists/trombi'    => $this->make_hook('trombi',    AUTH_COOKIE),
+            '%grp/lists/annu'      => $this->make_hook('annu',      AUTH_COOKIE),
             '%grp/lists/archives'  => $this->make_hook('archives',  AUTH_COOKIE),
 
             '%grp/lists/moderate'  => $this->make_hook('moderate',  AUTH_MDP),
index c33621f..009aa23 100644 (file)
 <h1>
   {$plset_mods[$plset_mod]}
   {if $plset_mods|@count > 1}[
+  {assign var=has_prev value=false}
   {foreach from=$plset_mods key=mod item=desc name=mods}
     {if $mod neq $plset_mod}
-    <a href="{$plset_base}/{$mod}{$plset_search}">{$desc}</a> {if !$smarty.foreach.mods.last}| {/if}
+    {if $has_prev}| {/if}
+    <a href="{$platal->ns}{$plset_base}/{$mod}{$plset_search}">{$desc}</a>
+    {assign var=has_prev value=true}
     {/if}
   {/foreach}
   ]
similarity index 90%
rename from templates/lists/trombi.tpl
rename to templates/lists/annu.tpl
index e2efcbe..3ae9cfd 100644 (file)
   {foreach from=$owners item=xs key=promo}
     {foreach from=$xs item=x}
       {if $promo}
-      {cycle values="1,2,3" assign="loop"}
+      {cycle values="1,2,3,4" assign="loop"}
       {if $loop eq "1"}<tr>{/if}
         <td class='center'>
-          <img src="photo/{$x.l}" width="110" alt=" [ PHOTO ] " />
+          <img src="photo/{$x.l}" width="80" alt=" [ PHOTO ] " />
           <br />
           <a href="profile/{$x.l}" class="popup2">
             {$x.n} ({$promo})
           </a>
         </td>
-      {if $loop eq "3"}</tr>{/if}
+      {if $loop eq "4"}</tr>{/if}
       {/if}
     {/foreach}
   {/foreach}
   {if $loop eq "1"}
     {cycle values="1,2,3" assign="loop"}
     {cycle values="1,2,3" assign="loop"}
-    <td></td><td></td></tr>
+    {cycle values="1,2,3" assign="loop"}
+    <td></td><td></td><td></td></tr>
   {elseif $loop eq "2"}
     {cycle values="1,2,3" assign="loop"}
+    {cycle values="1,2,3" assign="loop"}
+    <td></td><td></td></tr>
+  {elseif $loop eq "3"}
+    {cycle values="1,2,3" assign="loop"}
     <td></td></tr>
   {/if}
 </table>
 
-<h1>
-  membres de la liste
-</h1>
-
-{$trombi->show()|smarty:nodefaults}
-
+{include file="core/plset.tpl"}
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 695879b..39ba296 100644 (file)
@@ -35,9 +35,9 @@
       [liste des membres]
       {/if}
       {if $on neq trombi}
-      [<a href='{$platal->ns}lists/trombi/{$platal->argv[1]}'>trombinoscope</a>]
+      [<a href='{$platal->ns}lists/annu/{$platal->argv[1]}'>annuaire/trombi</a>]
       {else}
-      [trombinoscope]
+      [annuaire/trombi]
       {/if}
       {if $on neq archives}
       [<a href='{$platal->ns}lists/archives/{$platal->argv[1]}'>archives</a>]