Fix profile link in public search for unregistered users.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 28 Mar 2008 09:33:59 +0000 (10:33 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 28 Mar 2008 09:33:59 +0000 (10:33 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
modules/profile.php
plugins/function.make_forlife.php [new file with mode: 0644]
templates/include/minifiche.tpl

index d8780f2..a8d2c57 100644 (file)
@@ -190,11 +190,15 @@ class ProfileModule extends PLModule
                       WHERE  matricule={?}", $x);
             $login = $res->fetchOneCell();
         } else {
-            $login = get_user_forlife($x);
+            $login = get_user_forlife($x, S::logged() ? '_default_user_callback'
+                                                      : '_silent_user_callback');
         }
 
         if (empty($login)) {
-            if (preg_match('/([-a-z]+)\.([-a-z]+)\.([0-9]{4})/i', $x, $matches)) {
+            if (!S::logged()) {
+                $page->kill("Ce camarade n'a pas de fiche publique.");
+                return;
+            } else if (preg_match('/([-a-z]+)\.([-a-z]+)\.([0-9]{4})/i', $x, $matches)) {
                 $matches = str_replace('-', '_', $matches);
                 $res = XDB::query("SELECT user_id
                                      FROM auth_user_md5
diff --git a/plugins/function.make_forlife.php b/plugins/function.make_forlife.php
new file mode 100644 (file)
index 0000000..8578f90
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+/***************************************************************************
+ *  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                *
+ ***************************************************************************/
+require_once 'platal.inc.php';
+
+function smarty_function_make_forlife($params, &$smarty)
+{
+  return make_forlife($params['nom'], $params['prenom'], $params['promo']);
+}
+
+/* vim: set expandtab enc=utf-8: */
+?>
index 959f017..66ecc64 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
-
 {if (!$c.inscrit && $smarty.session.auth ge AUTH_COOKIE) || $c.dcd}<div class='grayed'>{/if}
 <div class="contact" {if $c.inscrit}{if $smarty.session.auth ge AUTH_COOKIE}title="fiche mise à jour le {$c.date|date_format}"{/if}{/if}>
 
   <div class="nom">
     {if $c.sexe}&bull;{/if}
-    {if !$c.dcd && $c.inscrit}<a href="profile/{$c.forlife}" class="popup2">{/if}
+    {if !$c.dcd && ($c.inscrit || $smarty.session.auth eq AUTH_PUBLIC)}<a href="profile/{if $c.inscrit}{$c.forlife}{else}{make_forlife nom=$c.nom prenom=$c.prenom promo=$c.promo}{/if}" class="popup2">{/if}
     {if $c.nom_usage}{$c.nom_usage} {$c.prenom}<br />({$c.nom}){else}{$c.nom} {$c.prenom}{/if}
-    {if !$c.dcd && $c.inscrit}</a>{/if}
+    {if !$c.dcd && ($c.inscrit || $smarty.session.auth eq AUTH_PUBLIC)}</a>{/if}
   </div>
 
   <div class="appli">