From: Stéphane Jacob Date: Mon, 19 Jul 2010 19:04:00 +0000 (+0200) Subject: Temporarily fixes promo in xnet announces. X-Git-Tag: xorg/1.0.1~312 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=5a9ad4b0cc40bdf9ec1955fd6eb1d5fd173e6de1;p=platal.git Temporarily fixes promo in xnet announces. Signed-off-by: Stéphane Jacob --- diff --git a/include/validations/evts.inc.php b/include/validations/evts.inc.php index ddfdef5..4a7416f 100644 --- a/include/validations/evts.inc.php +++ b/include/validations/evts.inc.php @@ -134,6 +134,7 @@ class EvtReq extends Validate public function commit() { + /* TODO: refines this filter on promotions by using userfilter. */ if (XDB::execute("INSERT INTO announces SET uid = {?}, creation_date=NOW(), titre={?}, texte={?}, expiration={?}, promo_min={?}, promo_max={?}, flags=CONCAT(flags,',valide,wiki')", diff --git a/modules/axletter/axletter.inc.php b/modules/axletter/axletter.inc.php index 761724c..f31f979 100644 --- a/modules/axletter/axletter.inc.php +++ b/modules/axletter/axletter.inc.php @@ -175,6 +175,7 @@ class AXLetter extends MassMailer if (!$this->_promo_min && !$this->_promo_max && !$this->_subset) { return '1'; } + /* TODO: refines this filter on promotions by using userfilter. */ $where = array(); if ($this->_promo_min) { $where[] = "((ni.uid = 0 AND ni.promo >= {$this->_promo_min}) OR (ni.uid != 0 AND u.promo >= {$this->_promo_min}))"; diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index b46ffed..e4449a0 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -81,24 +81,34 @@ class XnetGrpModule extends PLModule Env::i('unread'), S::i('uid')); pl_redirect("#art" . Env::i('unread')); } - // XXX: Fix promo_min; promo_max - $arts = XDB::iterator("SELECT a.*, FIND_IN_SET('photo', a.flags) AS photo + + /* TODO: refines this filter on promotions by using userfilter. */ + $user = S::user(); + if ($user->hasProfile()) { + $promo = XDB::format('{?}', $user->profile()->entry_year); + $minCondition = ' OR promo_min <= ' . $promo; + $maxCondition = ' OR promo_max >= ' . $promo; + } else { + $minCondition = ''; + $maxCondition = ''; + } + $arts = XDB::iterator('SELECT a.*, FIND_IN_SET(\'photo\', a.flags) AS photo FROM group_announces AS a LEFT JOIN group_announces_read AS r ON (r.uid = {?} AND r.announce_id = a.id) WHERE asso_id = {?} AND expiration >= CURRENT_DATE() - AND (promo_min = 0 OR promo_min <= {?}) - AND (promo_max = 0 OR promo_max >= {?}) + AND (promo_min = 0' . $minCondition . ') + AND (promo_max = 0' . $maxCondition . ') AND r.announce_id IS NULL - ORDER BY a.expiration", - S::i('uid'), $globals->asso('id'), S::i('promo'), S::i('promo')); - $index = XDB::iterator("SELECT a.id, a.titre, r.uid IS NULL AS nonlu + ORDER BY a.expiration', + S::i('uid'), $globals->asso('id')); + $index = XDB::iterator('SELECT a.id, a.titre, r.uid IS NULL AS nonlu FROM group_announces AS a LEFT JOIN group_announces_read AS r ON (a.id = r.announce_id AND r.uid = {?}) WHERE asso_id = {?} AND expiration >= CURRENT_DATE() - AND (promo_min = 0 OR promo_min <= {?}) - AND (promo_max = 0 OR promo_max >= {?}) - ORDER BY a.expiration", - S::i('uid'), $globals->asso('id'), S::i('promo'), S::i('promo')); + AND (promo_min = 0' . $minCondition . ') + AND (promo_max = 0' . $maxCondition . ') + ORDER BY a.expiration', + S::i('uid'), $globals->asso('id')); $page->assign('article_index', $index); } else { $arts = XDB::iterator("SELECT *, FIND_IN_SET('photo', flags) AS photo diff --git a/templates/xnetgrp/announce-edit.tpl b/templates/xnetgrp/announce-edit.tpl index 92ecf00..b387273 100644 --- a/templates/xnetgrp/announce-edit.tpl +++ b/templates/xnetgrp/announce-edit.tpl @@ -26,6 +26,7 @@ function visibilityChange(box) { var state = (box.checked ? 'none' : ''); document.getElementById('promo_titre').style.display = state; + document.getElementById('promo_explanation').style.display = state; document.getElementById('promo_min_tr').style.display = state; document.getElementById('promo_max_tr').style.display = state; document.getElementById('promo_range_tr').style.display = state; @@ -163,7 +164,10 @@ function visibilityChange(box) - Promotions cibles + Promotions d'entrée cibles + + + {icon name=information} par exemple 2004 pour les X2004 {include file="include/field.promo.tpl" promo_min=$art.promo_min promo_max=$art.promo_max} {if $art.public}