From 5e1932971f861f2ca29f27384c6a502c4702de76 Mon Sep 17 00:00:00 2001
From: x2003bruneau
Date: Sun, 22 Oct 2006 14:57:23 +0000
Subject: [PATCH] Can generate multi-user vcards: - add a vcard with all 'my
contacts' - add a vcard with all the members of a group
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1003 839d8a87-29fc-0310-9880-83ba4fa771e5
---
ChangeLog | 6 ++++
modules/carnet.php | 25 +++++++++----
modules/profile.php | 74 ++------------------------------------
modules/xnetgrp.php | 33 ++++++++++++-----
templates/carnet/mescontacts.tpl | 30 +++++++++-------
templates/vcard.tpl | 2 +-
templates/xnet/groupe/annuaire.tpl | 26 +++++++++++---
7 files changed, 92 insertions(+), 104 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9582d12..9186518 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,12 @@ New:
* Admin:
- Can add sorting key in Table Editor. -FRU
+ * Carnet:
+ - Add a vcard of all the contacts -FRU
+
+ * Xnet:
+ - Add a vcard of all the members of a group -FRU
+
Bug/Wish:
* Admin:
diff --git a/modules/carnet.php b/modules/carnet.php
index 6d05b68..88c1d84 100644
--- a/modules/carnet.php
+++ b/modules/carnet.php
@@ -24,15 +24,16 @@ class CarnetModule extends PLModule
function handlers()
{
return array(
- 'carnet' => $this->make_hook('index', AUTH_COOKIE),
- 'carnet/panel' => $this->make_hook('panel', AUTH_COOKIE),
- 'carnet/notifs' => $this->make_hook('notifs', AUTH_COOKIE),
+ 'carnet' => $this->make_hook('index', AUTH_COOKIE),
+ 'carnet/panel' => $this->make_hook('panel', AUTH_COOKIE),
+ 'carnet/notifs' => $this->make_hook('notifs', AUTH_COOKIE),
- 'carnet/contacts' => $this->make_hook('contacts', AUTH_COOKIE),
- 'carnet/contacts/pdf' => $this->make_hook('pdf', AUTH_COOKIE),
+ 'carnet/contacts' => $this->make_hook('contacts', AUTH_COOKIE),
+ 'carnet/contacts/pdf' => $this->make_hook('pdf', AUTH_COOKIE),
+ 'carnet/contacts/ical' => $this->make_hook('ical', AUTH_COOKIE),
+ 'carnet/contacts/vcard' => $this->make_hook('vcard', AUTH_COOKIE),
- 'carnet/rss' => $this->make_hook('rss', AUTH_PUBLIC),
- 'carnet/ical' => $this->make_hook('ical', AUTH_PUBLIC),
+ 'carnet/rss' => $this->make_hook('rss', AUTH_PUBLIC),
);
}
@@ -372,6 +373,16 @@ class CarnetModule extends PLModule
header('Content-Type: text/calendar; charset=utf-8');
}
+
+ function handler_vcard(&$page)
+ {
+ $res = XDB::query('SELECT contact
+ FROM contacts
+ WHERE uid = {?}', S::v('uid'));
+ require_once('vcard.inc.php');
+ $vcard = new VCard($res->fetchColumn());
+ $vcard->do_page(&$page);
+ }
}
?>
diff --git a/modules/profile.php b/modules/profile.php
index f32a683..d3a5530 100644
--- a/modules/profile.php
+++ b/modules/profile.php
@@ -659,34 +659,6 @@ class ProfileModule extends PLModule
}
}
- function vcard_escape($text)
- {
- return preg_replace('/[,;]/', '\\\\$0', $text);
- }
-
- function format_adr($params, &$smarty)
- {
- // $adr1, $adr2, $adr3, $postcode, $city, $region, $country
- extract($params['adr']);
- $adr = trim($adr1);
- $adr = trim("$adr\n$adr2");
- $adr = trim("$adr\n$adr3");
- return $this->vcard_text_encode(';;'
- . $this->vcard_escape($adr) . ';'
- . $this->vcard_escape($city) . ';'
- . $this->vcard_escape($region) . ';'
- . $this->vcard_escape($postcode) . ';'
- . $this->vcard_escape($country), false);
- }
-
- function vcard_text_encode($text, $escape = true)
- {
- if ($escape) {
- $text = $this->vcard_escape($text);
- }
- return str_replace("\n", "\\n", $text); //implode('\n', explode("\n", $text));
- }
-
function handler_vcard(&$page, $x = null)
{
if (is_null($x)) {
@@ -699,49 +671,9 @@ class ProfileModule extends PLModule
$x = substr($x, 0, strlen($x) - 4);
}
- $page->changeTpl('vcard.tpl', NO_SKIN);
- require_once 'xorg.misc.inc.php';
- require_once 'user.func.inc.php';
-
- $page->register_modifier('vcard_enc', array($this, 'vcard_text_encode'));
- $page->register_function('format_adr', array($this, 'format_adr'));
-
- $login = get_user_forlife($x);
- $user = get_user_details($login);
-
- if (strlen(trim($user['freetext']))) {
- $user['freetext'] = html_entity_decode($user['freetext']);
- }
-
- // alias virtual
- $res = XDB::query(
- "SELECT alias
- FROM virtual
- INNER JOIN virtual_redirect USING(vid)
- INNER JOIN auth_user_quick ON ( user_id = {?} AND emails_alias_pub = 'public' )
- WHERE ( redirect={?} OR redirect={?} )
- AND alias LIKE '%@{$globals->mail->alias_dom}'",
- S::v('uid'),
- $user['forlife'].'@'.$globals->mail->domain,
- $user['forlife'].'@'.$globals->mail->domain2);
-
- $user['virtualalias'] = $res->fetchOneCell();
-
- // get photo
- $res = XDB::query(
- "SELECT attach, attachmime
- FROM photo AS p
- INNER JOIN aliases AS a ON (a.id = p.uid AND a.type = 'a_vie')
- WHERE a.alias = {?}", $login);
- if ($res->numRows()) {
- $user['photo'] = $res->fetchOneAssoc();
- }
- $page->assign('users', array($user));
-
- header("Pragma: ");
- header("Cache-Control: ");
- header("Content-type: text/x-vcard; charset=iso-8859-15");
- header("Content-Transfer-Encoding: 8bit");
+ require_once('vcard.inc.php');
+ $vcard = new VCard($x);
+ $vcard->do_page($page);
}
function handler_admin_trombino(&$page, $uid = null, $action = null) {
diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php
index 522fbcc..0b3dc7d 100644
--- a/modules/xnetgrp.php
+++ b/modules/xnetgrp.php
@@ -65,14 +65,15 @@ class XnetGrpModule extends PLModule
function handlers()
{
return array(
- '%grp' => $this->make_hook('index', AUTH_PUBLIC),
- '%grp/asso.php' => $this->make_hook('index', AUTH_PUBLIC),
- '%grp/logo' => $this->make_hook('logo', AUTH_PUBLIC),
- '%grp/edit' => $this->make_hook('edit', AUTH_MDP),
- '%grp/mail' => $this->make_hook('mail', AUTH_MDP),
- '%grp/annuaire' => $this->make_hook('annuaire', AUTH_MDP),
- '%grp/subscribe' => $this->make_hook('subscribe', AUTH_MDP),
- '%grp/paiement' => $this->make_hook('paiement', AUTH_MDP),
+ '%grp' => $this->make_hook('index', AUTH_PUBLIC),
+ '%grp/asso.php' => $this->make_hook('index', AUTH_PUBLIC),
+ '%grp/logo' => $this->make_hook('logo', AUTH_PUBLIC),
+ '%grp/edit' => $this->make_hook('edit', AUTH_MDP),
+ '%grp/mail' => $this->make_hook('mail', AUTH_MDP),
+ '%grp/annuaire' => $this->make_hook('annuaire', AUTH_MDP),
+ '%grp/annuaire/vcard' => $this->make_hook('vcard', AUTH_MDP),
+ '%grp/subscribe' => $this->make_hook('subscribe', AUTH_MDP),
+ '%grp/paiement' => $this->make_hook('paiement', AUTH_MDP),
'%grp/admin/annuaire'
=> $this->make_hook('admin_annuaire', AUTH_MDP),
@@ -326,6 +327,22 @@ class XnetGrpModule extends PLModule
$page->assign('ann', $ann);
}
+ function handler_vcard(&$page)
+ {
+ global $globals;
+
+ if (($globals->asso('pub') == 'public' && is_member()) || may_update()) {
+ $res = XDB::query('SELECT uid
+ FROM groupex.membres
+ WHERE asso_id = {?}', $globals->asso('id'));
+ require_once('vcard.inc.php');
+ $vcard = new VCard($res->fetchColumn(), 'Membre du groupe ' . $globals->asso('nom'));
+ $vcard->do_page($page);
+ } else {
+ return PL_NOTALLOWED;
+ }
+ }
+
function handler_subscribe(&$page, $u = null)
{
global $globals;
diff --git a/templates/carnet/mescontacts.tpl b/templates/carnet/mescontacts.tpl
index e8bdbfe..d72736c 100644
--- a/templates/carnet/mescontacts.tpl
+++ b/templates/carnet/mescontacts.tpl
@@ -54,18 +54,24 @@ Pour r
[]
-
+
+
+ Tu peux télécharger une de tes contacts :
+
+
{if $trombi}
diff --git a/templates/vcard.tpl b/templates/vcard.tpl
index 01935f4..dd9ad0e 100644
--- a/templates/vcard.tpl
+++ b/templates/vcard.tpl
@@ -80,6 +80,6 @@ PHOTO;ENCODING=b;TYPE={$vcard.photo.attachmime}:{$vcard.photo.attach|base64_enco
{/if}
SORT-STRING:{$vcard.nom|vcard_enc}
REV:{$vcard.date|date_format:"%Y%m%dT000000Z"}
-END:VCARD
+END:VCARD{"\n"}
{/foreach}
{* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/templates/xnet/groupe/annuaire.tpl b/templates/xnet/groupe/annuaire.tpl
index 95e5d5a..83279bd 100644
--- a/templates/xnet/groupe/annuaire.tpl
+++ b/templates/xnet/groupe/annuaire.tpl
@@ -30,15 +30,31 @@ Le groupe {$asso.nom} compte {$nb_tot} membres.
Les membres extérieurs du groupe sont intégrés à cette liste, et repérés par l'inscription 'extérieur' dans la colonne promotion.
-{if $admin}
-Fonctionnalités visibles uniquement par les administrateurs :
+Tu peux également :
-{/if}
[tout]
--
2.1.4