Merge branch 'platal-0.9.17'
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 27 Jun 2008 22:08:34 +0000 (00:08 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 27 Jun 2008 22:08:34 +0000 (00:08 +0200)
ChangeLog
htdocs/images/icons/page_excel.gif [new file with mode: 0644]
htdocs/images/icons/page_white_excel.gif [new file with mode: 0644]
include/vcard.inc.php
modules/xnetgrp.php
templates/xnetgrp/annuaire-csv.tpl [new file with mode: 0644]
templates/xnetgrp/annuaire.tpl
templates/xnetgrp/membres-edit.tpl

index 6eeecb4..82f1998 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -50,6 +50,9 @@ Bug/Wish:
         - #807: Notify groupes managers of unsubscriptions                 -FRU
         - #814: Group managers can change the visibility of the group      -FRU
         - #824: Fix redirection when changing status of the user           -FRU
+        - #846: Don't export users without a forlife in the vcard          -FRU
+        - #847: Can export the directory as .csv file                      -FRU
+        - #848: Add a free text field in user profile                      -FRU
 
     * XnetEvents:
         - #825: Show the number of comers when the events contains 1 part  -FRU
diff --git a/htdocs/images/icons/page_excel.gif b/htdocs/images/icons/page_excel.gif
new file mode 100644 (file)
index 0000000..c424a63
Binary files /dev/null and b/htdocs/images/icons/page_excel.gif differ
diff --git a/htdocs/images/icons/page_white_excel.gif b/htdocs/images/icons/page_white_excel.gif
new file mode 100644 (file)
index 0000000..422293b
Binary files /dev/null and b/htdocs/images/icons/page_white_excel.gif differ
index cba4092..20aa9ce 100644 (file)
@@ -36,8 +36,11 @@ class VCardIterator implements PlIterator
 
     public function add_user($user)
     {
-        $this->user_list[] = get_user_forlife($user);
-        $this->count++;
+        $forlife = get_user_forlife($user, '_silent_user_callback');
+        if ($forlife) {
+            $this->user_list[] = get_user_forlife($user);
+            $this->count++;
+        }
     }
 
     public function first()
@@ -171,7 +174,6 @@ class VCard
         header("Pragma: ");
         header("Cache-Control: ");
         header("Content-type: text/x-vcard; charset=UTF-8");
-        header("Content-Transfer-Encoding: 8bit");
   }
 }
 
index 543c8d3..3a6ea7e 100644 (file)
@@ -34,7 +34,7 @@ function get_infos($email)
     }
 
     $res = XDB::query(
-            "SELECT  uid, nom, prenom, email, email AS email2, perms='admin', origine, sexe
+            "SELECT  uid, nom, prenom, email, email AS email2, perms='admin', origine, comm, sexe
                FROM  groupex.membres
               WHERE  $field = {?} AND asso_id = {?}", $email, $globals->asso('id'));
 
@@ -54,7 +54,7 @@ function get_infos($email)
                          u.prenom, b.alias,
                          CONCAT(b.alias, '@m4x.org') AS email,
                          CONCAT(b.alias, '@polytechnique.org') AS email2,
-                         m.perms = 'admin' AS perms, m.origine,
+                         m.perms = 'admin' AS perms, m.origine, m.comm,
                          FIND_IN_SET('femme', u.flags) AS sexe
                    FROM  auth_user_md5   AS u
              INNER JOIN  aliases         AS a ON ( u.user_id = a.id AND a.type != 'homonyme' )
@@ -82,6 +82,7 @@ class XnetGrpModule extends PLModule
             '%grp/forum'          => $this->make_hook('forum',     AUTH_MDP, 'groupmember'),
             '%grp/annuaire'       => $this->make_hook('annuaire',  AUTH_MDP, 'groupannu'),
             '%grp/annuaire/vcard' => $this->make_hook('vcard',     AUTH_MDP, 'groupmember:groupannu'),
+            '%grp/annuaire/csv'   => $this->make_hook('csv',       AUTH_MDP, 'groupmember:groupannu'),
             '%grp/trombi'         => $this->make_hook('trombi',    AUTH_MDP, 'groupannu'),
             '%grp/geoloc'         => $this->make_hook('geoloc',    AUTH_MDP, 'groupannu'),
             '%grp/subscribe'      => $this->make_hook('subscribe', AUTH_MDP),
@@ -438,6 +439,7 @@ class XnetGrpModule extends PLModule
                            m.perms='admin' AS admin,
                            m.origine='X' AS x,
                            u.perms!='pending' AS inscrit,
+                           m.comm as comm,
                            m.uid, IF(e.email IS NULL AND FIND_IN_SET('googleapps', u.mail_storage) = 0, NULL, 1) AS actif
                      FROM  groupex.membres AS m
                 LEFT JOIN  auth_user_md5   AS u ON ( u.user_id = m.uid )
@@ -472,6 +474,34 @@ class XnetGrpModule extends PLModule
         $vcard->do_page($page);
     }
 
