migrate vcard.php
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 11 Jul 2006 20:28:41 +0000 (20:28 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 11 Jul 2006 20:28:41 +0000 (20:28 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@444 839d8a87-29fc-0310-9880-83ba4fa771e5

htdocs/vcard.php [deleted file]
modules/profile.php
templates/fiche.tpl
templates/include/minifiche.tpl
templates/xnet/groupe/annuaire.tpl
templates/xnet/groupe/evt-admin.tpl

diff --git a/htdocs/vcard.php b/htdocs/vcard.php
deleted file mode 100644 (file)
index b037519..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 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                *
- ***************************************************************************/
-
-require_once("xorg.inc.php");
-new_nonhtml_page('vcard.tpl', AUTH_COOKIE);
-require_once("xorg.misc.inc.php");
-require_once("user.func.inc.php");
-
-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");
-}
-
-$page->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();
-?>
index 7713e7b..1f22180 100644 (file)
@@ -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;
+    }
 }
 
 ?>
index 4679c95..72377ef 100644 (file)
@@ -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}&nbsp;
-        <a href="vcard.php/{$x.forlife}.vcf?x={$x.forlife}">
+        <a href="vcard/{$x.forlife}.vcf">
           <img src="images/vcard.png" alt="Afficher la carte de visite" title="Afficher la carte de visite"/>
         </a>
         {if !$x.is_contact}
index 61c18c3..0c2d67d 100644 (file)
@@ -59,7 +59,7 @@
         <a href="{rel}/fiche.php?user={$c.forlife}" class="popup2">{*
         *}<img src="{rel}/images/loupe.gif" alt="Afficher la fiche" title="Afficher la fiche" /></a>
       {if !$c.dcd}
-        <a href="{rel}/vcard.php/{$c.forlife}.vcf?x={$c.forlife}">{*
+        <a href="{rel}/vcard/{$c.forlife}.vcf">{*
         *}<img src="{rel}/images/vcard.png" alt="Afficher la carte de visite" title="Afficher la carte de visite" /></a>
         <a href="{rel}/carnet/contacts?action={$show_action}&amp;user={$c.forlife}">{*
         *}<img src="{rel}/images/{$show_action}.gif" alt="{if $show_action eq "ajouter"}Ajouter à mes{else}Retirer de mes{/if} contacts"
index 636abe9..02899a7 100644 (file)
@@ -65,7 +65,7 @@ Fonctionnalit
     <td>
       {if $m.x}
       <a href="https://www.polytechnique.org/fiche.php?user={$m.email}"><img src="{rel}/images/loupe.gif" alt="[fiche]" /></a>
-      <a href="https://www.polytechnique.org/vcard.php/{$m.email}.vcf/?x={$m.email}"><img src="{rel}/images/vcard.png" alt="[vcard]" /></a>
+      <a href="https://www.polytechnique.org/vcard/{$m.email}.vcf"><img src="{rel}/images/vcard.png" alt="[vcard]" /></a>
       <a href="mailto:{$m.email}@polytechnique.org"><img src="{rel}/images/mail.png" alt="mail" /></a>
       {else}
       <a href="mailto:{$m.email}"><img src="{rel}/images/mail.png" alt="mail" /></a>
index df1d0d8..156cec4 100644 (file)
@@ -82,7 +82,7 @@ Ils ont pay
     <td>{$m.promo}</td>
     <td>
       <a href="https://www.polytechnique.org/fiche.php?user={$m.email}"><img src="{rel}/images/loupe.gif" alt="[fiche]" /></a>
-      <a href="https://www.polytechnique.org/vcard.php/{$m.email}.vcf/?x={$m.email}"><img src="{rel}/images/vcard.png" alt="[vcard]" /></a>
+      <a href="https://www.polytechnique.org/vcard/{$m.email}.vcf"><img src="{rel}/images/vcard.png" alt="[vcard]" /></a>
       <a href="mailto:{$m.email}@polytechnique.org"><img src="{rel}/images/mail.png" alt="mail" /></a>
     </td>
     <td>{$m.montant}</td>
@@ -127,7 +127,7 @@ Ils ont pay
     <td>
       {if $m.x}
       <a href="https://www.polytechnique.org/fiche.php?user={$m.email}"><img src="{rel}/images/loupe.gif" alt="[fiche]" /></a>
-      <a href="https://www.polytechnique.org/vcard.php/{$m.email}.vcf/?x={$m.email}"><img src="{rel}/images/vcard.png" alt="[vcard]" /></a>
+      <a href="https://www.polytechnique.org/vcard/{$m.email}.vcf"><img src="{rel}/images/vcard.png" alt="[vcard]" /></a>
       <a href="mailto:{$m.email}@polytechnique.org"><img src="{rel}/images/mail.png" alt="mail" /></a>
       {else}
       <a href="mailto:{$m.email}"><img src="{rel}/images/mail.png" alt="mail"></a>