Images and link to discussion in events RSS
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Fri, 30 Mar 2007 12:54:13 +0000 (12:54 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Fri, 30 Mar 2007 12:54:13 +0000 (12:54 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1630 839d8a87-29fc-0310-9880-83ba4fa771e5

classes/plupload.php
classes/xdb.php
include/marketing.inc.php
modules/events.php
modules/profile.php
modules/profile/tabs.inc.php [moved from include/tabs.inc.php with 100% similarity]
templates/events/rss.tpl
upgrade/0.9.14/geoloc.utf8.php

index b3dbb56..ea84ca1 100644 (file)
@@ -116,7 +116,7 @@ class PlUpload
     public function rm()
     {
         @unlink($this->filename);
-        clearstatcache();
+        @clearstatcache();
     }
 
     public function rename($fn)
index 0523a96..da211a0 100644 (file)
@@ -41,7 +41,7 @@ class XDB
 
     public static function _prepare($args)
     {
-        $query    = array_map(Array('XDB', '_db_escape'), $args);
+        $query    = array_map(Array('XDB', 'escape'), $args);
         $query[0] = str_replace('{?}', '%s', str_replace('%',   '%%', $args[0]));
         return call_user_func_array('sprintf', $query);
     }
@@ -143,7 +143,7 @@ class XDB
         return XDB::$mysqli->affected_rows;
     }
 
-    public static function _db_escape($var)
+    public static function escape($var)
     {
         switch (gettype($var)) {
           case 'boolean':
index 3765729..600f4f6 100644 (file)
@@ -43,7 +43,7 @@ class Marketing
     {
         $this->user         = $this->getUser($uid, $email);
         $this->sender_mail  = $this->getFrom($from, $sender);
-        $this->engine       = $this->getEngine($type, $data, $from == 'user' ? null : $this->sender);
+        $this->engine      =& $this->getEngine($type, $data, $from == 'user' ? null : $this->sender);
 
         $this->type   = $type;
         $this->data   = $data;
@@ -85,13 +85,18 @@ class Marketing
         }
     }
 
-    private function getEngine($type, $data, $from)
+    private function &getEngine($type, $data, $from)
     {
         $class = $type . 'Marketing';
         if (!class_exists($class, false)) {
             $class= 'DefaultMarketing';
         }
-        return new $class($data, $from);
+        if (!is_subclass_of($class, 'MarketingEngine')) {
+            $engine = null;
+        } else {
+            $engine = new $class($data, $from);
+        }
+        return $engine;
     }
 
     public function getTitle()
index ff0ca57..4981279 100644 (file)
@@ -27,7 +27,7 @@ class EventsModule extends PLModule
             'events'         => $this->make_hook('ev',        AUTH_COOKIE),
             'rss'            => $this->make_hook('rss', AUTH_PUBLIC),
             'events/preview' => $this->make_hook('preview', AUTH_PUBLIC, 'user', NO_AUTH),
-            'events/photo'   => $this->make_hook('photo', AUTH_COOKIE),
+            'events/photo'   => $this->make_hook('photo', AUTH_PUBLIC),
             'events/submit'  => $this->make_hook('ev_submit', AUTH_MDP),
             'admin/events'   => $this->make_hook('admin_events',     AUTH_MDP, 'admin'),
 
@@ -251,11 +251,12 @@ class EventsModule extends PLModule
         $uid = init_rss('events/rss.tpl', $user, $hash);
             
         $rss = XDB::iterator(
-                'SELECT  e.id, e.titre, e.texte, e.creation_date,
+                'SELECT  e.id, e.titre, e.texte, e.creation_date, e.post_id, p.attachmime IS NOT NULL AS photo,
                          IF(u2.nom_usage = "", u2.nom, u2.nom_usage) AS nom, u2.prenom, u2.promo
                    FROM  auth_user_md5   AS u
              INNER JOIN  evenements      AS e ON ( (e.promo_min = 0 || e.promo_min <= u.promo)
                                                  AND (e.promo_max = 0 || e.promo_max >= u.promo) )
+              LEFT JOIN  evenements_photo AS p ON (p.eid = e.id)
              INNER JOIN  auth_user_md5   AS u2 ON (u2.user_id = e.user_id)
                   WHERE  u.user_id = {?} AND FIND_IN_SET(e.flags, "valide")
                                          AND peremption >= NOW()', $uid);
index 63102d6..a7bc193 100644 (file)
@@ -265,7 +265,7 @@ class ProfileModule extends PLModule
         $page->addCssLink('profil.css');
         $page->assign('xorg_title', 'Polytechnique.org - Mon Profil');
 
-        require_once 'tabs.inc.php';
+        require_once dirname(__FILE__) . '/profile/tabs.inc.php';
         require_once 'profil.func.inc.php';
         require_once 'synchro_ax.inc.php';
 
index 340cfc2..30faf33 100644 (file)
       <title>{$line.titre|strip_tags}</title>
       <guid isPermaLink="false">{$line.id}</guid>
       <link>{#globals.baseurl#}/events#newsid{$line.id}</link>
-      <description><![CDATA[{$line.texte|nl2br}]]></description>
+      <description><![CDATA[
+        {if $line.photo}
+        <div style="float: left; padding-right: 0.5em">
+          <img src="{#globals.baseurl#}/events/photo/{$line.id}" alt="{$line.title}" />
+        </div>
+        {/if}
+        <div>{$line.texte}</div>
+        {if $line.post_id neq -1}
+        <div style="clear: both">
+          <br />
+          <a href="{#globals.baseurl#}/banana/{#globals.banana.event_reply#|default:#globals.banana.event_forum#}/read/{$line.post_id}">
+          {icon name=comments full=true} Suivre la discussion
+          </a>
+        </div>
+        {/if}
+      ]]></description>
       <author>{$line.prenom} {$line.nom} (X{$line.promo})</author>
       <pubDate>{$line.creation_date|rss_date}</pubDate>
     </item>
index 635c018..32d07cd 100755 (executable)
@@ -22,10 +22,10 @@ foreach ($tables as $table) {
         $from = array();
         $to   = array();
         foreach ($array as $key=>$value) {
-            $from[] = $key . '="' . XDB::_db_escape($value) . '"';
+            $from[] = $key . '="' . XDB::escape($value) . '"';
             $valued = utf8_decode($value);
             if (is_utf8($value) && $valued != $value) {
-                $to[] = $key . '="' . XDB::_db_escape($valued) .'"';
+                $to[] = $key . '="' . XDB::escape($valued) .'"';
             }
         }
         if (!empty($to)) {