From: x2000habouzit Date: Tue, 11 Jul 2006 20:28:41 +0000 (+0000) Subject: migrate vcard.php X-Git-Tag: xorg/0.9.11~455 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=e49018a74296afc7021b6623007f2655fb6fa519;p=platal.git migrate vcard.php git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@444 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/htdocs/vcard.php b/htdocs/vcard.php deleted file mode 100644 index b037519..0000000 --- a/htdocs/vcard.php +++ /dev/null @@ -1,62 +0,0 @@ -register_modifier('qp_enc', 'quoted_printable_encode'); -$page->register_function('format_adr', 'format_adr'); - -$login = get_user_forlife(Env::get('x')); -$user = get_user_details($login); - -// alias virtual -$res = $globals->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}'", - Session::getInt('uid'), $user['forlife'].'@'.$globals->mail->domain, $user['forlife'].'@'.$globals->mail->domain2); -$user['virtualalias'] = $res->fetchOneCell(); - -$page->assign_by_ref('vcard', $user); - -header("Pragma: "); -header("Cache-Control: "); -header("Content-type: text/x-vcard\n"); -header("Content-Transfer-Encoding: Quoted-Printable\n"); - -$page->run(); -?> diff --git a/modules/profile.php b/modules/profile.php index 7713e7b..1f22180 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -24,9 +24,12 @@ class ProfileModule extends PLModule function handlers() { return array( - 'photo' => $this->make_hook('photo', AUTH_PUBLIC), - 'photo/change' => $this->make_hook('photo_change', AUTH_MDP), - 'trombi' => $this->make_hook('trombi', AUTH_COOKIE), + 'photo' => $this->make_hook('photo', AUTH_PUBLIC), + 'photo/change' => $this->make_hook('photo_change', AUTH_MDP), + + 'trombi' => $this->make_hook('trombi', AUTH_COOKIE), + + 'vcard' => $this->make_hook('vcard', AUTH_COOKIE), ); } @@ -165,6 +168,62 @@ class ProfileModule extends PLModule return PL_OK; } + + function format_adr($params, &$smarty) + { + // $adr1, $adr2, $adr3, $postcode, $city, $region, $country + extract($params['adr']); + $adr = $adr1; + $adr = trim("$adr\n$adr2"); + $adr = trim("$adr\n$adr3"); + return quoted_printable_encode(";;$adr;$city;$region;$postcode;$country"); + } + + function handler_vcard(&$page, $x = null) + { + if (is_null($x)) { + return PL_NOT_FOUND; + } + + global $globals; + + if (substr($x, -4) == '.vcf') { + $x = substr($x, 0, strlen($x) - 4); + } + + new_nonhtml_page('vcard.tpl', AUTH_COOKIE); + require_once 'xorg.misc.inc.php'; + require_once 'user.func.inc.php'; + + $page->register_modifier('qp_enc', 'quoted_printable_encode'); + $page->register_function('format_adr', array($this, 'format_adr')); + + $login = get_user_forlife($x); + $user = get_user_details($login); + + // alias virtual + $res = $globals->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}'", + Session::getInt('uid'), + $user['forlife'].'@'.$globals->mail->domain, + $user['forlife'].'@'.$globals->mail->domain2); + + $user['virtualalias'] = $res->fetchOneCell(); + + $page->assign_by_ref('vcard', $user); + + header("Pragma: "); + header("Cache-Control: "); + header("Content-type: text/x-vcard\n"); + header("Content-Transfer-Encoding: Quoted-Printable\n"); + + return PL_OK; + } } ?> diff --git a/templates/fiche.tpl b/templates/fiche.tpl index 4679c95..72377ef 100644 --- a/templates/fiche.tpl +++ b/templates/fiche.tpl @@ -44,7 +44,7 @@ function chgMainWinLoc( strPage ) { {$x.prenom} {if $x.nom_usage eq ""}{$x.nom}{else}{$x.nom_usage} ({$x.nom}){/if} {if $logged} {if $x.nickname} (aka {$x.nickname}){/if}  - + Afficher la carte de visite {if !$x.is_contact} diff --git a/templates/include/minifiche.tpl b/templates/include/minifiche.tpl index 61c18c3..0c2d67d 100644 --- a/templates/include/minifiche.tpl +++ b/templates/include/minifiche.tpl @@ -59,7 +59,7 @@ {* *}Afficher la fiche {if !$c.dcd} - {* + {* *}Afficher la carte de visite {* *}{if $show_action eq {if $m.x} [fiche] - [vcard] + [vcard] mail {else} mail diff --git a/templates/xnet/groupe/evt-admin.tpl b/templates/xnet/groupe/evt-admin.tpl index df1d0d8..156cec4 100644 --- a/templates/xnet/groupe/evt-admin.tpl +++ b/templates/xnet/groupe/evt-admin.tpl @@ -82,7 +82,7 @@ Ils ont pay {$m.promo} [fiche] - [vcard] + [vcard] mail {$m.montant} @@ -127,7 +127,7 @@ Ils ont pay {if $m.x} [fiche] - [vcard] + [vcard] mail {else} mail