From f62bd784d0c37b8cbf773310e2c6457d856bceef Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Fri, 30 Mar 2007 12:54:13 +0000 Subject: [PATCH] Images and link to discussion in events RSS git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1630 839d8a87-29fc-0310-9880-83ba4fa771e5 --- classes/plupload.php | 2 +- classes/xdb.php | 4 ++-- include/marketing.inc.php | 11 ++++++++--- modules/events.php | 5 +++-- modules/profile.php | 2 +- {include => modules/profile}/tabs.inc.php | 0 templates/events/rss.tpl | 17 ++++++++++++++++- upgrade/0.9.14/geoloc.utf8.php | 4 ++-- 8 files changed, 33 insertions(+), 12 deletions(-) rename {include => modules/profile}/tabs.inc.php (100%) diff --git a/classes/plupload.php b/classes/plupload.php index b3dbb56..ea84ca1 100644 --- a/classes/plupload.php +++ b/classes/plupload.php @@ -116,7 +116,7 @@ class PlUpload public function rm() { @unlink($this->filename); - clearstatcache(); + @clearstatcache(); } public function rename($fn) diff --git a/classes/xdb.php b/classes/xdb.php index 0523a96..da211a0 100644 --- a/classes/xdb.php +++ b/classes/xdb.php @@ -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': diff --git a/include/marketing.inc.php b/include/marketing.inc.php index 3765729..600f4f6 100644 --- a/include/marketing.inc.php +++ b/include/marketing.inc.php @@ -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() diff --git a/modules/events.php b/modules/events.php index ff0ca57..4981279 100644 --- a/modules/events.php +++ b/modules/events.php @@ -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); diff --git a/modules/profile.php b/modules/profile.php index 63102d6..a7bc193 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -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'; diff --git a/include/tabs.inc.php b/modules/profile/tabs.inc.php similarity index 100% rename from include/tabs.inc.php rename to modules/profile/tabs.inc.php diff --git a/templates/events/rss.tpl b/templates/events/rss.tpl index 340cfc2..30faf33 100644 --- a/templates/events/rss.tpl +++ b/templates/events/rss.tpl @@ -37,7 +37,22 @@ {$line.titre|strip_tags} {$line.id} {#globals.baseurl#}/events#newsid{$line.id} - + + {$line.title} + + {/if} +
{$line.texte}
+ {if $line.post_id neq -1} +
+
+ + {icon name=comments full=true} Suivre la discussion + +
+ {/if} + ]]>
{$line.prenom} {$line.nom} (X{$line.promo}) {$line.creation_date|rss_date} diff --git a/upgrade/0.9.14/geoloc.utf8.php b/upgrade/0.9.14/geoloc.utf8.php index 635c018..32d07cd 100755 --- a/upgrade/0.9.14/geoloc.utf8.php +++ b/upgrade/0.9.14/geoloc.utf8.php @@ -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)) { -- 2.1.4