X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Faxletter%2Faxletter.inc.php;h=b42ad353f5c858afb02781bc76ce5d702cfaf19d;hb=6713fc49bdc5e67e5243b4ac684eed9b3f00ef63;hp=7cf486e490451b8e3855764c8ae46669e2d3a20b;hpb=2d88346f4b0d60bf0d7e1d340a2dfd6535ed5b82;p=platal.git diff --git a/modules/axletter/axletter.inc.php b/modules/axletter/axletter.inc.php index 7cf486e..b42ad35 100644 --- a/modules/axletter/axletter.inc.php +++ b/modules/axletter/axletter.inc.php @@ -1,6 +1,6 @@ _id, $this->_shortname, $this->_title_mail, $this->_title, $this->_body, $this->_signature, $this->_promo_min, $this->_promo_max, - $this->_echeance, $this->_date, $this->_bits) = $id; + $this->_subset_to, $this->_subset_rm, $this->_echeance, $this->_date, $this->_bits) = $id; if ($this->_date == '0000-00-00') { $this->_date = 0; } + $this->_subset_to = ($this->_subset_to ? explode("\n", $this->_subset_to) : null); + $this->_subset = (count($this->_subset_to) > 0); } protected function assignData(&$smarty) @@ -132,13 +137,13 @@ class AXLetter extends MassMailer static public function hasPerms() { - if (S::has_perms()) { + if (S::admin()) { return true; } - $res = XDB::query("SELECT 1 + $res = XDB::query("SELECT COUNT(*) FROM axletter_rights WHERE user_id = {?}", S::i('uid')); - return $res->fetchOneCell(); + return ($res->fetchOneCell() > 0); } static public function grantPerms($uid) @@ -167,7 +172,7 @@ class AXLetter extends MassMailer protected function subscriptionWhere() { - if (!$this->_promo_min && !$this->_promo_max) { + if (!$this->_promo_min && !$this->_promo_max && !$this->_subset) { return '1'; } $where = array(); @@ -177,6 +182,21 @@ class AXLetter extends MassMailer if ($this->_promo_max) { $where[] = "((ni.user_id = 0 AND ni.promo <= {$this->_promo_max}) OR (ni.user_id != 0 AND u.promo <= {$this->_promo_max}))"; } + if ($this->_subset) { + require_once("emails.inc.php"); + $ids = ids_from_mails($this->_subset_to); + $ids_list = implode(',', $ids); + if(count($ids) > 0) { + if ($this->_subset_rm) { + $where[] = "ni.user_id NOT IN ($ids_list)"; + } else { + $where[] = "ni.user_id IN ($ids_list)"; + } + } else { + // No valid email + $where[] = "0"; + } + } return implode(' AND ', $where); }