Show poster photo in banana headers
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 30 Sep 2007 10:40:56 +0000 (12:40 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 30 Sep 2007 10:40:56 +0000 (12:40 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
ChangeLog
include/banana/hooks.inc.php
modules/banana.php
templates/banana/profile.tpl
upgrade/0.9.15/07_forums.sql [new file with mode: 0644]

index 578720c..9de2333 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,9 @@ VERSION 0.9.15                                                        XX XX 2007
 
 New:
 
 
 New:
 
+    * Banana:
+        - Show poster photo                                                -FRU
+
     * Core:
         - Auto-redirect HTML pages to HTTPS                                -FRU
 
     * Core:
         - Auto-redirect HTML pages to HTTPS                                -FRU
 
index 54c5f53..f996497 100644 (file)
@@ -170,6 +170,33 @@ function hook_makeLink($params)
 }
 }
 
 }
 }
 
+function hook_hasXFace($headers)
+{
+    return isset($headers['x-org-id']) || isset($headers['x-org-mail']);
+}
+
+function hook_getXFace($headers)
+{
+    $login = @$headers['x-org-id'];
+    if (!$login) {
+        @list($login, ) = explode('@', $headers['x-org-mail']);
+    }
+    if (!$login) {
+        return false;
+    }
+    if (isset($headers['x-face'])) {
+        $res = XDB::query("SELECT  p.uid
+                             FROM  forums.profils AS p
+                       INNER JOIN  aliases AS a ON (p.uid = a.id)
+                            WHERE  FIND_IN_SET('xface', p.flags) AND a.alias = {?}",
+                          $login);
+        if ($res->numRows()) {
+            return false;
+        }
+    }
+    pl_redirect('photo/' . $login);
+}
+
 function hook_makeJs($src)
 {
     global $page;
 function hook_makeJs($src)
 {
     global $page;
index 891b505..640012d 100644 (file)
@@ -82,31 +82,42 @@ class BananaModule extends PLModule
         && Post::has('bananaupdate') && Post::v('action')=="OK" ))
         {
             $req = XDB::query("
         && Post::has('bananaupdate') && Post::v('action')=="OK" ))
         {
             $req = XDB::query("
-                SELECT  nom,mail,sig,if(FIND_IN_SET('threads',flags),'1','0'),
-                        IF(FIND_IN_SET('automaj',flags),'1','0')
+                SELECT  nom, mail, sig,
+                        FIND_IN_SET('threads', flags),
+                        FIND_IN_SET('automaj', flags),
+                        FIND_IN_SET('xface', flags)
                   FROM  forums.profils
                  WHERE  uid = {?}", S::v('uid'));
                   FROM  forums.profils
                  WHERE  uid = {?}", S::v('uid'));
-            if (!(list($nom,$mail,$sig,$disp,$maj) = $req->fetchOneRow())) {
-                $nom  = S::v('prenom').' '.S::v('nom');
-                $mail = S::v('forlife').'@'.$globals->mail->domain;
-                $sig  = $nom.' ('.S::v('promo').')';
-                $disp = 0;
-                $maj  = 0;
+            if (!(list($nom, $mail, $sig, $disp, $maj, $xface) = $req->fetchOneRow())) {
+                $nom   = S::v('prenom').' '.S::v('nom');
+                $mail  = S::v('forlife').'@'.$globals->mail->domain;
+                $sig   = $nom.' ('.S::v('promo').')';
+                $disp  = 0;
+                $maj   = 0;
+                $xface = 0;
             }
             }
-            $page->assign('nom' , $nom);
-            $page->assign('mail', $mail);
-            $page->assign('sig' , $sig);
-            $page->assign('disp', $disp);
-            $page->assign('maj' , $maj);
+            $page->assign('nom' ,  $nom);
+            $page->assign('mail',  $mail);
+            $page->assign('sig',   $sig);
+            $page->assign('disp',  $disp);
+            $page->assign('maj',   $maj);
+            $page->assign('xface', $xface);
         } else {
         } else {
-            XDB::execute(
-                'REPLACE INTO  forums.profils (uid,sig,mail,nom,flags)
-                       VALUES  ({?},{?},{?},{?},{?})',
-                S::v('uid'), Post::v('bananasig'),
-                Post::v('bananamail'), Post::v('banananame'),
-                (Post::b('bananadisplay') ? 'threads,' : '') .
-                (Post::b('bananaupdate') ? 'automaj' : '')
-            );
+            $flags = array();
+            if (Post::b('bananadisplay')) {
+                $flags[] = 'threads';
+            }
+            if (Post::b('bananaupdate')) {
+                $flags[] = 'automaj';
+            }
+            if (Post::b('bananaxface')) {
+                $flags[] = 'xface';
+            }
+            XDB::execute("REPLACE INTO  forums.profils (uid, sig, mail, nom, flags)
+                                VALUES  ({?}, {?}, {?}, {?}, {?})",
+                         S::v('uid'), Post::v('bananasig'),
+                         Post::v('bananamail'), Post::v('banananame'),
+                         implode(',', $flags));
         }
     }
 
         }
     }
 
index 4298195..bb97abd 100644 (file)
@@ -38,7 +38,7 @@
 {if !$smarty.post.action}
 
       <p class="normal">
 {if !$smarty.post.action}
 
       <p class="normal">