+    function handler_csv(&$page, $filename = null)
+    {
+        global $globals;
+        if (is_null($filename)) {
+            $filename = $globals->asso('diminutif') . '.csv';
+        }
+        $ann = XDB::iterator(
+                  "SELECT  IF(m.origine='X',IF(u.nom_usage<>'', u.nom_usage, u.nom) ,m.nom) AS nom,
+                           IF(m.origine='X',u.prenom,m.prenom) AS prenom,
+                           IF(m.origine='X', u.promo, IF(m.origine='ext', 'extérieur', 'personne morale')) AS promo,
+                           IF(m.origine='X' AND u.perms != 'pending',CONCAT(a.alias, '@', {?}), m.email) AS email,
+                           IF(m.origine='X',FIND_IN_SET('femme', u.flags), m.sexe) AS femme,
+                           m.comm as comm
+                     FROM  groupex.membres AS m
+                LEFT JOIN  auth_user_md5   AS u ON ( u.user_id = m.uid )
+                LEFT JOIN  aliases         AS a ON ( a.id = m.uid AND a.type = 'a_vie' )
+                    WHERE  m.asso_id = {?}
+                           AND (m.origine != 'X' OR u.perms != 'pending' OR m.email IS NOT NULL)
+                 GROUP BY  m.uid
+                 ORDER BY  nom, prenom",
+                 $globals->mail->domain, $globals->asso('id'));
+        header('Content-Type: text/x-csv; charset=utf-8;');
+        header('Pragma: ');
+        header('Cache-Control: ');
+        $page->changeTpl('xnetgrp/annuaire-csv.tpl', NO_SKIN);
+        $page->assign('ann', $ann);
+    }
+
     function handler_subscribe(&$page, $u = null)
     {
         global $globals;
@@ -975,20 +1005,29 @@ class XnetGrpModule extends PLModule
                                SET prenom={?}, nom={?}, email={?}, sexe={?}, origine={?}
                              WHERE uid={?} AND asso_id={?}',
                            $user['prenom'], $user['nom'], Post::v('email'),
-                           $user['sexe'], $user['origine'], $user['uid'],
-                           $globals->asso('id'));
+                           $user['sexe'], $user['origine'],
+                           $user['uid'], $globals->asso('id'));
                 $user['email']   = Post::v('email');
                 $user['email2']  = Post::v('email');
+                $page->trigSuccess('Données de l\'utilisateur mise à jour.');
             }
 
             $perms = Post::i('is_admin');
