From 1cc0afe77b0c234f12840a84b0adac52fe07c4fe Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Mon, 2 Apr 2007 20:19:17 +0000 Subject: [PATCH] Add geoloc for ML by porting ML trombi to PlSet git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1658 839d8a87-29fc-0310-9880-83ba4fa771e5 --- include/user.func.inc.php | 13 ++++-- include/userset.inc.php | 24 +++++++++- modules/lists.php | 79 +++++++++++--------------------- modules/xnetlists.php | 2 +- templates/core/plset.tpl | 5 +- templates/lists/{trombi.tpl => annu.tpl} | 20 ++++---- templates/lists/header_listes.tpl | 4 +- 7 files changed, 78 insertions(+), 69 deletions(-) rename templates/lists/{trombi.tpl => annu.tpl} (90%) diff --git a/include/user.func.inc.php b/include/user.func.inc.php index e1b3b88..ae26305 100644 --- a/include/user.func.inc.php +++ b/include/user.func.inc.php @@ -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) { diff --git a/include/userset.inc.php b/include/userset.inc.php index bdfb90a..f96ccfb 100644 --- a/include/userset.inc.php +++ b/include/userset.inc.php @@ -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); } diff --git a/modules/lists.php b/modules/lists.php index 8dbf769..7111516 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -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) diff --git a/modules/xnetlists.php b/modules/xnetlists.php index 31ac9c3..a892132 100644 --- a/modules/xnetlists.php +++ b/modules/xnetlists.php @@ -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), diff --git a/templates/core/plset.tpl b/templates/core/plset.tpl index c33621f..009aa23 100644 --- a/templates/core/plset.tpl +++ b/templates/core/plset.tpl @@ -33,9 +33,12 @@

{$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} - {$desc} {if !$smarty.foreach.mods.last}| {/if} + {if $has_prev}| {/if} + {$desc} + {assign var=has_prev value=true} {/if} {/foreach} ] diff --git a/templates/lists/trombi.tpl b/templates/lists/annu.tpl similarity index 90% rename from templates/lists/trombi.tpl rename to templates/lists/annu.tpl index e2efcbe..3ae9cfd 100644 --- a/templates/lists/trombi.tpl +++ b/templates/lists/annu.tpl @@ -74,34 +74,34 @@ {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"}{/if} -  [ PHOTO ] +  [ PHOTO ]
{$x.n} ({$promo}) - {if $loop eq "3"}{/if} + {if $loop eq "4"}{/if} {/if} {/foreach} {/foreach} {if $loop eq "1"} {cycle values="1,2,3" assign="loop"} {cycle values="1,2,3" assign="loop"} - + {cycle values="1,2,3" assign="loop"} + {elseif $loop eq "2"} {cycle values="1,2,3" assign="loop"} + {cycle values="1,2,3" assign="loop"} + + {elseif $loop eq "3"} + {cycle values="1,2,3" assign="loop"} {/if} -

- membres de la liste -

- -{$trombi->show()|smarty:nodefaults} - +{include file="core/plset.tpl"} {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/lists/header_listes.tpl b/templates/lists/header_listes.tpl index 695879b..39ba296 100644 --- a/templates/lists/header_listes.tpl +++ b/templates/lists/header_listes.tpl @@ -35,9 +35,9 @@ [liste des membres] {/if} {if $on neq trombi} - [trombinoscope] + [annuaire/trombi] {else} - [trombinoscope] + [annuaire/trombi] {/if} {if $on neq archives} [archives] -- 2.1.4