}
}
+/** A multipage view for users
+ * Allows the display of bounds when sorting by name or promo.
+ */
+abstract class UserView extends MultipageView
+{
+ protected function getBoundValue($user)
+ {
+ if ($user instanceof User) {
+ switch ($this->bound_field) {
+ case 'name':
+ $name = $user->lastName();
+ return strtoupper($name);
+ case 'promo':
+ if ($user->hasProfile()) {
+ return $user->profile()->promo();
+ } else {
+ return null;
+ }
+ default:
+ return null;
+ }
+ }
+ return null;
+ }
+
+ public function bounds()
+ {
+ $order = Env::v('order', $this->defaultkey);
+ $show_bounds = 0;
+ if (($order == "name") || ($order == "-name")) {
+ $this->bound_field = "name";
+ $show_bounds = 1;
+ } elseif (($order == "promo") || ($order == "-promo")) {
+ $this->bound_field = "promo";
+ $show_bounds = -1;
+ }
+ if ($order{0} == '-') {
+ $show_bounds = -$show_bounds;
+ }
+ return $show_bounds;
+ }
+}
+
+class XnetFicheView extends UserView
+{
+ public function __construct(PlSet $set, array $params)
+ {
+ $this->entriesPerPage = 20;
+ $this->addSort(new PlViewOrder('name', array(new UFO_Name(Profile::DN_SORT)), 'nom'));
+ $this->addSort(new PlViewOrder('promo', array(
+ new UFO_Promo(UserFilter::DISPLAY, true),
+ new UFO_Name(Profile::DN_SORT),
+ ), 'promotion'));
+ parent::__construct($set, $params);
+ }
+
+ public function templateName()
+ {
+ return 'include/plview.xnetuser.tpl';
+ }
+}
+
class GadgetView implements PlView
{
public function __construct(PlSet $set, array $params)
{
global $globals;
+ __autoload('userset');
+ $admins = false;
if ($action == 'trombi') {
- __autoload('userset');
- if ($action == 'trombi') {
- $view = new ProfileSet(new UFC_Group($globals->asso('id')));
- } else {
- $view = new UserSet(new UFC_Group($globals->asso('id')));
+ $view = new ProfileSet(new UFC_Group($globals->asso('id')));
+ } else {
+ if ($action == 'admins') {
+ $admins = true;
+ $action = $subaction;
}
- $view->addMod('trombi', 'Trombinoscope');
- $view->apply('annuaire', $page, $action, $subaction);
- $page->changeTpl('xnetgrp/annuaire.tpl');
- $count = XDB::fetchOneCell('SELECT COUNT(*)
- FROM group_members
- WHERE asso_id = {?}',
- $globals->asso('id'));
- $page->assign('nb_tot', $count);
- return;
+ $view = new UserSet(new UFC_Group($globals->asso('id'), $admins));
}
-
+ $view->addMod('xnetfiche', 'Annuaire');
+ $view->addMod('trombi', 'Trombinoscope');
+ $view->apply('annuaire', $page, $action);
+ $page->assign('only_admin', $admins);
$page->changeTpl('xnetgrp/annuaire.tpl');
- $sort = Env::s('order', 'directory_name');
- $ofs = Env::i('offset');
- if ($ofs < 0) {
- $ofs = 0;
- }
-
- $sdesc = $sort{0} == '-';
- $sf = $sdesc ? substr($sort, 1) : $sort;
- if ($sf == 'promo') {
- $se = new UFO_Promo(null, $sdesc);
- } else {
- $se = new UFO_Name($sf, null, null, $sdesc);
- }
-
- if (Env::b('admin')) {
- $uf = $globals->asso()->getAdminsFilter(null, $se);
- } else {
- $uf = $globals->asso()->getMembersFilter(null, $se);
- }
- $users = $uf->getUsers(new PlLimit(NB_PER_PAGE, $ofs * NB_PER_PAGE));
- $count = $uf->getTotalCount();
-
- $page->assign('nb_tot', $count);
- $page->assign('pages', floor(($count + NB_PER_PAGE - 1) / NB_PER_PAGE));
- $page->assign('current', $ofs);
- $page->assign('order', $sort);
- $page->assign('users', $users);
- $page->assign('only_admin', Env::b('admin'));
}
function handler_trombi($page)
--- /dev/null
+{**************************************************************************}
+{* *}
+{* Copyright (C) 2003-2011 Polytechnique.org *}
+{* http://opensource.polytechnique.org/ *}
+{* *}
+{* This program is free software; you can redistribute it and/or modify *}
+{* it under the terms of the GNU General Public License as published by *}
+{* the Free Software Foundation; either version 2 of the License, or *}
+{* (at your option) any later version. *}
+{* *}
+{* This program is distributed in the hope that it will be useful, *}
+{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
+{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
+{* GNU General Public License for more details. *}
+{* *}
+{* You should have received a copy of the GNU General Public License *}
+{* along with this program; if not, write to the Free Software *}
+{* Foundation, Inc., *}
+{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
+{* *}
+{**************************************************************************}
+
+<tr>
+ <td>
+ {profile user=$user promo=false}
+ </td>
+ <td>
+ {if $user->group_perms eq 'admin' && $user->category()}<strong>{/if}
+ {$user->category()|default:"Extérieur"}
+ {if $user->group_perms eq 'admin' && $user->category()}</strong>{/if}
+ </td>
+ <td>{if $user->group_comm}{$user->group_comm}{else} {/if}</td>
+ <td class="right">
+ {if $user->hasProfile()}
+ <a href="https://www.polytechnique.org/vcard/{$user->login()}.vcf">{icon name=vcard title="[vcard]"}</a>
+ {/if}
+ <a href="mailto:{$user->bestEmail()}">{icon name=email title="email"}</a>
+ </td>
+ {if $is_admin}
+ <td class="center">
+ <a href="{$platal->ns}member/{$user->login()}">{icon name=user_edit title="Édition du profil"}</a>
+ <a href="{$platal->ns}member/del/{$user->login()}">{icon name=delete title="Supprimer de l'annuaire"}</a>
+ </td>
+ {/if}
+</tr>
--- /dev/null
+{**************************************************************************}
+{* *}
+{* Copyright (C) 2003-2011 Polytechnique.org *}
+{* http://opensource.polytechnique.org/ *}
+{* *}
+{* This program is free software; you can redistribute it and/or modify *}
+{* it under the terms of the GNU General Public License as published by *}
+{* the Free Software Foundation; either version 2 of the License, or *}
+{* (at your option) any later version. *}
+{* *}
+{* This program is distributed in the hope that it will be useful, *}
+{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
+{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
+{* GNU General Public License for more details. *}
+{* *}
+{* You should have received a copy of the GNU General Public License *}
+{* along with this program; if not, write to the Free Software *}
+{* Foundation, Inc., *}
+{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
+{* *}
+{**************************************************************************}
+
+
+<table summary="membres du groupe" class="bicol">
+ <tr>
+ <th>Nom</th>
+ <th>Promo</th>
+ <th colspan="2">Infos</th>
+ {if $is_admin}
+ <th>Actions</th>
+ {/if}
+ </tr>
+ {assign var=lostUsers value=false}
+ {foreach from=$set item=user}
+ {if $user->lost}{assign var=lostUsers value=true}{/if}
+ {include file="include/plview.xnetuser.entry.tpl" user=$user}
+ {/foreach}
+</table>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
<h1>{$asso->nom} : Annuaire du groupe </h1>
<p class="descr">
-Le groupe {$asso->nom} compte {$nb_tot} membres :
+Le groupe {$asso->nom} compte {$plset_count} membres :
</p>
<ul class="descr">
</li>
</ul>
-{if $plset_base}
-{include core=plset.tpl}
-{else}
-
<p class="center">
-[<a href="{$platal->ns}annuaire?order={$order}" {if !$only_admin}class="erreur"{/if}>tous les membres</a>]
-[<a href="{$platal->ns}annuaire?order={$order}&admin=1" {if $only_admin}class="erreur"{/if}>animateurs</a>]<br/>
-{*
- XXX: This code has been temporary dropped, waiting for a cleaner way to do that stuff
-{foreach from=$alphabet item=c}
-{if $c}
-[<a href="{$platal->ns}annuaire?order={$order}&admin={$only_admin}"{if $request_group eq $c} class="erreur"{/if}>{$c}</a>]
-{/if}
-{/foreach}
-*}
+[<a href="{$platal->ns}{$plset_base}/{$plset_mod}{$plset_args}" {if !$only_admin}class="erreur"{/if}>tous les membres</a>]
+[<a href="{$platal->ns}{$plset_base}/admins/{$plset_mod}{$plset_args}" {if $only_admin}class="erreur"{/if}>animateurs</a>]
</p>
-<table summary="membres du groupe" class="bicol">
- <tr>
- <th>
- <a href="{$platal->ns}annuaire?order={if $order eq 'directory_name'}-{/if}directory_name&admin={$only_admin}">
- {if $order eq 'directory_name'}
- <img src="{$platal->baseurl}images/dn.png" alt="" title="Tri croissant" />
- {elseif $order eq '-directory_name'}
- <img src="{$platal->baseurl}images/up.png" alt="" title="Tri décroissant" />
- {/if}
- NOM Prénom
- </a>
- </th>
- <th>
- <a href="{$platal->ns}annuaire?order={if $order eq 'promo'}-{/if}promo&admin={$only_admin}">
- {if $order eq '-promo'}
- <img src="{$platal->baseurl}images/dn.png" alt="" title="Tri croissant" />
- {elseif $order eq 'promo'}
- <img src="{$platal->baseurl}images/up.png" alt="" title="Tri décroissant" />
- {/if}
- Promo
- </a>
- </th>
- <th colspan="2">Infos</th>
- {if $is_admin}
- <th>Actions</th>
- {/if}
- </tr>
- {assign var=lostUsers value=false}
- {foreach from=$users item=user}
- <tr>
- <td>
- {if $user->lost}{assign var=lostUsers value=true}{/if}
- {profile user=$user promo=false}
- </td>
- <td>
- {if $user->group_perms eq 'admin' && $user->category()}<strong>{/if}
- {$user->category()|default:"Extérieur"}
- {if $user->group_perms eq 'admin' && $user->category()}</strong>{/if}
- </td>
- {if $user->group_comm}
- <td>{$user->group_comm}</td>
- {/if}
- <td class="right"{if !$user->group_comm} colspan="2"{/if}>
- {if $user->hasProfile()}
- <a href="https://www.polytechnique.org/vcard/{$user->login()}.vcf">{icon name=vcard title="[vcard]"}</a>
- {/if}
- <a href="mailto:{$user->bestEmail()}">{icon name=email title="email"}</a>
- </td>
- {if $is_admin}
- <td class="center">
- <a href="{$platal->ns}member/{$user->login()}">{icon name=user_edit title="Édition du profil"}</a>
- <a href="{$platal->ns}member/del/{$user->login()}">{icon name=delete title="Supprimer de l'annuaire"}</a>
- </td>
- {/if}
- </tr>
- {/foreach}
-</table>
-
-{if $pages gt 1}
-<p class="descr" style="text-align: center">
-{section name="links" loop=$pages}
-{if $smarty.section.links.index eq $current}
-<span class="erreur">{$smarty.section.links.iteration}</span>
-{else}
-{if $smarty.section.links.first}
-<a href="{$platal->ns}annuaire?offset={$current-1}&order={$order}&admin={$only_admin}">précédente</a>
-{/if}
-<a href="{$platal->ns}annuaire?offset={$smarty.section.links.index}&order={$order}&admin={$only_admin}">{$smarty.section.links.iteration}</a>
-{if $smarty.section.links.last}
-<a href="{$platal->ns}annuaire?offset={$current+1}&order={$order}&admin={$only_admin}">suivante</a>
-{/if}
-{/if}
-{/section}
-</p>
-{/if}
+{include core=plset.tpl}
{if $lostUsers}
<p class="smaller">
</p>
{/if}
-{/if}
-
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}