X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fevents.php;h=b4a36812d7dfed99711979bfe798c210ab24a332;hb=e00bc67e218cc6ba38923da4ca1af7219b648cce;hp=ac4a68b040cbce79b333db2b005014c9af2e8598;hpb=16703e553d2616c5a8c20a0ed11dd985552f8991;p=platal.git diff --git a/modules/events.php b/modules/events.php index ac4a68b..b4a3681 100644 --- a/modules/events.php +++ b/modules/events.php @@ -1,6 +1,6 @@ 0, 'titre' => 'Bienvenue sur la nouvelle version du site !', 'text' => 'Le site a été mis à jour depuis ta dernière visite vers la version ' . $globals->version - . '. Nous t\'invitons à en découvrir les nouveautés en te rendant sur ' - . 'nos forums ou en consultant ' - . 'la liste exhaustive des modifications.

' - . 'Tu peux également consulter le panorama des services ' - . 'fournis par le site.', + . '.
Nous t\'invitons à faire un tour d\'horizon des ' + . 'nouveautés.

' + . 'Tu peux également retrouver ces informations sur ' + . 'les forums, ou sur la liste exhaustive des modifications.', 'priorite' => 255, 'promo_min' => 0, 'promo_max' => 0, @@ -82,43 +81,6 @@ class EventsModule extends PLModule return $res->fetchOneAssoc(); } - private function get_events($where, $order, array &$array, $name) - { - // affichage des evenements - // annonces promos triées par présence d'une limite sur les promos - // puis par dates croissantes d'expiration - $promo = S::v('promo'); - $uid = S::i('uid'); - $sql = "SELECT e.id,e.titre, ev.user_id IS NULL AS nonlu - FROM evenements AS e - LEFT JOIN evenements_vus AS ev ON (e.id = ev.evt_id AND ev.user_id = {?}) - WHERE FIND_IN_SET('valide', e.flags) AND peremption >= NOW() - AND (e.promo_min = 0 || e.promo_min <= {?}) - AND (e.promo_max = 0 || e.promo_max >= {?}) - AND $where - ORDER BY $order"; - $sum = XDB::iterator($sql, $uid, $promo, $promo); - if (!$sum->total()) { - return false; - } - $sql = "SELECT e.id,e.titre,e.texte,e.post_id,a.user_id,a.nom,a.prenom,a.promo,l.alias AS forlife, - p.x, p.y, p.attach IS NOT NULL AS img, FIND_IN_SET('wiki', e.flags) AS wiki - FROM evenements AS e - LEFT JOIN evenements_photo AS p ON (e.id = p.eid) - INNER JOIN auth_user_md5 AS a ON e.user_id=a.user_id - INNER JOIN aliases AS l ON ( a.user_id=l.id AND l.type='a_vie' ) - LEFT JOIN evenements_vus AS ev ON (e.id = ev.evt_id AND ev.user_id = {?}) - WHERE FIND_IN_SET('valide', e.flags) AND peremption >= NOW() - AND (e.promo_min = 0 || e.promo_min <= {?}) - AND (e.promo_max = 0 || e.promo_max >= {?}) - AND ev.user_id IS NULL - AND $where - ORDER BY $order"; - $evt = XDB::iterator($sql, $uid, $promo, $promo); - $array[$name] = array('events' => $evt, 'summary' => $sum); - return true; - } - private function upload_image(PlatalPage &$page, PlUpload &$upload) { if (@!$_FILES['image']['tmp_name'] && !Env::v('image_url')) { @@ -128,7 +90,7 @@ class EventsModule extends PLModule $page->trig('Impossible de télécharger l\'image'); return false; } elseif (!$upload->isType('image')) { - $page->trig('Le fichier n\'est pas une image valide au format JPEG, GIF ou PNG'); + $page->trig('Le fichier n\'est pas une image valide au format JPEG, GIF ou PNG.'); $upload->rm(); return false; } elseif (!$upload->resizeImage(200, 300, 100, 100, 32284)) { @@ -199,18 +161,41 @@ class EventsModule extends PLModule } $array = array(); - $this->get_events('FIND_IN_SET(\'important\', e.flags)', 'e.creation_date DESC', $array, 'important'); - $this->get_events('e.creation_date > DATE_SUB(CURDATE(), INTERVAL 2 DAY) - AND NOT FIND_IN_SET(\'important\', e.flags)', - 'e.creation_date DESC', $array, 'news'); - $this->get_events('e.peremption < DATE_ADD(CURDATE(), INTERVAL 2 DAY) - AND e.creation_date <= DATE_SUB(CURDATE(), INTERVAL 2 DAY) - AND NOT FIND_IN_SET(\'important\', e.flags)', - 'e.peremption, e.creation_date DESC', $array, 'end'); - $this->get_events('e.peremption >= DATE_ADD(CURDATE(), INTERVAL 2 DAY) - AND e.creation_date <= DATE_SUB(CURDATE(), INTERVAL 2 DAY) - AND NOT FIND_IN_SET(\'important\', e.flags)', - 'e.peremption, e.creation_date DESC', $array, 'body'); + $it = XDB::iterator("SELECT e.id,e.titre,e.texte,e.post_id,a.user_id,a.nom,a.prenom,a.promo,l.alias AS forlife, + p.x, p.y, p.attach IS NOT NULL AS img, FIND_IN_SET('wiki', e.flags) AS wiki, + FIND_IN_SET('important', e.flags) AS important, + e.creation_date > DATE_SUB(CURDATE(), INTERVAL 2 DAY) AS news, + e.peremption < DATE_ADD(CURDATE(), INTERVAL 2 DAY) AS end, + ev.user_id IS NULL AS nonlu + FROM evenements AS e + LEFT JOIN evenements_photo AS p ON (e.id = p.eid) + INNER JOIN auth_user_md5 AS a ON e.user_id=a.user_id + INNER JOIN aliases AS l ON ( a.user_id=l.id AND l.type='a_vie' ) + LEFT JOIN evenements_vus AS ev ON (e.id = ev.evt_id AND ev.user_id = {?}) + WHERE FIND_IN_SET('valide', e.flags) AND peremption >= NOW() + AND (e.promo_min = 0 || e.promo_min <= {?}) + AND (e.promo_max = 0 || e.promo_max >= {?}) + ORDER BY important DESC, news DESC, end DESC, e.peremption, e.creation_date DESC", + S::i('uid'), S::i('promo'), S::i('promo')); + $cats = array('important', 'news', 'end', 'body'); + $body = $it->next(); + foreach ($cats as $cat) { + $data = array(); + if (!$body) { + continue; + } + do { + if ($cat == 'body' || $body[$cat]) { + $data[] = $body; + } else { + break; + } + $body = $it->next(); + } while ($body); + if (!empty($data)) { + $array[$cat] = $data; + } + } $page->assign_by_ref('events', $array); } @@ -254,7 +239,8 @@ class EventsModule extends PLModule $rss = XDB::iterator( '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 + IF(u2.nom_usage = "", u2.nom, u2.nom_usage) AS nom, u2.prenom, u2.promo, + FIND_IN_SET(\'wiki\', e.flags) AS wiki 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) ) @@ -487,7 +473,7 @@ class EventsModule extends PLModule FIND_IN_SET('valide', e.flags) AS fvalide, FIND_IN_SET('archive', e.flags) AS farch, u.promo, u.nom, u.prenom, a.alias AS forlife, - FIND_IN_SET('wiki', flags) AS wiki + FIND_IN_SET('wiki', e.flags) AS wiki FROM evenements AS e INNER JOIN auth_user_md5 AS u ON(e.user_id = u.user_id) INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type='a_vie')