0f592c92535ce2f6322bb55e0ae6af450c337039
2 /***************************************************************************
3 * Copyright (C) 2003-2009 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
27 interface UserFilterCondition
29 const COND_TRUE
= 'TRUE';
30 const COND_FALSE
= 'FALSE';
32 /** Check that the given user matches the rule.
34 public function buildCondition(UserFilter
&$uf);
37 abstract class UFC_OneChild
implements UserFilterCondition
41 public function __construct($child = null
)
43 if (!is_null($child) && ($child instanceof UserFilterCondition
)) {
44 $this->setChild($child);
48 public function setChild(UserFilterCondition
&$cond)
50 $this->child
=& $cond;
54 abstract class UFC_NChildren
implements UserFilterCondition
56 protected $children = array();
58 public function __construct()
60 $children = func_get_args();
61 foreach ($children as &$child) {
62 if (!is_null($child) && ($child instanceof UserFilterCondition
)) {
63 $this->addChild($child);
68 public function addChild(UserFilterCondition
&$cond)
70 $this->children
[] =& $cond;
73 protected function catConds(array $cond, $op, $fallback)
75 if (count($cond) == 0) {
77 } else if (count($cond) == 1) {
80 return '(' . implode(') ' . $op . ' (', $cond) . ')';
85 class UFC_True
implements UserFilterCondition
87 public function buildCondition(UserFilter
&$uf)
89 return self
::COND_TRUE
;
93 class UFC_False
implements UserFilterCondition
95 public function buildCondition(UserFilter
&$uf)
97 return self
::COND_FALSE
;
101 class UFC_Not
extends UFC_OneChild
103 public function buildCondition(UserFilter
&$uf)
105 $val = $this->child
->buildCondition($uf);
106 if ($val == self
::COND_TRUE
) {
107 return self
::COND_FALSE
;
108 } else if ($val == self
::COND_FALSE
) {
109 return self
::COND_TRUE
;
111 return 'NOT (' . $val . ')';
116 class UFC_And
extends UFC_NChildren
118 public function buildCondition(UserFilter
&$uf)
120 if (empty($this->children
)) {
121 return self
::COND_FALSE
;
123 $true = self
::COND_FALSE
;
125 foreach ($this->children
as &$child) {
126 $val = $child->buildCondition($uf);
127 if ($val == self
::COND_TRUE
) {
128 $true = self
::COND_TRUE
;
129 } else if ($val == self
::COND_FALSE
) {
130 return self
::COND_FALSE
;
135 return $this->catConds($conds, 'AND', $true);
140 class UFC_Or
extends UFC_NChildren
142 public function buildCondition(UserFilter
&$uf)
144 if (empty($this->children
)) {
145 return self
::COND_TRUE
;
147 $true = self
::COND_TRUE
;
149 foreach ($this->children
as &$child) {
150 $val = $child->buildCondition($uf);
151 if ($val == self
::COND_TRUE
) {
152 return self
::COND_TRUE
;
153 } else if ($val == self
::COND_FALSE
) {
154 $true = self
::COND_FALSE
;
159 return $this->catConds($conds, 'OR', $true);
164 class UFC_Promo
implements UserFilterCondition
171 public function __construct($comparison, $grade, $promo)
173 $this->grade
= $grade;
174 $this->comparison
= $comparison;
175 $this->promo
= $promo;
176 if ($this->grade
!= UserFilter
::DISPLAY
) {
177 UserFilter
::assertGrade($this->grade
);
181 public function buildCondition(UserFilter
&$uf)
183 if ($this->grade
== UserFilter
::DISPLAY
) {
184 $sub = $uf->addDisplayFilter();
185 return XDB
::format('pd' . $sub . '.promo = {?}', $this->promo
);
187 $sub = $uf->addEducationFilter(true
, $this->grade
);
188 $field = 'pe' . $sub . '.' . UserFilter
::promoYear($this->grade
);
189 return $field . ' IS NOT NULL AND ' . $field . ' ' . $this->comparison
. ' ' . XDB
::format('{?}', $this->promo
);
194 class UFC_Name
implements UserFilterCondition
206 public function __construct($type, $text, $mode)
213 private function buildNameQuery($type, $variant, $where, UserFilter
&$uf)
215 $sub = $uf->addNameFilter($type, $variant);
216 return str_replace('$ME', 'pn' . $sub, $where);
219 public function buildCondition(UserFilter
&$uf)
223 if (($this->mode
& self
::PARTICLE
) == self
::PARTICLE
) {
224 $left = 'CONCAT($ME.particle, \' \', $ME.name)';
226 if (($this->mode
& self
::CONTAINS
) == 0) {
227 $right = XDB
::format('{?}', $this->text
);
229 } else if (($this->mode
& self
::CONTAINS
) == self
::PREFIX
) {
230 $right = XDB
::format('CONCAT({?}, \'%\')', $this->text
);
231 } else if (($this->mode
& self
::CONTAINS
) == self
::SUFFIX
) {
232 $right = XDB
::format('CONCAT(\'%\', {?})', $this->text
);
234 $right = XDB
::format('CONCAT(\'%\', {?}, \'%\')', $this->text
);
236 $cond = $left . $op . $right;
237 $conds = array($this->buildNameQuery($this->type
, null
, $cond, $uf));
238 if (($this->mode
& self
::VARIANTS
) != 0 && isset(UserFilter
::$name_variants[$this->type
])) {
239 foreach (UserFilter
::$name_variants[$this->type
] as $var) {
240 $conds[] = $this->buildNameQuery($this->type
, $var, $cond, $uf);
243 return implode(' OR ', $conds);
247 class UFC_Dead
implements UserFilterCondition
252 public function __construct($comparison = null
, $date = null
)
254 $this->comparison
= $comparison;
258 public function buildCondition(UserFilter
&$uf)
260 $str = 'p.deathdate IS NOT NULL';
261 if (!is_null($this->comparison
)) {
262 $str .= ' AND p.deathdate ' . $this->comparison
. ' ' . XDB
::format('{?}', date('Y-m-d', $this->date
));
268 class UFC_Registered
implements UserFilterCondition
274 public function __construct($active = false
, $comparison = null
, $date = null
)
276 $this->only_active
= $active;
277 $this->comparison
= $comparison;
281 public function buildCondition(UserFilter
&$uf)
284 $date = 'a.uid IS NOT NULL AND a.state = \'active\'';
286 $date = 'a.uid IS NOT NULL AND a.state != \'pending\'';
288 if (!is_null($this->comparison
)) {
289 $date .= ' AND a.registration_date ' . $this->comparison
. ' ' . XDB
::format('{?}', date('Y-m-d', $this->date
));
295 class UFC_Sex
implements UserFilterCondition
298 public function __construct($sex)
303 public function buildCondition(UserFilter
&$uf)
305 if ($this->sex
!= User
::GENDER_MALE
&& $this->sex
!= User
::GENDER_FEMALE
) {
306 return self
::COND_FALSE
;
308 return XDB
::format('p.sex = {?}', $this->sex
== User
::GENDER_FEMALE ?
'female' : 'male');
313 class UFC_Group
implements UserFilterCondition
317 public function __construct($group, $admin = false
)
319 $this->group
= $group;
320 $this->admin
= $admin;
323 public function buildCondition(UserFilter
&$uf)
325 $sub = $uf->addGroupFilter($this->group
);
326 $where = 'gpm' . $sub . '.perms IS NOT NULL';
328 $where .= ' AND gpm' . $sub . '.perms = \'admin\'';
334 class UFC_Email
implements UserFilterCondition
337 public function __construct($email)
339 $this->email
= $email;
342 public function buildCondition(UserFilter
&$uf)
344 if (User
::isForeignEmailAddress($this->email
)) {
345 $sub = $uf->addEmailRedirectFilter($this->email
);
346 return XDB
::format('e' . $sub . '.email IS NOT NULL OR a.email = {?}', $this->email
);
347 } else if (User
::isVirtualEmailAddress($this->email
)) {
348 $sub = $uf->addVirtualEmailFilter($this->email
);
349 return 'vr' . $sub . '.redirect IS NOT NULL';
351 @list
($user, $domain) = explode('@', $this->email
);
352 $sub = $uf->addAliasFilter($user);
353 return 'al' . $sub . '.alias IS NOT NULL';
358 class UFC_EmailList
implements UserFilterCondition
361 public function __construct($emails)
363 $this->emails
= $emails;
366 public function buildCondition(UserFilter
&$uf)
373 if (count($this->emails
) == 0) {
374 return UserFilterCondition
::COND_TRUE
;
377 foreach ($this->emails
as $entry) {
378 if (User
::isForeignEmailAddress($entry)) {
379 if (is_null($email)) {
380 $email = $uf->addEmailRedirectFilter();
382 $cond[] = XDB
::format('e' . $email . '.email = {?} OR a.email = {?}', $entry, $entry);
383 } else if (User
::isVirtualEmailAddress($entry)) {
384 if (is_null($virtual)) {
385 $virtual = $uf->addVirtualEmailFilter();
387 $cond[] = XDB
::format('vr' . $virtual . '.redirect IS NOT NULL AND v' . $virtual . '.alias = {?}', $entry);
389 if (is_null($alias)) {
390 $alias = $uf->addAliasFilter();
392 @list
($user, $domain) = explode('@', $entry);
393 $cond[] = XDB
::format('al' . $alias . '.alias = {?}', $user);
396 return '(' . implode(') OR (', $cond) . ')';
400 class UFC_Contact
implements UserFilterCondition
403 public function __construct($uid = null
)
406 $this->uid
= S
::i('uid');
407 } else if ($uid instanceof PlUser
) {
408 $this->uid
= $uid->id();
409 } else if (ctype_digit($uid)) {
410 $this->uid
= (int)$uid;
412 Platal
::page()->kill("Invalid contact type");
416 public function buildCondition(UserFilter
&$uf)
418 $sub = $uf->addContactFilter($this->uid
);
419 return 'c' . $sub . '.contact IS NOT NULL';
427 abstract class UserFilterOrder
429 protected $desc = false
;
431 public function buildSort(UserFilter
&$uf)
433 $sel = $this->getSortTokens($uf);
434 if (!is_array($sel)) {
438 foreach ($sel as $k=>$s) {
439 $sel[$k] = $s . ' DESC';
445 abstract protected function getSortTokens(UserFilter
&$uf);
448 class UFO_Promo
extends UserFilterOrder
452 public function __construct($grade = null
, $desc = false
)
454 $this->grade
= $grade;
458 protected function getSortTokens(UserFilter
&$uf)
460 if (UserFilter
::isGrade($this->grade
)) {
461 $sub = $uf->addEducationFilter($this->grade
);
462 return 'pe' . $sub . '.' . UserFilter
::promoYear($this->grade
);
464 $sub = $uf->addDisplayFilter();
465 return 'pd' . $sub . '.promo';
470 class UFO_Name
extends UserFilterOrder
476 public function __construct($type, $variant = null
, $particle = false
, $desc = false
)
479 $this->variant
= $variant;
480 $this->particle
= $particle;
484 protected function getSortTokens(UserFilter
&$uf)
486 if (UserFilter
::isDisplayName($this->type
)) {
487 $sub = $uf->addDisplayFilter();
488 return 'pd' . $sub . '.' . $this->type
;
490 $sub = $uf->addNameFilter($this->type
, $this->variant
);
491 if ($this->particle
) {
492 return 'CONCAT(pn' . $sub . '.particle, \' \', pn' . $sub . '.name)';
494 return 'pn' . $sub . '.name';
500 class UFO_Registration
extends UserFilterOrder
502 public function __construct($desc = false
)
507 protected function getSortTokens(UserFilter
&$uf)
509 return 'a.registration_date';
513 /***********************************
514 *********************************
516 *********************************
517 ***********************************/
521 static private $joinMethods = array();
524 private $sort = array();
525 private $query = null
;
526 private $orderby = null
;
528 private $lastcount = null
;
530 public function __construct($cond = null
, $sort = null
)
532 if (empty(self
::$joinMethods)) {
533 $class = new ReflectionClass('UserFilter');
534 foreach ($class->getMethods() as $method) {
535 $name = $method->getName();
536 if (substr($name, -5) == 'Joins' && $name != 'buildJoins') {
537 self
::$joinMethods[] = $name;
541 if (!is_null($cond)) {
542 if ($cond instanceof UserFilterCondition
) {
543 $this->setCondition($cond);
546 if (!is_null($sort)) {
547 if ($sort instanceof UserFilterOrder
) {
548 $this->addSort($sort);
549 } else if (is_array($sort)) {
550 foreach ($sort as $s) {
557 private function buildQuery()
559 if (is_null($this->orderby
)) {
561 foreach ($this->sort
as $sort) {
562 $orders = array_merge($orders, $sort->buildSort($this));
564 if (count($orders) == 0) {
567 $this->orderby
= 'ORDER BY ' . implode(', ', $orders);
570 if (is_null($this->query
)) {
571 $where = $this->root
->buildCondition($this);
572 $joins = $this->buildJoins();
573 $this->query
= 'FROM accounts AS a
574 INNER JOIN account_profiles AS ap ON (ap.uid = a.uid AND FIND_IN_SET(\'owner\', ap.perms))
575 INNER JOIN profiles AS p ON (p.pid = ap.pid)
577 WHERE (' . $where . ')';
581 private function formatJoin(array $joins)
584 foreach ($joins as $key => $infos) {
587 if ($mode == 'inner') {
588 $str .= 'INNER JOIN ';
589 } else if ($mode == 'left') {
590 $str .= 'LEFT JOIN ';
592 Platal
::page()->kill("Join mode error");
594 $str .= $table . ' AS ' . $key;
595 if (isset($infos[2])) {
596 $str .= ' ON (' . str_replace(array('$ME', '$PID', '$UID'), array($key, 'p.pid', 'a.uid'), $infos[2]) . ')';
603 private function buildJoins()
606 foreach (self
::$joinMethods as $method) {
607 $joins = array_merge($joins, $this->$method());
609 return $this->formatJoin($joins);
612 private function getUIDList($uids = null
, $count = null
, $offset = null
)
616 if (!is_null($count)) {
617 if (!is_null($offset)) {
618 $limit = XDB
::format('LIMIT {?}, {?}', $offset, $count);
620 $limit = XDB
::format('LIMIT {?}', $count);
624 if (!is_null($uids)) {
625 $cond = ' AND a.uid IN (' . implode(', ', $uids) . ')';
627 $fetched = XDB
::fetchColumn('SELECT SQL_CALC_FOUND_ROWS a.uid
628 ' . $this->query
. $cond . '
630 ' . $this->orderby
. '
632 $this->lastcount
= (int)XDB
::fetchOneCell('SELECT FOUND_ROWS()');
636 /** Check that the user match the given rule.
638 public function checkUser(PlUser
&$user)
641 $count = (int)XDB
::fetchOneCell('SELECT COUNT(*)
642 ' . $this->query
. XDB
::format(' AND a.uid = {?}', $user->id()));
646 /** Filter a list of user to extract the users matching the rule.
648 public function filter(array $users, $count = null
, $offset = null
)
653 foreach ($users as $user) {
654 $uids[] = $user->id();
655 $table[$user->id()] = $user;
657 $fetched = $this->getUIDList($uids, $count, $offset);
659 foreach ($fetched as $uid) {
660 $output[] = $table[$uid];
665 public function getUIDs($count = null
, $offset = null
)
667 return $this->getUIDList(null
, $count, $offset);
670 public function getUsers($count = null
, $offset = null
)
672 return User
::getBulkUsersWithUIDs($this->getUIDs($count, $offset));
675 public function getTotalCount()
677 if (is_null($this->lastcount
)) {
679 return (int)XDB
::fetchOneCell('SELECT COUNT(*)
683 return $this->lastcount
;
687 public function setCondition(UserFilterCondition
&$cond)
689 $this->root
=& $cond;
693 public function addSort(UserFilterOrder
&$sort)
695 $this->sort
[] = $sort;
696 $this->orderby
= null
;
699 static public function getLegacy($promo_min, $promo_max)
701 if ($promo_min != 0) {
702 $min = new UFC_Promo('>=', self
::GRADE_ING
, intval($promo_min));
704 $min = new UFC_True();
706 if ($promo_max != 0) {
707 $max = new UFC_Promo('<=', self
::GRADE_ING
, intval($promo_max));
709 $max = new UFC_True();
711 return new UserFilter(new UFC_And($min, $max));
714 static private function getDBSuffix($string)
716 return preg_replace('/[^a-z0-9]/i', '', $string);
721 private function register_optional(array &$table, $val)
724 $sub = $this->option++
;
727 $sub = self
::getDBSuffix($val);
731 $table[$sub] = $index;
737 const DISPLAY
= 'display';
739 public function addDisplayFilter()
745 private function displayJoins()
748 return array('pd' => array('left', 'profile_display', '$ME.pid = $PID'));
757 const LASTNAME
= 'lastname';
758 const FIRSTNAME
= 'firstname';
759 const NICKNAME
= 'nickname';
760 const PSEUDONYM
= 'pseudonym';
763 const VN_MARITAL
= 'marital';
764 const VN_ORDINARY
= 'ordinary';
765 const VN_OTHER
= 'other';
766 const VN_INI
= 'ini';
768 const DN_FULL
= 'directory_name';
769 const DN_DISPLAY
= 'yourself';
770 const DN_YOURSELF
= 'yourself';
771 const DN_DIRECTORY
= 'directory_name';
772 const DN_PRIVATE
= 'private_name';
773 const DN_PUBLIC
= 'public_name';
774 const DN_SHORT
= 'short_name';
775 const DN_SORT
= 'sort_name';
777 static public $name_variants = array(
778 self
::LASTNAME
=> array(self
::VN_MARITAL
, self
::VN_ORDINARY
),
779 self
::FIRSTNAME
=> array(self
::VN_ORDINARY
, self
::VN_INI
, self
::VN_OTHER
)
782 static public function assertName($name)
784 if (!Profile
::getNameTypeId($name)) {
785 Platal
::page()->kill('Invalid name type');
789 static public function isDisplayName($name)
791 return $name == self
::DN_FULL ||
$name == self
::DN_DISPLAY
792 ||
$name == self
::DN_YOURSELF ||
$name == self
::DN_DIRECTORY
793 ||
$name == self
::DN_PRIVATE ||
$name == self
::DN_PUBLIC
794 ||
$name == self
::DN_SHORT ||
$name == self
::DN_SORT
;
797 private $pn = array();
798 public function addNameFilter($type, $variant = null
)
800 if (!is_null($variant)) {
801 $ft = $type . '_' . $variant;
806 self
::assertName($ft);
808 if (!is_null($variant) && $variant == 'other') {
809 $sub .= $this->option++
;
811 $this->pn
[$sub] = Profile
::getNameTypeId($ft);
815 private function nameJoins()
818 foreach ($this->pn
as $sub => $type) {
819 $joins['pn' . $sub] = array('left', 'profile_name', '$ME.pid = $PID AND $ME.typeid = ' . $type);
827 const GRADE_ING
= 'Ing.';
828 const GRADE_PHD
= 'PhD';
829 const GRADE_MST
= 'M%';
830 static public function isGrade($grade)
832 return $grade == self
::GRADE_ING ||
$grade == self
::GRADE_PHD ||
$grade == self
::GRADE_MST
;
835 static public function assertGrade($grade)
837 if (!self
::isGrade($grade)) {
838 Platal
::page()->killError("Diplôme non valide");
842 static public function promoYear($grade)
844 // XXX: Definition of promotion for phds and masters might change in near future.
845 return ($grade == UserFilter
::GRADE_ING
) ?
'entry_year' : 'grad_year';
848 private $pepe = array();
849 private $with_pee = false
;
850 public function addEducationFilter($x = false
, $grade = null
)
853 $index = $this->option
;
854 $sub = $this->option++
;
856 self
::assertGrade($grade);
859 $this->with_pee
= true
;
862 $this->pepe
[$index] = $sub;
866 private function educationJoins()
869 if ($this->with_pee
) {
870 $joins['pee'] = array('inner', 'profile_education_enum', 'pee.abbreviation = \'X\'');
872 foreach ($this->pepe
as $grade => $sub) {
873 if ($this->isGrade($grade)) {
874 $joins['pe' . $sub] = array('left', 'profile_education', '$ME.eduid = pee.id AND $ME.uid = $PID');
875 $joins['pede' . $sub] = array('inner', 'profile_education_degree_enum', '$ME.id = pe' . $sub . '.degreeid AND $ME.abbreviation LIKE ' .
876 XDB
::format('{?}', $grade));
878 $joins['pe' . $sub] = array('left', 'profile_education', '$ME.uid = $PID');
879 $joins['pee' . $sub] = array('inner', 'profile_education_enum', '$ME.id = pe' . $sub . '.eduid');
880 $joins['pede' . $sub] = array('inner', 'profile_education_degree_enum', '$ME.id = pe' . $sub . '.degreeid');
889 private $gpm = array();
890 public function addGroupFilter($group = null
)
892 if (!is_null($group)) {
893 if (ctype_digit($group)) {
894 $index = $sub = $group;
897 $sub = self
::getDBSuffix($group);
900 $sub = 'group_' . $this->option++
;
904 $this->gpm
[$sub] = $index;
908 private function groupJoins()
911 foreach ($this->gpm
as $sub => $key) {
913 $joins['gpa' . $sub] = array('inner', 'groupex.asso');
914 $joins['gpm' . $sub] = array('left', 'groupex.membres', '$ME.uid = $UID AND $ME.asso_id = gpa' . $sub . '.id');
915 } else if (ctype_digit($key)) {
916 $joins['gpm' . $sub] = array('left', 'groupex.membres', '$ME.uid = $UID AND $ME.asso_id = ' . $key);
918 $joins['gpa' . $sub] = array('inner', 'groupex.asso', XDB
::format('$ME.diminutif = {?}', $key));
919 $joins['gpm' . $sub] = array('left', 'groupex.membres', '$ME.uid = $UID AND $ME.asso_id = gpa' . $sub . '.id');
927 private $e = array();
928 public function addEmailRedirectFilter($email = null
)
930 return $this->register_optional($this->e
, $email);
933 private $ve = array();
934 public function addVirtualEmailFilter($email = null
)
936 $this->addAliasFilter(self
::ALIAS_FORLIFE
);
937 return $this->register_optional($this->ve
, $email);
940 const ALIAS_BEST
= 'bestalias';
941 const ALIAS_FORLIFE
= 'forlife';
942 private $al = array();
943 public function addAliasFilter($alias = null
)
945 return $this->register_optional($this->al
, $alias);
948 private function emailJoins()
952 foreach ($this->e
as $sub=>$key) {
954 $joins['e' . $sub] = array('left', 'emails', '$ME.uid = $UID AND $ME.flags != \'filter\'');
956 $joins['e' . $sub] = array('left', 'emails', XDB
::format('$ME.uid = $UID AND $ME.flags != \'filter\' AND $ME.email = {?}', $key));
959 foreach ($this->al
as $sub=>$key) {
961 $joins['al' . $sub] = array('left', 'aliases', '$ME.id = $UID AND $ME.type IN (\'alias\', \'a_vie\')');
962 } else if ($key == self
::ALIAS_BEST
) {
963 $joins['al' . $sub] = array('left', 'aliases', '$ME.id = $UID AND $ME.type IN (\'alias\', \'a_vie\') AND FIND_IN_SET(\'bestalias\', $ME.flags)');
964 } else if ($key == self
::ALIAS_FORLIFE
) {
965 $joins['al' . $sub] = array('left', 'aliases', '$ME.id = $UID AND $ME.type = \'a_vie\'');
967 $joins['al' . $sub] = array('left', 'aliases', XDB
::format('$ME.id = $UID AND $ME.type IN (\'alias\', \'a_vie\') AND $ME.alias = {?}', $key));
970 foreach ($this->ve
as $sub=>$key) {
972 $joins['v' . $sub] = array('left', 'virtual', '$ME.type = \'user\'');
974 $joins['v' . $sub] = array('left', 'virtual', XDB
::format('$ME.type = \'user\' AND $ME.alias = {?}', $key));
976 $joins['vr' . $sub] = array('left', 'virtual_redirect', XDB
::format('$ME.vid = v' . $sub . '.vid
977 AND ($ME.redirect IN (CONCAT(al_forlife.alias, \'@\', {?}),
978 CONCAT(al_forlife.alias, \'@\', {?}),
980 $globals->mail
->domain
, $globals->mail
->domain2
));
988 private $cts = array();
989 public function addContactFilter($uid = null
)
991 return $this->register_optional($this->cts
, is_null($uid) ? null
: 'user_' . $uid);
994 private function contactJoins()
997 foreach ($this->cts
as $sub=>$key) {
999 $joins['c' . $sub] = array('left', 'contacts', '$ME.contact = $UID');
1001 $joins['c' . $sub] = array('left', 'contacts', XDB
::format('$ME.uid = {?} AND $ME.contact = $UID', substr($key, 5)));
1009 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: