From 102f4e64c74b88ed6215a4986fca98658871711e Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Fri, 27 Jun 2008 23:41:24 +0200 Subject: [PATCH 1/1] Can export X.net directory as a .csv file (Close #847) Signed-off-by: Florent Bruneau --- htdocs/images/icons/page_excel.gif | Bin 0 -> 1337 bytes htdocs/images/icons/page_white_excel.gif | Bin 0 -> 1083 bytes modules/xnetgrp.php | 29 +++++++++++++++++++++++++++++ templates/xnetgrp/annuaire-csv.tpl | 30 ++++++++++++++++++++++++++++++ templates/xnetgrp/annuaire.tpl | 6 ++++++ 5 files changed, 65 insertions(+) create mode 100644 htdocs/images/icons/page_excel.gif create mode 100644 htdocs/images/icons/page_white_excel.gif create mode 100644 templates/xnetgrp/annuaire-csv.tpl diff --git a/htdocs/images/icons/page_excel.gif b/htdocs/images/icons/page_excel.gif new file mode 100644 index 0000000000000000000000000000000000000000..c424a63072a7484f559dcb7a932072976c271d1b GIT binary patch literal 1337 zcmZ?wbhEHb6krfwc*ek>lek?kWv4;vF5?m@lk7d_74jB^`>o3k*<^0EtvYO9SMOM_ z=Ty1hx%QAt<5AZpGmjQ4&(Es$gD5;k?AcZL!4*a!QuOmaa>$-T1I+TVeCM-j;2TT6R~o z9LQ?lQ`~hhcfytlQ+F<$cA|9Q!HtVAH*LB2a?9mUTW);YdTY+kYhU)<{I>7%)ZYz)#6UnC|M7dQq4_~7=_w`&ZHAlb{hAhU3*!z#m51hkNWfl&k~E0PXj zYk=5E5Vj47U0za90#p+KVkc)LrU2PM%%D>g666eIPXMy{(jn{xAa)Xjy#d57OHK#r zJpg1I{%mZ>h067*Zsl~~_003E5l3Y*(RKzp~$W{Rb0FVZP5^n|uJ6Q$><}(Pf zsA2|&HOm+n#MKaD8WIc)qTvh-JB$%xp98^x!YFp8IL#Os&_KY*L_^T zCF|)Z7#SE?0Mh_S1*ni=U_aX6&nw*0Dl8<#?%&-l=;b|OqL-_NY>&T?kAveJdwWYi z^Qk>E=PaA=H%FVtUtCN^#!!o!TY%rd%g2*3 za|_7$mz5QYtj}yYTGY0xynS^=-;Ub;lPwd^7f%6#&8;(M&YZowf8O57i}p=lynp7h zL$g*MowxSF>~+t&)}L6q`Rs}lHxFKVaOV1xOV6G?d;R+LmoHzw|N8dl&mXX>p@ia3 z7ET5R8wSPye>|O?gWR3m4Gj#97#NriBo-9pFacHN=9Lry#T6nVqZHV0Ft9O5L$oF) z7Z*4N1o$AEhRXhSje!v)a#7m#7=^+Z9weul7bST zng9?xIU_Lz$Od8touZH+XCQk5kj!vFuj7ybYL zcQMe8I}8j5@{&u7%D`%Ys+lYq7zptpo`aYUi3E^6Pz(}AV_(Pv2LMQh!GM8bp$7v) zI2QwhcPj(KtcMH?>gyO7gtsv;1n@F2gjg~#Sv-MZNMM2WNjWFxWF{3QmZYXAfD(*z zeolT-aY15oDp;C&L`iA|Fj5#8obwARi!#$QN)#M{=_^%7!80#ePe;MXz`z2S20$u6 znUsO8-CFp(|T_Cfj(hZuu!9*5jnC zzV~g#v}-zS!i92XT!Fzhg4W79YAWoe)|`I+ $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), @@ -473,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; diff --git a/templates/xnetgrp/annuaire-csv.tpl b/templates/xnetgrp/annuaire-csv.tpl new file mode 100644 index 0000000..30e6a7c --- /dev/null +++ b/templates/xnetgrp/annuaire-csv.tpl @@ -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: *} diff --git a/templates/xnetgrp/annuaire.tpl b/templates/xnetgrp/annuaire.tpl index acb7244..552fb53 100644 --- a/templates/xnetgrp/annuaire.tpl +++ b/templates/xnetgrp/annuaire.tpl @@ -42,6 +42,12 @@ Le groupe {$asso.nom} compte {$nb_tot} membres : {/if}
  • + + {icon name=page_excel title="Fichier Excel"} + Obtenir au format Excel + +
  • +
  • {icon name=vcard title="Carte de visite"} Ajouter les membres à ton carnet d'adresse -- 2.1.4