-            if ($user['perms'] != $perms) {
-                XDB::query('UPDATE groupex.membres SET perms={?}
+            $comm  = trim(Post::s('comm'));
+            if ($user['perms'] != $perms || $user['comm'] != $comm) {
+                XDB::query('UPDATE groupex.membres
+                               SET perms={?}, comm={?}
                              WHERE uid={?} AND asso_id={?}',
-                            $perms ? 'admin' : 'membre',
+                            $perms ? 'admin' : 'membre', $comm,
                             $user['uid'], $globals->asso('id'));
+                if ($perms != $user['perms']) {
+                    $page->trigSuccess('Permissions modifiées !');
+                }
+                if ($comm != $user['comm']) {
+                    $page->trigSuccess('Commentaire mis à jour.');
+                }
                 $user['perms'] = $perms;
-                $page->trigSuccess('Permissions modifiées !');
+                $user['comm'] = $comm;
             }
 
             // Update ML subscriptions
@@ -1039,7 +1078,6 @@ class XnetGrpModule extends PLModule
         }
 
         $page->assign('user', $user);
-        echo $user['email2'];
         $listes = $mmlist->get_lists($user['email2']);
         $page->assign('listes', $listes);
 
diff --git a/templates/xnetgrp/annuaire-csv.tpl b/templates/xnetgrp/annuaire-csv.tpl
new file mode 100644 (file)
index 0000000..30e6a7c
--- /dev/null
@@ -0,0 +1,30 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2008 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               *}
+{*                                                                        *}
+{**************************************************************************}
+Nom,Prénom,Sexe,Promotion,Email,Commentaire
+{if $ann}
+{iterate from=$ann item=m}
+
+{$m.nom},{$m.prenom},{if $m.sexe}F{else}M{/if},{$m.promo},{$m.email},{$m.comm|replace:',':'\,'}
+
+{/iterate}
+{/if}
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 8b42863..552fb53 100644 (file)
@@ -42,6 +42,12 @@ Le groupe {$asso.nom} compte {$nb_tot} membres&nbsp;:
   </li>
   {/if}
   <li>
+    <a href="{$platal->ns}annuaire/csv/{$asso.diminutif}.csv">
+      {icon name=page_excel title="Fichier Excel"} 
+      Obtenir au format Excel
+    </a>
+  </li>
+  <li>
     <a href="{$platal->ns}annuaire/vcard/photos/{$asso.diminutif}.vcf">
       {icon name=vcard title="Carte de visite"} 
       Ajouter les membres à ton carnet d'adresse
@@ -64,7 +70,7 @@ Le groupe {$asso.nom} compte {$nb_tot} membres&nbsp;:
 {/foreach}
 </p>
 
-<table summary="membres du groupe" class="tinybicol">
+<table summary="membres du groupe" class="bicol">
   <tr>
     <th>
       <a href="{$platal->ns}annuaire?order=alpha{if $sort neq "alpha_inv"}_inv{/if}{if $request_group and $group eq 'initiale'}&amp;initiale={$request_group}{/if}{if $only_admin}&amp;admin=1{/if}">
@@ -86,7 +92,7 @@ Le groupe {$asso.nom} compte {$nb_tot} membres&nbsp;:
         Promo
       </a>
     </th>
-    <th>Infos</th>
+    <th colspan="2">Infos</th>
     {if $is_admin}
     <th>Actions</th>
     {/if}
@@ -108,7 +114,10 @@ Le groupe {$asso.nom} compte {$nb_tot} membres&nbsp;:
       {assign var=broken value=true}
       {/if}</td>
     <td>{if $m.admin}<strong>{/if}{$m.promo}{if $m.admin}</strong>{/if}</td>
-    <td class="center">
+    {if $m.comm}
+    <td>{$m.comm}</td>
+    {/if}
+    <td class="center" {if !$m.comm}colspan="2"{/if}>
       {if $m.inscrit}
       <a href="https://www.polytechnique.org/vcard/{$m.email}.vcf">{icon name=vcard title="[vcard]"}</a>
       <a href="mailto:{$m.email}@polytechnique.org">{icon name=email title="mail"}</a>
index 6baa2ec..0dc6347 100644 (file)
@@ -60,7 +60,7 @@
   <table cellpadding="0" cellspacing="0" class='tinybicol'>
     <tr class="pair">
       <td class="titre">
-        Permissions:
+        Permissions&nbsp;:
       </td>
       <td>
         <select name="is_admin">
     </tr>
     <tr class="impair">
       <td class="titre">
-        Email:
+        Email&nbsp;:
       </td>
       <td>
         <input type="text" value="{$user.email}" name="email" size="40" />
       </td>
     </tr>
+    {/if}
+    <tr class="impair">
+      <td class="titre">
+        Commentaire&nbsp;:
+      </td>
+      <td>
+        <input type="text" name="comm" value="{$user.comm}" size="40" maxlength="255" /><br />
+        <small>Poste, origine, ... (accessible à toutes les personnes autorisées à consulter l'annuaire)</small>
+      </td>
+    </tr>
+    {if $user.origine neq X}
     <tr id="make_X" {if $user.origine eq "groupe"}style="display: none"{/if}>
       <td colspan="2">
         <span id="make_X_cb">