X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fuserfilter%2Fconditions.inc.php;h=2ad8d1dd7ceed6587220a2439d73d09df5c4912e;hb=73317355964c4cd538157f8b281a1384b7e38e4d;hp=cb8f5de1872c219a3aba7aa2420602f38672d10b;hpb=db492b02844731e76d232a9f6c8be252b570e4bb;p=platal.git diff --git a/classes/userfilter/conditions.inc.php b/classes/userfilter/conditions.inc.php index cb8f5de..2ad8d1d 100644 --- a/classes/userfilter/conditions.inc.php +++ b/classes/userfilter/conditions.inc.php @@ -1,6 +1,6 @@ nlid = $nlid; $this->issue_id = $issue_id; @@ -847,7 +847,11 @@ class UFC_NLSubscribed extends UserFilterCondition public function buildCondition(PlFilter $uf) { $sub = $uf->addNewsLetterFilter($this->nlid); - return XDB::format($sub . '.nlid IS NOT NULL AND ( ' . $sub . '.last IS NULL OR ' . $sub . '.last < {?})', $this->issue_id); + $cond = $sub . '.nlid IS NOT NULL'; + if (!is_null($this->issue_id)) { + $cond = XDB::format($cond . ' AND ( ' . $sub . '.last IS NULL OR ' . $sub . '.last < {?})', $this->issue_id); + } + return $cond; } } // }}} @@ -858,12 +862,19 @@ class UFC_NLSubscribed extends UserFilterCondition */ class UFC_Group extends UserFilterCondition { + const BOTH = 0; + const NOTIFIED = 1; + const UNNOTIFIED = 2; + private $group; private $anim; - public function __construct($group, $anim = false) + private $notified; + + public function __construct($group, $anim = false, $notified = self::BOTH) { $this->group = $group; $this->anim = $anim; + $this->notified = $notified; } public function buildCondition(PlFilter $uf) @@ -877,6 +888,10 @@ class UFC_Group extends UserFilterCondition if ($this->anim) { $where .= ' AND gpm' . $sub . '.perms = \'admin\''; } + if ($this->notified != self::BOTH) { + $where .= ' AND ' . ($this->notified == self::UNNOTIFIED ? 'NOT ' : '') + . "FIND_IN_SET('notify', gpm" . $sub . '.flags)'; + } return $where; } } @@ -966,7 +981,7 @@ class UFC_Email extends UserFilterCondition $cond = array(); if (count($this->emails) == 0) { - return PlFilterCondition::COND_TRUE; + return PlFilterCondition::COND_FALSE; } foreach ($this->emails as $entry) { @@ -1013,14 +1028,16 @@ abstract class UFC_Address extends UserFilterCondition /** Flags for addresses */ + const FLAG_NONE = 0x0000; const FLAG_CURRENT = 0x0001; const FLAG_TEMP = 0x0002; const FLAG_SECOND = 0x0004; const FLAG_MAIL = 0x0008; const FLAG_CEDEX = 0x0010; + const FLAG_AX_MAIL = 0x0020; // Binary OR of those flags - const FLAG_ANY = 0x001F; + const FLAG_ANY = 0x003F; /** Text of these flags */ @@ -1030,6 +1047,7 @@ abstract class UFC_Address extends UserFilterCondition self::FLAG_SECOND => 'secondary', self::FLAG_MAIL => 'mail', self::FLAG_CEDEX => 'cedex', + self::FLAG_AX_MAIL => 'ax_mail', ); protected $flags; @@ -1083,7 +1101,7 @@ class UFC_AddressComponent extends UFC_Address private $fieldtype; private $exact; - public function __construct($val, $fieldtype, $exact = true, $type = null, $flags = self::FLAG_ANY) + public function __construct($val, $fieldtype, $type = null, $flags = self::FLAG_ANY) { if (!in_array($fieldtype, self::$components)) { Platal::page()->killError('Invalid address field type: ' . $this->fieldtype); @@ -1095,7 +1113,6 @@ class UFC_AddressComponent extends UFC_Address } $this->val = $val; $this->fieldtype = $fieldtype; - $this->exact = $exact; } public function buildCondition(PlFilter $uf) @@ -1582,6 +1599,27 @@ class UFC_WatchPromo extends UFC_UserRelated } } // }}} +// {{{ class UFC_WatchGroup +/** Filters users belonging to a group watched by selected user + * @param $user Selected user (the one watching group) + */ +class UFC_WatchGroup extends UFC_UserRelated +{ + public function buildCondition(PlFilter $uf) + { + $groups = $this->user->watchGroups(); + if (count($groups) == 0) { + return PlFilterCondition::COND_FALSE; + } + $conditions = array(); + foreach ($groups as $group) { + $sub = $uf->addGroupFilter($group); + $conditions[] = 'gpm' . $sub . '.perms IS NOT NULL'; + } + return implode(' OR ', $conditions); + } +} +// }}} // {{{ class UFC_WatchContact /** Filters users watched by selected user */ @@ -1683,5 +1721,5 @@ class UFC_PartnerSharingID extends UserFilterCondition } // }}} -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: ?>