Rename XnetUserView to GroupMemberView and add ListMemberView.
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Sun, 8 May 2011 16:21:41 +0000 (18:21 +0200)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Sun, 8 May 2011 16:21:41 +0000 (18:21 +0200)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
include/userset.inc.php
templates/include/plview.groupmember.entry.tpl [moved from templates/include/plview.xnetuser.entry.tpl with 100% similarity]
templates/include/plview.groupmember.tpl [moved from templates/include/plview.xnetuser.tpl with 96% similarity]
templates/include/plview.listmember.tpl [new file with mode: 0644]

index be7564d..88028d6 100644 (file)
@@ -123,22 +123,27 @@ class AdvancedSearchSet extends SearchSet
     }
 }
 
-/** Simple set based on an array of User objects
+/** Simple set based on an array of User emails
  */
-class ArraySet extends ProfileSet
+class UserArraySet extends UserSet
 {
-    public function __construct(array $users)
+    public function __construct(array $emails)
     {
-        $hruids = User::getBulkHruid($users, array('User', '_silent_user_callback'));
-        if (is_null($hruids) || count($hruids) == 0) {
-            $cond = new PFC_False();
-        } else {
-            $cond = new UFC_Hruid($hruids);
-        }
-        parent::__construct($cond);
+        parent::__construct(new UFC_Email($emails));
     }
 }
 
+/** Simple set based on an array of Profile emails
+ */
+class ProfileArraySet extends ProfileSet
+{
+    public function __construct(array $emails)
+    {
+        parent::__construct(new UFC_Email($emails));
+    }
+}
+
+
 /** A multipage view for profiles
  * Allows the display of bounds when sorting by name or promo.
  */
@@ -345,7 +350,7 @@ abstract class UserView extends MultipageView
     }
 }
 
-class XnetFicheView extends UserView
+class GroupMemberView extends UserView
 {
     public function __construct(PlSet $set, array $params)
     {
@@ -360,7 +365,26 @@ class XnetFicheView extends UserView
 
     public function templateName()
     {
-        return 'include/plview.xnetuser.tpl';
+        return 'include/plview.groupmember.tpl';
+    }
+}
+
+class ListMemberView extends UserView
+{
+    public function __construct(PlSet $set, array $params)
+    {
+        $this->entriesPerPage = 100;
+        $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.listmember.tpl';
     }
 }
 
similarity index 96%
rename from templates/include/plview.xnetuser.tpl
rename to templates/include/plview.groupmember.tpl
index 8a0342b..f22449b 100644 (file)
@@ -33,7 +33,7 @@
   {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}
+    {include file="include/plview.groupmember.entry.tpl" user=$user}
   {/foreach}
 </table>
 
diff --git a/templates/include/plview.listmember.tpl b/templates/include/plview.listmember.tpl
new file mode 100644 (file)
index 0000000..6d9f75b
--- /dev/null
@@ -0,0 +1,72 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  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="abonnés à la liste" class="bicol" cellpadding="0" cellspacing="0">
+  {if $details.own || hasPerms('admin,groupadmin')}
+  <tr><td colspan="2">
+  <a href="{$platal->ns}lists/csv/{$platal->argv[1]}/{$platal->argv[1]}.csv">
+    {icon name="page_excel" title="Télécharger la liste des membres"}
+    Télécharger la liste des membres au format Excel
+  </a>
+  </td></tr>
+  {/if}
+
+  {assign var=current_key value=''}
+  {foreach from=$set item=user}
+  <tr>
+    <td class="titre" style="width: 20%">
+      {if $order eq 'promo'}
+        {assign var=user_key value=$user->promo()}
+      {elseif $order eq 'name'}
+        {assign var=user_key value=$user->lastName()|string_format:'%.1s'|upper}
+      {else}
+        {assign var=user_key value=''}
+      {/if}
+      {if $user_key neq $current_key}
+        {assign var=current_key value=$user_key}
+        {$user_key}
+      {/if}
+    </td>
+    <td>
+      {if $user->hasProfile()}
+        {if $user->lost}{assign var=lostUsers value=true}{/if}
+        {profile user=$user}
+      {else}
+        {$user->displayName()}
+      {/if}
+    </td>
+    {if t($delete)}
+      <td class="center">
+        {if t($user.uid)}
+          <a href="{$platal->ns}member/{$user.uid}">{icon name=user_edit title='Éditer'}</a>&nbsp;
+        {else}
+          {icon name=null}&nbsp;
+        {/if}
+        <a href='{$platal->pl_self(1)}?{$delete}={$user.email}&amp;token={xsrf_token}'>{icon name=cross title='Retirer'}</a>
+      </td>
+    {/if}
+  </tr>
+  {/foreach}
+</table>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}