<?php
/***************************************************************************
- * Copyright (C) 2003-2011 Polytechnique.org *
+ * Copyright (C) 2003-2014 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
{
private $nlid;
private $issue_id;
- public function __construct($nlid, $issue_id)
+ public function __construct($nlid, $issue_id = null)
{
$this->nlid = $nlid;
$this->issue_id = $issue_id;
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;
}
}
// }}}
*/
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)
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;
}
}
$cond = array();
if (count($this->emails) == 0) {
- return PlFilterCondition::COND_TRUE;
+ return PlFilterCondition::COND_FALSE;
}
foreach ($this->emails as $entry) {
/** 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
*/
self::FLAG_SECOND => 'secondary',
self::FLAG_MAIL => 'mail',
self::FLAG_CEDEX => 'cedex',
+ self::FLAG_AX_MAIL => 'ax_mail',
);
protected $flags;
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);
}
$this->val = $val;
$this->fieldtype = $fieldtype;
- $this->exact = $exact;
}
public function buildCondition(PlFilter $uf)
}
}
// }}}
+// {{{ 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
*/
}
// }}}
-// 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:
?>