-        Tu peux régler quelques paramètres qui apparaîtront sur les messages lorsque 
+        Tu peux régler quelques paramètres qui apparaîtront sur les messages lorsque
         tu posteras sur les forums. Cela ne te permettra pas d'être anonyme, puisque
         tout le monde pourra remonter à ton identité en regardant ta fiche. L'objectif
         est simplement de permettre plus de convivialité.
         tu posteras sur les forums. Cela ne te permettra pas d'être anonyme, puisque
         tout le monde pourra remonter à ton identité en regardant ta fiche. L'objectif
         est simplement de permettre plus de convivialité.
       <form action="banana/profile" method="post">
         <table class="bicol" cellpadding="3" cellspacing="0" summary="Configuration de Banana">
           <tr>
       <form action="banana/profile" method="post">
         <table class="bicol" cellpadding="3" cellspacing="0" summary="Configuration de Banana">
           <tr>
-            <th colspan="2">
-              Profil Banana
-            </th>
+            <th colspan="2">Profil Banana</th>
           </tr>
           </tr>
-          <tr class="pair">
-            <td class="bicoltitre">
-              Nom
-            </td>
-            <td>
-              <input type="text" name="banananame" value="{$nom}" />
-            </td>
+          <tr>
+            <td class="titre">Nom</td>
+            <td><input type="text" name="banananame" value="{$nom}" /></td>
           </tr>
           </tr>
-          <tr class="impair">
-            <td class="bicoltitre">
-              Adresse électronique
-            </td>
-            <td>
-              <input type="text" name="bananamail" value="{$mail}" />
-            </td>
+          <tr>
+            <td class="titre">Adresse électronique</td>
+            <td><input type="text" name="bananamail" value="{$mail}" /></td>
           </tr>
           </tr>
-          <tr class="pair">
-            <td class="bicoltitre">
-              Signature
-            </td>
-            <td>
-              <textarea name="bananasig" cols="50" rows="4">{$sig}</textarea>
-            </td>
+          <tr>
+            <td class="titre">Signature</td>
+            <td><textarea name="bananasig" cols="50" rows="4">{$sig}</textarea></td>
           </tr>
           </tr>
-          <tr class="impair">
-            <td class="bicoltitre">
-              Affichage des fils de discussion
-            </td>
+          <tr class="pair">
+            <td class="titre">Affichage des fils de discussion</td>
             <td>
             <td>
-              <input type="radio" name="bananadisplay" value="0" 
-              {if !$disp}checked="checked"{/if} /> Afficher tous 
+              <input type="radio" name="bananadisplay" value="0"
+              {if !$disp}checked="checked"{/if} /> Afficher tous
               les messages
               <br />
               les messages
               <br />
-              <input type="radio" name="bananadisplay" value="1" 
-              {if $disp}checked="checked"{/if} /> Afficher 
-              seulement les fils de discussion contenant des messages non lus 
+              <input type="radio" name="bananadisplay" value="1"
+              {if $disp}checked="checked"{/if} /> Afficher
+              seulement les fils de discussion contenant des messages non lus
             </td>
           </tr>
           <tr class="pair">
             </td>
           </tr>
           <tr class="pair">
-            <td class="bicoltitre">
-              Mise à jour des messages non lus
-            </td>
+            <td class="titre">Mise à jour des messages non lus</td>
             <td>
             <td>
-              <input type="radio" name="bananaupdate" value="1" 
+              <input type="radio" name="bananaupdate" value="1"
               {if $maj}checked="checked"{/if} /> Automatique
               <br />
               {if $maj}checked="checked"{/if} /> Automatique
               <br />
-              <input type="radio" name="bananaupdate" value="0" 
+              <input type="radio" name="bananaupdate" value="0"
               {if !$maj}checked="checked"{/if} /> Manuelle
             </td>
           </tr>
               {if !$maj}checked="checked"{/if} /> Manuelle
             </td>
           </tr>
-          <tr class="impair">
-            <td class="bouton" colspan="2">
-              <input type="submit" name="action" value="OK" />
+          <tr class="pair">
+            <td class="titre" colspan="2">
+              <input type="checkbox" {if $xface}checked="checked"{/if} name="bananaxface" id="xface" />
+              <label for="xface">Afficher mon X-Face plutôt que ma photo si il est disponible</label>
             </td>
           </tr>
         </table>
             </td>
           </tr>
         </table>
+        <div class="center"><input type="submit" name="action" value="Enregistrer" /></div>
       </form>
 
 {else}
       </form>
 
 {else}
   </tr>
 </table>
 
   </tr>
 </table>
 
+<p class="smaller">
+  {icon name="lightbulb" title="Astuce"}Astuce&nbsp;:
+  Tu peux également consulter les fora en utilisant un client NNTP tel que
+  Outlook Express ou Thunderbird.<br />N'hésite pas à <a href="password/smtp?doc=nntp">
+  consulter la documentation et à activer ton accès</a> pour utiliser ce service.
+</p>
+
+
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
diff --git a/upgrade/0.9.15/07_forums.sql b/upgrade/0.9.15/07_forums.sql
new file mode 100644 (file)
index 0000000..86419fc
--- /dev/null
@@ -0,0 +1,5 @@
+use forums;
+alter table profils change flags flags set('threads','automaj','xface') not null;
+use x4dat;
+
+# vim:set syntax=mysql: