+// {{{ class UFC_AccountType
+/** Filters users who have one of the given account types
+ */
+class UFC_AccountType implements UserFilterCondition
+{
+ private $types;
+
+ public function __construct()
+ {
+ $this->types = pl_flatten(func_get_args());
+ }
+
+ public function buildCondition(PlFilter &$uf)
+ {
+ $uf->requireAccounts();
+ return XDB::format('a.type IN {?}', $this->types);
+ }
+}
+// }}}
+
+// {{{ class UFC_AccountPerm
+/** Filters users who have one of the given permissions
+ */
+class UFC_AccountPerm implements UserFilterCondition
+{
+ private $perms;
+
+ public function __construct()
+ {
+ $this->perms = pl_flatten(func_get_args());
+ }
+
+ public function buildCondition(PlFilter &$uf)
+ {
+ $uf->requirePerms();
+ $conds = array();
+ foreach ($this->perms as $perm) {
+ $conds[] = XDB::format('FIND_IN_SET({?}, IF(a.user_perms IS NULL, at.perms,
+ CONCAT(at.perms, \',\', a.user_perms)))',
+ $perm);
+ }
+ if (empty($conds)) {
+ return self::COND_TRUE;
+ } else {
+ return implode(' OR ', $conds);
+ }
+ }
+}
+// }}}
+