Fetches Groupes X logos directly from the database and not from .net on .org.
authorStéphane Jacob <sj@m4x.org>
Tue, 8 Sep 2009 08:23:01 +0000 (10:23 +0200)
committerStéphane Jacob <sj@m4x.org>
Tue, 8 Sep 2009 11:17:22 +0000 (13:17 +0200)
modules/profile.php
templates/profile/groupesx.tpl

index b80d0e2..14ccc88 100644 (file)
@@ -51,6 +51,7 @@ class ProfileModule extends PLModule
             'referent/country'     => $this->make_hook('ref_country',       AUTH_COOKIE, 'user', NO_AUTH),
 
             'groupes-x'            => $this->make_hook('xnet',              AUTH_COOKIE),
+            'groupes-x/logo'       => $this->make_hook('xnetlogo',          AUTH_PUBLIC),
 
             'vcard'                => $this->make_hook('vcard',             AUTH_COOKIE),
             'admin/binets'         => $this->make_hook('admin_binets',      AUTH_MDP,    'admin'),
@@ -714,6 +715,28 @@ class ProfileModule extends PLModule
         $page->assign('assos', $req->fetchAllAssoc());
     }
 
+    function handler_xnetlogo(&$page, $id)
+    {
+        if (is_null($id)) {
+            return PL_NOT_FOUND;
+        }
+
+        $res = XDB::query('SELECT  logo, logo_mime
+                             FROM  groupex.asso
+                            WHERE  id = {?}', $id);
+        list($logo, $logo_mime) = $res->fetchOneRow();
+
+        if (!empty($logo)) {
+            header("Content-type: $mime");
+            echo $logo;
+        } else {
+            header('Content-type: image/jpeg');
+            readfile(dirname(__FILE__) . '/../htdocs/images/dflt_carre.jpg');
+        }
+
+        exit;
+    }
+
     function handler_vcard(&$page, $x = null)
     {
         if (is_null($x)) {
index b9c6b49..f3ea167 100644 (file)
@@ -32,7 +32,7 @@
     <legend style="padding:4px"><strong><a href="http://www.polytechnique.net/login/{$asso.diminutif}">{$asso.nom}</a></strong></legend>
     {if $asso.has_logo}
     <a href="http://www.polytechnique.net/login/{$asso.diminutif}" style="width: 30%; display: block; float: right; ">
-      <img alt="[ LOGO ]" src="http://www.polytechnique.net/{$asso.diminutif}/logo" style="width: 100%" />
+      <img alt="[ LOGO ]" src="{$globals->baseurl}/groupes-x/logo/{$asso.asso_id}" style="width: 100%" />
     </a>
     {/if}
     <ul style="padding-top:0px;padding-bottom:0px">