From 8da7bf1d280e3624e805c5c77137aa3de55b9d5f Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Sun, 21 Nov 2010 15:31:01 +0100 Subject: [PATCH] Fixes list display. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- modules/lists/lists.inc.php | 32 ++++++++++---------- templates/lists/admin.tpl | 60 +++++--------------------------------- templates/lists/display_list.tpl | 58 ++++++++++++++++++++++++++++++++++++ templates/lists/members.tpl | 63 +++------------------------------------- 4 files changed, 86 insertions(+), 127 deletions(-) create mode 100644 templates/lists/display_list.tpl diff --git a/modules/lists/lists.inc.php b/modules/lists/lists.inc.php index 0a8e0d2..5f8c2f4 100644 --- a/modules/lists/lists.inc.php +++ b/modules/lists/lists.inc.php @@ -21,33 +21,35 @@ // {{{ function list_sort_owners -function list_sort_owners(&$members, $tri_promo = true) +function list_sort_owners($members, $tri_promo = true) { global $globals; - $membres = Array(); + // $membres' structure is the following: $sortKey => $key => $listMember + $membres = array(); - foreach($members as $mem) { - $user = User::getSilent($mem); + foreach($members as $member) { + $user = User::getSilent($member); if (!$user) { - $membres[0][] = array('l' => $mem, 'p' => (!$tri_promo ? 'inconnus' : null), 'n' => null, 'x' => null, 'b' => null); + $membres[0][$member] = array('name' => null, 'email' => $member, 'category' => null, 'uid' => null, 'lost' => null, 'hasProfile' => null); } else { + $hasProfile = $user->hasProfile(); $uid = $user->id(); - $nom = $user->directoryName(); - $promo = $user->category(); - if (!$promo) { - $promo = 'extérieurs'; - } - $key = $tri_promo ? ($promo != 'extérieurs' ? $promo : 0) : strtoupper(@$nom{0}); - if ($tri_promo) { - $promo = null; + $name = $user->directoryName(); + $category = $user->category(); + $key = $tri_promo ? ($category ? $category : 'AAAAA') : strtoupper($name{0}); + if (!$category) { + $category = 'extérieurs'; } - $membres[$key][$nom.$mem] = array('n' => $nom, 'l' => $mem, 'p' => $promo, 'x' => $uid, 'b' => $user->lost); + $membres[$key][$name . $member] = array('name' => $name, 'email' => $member, 'category' => $category, + 'uid' => $uid, 'lost' => $user->lost, 'hasProfile' => $hasProfile); } } ksort($membres); - foreach($membres as $key=>$val) ksort($membres[$key]); + foreach($membres as $membre) { + ksort($membre); + } return $membres; } diff --git a/templates/lists/admin.tpl b/templates/lists/admin.tpl index f5974c6..24d8783 100644 --- a/templates/lists/admin.tpl +++ b/templates/lists/admin.tpl @@ -108,33 +108,10 @@ emails de marketing. Une fois inscrits à Polytechnique.org, l'inscription à la
{xsrf_token_field} - {foreach from=$owners item=users key=alpha} - {foreach from=$users item=user name=all} - - - - - {/foreach} - {/foreach} + {include file='lists/display_list.tpl' list=$owners delete='del_owner' no_sort_key='' promo=true} - @@ -150,47 +127,24 @@ emails de marketing. Une fois inscrits à Polytechnique.org, l'inscription à la {xsrf_token_field}
- {if $smarty.foreach.all.first} - {if $alpha}{$alpha}{/if} - {/if} - - {if t($user.x)} - {if t($user.b)}{assign var=lostUsers value=true}{/if} - {profile user=$user.x promo=false} - {elseif t($user.x)} - {if $user.n|trim}{$x.n}{else}{$user.l}{/if} - {elseif t($user.n)} - {$user.n} - {else} - {$user.l} - {/if} - {icon name=cross title='retirer modérateur'} -
Ajouter +
- {foreach from=$members item=users key=alpha} - {foreach from=$users item=user name=all} + {include file='lists/display_list.tpl' list=$members delete='del_member' no_sort_key='' promo=true} - - - - {/foreach} - {/foreach} - - + - - - diff --git a/templates/lists/display_list.tpl b/templates/lists/display_list.tpl new file mode 100644 index 0000000..5b04544 --- /dev/null +++ b/templates/lists/display_list.tpl @@ -0,0 +1,58 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2010 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 *} +{* *} +{**************************************************************************} + +{assign var=lostUsers value=false} +{foreach from=$list item=users key=sort_key} +{foreach from=$users item=user name=all} + + + + {if t($delete)} + + {/if} + +{/foreach} +{/foreach} + +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/lists/members.tpl b/templates/lists/members.tpl index df7d909..f266b49 100644 --- a/templates/lists/members.tpl +++ b/templates/lists/members.tpl @@ -85,34 +85,7 @@ {if $owners|@count}
- {if $smarty.foreach.all.first} - {if $alpha}{$alpha}{/if} - {/if} - - {if t($user.x)} - {if t($user.b)}{assign var=lostUsers value=true}{/if} - {profile user=$user.x promo=false} - {elseif t($user.x)} - {if $user.n|trim}{$x.n}{else}{$user.l}{/if} - {elseif t($user.n)} - {$user.n} - {else} - {$user.l} - {/if} - {icon name=cross title='retirer membre'} -
AjouterAjouter
Liste +
ou fichier(*) + *
+
+ {if $smarty.foreach.all.first} + {if $sort_key neq 'AAAAA'}{$sort_key}{else}{$no_sort_key}{/if} + {/if} + + {if t($user.hasProfile)} + {if t($user.lost)}{assign var=lostUsers value=true}{/if} + {profile user=$user.uid promo=$promo} + {elseif t($user.uid)} + {if t($user.name)}{$user.name}{else}{$user.email}{/if}{if t($promo)} (extérieur){/if} + {elseif t($user.name)} + {$user.name} + {else} + {$user.email} + {/if} + + {if t($user.uid)} + {icon name=user_edit title='Éditer'}  + {else} + {icon name=null}  + {/if} + {icon name=cross title='Retirer'} +
- {foreach from=$owners item=xs key=promo} - {foreach from=$xs item=user name=all} - - - - {if $user.p} - - {/if} - - {/foreach} - {/foreach} + {include file='lists/display_list.tpl' list=$owners delete=false no_sort_key='non-X' promo=$smarty.get.alpha}
- {if $smarty.foreach.all.first} - {if $promo}{$promo}{else}non-X{/if} - {/if} - - {if $promo && $user.x} - {if $user.b}{assign var=lostUsers value=true}{/if} - {profile user=$user.x promo=false} - {elseif $user.x} - {if $user.n|trim}{$x.n}{else}{$user.l}{/if} - {elseif $user.n} - {$user.n} - {else} - {$user.l} - {/if} - - {$user.p} -
{/if} @@ -129,45 +102,17 @@ {if $members|@count} {if $details.own || hasPerms('admin,groupadmin')} - {/if} - {assign var=lostUsers value=false} - {foreach from=$members item=users key=promo} - {foreach from=$users item=user name=all} - - - - {if $user.p} - - {/if} - - {/foreach} - {/foreach} + {include file='lists/display_list.tpl' list=$members delete=false no_sort_key='non-X' promo=$smarty.get.alpha}
+
{icon name="page_excel" title="Télécharger la liste des membres"} Télécharger la liste des membres au format Excel
- {if $smarty.foreach.all.first} - {if $promo}{$promo}{else}non-X{/if} - {/if} - - {if $promo && $user.x} - {if $user.b}{assign var=lostUsers value=true}{/if} - {profile user=$user.x promo=false} - {elseif $user.x} - {if $user.n|trim}{$x.n}{else}{$user.l}{/if} - {elseif $user.n} - {$user.n} - {else} - {$user.l} - {/if} - - {$user.p} -
-{if $lostUsers} +{if t($lostUsers)}

{icon name=error} Un camarade signalé par ce symbole n'a plus d'adresse de redirection et ne peut donc plus être contacté via son adresse polytechnique.org. Si tu connais sa nouvelle adresse, tu peux nous la communiquer en -- 2.1.4