Commit | Line | Data |
---|---|---|
a087cc8d FB |
1 | <?php |
2 | /*************************************************************************** | |
d4c08d89 | 3 | * Copyright (C) 2003-2010 Polytechnique.org * |
a087cc8d FB |
4 | * http://opensource.polytechnique.org/ * |
5 | * * | |
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. * | |
10 | * * | |
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. * | |
15 | * * | |
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 * | |
18 | * Foundation, Inc., * | |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
20 | ***************************************************************************/ | |
21 | ||
d865c296 FB |
22 | |
23 | /****************** | |
24 | * CONDITIONS | |
25 | ******************/ | |
26 | ||
8363588b | 27 | // {{{ interface UserFilterCondition |
2d83cac9 RB |
28 | /** This interface describe objects which filter users based |
29 | * on various parameters. | |
30 | * The parameters of the filter must be given to the constructor. | |
31 | * The buildCondition function is called by UserFilter when | |
32 | * actually building the query. That function must call | |
33 | * $uf->addWheteverFilter so that the UserFilter makes | |
34 | * adequate joins. It must return the 'WHERE' condition to use | |
35 | * with the filter. | |
36 | */ | |
dcc63ed5 | 37 | interface UserFilterCondition extends PlFilterCondition |
a087cc8d | 38 | { |
a087cc8d | 39 | } |
8363588b | 40 | // }}} |
a087cc8d | 41 | |
8363588b | 42 | // {{{ class UFC_Profile |
53eae167 RB |
43 | /** Filters users who have a profile |
44 | */ | |
eb1449b8 FB |
45 | class UFC_Profile implements UserFilterCondition |
46 | { | |
dcc63ed5 | 47 | public function buildCondition(PlFilter &$uf) |
eb1449b8 FB |
48 | { |
49 | return '$PID IS NOT NULL'; | |
50 | } | |
51 | } | |
8363588b | 52 | // }}} |
eb1449b8 | 53 | |
ddba9d4f RB |
54 | // {{{ class UFC_Hruid |
55 | /** Filters users based on their hruid | |
56 | * @param $val Either an hruid, or a list of those | |
57 | */ | |
58 | class UFC_Hruid implements UserFilterCondition | |
59 | { | |
60 | private $hruids; | |
61 | ||
62 | public function __construct($val) | |
63 | { | |
64 | if (!is_array($val)) { | |
65 | $val = array($val); | |
66 | } | |
67 | $this->hruids = $val; | |
68 | } | |
69 | ||
70 | public function buildCondition(PlFilter &$uf) | |
71 | { | |
72 | $ufc->requireAccounts(); | |
73 | ||
74 | return 'a.hruid IN ' . XDB::formatArray($this->hruids); | |
75 | } | |
76 | } | |
77 | // }}} | |
78 | ||
f73a4f1b RB |
79 | // {{{ class UFC_Ip |
80 | /** Filters users based on one of their last IPs | |
81 | * @param $ip IP from which connection are checked | |
82 | */ | |
83 | class UFC_Ip implements UserFilterCondition | |
84 | { | |
85 | private $ip; | |
86 | ||
87 | public function __construct($ip) | |
88 | { | |
89 | $this->ip = $ip; | |
90 | } | |
91 | ||
92 | public function buildCondition(PlFilter &$uf) | |
93 | { | |
94 | $sub = $uf->addLoggerFilter(); | |
95 | $ip = ip_to_uint($this->ip); | |
96 | return XDB::format($sub . '.ip = {?} OR ' . $sub . '.forward_ip = {?}', $ip, $ip); | |
97 | } | |
98 | } | |
99 | // }}} | |
100 | ||
d7ddf29b RB |
101 | // {{{ class UFC_Comment |
102 | class UFC_Comment implements UserFilterCondition | |
103 | { | |
104 | private $text; | |
105 | ||
106 | public function __construct($text) | |
107 | { | |
108 | $this->text = $text; | |
109 | } | |
110 | ||
111 | public function buildCondition(PlFilter &$uf) | |
112 | { | |
113 | $uf->requireProfiles(); | |
658b4c83 | 114 | return 'p.freetext ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->text); |
d7ddf29b RB |
115 | } |
116 | } | |
117 | // }}} | |
118 | ||
8363588b | 119 | // {{{ class UFC_Promo |
5d2e55c7 | 120 | /** Filters users based on promotion |
53eae167 RB |
121 | * @param $comparison Comparison operator (>, =, ...) |
122 | * @param $grade Formation on which to restrict, UserFilter::DISPLAY for "any formation" | |
5d2e55c7 | 123 | * @param $promo Promotion on which the filter is based |
53eae167 | 124 | */ |
a087cc8d FB |
125 | class UFC_Promo implements UserFilterCondition |
126 | { | |
a087cc8d FB |
127 | |
128 | private $grade; | |
129 | private $promo; | |
130 | private $comparison; | |
131 | ||
132 | public function __construct($comparison, $grade, $promo) | |
133 | { | |
134 | $this->grade = $grade; | |
135 | $this->comparison = $comparison; | |
136 | $this->promo = $promo; | |
38c6fe96 FB |
137 | if ($this->grade != UserFilter::DISPLAY) { |
138 | UserFilter::assertGrade($this->grade); | |
139 | } | |
a087cc8d FB |
140 | } |
141 | ||
dcc63ed5 | 142 | public function buildCondition(PlFilter &$uf) |
a087cc8d | 143 | { |
38c6fe96 FB |
144 | if ($this->grade == UserFilter::DISPLAY) { |
145 | $sub = $uf->addDisplayFilter(); | |
1a23a02b | 146 | return XDB::format('pd' . $sub . '.promo ' . $this->comparison . ' {?}', $this->promo); |
38c6fe96 FB |
147 | } else { |
148 | $sub = $uf->addEducationFilter(true, $this->grade); | |
149 | $field = 'pe' . $sub . '.' . UserFilter::promoYear($this->grade); | |
150 | return $field . ' IS NOT NULL AND ' . $field . ' ' . $this->comparison . ' ' . XDB::format('{?}', $this->promo); | |
151 | } | |
784745ce FB |
152 | } |
153 | } | |
8363588b | 154 | // }}} |
784745ce | 155 | |
9e8bacfb FB |
156 | // {{{ class UFC_SchoolId |
157 | /** Filters users based on their shoold identifier | |
158 | * @param type Parameter type (Xorg, AX, School) | |
159 | * @param value School id value | |
160 | */ | |
161 | class UFC_SchooldId implements UserFilterCondition | |
162 | { | |
163 | const AX = 'ax'; | |
164 | const Xorg = 'xorg'; | |
165 | const School = 'school'; | |
166 | ||
167 | private $type; | |
168 | private $id; | |
169 | ||
170 | static public function assertType($type) | |
171 | { | |
172 | if ($type != self::AX && $type != self::Xorg && $type != self::School) { | |
173 | Platal::page()->killError("Type de matricule invalide: $type"); | |
174 | } | |
175 | } | |
176 | ||
177 | public function __construct($type, $id) | |
178 | { | |
179 | $this->type = $type; | |
180 | $this->id = $id; | |
181 | self::assertType($type); | |
182 | } | |
183 | ||
184 | public function buildCondition(PlFilter &$uf) | |
185 | { | |
186 | $uf->requireProfiles(); | |
187 | $id = $this->id; | |
188 | $type = $this->type; | |
189 | if ($type == self::School) { | |
190 | $type = self::Xorg; | |
191 | $id = Profile::getXorgId($id); | |
192 | } | |
193 | return XDB::format('p.' . $type . '_id = {?}', $id); | |
194 | } | |
195 | } | |
196 | // }}} | |
197 | ||
fb3b6547 | 198 | // {{{ class UFC_EducationSchool |
d7ddf29b RB |
199 | /** Filters users by formation |
200 | * @param $val The formation to search (either ID or array of IDs) | |
201 | */ | |
fb3b6547 | 202 | class UFC_EducationSchool implements UserFilterCondition |
a7f8e48a | 203 | { |
d7ddf29b | 204 | private $val; |
a7f8e48a | 205 | |
d7ddf29b | 206 | public function __construct($val) |
a7f8e48a | 207 | { |
d7ddf29b RB |
208 | if (!is_array($val)) { |
209 | $val = array($val); | |
210 | } | |
211 | $this->val = $val; | |
a7f8e48a RB |
212 | } |
213 | ||
214 | public function buildCondition(PlFilter &$uf) | |
215 | { | |
216 | $sub = $uf->addEducationFilter(); | |
d7ddf29b | 217 | return 'pe' . $sub . '.eduid IN ' . XDB::formatArray($this->val); |
a7f8e48a RB |
218 | } |
219 | } | |
220 | // }}} | |
221 | ||
fb3b6547 RB |
222 | // {{{ class UFC_EducationDegree |
223 | class UFC_EducationDegree implements UserFilterCondition | |
d7ddf29b RB |
224 | { |
225 | private $diploma; | |
226 | ||
227 | public function __construct($diploma) | |
228 | { | |
229 | if (! is_array($diploma)) { | |
230 | $diploma = array($diploma); | |
231 | } | |
232 | $this->diploma = $diploma; | |
233 | } | |
234 | ||
235 | public function buildCondition(PlFilter &$uf) | |
236 | { | |
237 | $sub = $uf->addEducationFilter(); | |
238 | return 'pee' . $sub . '.degreeid IN ' . XDB::formatArray($this->val); | |
239 | } | |
240 | } | |
241 | // }}} | |
242 | ||
fb3b6547 RB |
243 | // {{{ class UFC_EducationField |
244 | class UFC_EducationField implements UserFilterCondition | |
d7ddf29b RB |
245 | { |
246 | private $val; | |
247 | ||
248 | public function __construct($val) | |
249 | { | |
46e88fe3 RB |
250 | if (!is_array($val)) { |
251 | $val = array($val); | |
252 | } | |
d7ddf29b RB |
253 | $this->val = $val; |
254 | } | |
255 | ||
256 | public function buildCondition(PlFilter &$uf) | |
257 | { | |
258 | $sub = $uf->addEducationFilter(); | |
259 | return 'pee' . $sub . '.fieldid IN ' . XDB::formatArray($this->val); | |
260 | } | |
261 | } | |
262 | // }}} | |
263 | ||
8363588b | 264 | // {{{ class UFC_Name |
53eae167 | 265 | /** Filters users based on name |
5d2e55c7 | 266 | * @param $type Type of name field on which filtering is done (firstname, lastname...) |
53eae167 | 267 | * @param $text Text on which to filter |
5d2e55c7 | 268 | * @param $mode Flag indicating search type (prefix, suffix, with particule...) |
53eae167 | 269 | */ |
784745ce FB |
270 | class UFC_Name implements UserFilterCondition |
271 | { | |
658b4c83 RB |
272 | const PREFIX = XDB::WILDCARD_PREFIX; // 0x001 |
273 | const SUFFIX = XDB::WILDCARD_SUFFIX; // 0x002 | |
274 | const CONTAINS = XDB::WILDCARD_CONTAINS; // 0x003 | |
275 | const PARTICLE = 0x007; // self::CONTAINS | 0x004 | |
276 | const VARIANTS = 0x008; | |
784745ce FB |
277 | |
278 | private $type; | |
279 | private $text; | |
280 | private $mode; | |
281 | ||
282 | public function __construct($type, $text, $mode) | |
283 | { | |
284 | $this->type = $type; | |
285 | $this->text = $text; | |
286 | $this->mode = $mode; | |
287 | } | |
288 | ||
289 | private function buildNameQuery($type, $variant, $where, UserFilter &$uf) | |
290 | { | |
291 | $sub = $uf->addNameFilter($type, $variant); | |
292 | return str_replace('$ME', 'pn' . $sub, $where); | |
293 | } | |
294 | ||
dcc63ed5 | 295 | public function buildCondition(PlFilter &$uf) |
784745ce FB |
296 | { |
297 | $left = '$ME.name'; | |
784745ce FB |
298 | if (($this->mode & self::PARTICLE) == self::PARTICLE) { |
299 | $left = 'CONCAT($ME.particle, \' \', $ME.name)'; | |
300 | } | |
658b4c83 RB |
301 | $right = XDB::formatWildcards($this->mode & self::CONTAINS, $this->text); |
302 | ||
303 | $cond = $left . $right; | |
784745ce | 304 | $conds = array($this->buildNameQuery($this->type, null, $cond, $uf)); |
913a4e90 RB |
305 | if (($this->mode & self::VARIANTS) != 0 && isset(Profile::$name_variants[$this->type])) { |
306 | foreach (Profile::$name_variants[$this->type] as $var) { | |
784745ce FB |
307 | $conds[] = $this->buildNameQuery($this->type, $var, $cond, $uf); |
308 | } | |
309 | } | |
310 | return implode(' OR ', $conds); | |
a087cc8d FB |
311 | } |
312 | } | |
8363588b | 313 | // }}} |
a087cc8d | 314 | |
40585144 RB |
315 | // {{{ class UFC_NameTokens |
316 | /** Selects users based on tokens in their name (for quicksearch) | |
317 | * @param $tokens An array of tokens to search | |
318 | * @param $flags Flags the tokens must have (e.g 'public' for public search) | |
319 | * @param $soundex (bool) Whether those tokens are fulltext or soundex | |
320 | */ | |
321 | class UFC_NameTokens implements UserFilterCondition | |
322 | { | |
323 | /* Flags */ | |
324 | const FLAG_PUBLIC = 'public'; | |
325 | ||
326 | private $tokens; | |
327 | private $flags; | |
328 | private $soundex; | |
79a0b464 | 329 | private $exact; |
40585144 | 330 | |
79a0b464 | 331 | public function __construct($tokens, $flags = array(), $soundex = false, $exact = false) |
40585144 RB |
332 | { |
333 | $this->tokens = $tokens; | |
334 | if (is_array($flags)) { | |
335 | $this->flags = $flags; | |
336 | } else { | |
337 | $this->flags = array($flags); | |
338 | } | |
339 | $this->soundex = $soundex; | |
79a0b464 | 340 | $this->exact = $exact; |
40585144 RB |
341 | } |
342 | ||
dcc63ed5 | 343 | public function buildCondition(PlFilter &$uf) |
40585144 | 344 | { |
79a0b464 | 345 | $sub = $uf->addNameTokensFilter(!($this->exact || $this->soundex)); |
40585144 RB |
346 | $conds = array(); |
347 | if ($this->soundex) { | |
348 | $conds[] = $sub . '.soundex IN ' . XDB::formatArray($this->tokens); | |
79a0b464 RB |
349 | } else if ($this->exact) { |
350 | $conds[] = $sub . '.token IN ' . XDB::formatArray($this->tokens); | |
40585144 RB |
351 | } else { |
352 | $tokconds = array(); | |
353 | foreach ($this->tokens as $token) { | |
658b4c83 | 354 | $tokconds[] = $sub . '.token ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $token); |
40585144 RB |
355 | } |
356 | $conds[] = implode(' OR ', $tokconds); | |
357 | } | |
358 | ||
359 | if ($this->flags != null) { | |
360 | $conds[] = $sub . '.flags IN ' . XDB::formatArray($this->flags); | |
361 | } | |
362 | ||
363 | return implode(' AND ', $conds); | |
364 | } | |
365 | } | |
366 | // }}} | |
367 | ||
0fb3713c RB |
368 | // {{{ class UFC_Nationality |
369 | class UFC_Nationality implements UserFilterCondition | |
370 | { | |
d7ddf29b | 371 | private $val; |
0fb3713c | 372 | |
d7ddf29b | 373 | public function __construct($val) |
0fb3713c | 374 | { |
d7ddf29b RB |
375 | if (!is_array($val)) { |
376 | $val = array($val); | |
377 | } | |
378 | $this->val = $val; | |
0fb3713c RB |
379 | } |
380 | ||
381 | public function buildCondition(PlFilter &$uf) | |
382 | { | |
d7ddf29b RB |
383 | $uf->requireProfiles(); |
384 | $nat = XDB::formatArray($this->val); | |
385 | $conds = array( | |
386 | 'p.nationality1 IN ' . $nat, | |
387 | 'p.nationality2 IN ' . $nat, | |
388 | 'p.nationality3 IN ' . $nat, | |
389 | ); | |
390 | return implode(' OR ', $conds); | |
0fb3713c RB |
391 | } |
392 | } | |
393 | // }}} | |
394 | ||
8363588b | 395 | // {{{ class UFC_Dead |
53eae167 RB |
396 | /** Filters users based on death date |
397 | * @param $comparison Comparison operator | |
398 | * @param $date Date to which death date should be compared | |
399 | */ | |
4927ee54 FB |
400 | class UFC_Dead implements UserFilterCondition |
401 | { | |
38c6fe96 FB |
402 | private $comparison; |
403 | private $date; | |
404 | ||
405 | public function __construct($comparison = null, $date = null) | |
4927ee54 | 406 | { |
38c6fe96 FB |
407 | $this->comparison = $comparison; |
408 | $this->date = $date; | |
4927ee54 FB |
409 | } |
410 | ||
dcc63ed5 | 411 | public function buildCondition(PlFilter &$uf) |
4927ee54 | 412 | { |
d7ddf29b | 413 | $uf->requireProfiles(); |
38c6fe96 FB |
414 | $str = 'p.deathdate IS NOT NULL'; |
415 | if (!is_null($this->comparison)) { | |
416 | $str .= ' AND p.deathdate ' . $this->comparison . ' ' . XDB::format('{?}', date('Y-m-d', $this->date)); | |
4927ee54 | 417 | } |
38c6fe96 | 418 | return $str; |
4927ee54 FB |
419 | } |
420 | } | |
8363588b | 421 | // }}} |
4927ee54 | 422 | |
8363588b | 423 | // {{{ class UFC_Registered |
53eae167 RB |
424 | /** Filters users based on registration state |
425 | * @param $active Whether we want to use only "active" users (i.e with a valid redirection) | |
426 | * @param $comparison Comparison operator | |
427 | * @param $date Date to which users registration date should be compared | |
428 | */ | |
4927ee54 FB |
429 | class UFC_Registered implements UserFilterCondition |
430 | { | |
431 | private $active; | |
38c6fe96 FB |
432 | private $comparison; |
433 | private $date; | |
434 | ||
435 | public function __construct($active = false, $comparison = null, $date = null) | |
4927ee54 | 436 | { |
b2e8fc54 | 437 | $this->active = $active; |
38c6fe96 FB |
438 | $this->comparison = $comparison; |
439 | $this->date = $date; | |
4927ee54 FB |
440 | } |
441 | ||
dcc63ed5 | 442 | public function buildCondition(PlFilter &$uf) |
4927ee54 | 443 | { |
d7ddf29b | 444 | $uf->requireAccounts(); |
4927ee54 | 445 | if ($this->active) { |
38c6fe96 | 446 | $date = 'a.uid IS NOT NULL AND a.state = \'active\''; |
4927ee54 | 447 | } else { |
38c6fe96 FB |
448 | $date = 'a.uid IS NOT NULL AND a.state != \'pending\''; |
449 | } | |
450 | if (!is_null($this->comparison)) { | |
451 | $date .= ' AND a.registration_date ' . $this->comparison . ' ' . XDB::format('{?}', date('Y-m-d', $this->date)); | |
4927ee54 | 452 | } |
38c6fe96 | 453 | return $date; |
4927ee54 FB |
454 | } |
455 | } | |
8363588b | 456 | // }}} |
4927ee54 | 457 | |
8363588b | 458 | // {{{ class UFC_ProfileUpdated |
53eae167 RB |
459 | /** Filters users based on profile update date |
460 | * @param $comparison Comparison operator | |
461 | * @param $date Date to which profile update date must be compared | |
462 | */ | |
7e735012 FB |
463 | class UFC_ProfileUpdated implements UserFilterCondition |
464 | { | |
465 | private $comparison; | |
466 | private $date; | |
467 | ||
468 | public function __construct($comparison = null, $date = null) | |
469 | { | |
470 | $this->comparison = $comparison; | |
471 | $this->date = $date; | |
472 | } | |
473 | ||
dcc63ed5 | 474 | public function buildCondition(PlFilter &$uf) |
7e735012 | 475 | { |
d7ddf29b | 476 | $uf->requireProfiles(); |
7e735012 FB |
477 | return 'p.last_change ' . $this->comparison . XDB::format(' {?}', date('Y-m-d H:i:s', $this->date)); |
478 | } | |
479 | } | |
8363588b | 480 | // }}} |
7e735012 | 481 | |
8363588b | 482 | // {{{ class UFC_Birthday |
53eae167 RB |
483 | /** Filters users based on next birthday date |
484 | * @param $comparison Comparison operator | |
485 | * @param $date Date to which users next birthday date should be compared | |
486 | */ | |
7e735012 FB |
487 | class UFC_Birthday implements UserFilterCondition |
488 | { | |
489 | private $comparison; | |
490 | private $date; | |
491 | ||
492 | public function __construct($comparison = null, $date = null) | |
493 | { | |
494 | $this->comparison = $comparison; | |
495 | $this->date = $date; | |
496 | } | |
497 | ||
dcc63ed5 | 498 | public function buildCondition(PlFilter &$uf) |
7e735012 | 499 | { |
d7ddf29b | 500 | $uf->requireProfiles(); |
7e735012 FB |
501 | return 'p.next_birthday ' . $this->comparison . XDB::format(' {?}', date('Y-m-d', $this->date)); |
502 | } | |
503 | } | |
8363588b | 504 | // }}} |
7e735012 | 505 | |
8363588b | 506 | // {{{ class UFC_Sex |
53eae167 RB |
507 | /** Filters users based on sex |
508 | * @parm $sex One of User::GENDER_MALE or User::GENDER_FEMALE, for selecting users | |
509 | */ | |
4927ee54 FB |
510 | class UFC_Sex implements UserFilterCondition |
511 | { | |
512 | private $sex; | |
513 | public function __construct($sex) | |
514 | { | |
515 | $this->sex = $sex; | |
516 | } | |
517 | ||
dcc63ed5 | 518 | public function buildCondition(PlFilter &$uf) |
4927ee54 FB |
519 | { |
520 | if ($this->sex != User::GENDER_MALE && $this->sex != User::GENDER_FEMALE) { | |
521 | return self::COND_FALSE; | |
522 | } else { | |
d7ddf29b | 523 | $uf->requireProfiles(); |
24e08e33 | 524 | return XDB::format('p.sex = {?}', $this->sex == User::GENDER_FEMALE ? 'female' : 'male'); |
4927ee54 FB |
525 | } |
526 | } | |
527 | } | |
8363588b | 528 | // }}} |
4927ee54 | 529 | |
8363588b | 530 | // {{{ class UFC_Group |
53eae167 | 531 | /** Filters users based on group membership |
5d2e55c7 RB |
532 | * @param $group Group whose members we are selecting |
533 | * @param $anim Whether to restrict selection to animators of that group | |
53eae167 | 534 | */ |
4927ee54 FB |
535 | class UFC_Group implements UserFilterCondition |
536 | { | |
537 | private $group; | |
5d2e55c7 RB |
538 | private $anim; |
539 | public function __construct($group, $anim = false) | |
4927ee54 FB |
540 | { |
541 | $this->group = $group; | |
5d2e55c7 | 542 | $this->anim = $anim; |
4927ee54 FB |
543 | } |
544 | ||
dcc63ed5 | 545 | public function buildCondition(PlFilter &$uf) |
4927ee54 FB |
546 | { |
547 | $sub = $uf->addGroupFilter($this->group); | |
548 | $where = 'gpm' . $sub . '.perms IS NOT NULL'; | |
5d2e55c7 | 549 | if ($this->anim) { |
4927ee54 FB |
550 | $where .= ' AND gpm' . $sub . '.perms = \'admin\''; |
551 | } | |
552 | return $where; | |
553 | } | |
554 | } | |
8363588b | 555 | // }}} |
4927ee54 | 556 | |
0fb3713c | 557 | // {{{ class UFC_Binet |
d7ddf29b RB |
558 | /** Selects users based on their belonging to a given (list of) binet |
559 | * @param $binet either a binet_id or an array of binet_ids | |
560 | */ | |
0fb3713c RB |
561 | class UFC_Binet implements UserFilterCondition |
562 | { | |
d7ddf29b | 563 | private $val; |
0fb3713c | 564 | |
d7ddf29b | 565 | public function __construct($val) |
0fb3713c | 566 | { |
d7ddf29b RB |
567 | if (!is_array($val)) { |
568 | $val = array($val); | |
569 | } | |
570 | $this->val = $val; | |
0fb3713c RB |
571 | } |
572 | ||
573 | public function buildCondition(PlFilter &$uf) | |
574 | { | |
d7ddf29b RB |
575 | $sub = $uf->addBinetsFilter(); |
576 | return $sub . '.binet_id IN ' . XDB::formatArray($this->val); | |
a7f8e48a RB |
577 | } |
578 | } | |
579 | // }}} | |
580 | ||
581 | // {{{ class UFC_Section | |
46e88fe3 RB |
582 | /** Selects users based on section |
583 | * @param $section ID of the section | |
584 | */ | |
a7f8e48a RB |
585 | class UFC_Section implements UserFilterCondition |
586 | { | |
587 | private $section; | |
588 | ||
589 | public function __construct($section) | |
590 | { | |
591 | $this->section = $section; | |
592 | } | |
593 | ||
594 | public function buildCondition(PlFilter &$uf) | |
595 | { | |
596 | $uf->requireProfiles(); | |
597 | return 'p.section = ' . XDB::format('{?}', $this->section); | |
0fb3713c RB |
598 | } |
599 | } | |
600 | // }}} | |
601 | ||
8363588b | 602 | // {{{ class UFC_Email |
53eae167 RB |
603 | /** Filters users based on email address |
604 | * @param $email Email whose owner we are looking for | |
605 | */ | |
aa21c568 FB |
606 | class UFC_Email implements UserFilterCondition |
607 | { | |
608 | private $email; | |
609 | public function __construct($email) | |
610 | { | |
611 | $this->email = $email; | |
612 | } | |
613 | ||
dcc63ed5 | 614 | public function buildCondition(PlFilter &$uf) |
aa21c568 FB |
615 | { |
616 | if (User::isForeignEmailAddress($this->email)) { | |
617 | $sub = $uf->addEmailRedirectFilter($this->email); | |
618 | return XDB::format('e' . $sub . '.email IS NOT NULL OR a.email = {?}', $this->email); | |
21401768 FB |
619 | } else if (User::isVirtualEmailAddress($this->email)) { |
620 | $sub = $uf->addVirtualEmailFilter($this->email); | |
621 | return 'vr' . $sub . '.redirect IS NOT NULL'; | |
aa21c568 | 622 | } else { |
21401768 FB |
623 | @list($user, $domain) = explode('@', $this->email); |
624 | $sub = $uf->addAliasFilter($user); | |
aa21c568 FB |
625 | return 'al' . $sub . '.alias IS NOT NULL'; |
626 | } | |
627 | } | |
628 | } | |
8363588b | 629 | // }}} |
d865c296 | 630 | |
8363588b | 631 | // {{{ class UFC_EmailList |
5d2e55c7 | 632 | /** Filters users based on an email list |
53eae167 RB |
633 | * @param $emails List of emails whose owner must be selected |
634 | */ | |
21401768 FB |
635 | class UFC_EmailList implements UserFilterCondition |
636 | { | |
637 | private $emails; | |
638 | public function __construct($emails) | |
639 | { | |
640 | $this->emails = $emails; | |
641 | } | |
642 | ||
dcc63ed5 | 643 | public function buildCondition(PlFilter &$uf) |
21401768 FB |
644 | { |
645 | $email = null; | |
646 | $virtual = null; | |
647 | $alias = null; | |
648 | $cond = array(); | |
649 | ||
650 | if (count($this->emails) == 0) { | |
dcc63ed5 | 651 | return PlFilterCondition::COND_TRUE; |
21401768 FB |
652 | } |
653 | ||
654 | foreach ($this->emails as $entry) { | |
655 | if (User::isForeignEmailAddress($entry)) { | |
656 | if (is_null($email)) { | |
657 | $email = $uf->addEmailRedirectFilter(); | |
658 | } | |
659 | $cond[] = XDB::format('e' . $email . '.email = {?} OR a.email = {?}', $entry, $entry); | |
660 | } else if (User::isVirtualEmailAddress($entry)) { | |
661 | if (is_null($virtual)) { | |
662 | $virtual = $uf->addVirtualEmailFilter(); | |
663 | } | |
664 | $cond[] = XDB::format('vr' . $virtual . '.redirect IS NOT NULL AND v' . $virtual . '.alias = {?}', $entry); | |
665 | } else { | |
666 | if (is_null($alias)) { | |
667 | $alias = $uf->addAliasFilter(); | |
668 | } | |
669 | @list($user, $domain) = explode('@', $entry); | |
670 | $cond[] = XDB::format('al' . $alias . '.alias = {?}', $user); | |
671 | } | |
672 | } | |
673 | return '(' . implode(') OR (', $cond) . ')'; | |
674 | } | |
675 | } | |
8363588b | 676 | // }}} |
d865c296 | 677 | |
8363588b | 678 | // {{{ class UFC_Address |
2b9ca54d | 679 | abstract class UFC_Address implements UserFilterCondition |
c4b24511 | 680 | { |
2b9ca54d | 681 | /** Valid address type ('hq' is reserved for company addresses) |
036d1637 | 682 | */ |
2b9ca54d RB |
683 | const TYPE_HOME = 1; |
684 | const TYPE_PRO = 2; | |
685 | const TYPE_ANY = 3; | |
c4b24511 | 686 | |
2b9ca54d | 687 | /** Text for these types |
036d1637 | 688 | */ |
2b9ca54d RB |
689 | protected static $typetexts = array( |
690 | self::TYPE_HOME => 'home', | |
691 | self::TYPE_PRO => 'pro', | |
692 | ); | |
693 | ||
694 | protected $type; | |
c4b24511 | 695 | |
036d1637 RB |
696 | /** Flags for addresses |
697 | */ | |
698 | const FLAG_CURRENT = 0x0001; | |
699 | const FLAG_TEMP = 0x0002; | |
700 | const FLAG_SECOND = 0x0004; | |
701 | const FLAG_MAIL = 0x0008; | |
702 | const FLAG_CEDEX = 0x0010; | |
703 | ||
704 | // Binary OR of those flags | |
705 | const FLAG_ANY = 0x001F; | |
706 | ||
707 | /** Text of these flags | |
708 | */ | |
2b9ca54d | 709 | protected static $flagtexts = array( |
036d1637 RB |
710 | self::FLAG_CURRENT => 'current', |
711 | self::FLAG_TEMP => 'temporary', | |
712 | self::FLAG_SECOND => 'secondary', | |
713 | self::FLAG_MAIL => 'mail', | |
714 | self::FLAG_CEDEX => 'cedex', | |
715 | ); | |
716 | ||
2b9ca54d RB |
717 | protected $flags; |
718 | ||
719 | public function __construct($type = null, $flags = null) | |
720 | { | |
721 | $this->type = $type; | |
722 | $this->flags = $flags; | |
723 | } | |
724 | ||
725 | protected function initConds($sub) | |
726 | { | |
727 | $conds = array(); | |
728 | $types = array(); | |
729 | foreach (self::$typetexts as $flag => $type) { | |
730 | if ($flag & $this->type) { | |
731 | $types[] = $type; | |
732 | } | |
733 | } | |
734 | if (count($types)) { | |
735 | $conds[] = $sub . '.type IN ' . XDB::formatArray($types); | |
736 | } | |
737 | ||
738 | if ($this->flags != self::FLAG_ANY) { | |
739 | foreach(self::$flagtexts as $flag => $text) { | |
740 | if ($flag & $this->flags) { | |
741 | $conds[] = 'FIND_IN_SET(' . XDB::format('{?}', $text) . ', ' . $sub . '.flags)'; | |
742 | } | |
743 | } | |
744 | } | |
745 | return $conds; | |
746 | } | |
747 | ||
748 | } | |
749 | // }}} | |
750 | ||
751 | // {{{ class UFC_AddressText | |
752 | /** Select users based on their address, using full text search | |
753 | * @param $text Text for filter in fulltext search | |
658b4c83 | 754 | * @param $textSearchMode Mode for search (one of XDB::WILDCARD_*) |
2b9ca54d RB |
755 | * @param $type Filter on address type |
756 | * @param $flags Filter on address flags | |
757 | * @param $country Filter on address country | |
758 | * @param $locality Filter on address locality | |
759 | */ | |
760 | class UFC_AddressText extends UFC_Address | |
761 | { | |
2b9ca54d | 762 | |
036d1637 | 763 | private $text; |
2b9ca54d RB |
764 | private $textSearchMode; |
765 | ||
658b4c83 | 766 | public function __construct($text = null, $textSearchMode = XDB::WILDCARD_CONTAINS, |
2b9ca54d RB |
767 | $type = null, $flags = self::FLAG_ANY, $country = null, $locality = null) |
768 | { | |
769 | parent::__construct($type, $flags); | |
770 | $this->text = $text; | |
771 | $this->textSearchMode = $textSearchMode; | |
772 | $this->country = $country; | |
773 | $this->locality = $locality; | |
774 | } | |
775 | ||
776 | private function mkMatch($txt) | |
777 | { | |
658b4c83 | 778 | return XDB::formatWildcards($this->textSearchMode, $txt); |
2b9ca54d RB |
779 | } |
780 | ||
781 | public function buildCondition(PlFilter &$uf) | |
782 | { | |
783 | $sub = $uf->addAddressFilter(); | |
784 | $conds = $this->initConds($sub); | |
785 | if ($this->text != null) { | |
786 | $conds[] = $sub . '.text' . $this->mkMatch($this->text); | |
787 | } | |
788 | ||
789 | if ($this->country != null) { | |
790 | $subc = $uf->addAddressCountryFilter(); | |
791 | $subconds = array(); | |
792 | $subconds[] = $subc . '.country' . $this->mkMatch($this->country); | |
793 | $subconds[] = $subc . '.countryFR' . $this->mkMatch($this->country); | |
794 | $conds[] = implode(' OR ', $subconds); | |
795 | } | |
796 | ||
797 | if ($this->locality != null) { | |
798 | $subl = $uf->addAddressLocalityFilter(); | |
799 | $conds[] = $subl . '.name' . $this->mkMatch($this->locality); | |
800 | } | |
801 | ||
802 | return implode(' AND ', $conds); | |
803 | } | |
804 | } | |
805 | // }}} | |
806 | ||
46e88fe3 | 807 | // {{{ class UFC_AddressField |
2b9ca54d | 808 | /** Filters users based on their address, |
46e88fe3 RB |
809 | * @param $val Either a code for one of the fields, or an array of such codes |
810 | * @param $fieldtype The type of field to look for | |
2b9ca54d RB |
811 | * @param $type Filter on address type |
812 | * @param $flags Filter on address flags | |
2b9ca54d | 813 | */ |
46e88fe3 | 814 | class UFC_AddressField extends UFC_Address |
2b9ca54d | 815 | { |
46e88fe3 RB |
816 | const FIELD_COUNTRY = 1; |
817 | const FIELD_ADMAREA = 2; | |
818 | const FIELD_SUBADMAREA = 3; | |
819 | const FIELD_LOCALITY = 4; | |
820 | const FIELD_ZIPCODE = 5; | |
821 | ||
2b9ca54d RB |
822 | /** Data of the filter |
823 | */ | |
46e88fe3 RB |
824 | private $val; |
825 | private $fieldtype; | |
036d1637 | 826 | |
46e88fe3 | 827 | public function __construct($val, $fieldtype, $type = null, $flags = self::FLAG_ANY) |
036d1637 | 828 | { |
2b9ca54d | 829 | parent::__construct($type, $flags); |
46e88fe3 RB |
830 | |
831 | if (!is_array($val)) { | |
832 | $val = array($val); | |
833 | } | |
834 | $this->val = $val; | |
835 | $this->fieldtype = $fieldtype; | |
c4b24511 RB |
836 | } |
837 | ||
dcc63ed5 | 838 | public function buildCondition(PlFilter &$uf) |
c4b24511 | 839 | { |
036d1637 | 840 | $sub = $uf->addAddressFilter(); |
d7ddf29b | 841 | $conds = $this->initConds($sub); |
036d1637 | 842 | |
46e88fe3 RB |
843 | switch ($this->fieldtype) { |
844 | case self::FIELD_COUNTRY: | |
845 | $field = 'countryId'; | |
846 | break; | |
847 | case self::FIELD_ADMAREA: | |
848 | $field = 'administrativeAreaId'; | |
849 | break; | |
850 | case self::FIELD_SUBADMAREA: | |
851 | $field = 'subAdministrativeAreaId'; | |
852 | break; | |
853 | case self::FIELD_LOCALITY: | |
854 | $field = 'localityId'; | |
855 | break; | |
856 | case self::FIELD_ZIPCODE: | |
857 | $field = 'postalCode'; | |
858 | break; | |
859 | default: | |
61f61261 | 860 | Platal::page()->killError('Invalid address field type: ' . $this->fieldtype); |
46e88fe3 RB |
861 | } |
862 | $conds[] = $sub . '.' . $field . ' IN ' . XDB::formatArray($this->val); | |
036d1637 RB |
863 | |
864 | return implode(' AND ', $conds); | |
c4b24511 RB |
865 | } |
866 | } | |
8363588b | 867 | // }}} |
c4b24511 | 868 | |
8363588b | 869 | // {{{ class UFC_Corps |
4083b126 RB |
870 | /** Filters users based on the corps they belong to |
871 | * @param $corps Corps we are looking for (abbreviation) | |
872 | * @param $type Whether we search for original or current corps | |
873 | */ | |
874 | class UFC_Corps implements UserFilterCondition | |
875 | { | |
5d2e55c7 RB |
876 | const CURRENT = 1; |
877 | const ORIGIN = 2; | |
4083b126 RB |
878 | |
879 | private $corps; | |
880 | private $type; | |
881 | ||
882 | public function __construct($corps, $type = self::CURRENT) | |
883 | { | |
884 | $this->corps = $corps; | |
885 | $this->type = $type; | |
886 | } | |
887 | ||
dcc63ed5 | 888 | public function buildCondition(PlFilter &$uf) |
4083b126 | 889 | { |
5d2e55c7 RB |
890 | /** Tables shortcuts: |
891 | * pc for profile_corps, | |
4083b126 RB |
892 | * pceo for profile_corps_enum - orginal |
893 | * pcec for profile_corps_enum - current | |
894 | */ | |
895 | $sub = $uf->addCorpsFilter($this->type); | |
896 | $cond = $sub . '.abbreviation = ' . $corps; | |
897 | return $cond; | |
898 | } | |
899 | } | |
8363588b | 900 | // }}} |
4083b126 | 901 | |
8363588b | 902 | // {{{ class UFC_Corps_Rank |
4083b126 RB |
903 | /** Filters users based on their rank in the corps |
904 | * @param $rank Rank we are looking for (abbreviation) | |
905 | */ | |
906 | class UFC_Corps_Rank implements UserFilterCondition | |
907 | { | |
908 | private $rank; | |
909 | public function __construct($rank) | |
910 | { | |
911 | $this->rank = $rank; | |
912 | } | |
913 | ||
dcc63ed5 | 914 | public function buildCondition(PlFilter &$uf) |
4083b126 | 915 | { |
5d2e55c7 | 916 | /** Tables shortcuts: |
4083b126 RB |
917 | * pcr for profile_corps_rank |
918 | */ | |
919 | $sub = $uf->addCorpsRankFilter(); | |
920 | $cond = $sub . '.abbreviation = ' . $rank; | |
921 | return $cond; | |
922 | } | |
923 | } | |
8363588b | 924 | // }}} |
4083b126 | 925 | |
6a99c3ac RB |
926 | // {{{ class UFC_Job_Company |
927 | /** Filters users based on the company they belong to | |
928 | * @param $type The field being searched (self::JOBID, self::JOBNAME or self::JOBACRONYM) | |
929 | * @param $value The searched value | |
930 | */ | |
4e2f2ad2 | 931 | class UFC_Job_Company implements UserFilterCondition |
6a99c3ac RB |
932 | { |
933 | const JOBID = 'id'; | |
934 | const JOBNAME = 'name'; | |
935 | const JOBACRONYM = 'acronym'; | |
936 | ||
937 | private $type; | |
938 | private $value; | |
939 | ||
940 | public function __construct($type, $value) | |
941 | { | |
942 | $this->assertType($type); | |
943 | $this->type = $type; | |
944 | $this->value = $value; | |
945 | } | |
946 | ||
947 | private function assertType($type) | |
948 | { | |
949 | if ($type != self::JOBID && $type != self::JOBNAME && $type != self::JOBACRONYM) { | |
5d2e55c7 | 950 | Platal::page()->killError("Type de recherche non valide."); |
6a99c3ac RB |
951 | } |
952 | } | |
953 | ||
dcc63ed5 | 954 | public function buildCondition(PlFilter &$uf) |
6a99c3ac RB |
955 | { |
956 | $sub = $uf->addJobCompanyFilter(); | |
957 | $cond = $sub . '.' . $this->type . ' = ' . XDB::format('{?}', $this->value); | |
958 | return $cond; | |
959 | } | |
960 | } | |
961 | // }}} | |
962 | ||
963 | // {{{ class UFC_Job_Sectorization | |
964 | /** Filters users based on the ((sub)sub)sector they work in | |
46e88fe3 | 965 | * @param $val The ID of the sector, or an array of such IDs |
d7ddf29b | 966 | * @param $type The kind of search (subsubsector/subsector/sector) |
6a99c3ac | 967 | */ |
4e2f2ad2 | 968 | class UFC_Job_Sectorization implements UserFilterCondition |
6a99c3ac | 969 | { |
d7ddf29b RB |
970 | private $val; |
971 | private $type; | |
6a99c3ac | 972 | |
d7ddf29b RB |
973 | public function __construct($val, $type = UserFilter::JOB_SECTOR) |
974 | { | |
975 | self::assertType($type); | |
46e88fe3 RB |
976 | if (!is_array($val)) { |
977 | $val = array($val); | |
978 | } | |
d7ddf29b RB |
979 | $this->val = $val; |
980 | $this->type = $type; | |
981 | } | |
6a99c3ac | 982 | |
d7ddf29b | 983 | private static function assertType($type) |
6a99c3ac | 984 | { |
d7ddf29b RB |
985 | if ($type != UserFilter::JOB_SECTOR && $type != UserFilter::JOB_SUBSECTOR && $type != UserFilter::JOB_SUBSUBSECTOR) { |
986 | Platal::page()->killError("Type de secteur non valide."); | |
987 | } | |
6a99c3ac RB |
988 | } |
989 | ||
dcc63ed5 | 990 | public function buildCondition(PlFilter &$uf) |
6a99c3ac | 991 | { |
d7ddf29b RB |
992 | $sub = $uf->addJobSectorizationFilter($this->type); |
993 | return $sub . '.id = ' . XDB::format('{?}', $this->val); | |
6a99c3ac RB |
994 | } |
995 | } | |
996 | // }}} | |
997 | ||
998 | // {{{ class UFC_Job_Description | |
999 | /** Filters users based on their job description | |
1000 | * @param $description The text being searched for | |
1001 | * @param $fields The fields to search for (user-defined, ((sub|)sub|)sector) | |
1002 | */ | |
4e2f2ad2 | 1003 | class UFC_Job_Description implements UserFilterCondition |
6a99c3ac RB |
1004 | { |
1005 | ||
6a99c3ac RB |
1006 | private $description; |
1007 | private $fields; | |
1008 | ||
01cc5f9e | 1009 | public function __construct($description, $fields) |
6a99c3ac RB |
1010 | { |
1011 | $this->fields = $fields; | |
1012 | $this->description = $description; | |
1013 | } | |
1014 | ||
dcc63ed5 | 1015 | public function buildCondition(PlFilter &$uf) |
6a99c3ac RB |
1016 | { |
1017 | $conds = array(); | |
1018 | if ($this->fields & UserFilter::JOB_USERDEFINED) { | |
1019 | $sub = $uf->addJobFilter(); | |
658b4c83 | 1020 | $conds[] = $sub . '.description ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->description); |
6a99c3ac | 1021 | } |
01cc5f9e RB |
1022 | if ($this->fields & UserFilter::JOB_CV) { |
1023 | $uf->requireProfiles(); | |
658b4c83 | 1024 | $conds[] = 'p.cv ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->description); |
01cc5f9e | 1025 | } |
6a99c3ac RB |
1026 | if ($this->fields & UserFilter::JOB_SECTOR) { |
1027 | $sub = $uf->addJobSectorizationFilter(UserFilter::JOB_SECTOR); | |
658b4c83 | 1028 | $conds[] = $sub . '.name ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->description); |
6a99c3ac RB |
1029 | } |
1030 | if ($this->fields & UserFilter::JOB_SUBSECTOR) { | |
1031 | $sub = $uf->addJobSectorizationFilter(UserFilter::JOB_SUBSECTOR); | |
658b4c83 | 1032 | $conds[] = $sub . '.name ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->description); |
6a99c3ac RB |
1033 | } |
1034 | if ($this->fields & UserFilter::JOB_SUBSUBSECTOR) { | |
1035 | $sub = $uf->addJobSectorizationFilter(UserFilter::JOB_SUBSUBSECTOR); | |
658b4c83 | 1036 | $conds[] = $sub . '.name ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->description); |
6a99c3ac | 1037 | $sub = $uf->addJobSectorizationFilter(UserFilter::JOB_ALTERNATES); |
658b4c83 | 1038 | $conds[] = $sub . '.name ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->description); |
6a99c3ac RB |
1039 | } |
1040 | return implode(' OR ', $conds); | |
1041 | } | |
1042 | } | |
1043 | // }}} | |
1044 | ||
0a2e9c74 RB |
1045 | // {{{ class UFC_Networking |
1046 | /** Filters users based on network identity (IRC, ...) | |
1047 | * @param $type Type of network (-1 for any) | |
1048 | * @param $value Value to search | |
1049 | */ | |
4e2f2ad2 | 1050 | class UFC_Networking implements UserFilterCondition |
0a2e9c74 RB |
1051 | { |
1052 | private $type; | |
1053 | private $value; | |
1054 | ||
1055 | public function __construct($type, $value) | |
1056 | { | |
1057 | $this->type = $type; | |
1058 | $this->value = $value; | |
1059 | } | |
1060 | ||
dcc63ed5 | 1061 | public function buildCondition(PlFilter &$uf) |
0a2e9c74 RB |
1062 | { |
1063 | $sub = $uf->addNetworkingFilter(); | |
1064 | $conds = array(); | |
658b4c83 | 1065 | $conds[] = $sub . '.address ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->value); |
0a2e9c74 RB |
1066 | if ($this->type != -1) { |
1067 | $conds[] = $sub . '.network_type = ' . XDB::format('{?}', $this->type); | |
1068 | } | |
1069 | return implode(' AND ', $conds); | |
1070 | } | |
1071 | } | |
1072 | // }}} | |
1073 | ||
6d62969e RB |
1074 | // {{{ class UFC_Phone |
1075 | /** Filters users based on their phone number | |
1076 | * @param $num_type Type of number (pro/user/home) | |
1077 | * @param $phone_type Type of phone (fixed/mobile/fax) | |
1078 | * @param $number Phone number | |
1079 | */ | |
4e2f2ad2 | 1080 | class UFC_Phone implements UserFilterCondition |
6d62969e RB |
1081 | { |
1082 | const NUM_PRO = 'pro'; | |
1083 | const NUM_USER = 'user'; | |
1084 | const NUM_HOME = 'address'; | |
1085 | const NUM_ANY = 'any'; | |
1086 | ||
1087 | const PHONE_FIXED = 'fixed'; | |
1088 | const PHONE_MOBILE = 'mobile'; | |
1089 | const PHONE_FAX = 'fax'; | |
1090 | const PHONE_ANY = 'any'; | |
1091 | ||
1092 | private $num_type; | |
1093 | private $phone_type; | |
1094 | private $number; | |
1095 | ||
1096 | public function __construct($number, $num_type = self::NUM_ANY, $phone_type = self::PHONE_ANY) | |
1097 | { | |
9b8e5fb4 | 1098 | require_once('profil.func.inc.php'); |
6d62969e RB |
1099 | $this->number = $number; |
1100 | $this->num_type = $num_type; | |
1101 | $this->phone_type = format_phone_number($phone_type); | |
1102 | } | |
1103 | ||
dcc63ed5 | 1104 | public function buildCondition(PlFilter &$uf) |
6d62969e RB |
1105 | { |
1106 | $sub = $uf->addPhoneFilter(); | |
1107 | $conds = array(); | |
1108 | $conds[] = $sub . '.search_tel = ' . XDB::format('{?}', $this->number); | |
1109 | if ($this->num_type != self::NUM_ANY) { | |
1110 | $conds[] = $sub . '.link_type = ' . XDB::format('{?}', $this->num_type); | |
1111 | } | |
1112 | if ($this->phone_type != self::PHONE_ANY) { | |
1113 | $conds[] = $sub . '.tel_type = ' . XDB::format('{?}', $this->phone_type); | |
1114 | } | |
1115 | return implode(' AND ', $conds); | |
1116 | } | |
1117 | } | |
1118 | // }}} | |
1119 | ||
ceb512d2 RB |
1120 | // {{{ class UFC_Medal |
1121 | /** Filters users based on their medals | |
1122 | * @param $medal ID of the medal | |
1123 | * @param $grade Grade of the medal (null for 'any') | |
1124 | */ | |
4e2f2ad2 | 1125 | class UFC_Medal implements UserFilterCondition |
ceb512d2 RB |
1126 | { |
1127 | private $medal; | |
1128 | private $grade; | |
1129 | ||
1130 | public function __construct($medal, $grade = null) | |
1131 | { | |
1132 | $this->medal = $medal; | |
1133 | $this->grade = $grade; | |
1134 | } | |
1135 | ||
dcc63ed5 | 1136 | public function buildCondition(PlFilter &$uf) |
ceb512d2 RB |
1137 | { |
1138 | $conds = array(); | |
1139 | $sub = $uf->addMedalFilter(); | |
1140 | $conds[] = $sub . '.mid = ' . XDB::format('{?}', $this->medal); | |
1141 | if ($this->grade != null) { | |
1142 | $conds[] = $sub . '.gid = ' . XDB::format('{?}', $this->grade); | |
1143 | } | |
1144 | return implode(' AND ', $conds); | |
1145 | } | |
1146 | } | |
1147 | // }}} | |
1148 | ||
671b7073 RB |
1149 | // {{{ class UFC_Mentor_Expertise |
1150 | /** Filters users by mentoring expertise | |
1151 | * @param $expertise Domain of expertise | |
1152 | */ | |
4e2f2ad2 | 1153 | class UFC_Mentor_Expertise implements UserFilterCondition |
671b7073 RB |
1154 | { |
1155 | private $expertise; | |
1156 | ||
1157 | public function __construct($expertise) | |
1158 | { | |
1159 | $this->expertise = $expertise; | |
1160 | } | |
1161 | ||
dcc63ed5 | 1162 | public function buildCondition(PlFilter &$uf) |
671b7073 RB |
1163 | { |
1164 | $sub = $uf->addMentorFilter(UserFilter::MENTOR_EXPERTISE); | |
658b4c83 | 1165 | return $sub . '.expertise ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->expertise); |
671b7073 RB |
1166 | } |
1167 | } | |
1168 | // }}} | |
1169 | ||
1170 | // {{{ class UFC_Mentor_Country | |
1171 | /** Filters users by mentoring country | |
1172 | * @param $country Two-letters code of country being searched | |
1173 | */ | |
4e2f2ad2 | 1174 | class UFC_Mentor_Country implements UserFilterCondition |
671b7073 RB |
1175 | { |
1176 | private $country; | |
1177 | ||
1178 | public function __construct($country) | |
1179 | { | |
1180 | $this->country = $country; | |
1181 | } | |
1182 | ||
dcc63ed5 | 1183 | public function buildCondition(PlFilter &$uf) |
671b7073 RB |
1184 | { |
1185 | $sub = $uf->addMentorFilter(UserFilter::MENTOR_COUNTRY); | |
1186 | return $sub . '.country = ' . XDB::format('{?}', $this->country); | |
1187 | } | |
1188 | } | |
1189 | // }}} | |
1190 | ||
1191 | // {{{ class UFC_Mentor_Sectorization | |
1192 | /** Filters users based on mentoring (sub|)sector | |
c5da8574 RB |
1193 | * @param $sector ID of (sub)sector |
1194 | * @param $type Whether we are looking for a sector or a subsector | |
671b7073 | 1195 | */ |
4e2f2ad2 | 1196 | class UFC_Mentor_Sectorization implements UserFilterCondition |
671b7073 | 1197 | { |
c5da8574 RB |
1198 | const SECTOR = 1; |
1199 | const SUBSECTOR = 2; | |
671b7073 | 1200 | private $sector; |
c5da8574 | 1201 | private $type; |
671b7073 | 1202 | |
c5da8574 | 1203 | public function __construct($sector, $type = self::SECTOR) |
671b7073 RB |
1204 | { |
1205 | $this->sector = $sector; | |
c5da8574 | 1206 | $this->type = $type; |
671b7073 RB |
1207 | } |
1208 | ||
dcc63ed5 | 1209 | public function buildCondition(PlFilter &$uf) |
671b7073 RB |
1210 | { |
1211 | $sub = $uf->addMentorFilter(UserFilter::MENTOR_SECTOR); | |
c5da8574 RB |
1212 | if ($this->type == self::SECTOR) { |
1213 | $field = 'sectorid'; | |
1214 | } else { | |
1215 | $field = 'subsectorid'; | |
671b7073 | 1216 | } |
c5da8574 | 1217 | return $sub . '.' . $field . ' = ' . XDB::format('{?}', $this->sector); |
671b7073 RB |
1218 | } |
1219 | } | |
1220 | // }}} | |
1221 | ||
8363588b | 1222 | // {{{ class UFC_UserRelated |
5d2e55c7 | 1223 | /** Filters users based on a relation toward a user |
53eae167 RB |
1224 | * @param $user User to which searched users are related |
1225 | */ | |
4e7bf1e0 | 1226 | abstract class UFC_UserRelated implements UserFilterCondition |
3f42a6ad | 1227 | { |
009b8ab7 FB |
1228 | protected $user; |
1229 | public function __construct(PlUser &$user) | |
1230 | { | |
1231 | $this->user =& $user; | |
3f42a6ad | 1232 | } |
4e7bf1e0 | 1233 | } |
8363588b | 1234 | // }}} |
3f42a6ad | 1235 | |
8363588b | 1236 | // {{{ class UFC_Contact |
5d2e55c7 | 1237 | /** Filters users who belong to selected user's contacts |
53eae167 | 1238 | */ |
4e7bf1e0 FB |
1239 | class UFC_Contact extends UFC_UserRelated |
1240 | { | |
dcc63ed5 | 1241 | public function buildCondition(PlFilter &$uf) |
3f42a6ad | 1242 | { |
009b8ab7 | 1243 | $sub = $uf->addContactFilter($this->user->id()); |
3f42a6ad FB |
1244 | return 'c' . $sub . '.contact IS NOT NULL'; |
1245 | } | |
1246 | } | |
8363588b | 1247 | // }}} |
3f42a6ad | 1248 | |
8363588b | 1249 | // {{{ class UFC_WatchRegistration |
53eae167 RB |
1250 | /** Filters users being watched by selected user |
1251 | */ | |
4e7bf1e0 FB |
1252 | class UFC_WatchRegistration extends UFC_UserRelated |
1253 | { | |
dcc63ed5 | 1254 | public function buildCondition(PlFilter &$uf) |
4e7bf1e0 | 1255 | { |
a87530ea | 1256 | if (!$this->user->watchType('registration')) { |
dcc63ed5 | 1257 | return PlFilterCondition::COND_FALSE; |
009b8ab7 FB |
1258 | } |
1259 | $uids = $this->user->watchUsers(); | |
1260 | if (count($uids) == 0) { | |
dcc63ed5 | 1261 | return PlFilterCondition::COND_FALSE; |
009b8ab7 | 1262 | } else { |
07eb5b0e | 1263 | return '$UID IN ' . XDB::formatArray($uids); |
009b8ab7 | 1264 | } |
4e7bf1e0 FB |
1265 | } |
1266 | } | |
8363588b | 1267 | // }}} |
4e7bf1e0 | 1268 | |
8363588b | 1269 | // {{{ class UFC_WatchPromo |
53eae167 RB |
1270 | /** Filters users belonging to a promo watched by selected user |
1271 | * @param $user Selected user (the one watching promo) | |
1272 | * @param $grade Formation the user is watching | |
1273 | */ | |
4e7bf1e0 FB |
1274 | class UFC_WatchPromo extends UFC_UserRelated |
1275 | { | |
1276 | private $grade; | |
009b8ab7 | 1277 | public function __construct(PlUser &$user, $grade = UserFilter::GRADE_ING) |
4e7bf1e0 | 1278 | { |
009b8ab7 | 1279 | parent::__construct($user); |
4e7bf1e0 FB |
1280 | $this->grade = $grade; |
1281 | } | |
1282 | ||
dcc63ed5 | 1283 | public function buildCondition(PlFilter &$uf) |
4e7bf1e0 | 1284 | { |
009b8ab7 FB |
1285 | $promos = $this->user->watchPromos(); |
1286 | if (count($promos) == 0) { | |
dcc63ed5 | 1287 | return PlFilterCondition::COND_FALSE; |
009b8ab7 FB |
1288 | } else { |
1289 | $sube = $uf->addEducationFilter(true, $this->grade); | |
1290 | $field = 'pe' . $sube . '.' . UserFilter::promoYear($this->grade); | |
07eb5b0e | 1291 | return $field . ' IN ' . XDB::formatArray($promos); |
009b8ab7 | 1292 | } |
4e7bf1e0 FB |
1293 | } |
1294 | } | |
8363588b | 1295 | // }}} |
4e7bf1e0 | 1296 | |
8363588b | 1297 | // {{{ class UFC_WatchContact |
53eae167 RB |
1298 | /** Filters users watched by selected user |
1299 | */ | |
009b8ab7 | 1300 | class UFC_WatchContact extends UFC_Contact |
4e7bf1e0 | 1301 | { |
dcc63ed5 | 1302 | public function buildCondition(PlFilter &$uf) |
4e7bf1e0 | 1303 | { |
009b8ab7 | 1304 | if (!$this->user->watchContacts()) { |
dcc63ed5 | 1305 | return PlFilterCondition::COND_FALSE; |
009b8ab7 FB |
1306 | } |
1307 | return parent::buildCondition($uf); | |
4e7bf1e0 FB |
1308 | } |
1309 | } | |
8363588b | 1310 | // }}} |
4e7bf1e0 FB |
1311 | |
1312 | ||
d865c296 FB |
1313 | /****************** |
1314 | * ORDERS | |
1315 | ******************/ | |
1316 | ||
8363588b | 1317 | // {{{ class UserFilterOrder |
2d83cac9 RB |
1318 | /** Base class for ordering results of a query. |
1319 | * Parameters for the ordering must be given to the constructor ($desc for a | |
1320 | * descending order). | |
1321 | * The getSortTokens function is used to get actual ordering part of the query. | |
1322 | */ | |
7ca75030 | 1323 | abstract class UserFilterOrder extends PlFilterOrder |
d865c296 | 1324 | { |
2d83cac9 RB |
1325 | /** This function must return the tokens to use for ordering |
1326 | * @param &$uf The UserFilter whose results must be ordered | |
1327 | * @return The name of the field to use for ordering results | |
1328 | */ | |
61f61261 | 1329 | // abstract protected function getSortTokens(UserFilter &$uf); |
d865c296 | 1330 | } |
8363588b | 1331 | // }}} |
d865c296 | 1332 | |
8363588b | 1333 | // {{{ class UFO_Promo |
5d2e55c7 RB |
1334 | /** Orders users by promotion |
1335 | * @param $grade Formation whose promotion users should be sorted by (restricts results to users of that formation) | |
53eae167 RB |
1336 | * @param $desc Whether sort is descending |
1337 | */ | |
d865c296 FB |
1338 | class UFO_Promo extends UserFilterOrder |
1339 | { | |
1340 | private $grade; | |
1341 | ||
1342 | public function __construct($grade = null, $desc = false) | |
1343 | { | |
009b8ab7 | 1344 | parent::__construct($desc); |
d865c296 | 1345 | $this->grade = $grade; |
d865c296 FB |
1346 | } |
1347 | ||
61f61261 | 1348 | protected function getSortTokens(PlFilter &$uf) |
d865c296 FB |
1349 | { |
1350 | if (UserFilter::isGrade($this->grade)) { | |
1351 | $sub = $uf->addEducationFilter($this->grade); | |
1352 | return 'pe' . $sub . '.' . UserFilter::promoYear($this->grade); | |
1353 | } else { | |
1354 | $sub = $uf->addDisplayFilter(); | |
1355 | return 'pd' . $sub . '.promo'; | |
1356 | } | |
1357 | } | |
1358 | } | |
8363588b | 1359 | // }}} |
d865c296 | 1360 | |
8363588b | 1361 | // {{{ class UFO_Name |
53eae167 | 1362 | /** Sorts users by name |
5d2e55c7 RB |
1363 | * @param $type Type of name on which to sort (firstname...) |
1364 | * @param $variant Variant of that name to use (marital, ordinary...) | |
53eae167 RB |
1365 | * @param $particle Set to true if particles should be included in the sorting order |
1366 | * @param $desc If sort order should be descending | |
1367 | */ | |
d865c296 FB |
1368 | class UFO_Name extends UserFilterOrder |
1369 | { | |
1370 | private $type; | |
1371 | private $variant; | |
1372 | private $particle; | |
1373 | ||
1374 | public function __construct($type, $variant = null, $particle = false, $desc = false) | |
1375 | { | |
009b8ab7 | 1376 | parent::__construct($desc); |
d865c296 FB |
1377 | $this->type = $type; |
1378 | $this->variant = $variant; | |
1379 | $this->particle = $particle; | |
d865c296 FB |
1380 | } |
1381 | ||
61f61261 | 1382 | protected function getSortTokens(PlFilter &$uf) |
d865c296 | 1383 | { |
913a4e90 | 1384 | if (Profile::isDisplayName($this->type)) { |
d865c296 FB |
1385 | $sub = $uf->addDisplayFilter(); |
1386 | return 'pd' . $sub . '.' . $this->type; | |
1387 | } else { | |
1388 | $sub = $uf->addNameFilter($this->type, $this->variant); | |
1389 | if ($this->particle) { | |
1390 | return 'CONCAT(pn' . $sub . '.particle, \' \', pn' . $sub . '.name)'; | |
1391 | } else { | |
1392 | return 'pn' . $sub . '.name'; | |
1393 | } | |
1394 | } | |
1395 | } | |
1396 | } | |
8363588b | 1397 | // }}} |
d865c296 | 1398 | |
40585144 RB |
1399 | // {{{ class UFO_Score |
1400 | class UFO_Score extends UserFilterOrder | |
1401 | { | |
61f61261 | 1402 | protected function getSortTokens(PlFilter &$uf) |
40585144 RB |
1403 | { |
1404 | $sub = $uf->addNameTokensFilter(); | |
1405 | return 'SUM(' . $sub . '.score)'; | |
1406 | } | |
1407 | } | |
1408 | // }}} | |
1409 | ||
8363588b | 1410 | // {{{ class UFO_Registration |
53eae167 RB |
1411 | /** Sorts users based on registration date |
1412 | */ | |
38c6fe96 FB |
1413 | class UFO_Registration extends UserFilterOrder |
1414 | { | |
61f61261 | 1415 | protected function getSortTokens(PlFilter &$uf) |
38c6fe96 | 1416 | { |
009b8ab7 | 1417 | return 'a.registration_date'; |
38c6fe96 | 1418 | } |
009b8ab7 | 1419 | } |
8363588b | 1420 | // }}} |
38c6fe96 | 1421 | |
8363588b | 1422 | // {{{ class UFO_Birthday |
53eae167 RB |
1423 | /** Sorts users based on next birthday date |
1424 | */ | |
009b8ab7 FB |
1425 | class UFO_Birthday extends UserFilterOrder |
1426 | { | |
61f61261 | 1427 | protected function getSortTokens(PlFilter &$uf) |
38c6fe96 | 1428 | { |
009b8ab7 | 1429 | return 'p.next_birthday'; |
38c6fe96 FB |
1430 | } |
1431 | } | |
8363588b | 1432 | // }}} |
38c6fe96 | 1433 | |
8363588b | 1434 | // {{{ class UFO_ProfileUpdate |
53eae167 RB |
1435 | /** Sorts users based on last profile update |
1436 | */ | |
009b8ab7 FB |
1437 | class UFO_ProfileUpdate extends UserFilterOrder |
1438 | { | |
61f61261 | 1439 | protected function getSortTokens(PlFilter &$uf) |
009b8ab7 FB |
1440 | { |
1441 | return 'p.last_change'; | |
1442 | } | |
1443 | } | |
8363588b | 1444 | // }}} |
009b8ab7 | 1445 | |
8363588b | 1446 | // {{{ class UFO_Death |
53eae167 RB |
1447 | /** Sorts users based on death date |
1448 | */ | |
009b8ab7 FB |
1449 | class UFO_Death extends UserFilterOrder |
1450 | { | |
61f61261 | 1451 | protected function getSortTokens(PlFilter &$uf) |
009b8ab7 FB |
1452 | { |
1453 | return 'p.deathdate'; | |
1454 | } | |
1455 | } | |
8363588b | 1456 | // }}} |
009b8ab7 FB |
1457 | |
1458 | ||
d865c296 FB |
1459 | /*********************************** |
1460 | ********************************* | |
1461 | USER FILTER CLASS | |
1462 | ********************************* | |
1463 | ***********************************/ | |
1464 | ||
8363588b | 1465 | // {{{ class UserFilter |
2d83cac9 RB |
1466 | /** This class provides a convenient and centralized way of filtering users. |
1467 | * | |
1468 | * Usage: | |
1469 | * $uf = new UserFilter(new UFC_Blah($x, $y), new UFO_Coin($z, $t)); | |
1470 | * | |
1471 | * Resulting UserFilter can be used to: | |
1472 | * - get a list of User objects matching the filter | |
1473 | * - get a list of UIDs matching the filter | |
1474 | * - get the number of users matching the filter | |
1475 | * - check whether a given User matches the filter | |
1476 | * - filter a list of User objects depending on whether they match the filter | |
1477 | * | |
1478 | * Usage for UFC and UFO objects: | |
1479 | * A UserFilter will call all private functions named XXXJoins. | |
1480 | * These functions must return an array containing the list of join | |
1481 | * required by the various UFC and UFO associated to the UserFilter. | |
1482 | * Entries in those returned array are of the following form: | |
1483 | * 'join_tablealias' => array('join_type', 'joined_table', 'join_criter') | |
1484 | * which will be translated into : | |
1485 | * join_type JOIN joined_table AS join_tablealias ON (join_criter) | |
1486 | * in the final query. | |
1487 | * | |
1488 | * In the join_criter text, $ME is replaced with 'join_tablealias', $PID with | |
913a4e90 | 1489 | * profile.pid, and $UID with accounts.uid. |
2d83cac9 RB |
1490 | * |
1491 | * For each kind of "JOIN" needed, a function named addXXXFilter() should be defined; | |
1492 | * its parameter will be used to set various private vars of the UserFilter describing | |
1493 | * the required joins ; such a function shall return the "join_tablealias" to use | |
1494 | * when referring to the joined table. | |
1495 | * | |
1496 | * For example, if data from profile_job must be available to filter results, | |
1497 | * the UFC object will call $uf-addJobFilter(), which will set the 'with_pj' var and | |
1498 | * return 'pj', the short name to use when referring to profile_job; when building | |
1499 | * the query, calling the jobJoins function will return an array containing a single | |
1500 | * row: | |
1501 | * 'pj' => array('left', 'profile_job', '$ME.pid = $UID'); | |
1502 | * | |
1503 | * The 'register_optional' function can be used to generate unique table aliases when | |
1504 | * the same table has to be joined several times with different aliases. | |
1505 | */ | |
9b8e5fb4 | 1506 | class UserFilter extends PlFilter |
a087cc8d | 1507 | { |
9b8e5fb4 | 1508 | protected $joinMethods = array(); |
7ca75030 | 1509 | |
61f61261 RB |
1510 | protected $joinMetas = array( |
1511 | '$PID' => 'p.pid', | |
1512 | '$UID' => 'a.uid', | |
9b8e5fb4 | 1513 | ); |
d865c296 | 1514 | |
a087cc8d | 1515 | private $root; |
24e08e33 | 1516 | private $sort = array(); |
784745ce | 1517 | private $query = null; |
24e08e33 | 1518 | private $orderby = null; |
784745ce | 1519 | |
aa21c568 | 1520 | private $lastcount = null; |
d865c296 | 1521 | |
24e08e33 | 1522 | public function __construct($cond = null, $sort = null) |
5dd9d823 | 1523 | { |
06598c13 | 1524 | if (empty($this->joinMethods)) { |
d865c296 FB |
1525 | $class = new ReflectionClass('UserFilter'); |
1526 | foreach ($class->getMethods() as $method) { | |
1527 | $name = $method->getName(); | |
1528 | if (substr($name, -5) == 'Joins' && $name != 'buildJoins') { | |
06598c13 | 1529 | $this->joinMethods[] = $name; |
d865c296 FB |
1530 | } |
1531 | } | |
1532 | } | |
5dd9d823 | 1533 | if (!is_null($cond)) { |
06598c13 | 1534 | if ($cond instanceof PlFilterCondition) { |
5dd9d823 FB |
1535 | $this->setCondition($cond); |
1536 | } | |
1537 | } | |
24e08e33 FB |
1538 | if (!is_null($sort)) { |
1539 | if ($sort instanceof UserFilterOrder) { | |
1540 | $this->addSort($sort); | |
d865c296 FB |
1541 | } else if (is_array($sort)) { |
1542 | foreach ($sort as $s) { | |
1543 | $this->addSort($s); | |
1544 | } | |
24e08e33 FB |
1545 | } |
1546 | } | |
5dd9d823 FB |
1547 | } |
1548 | ||
784745ce FB |
1549 | private function buildQuery() |
1550 | { | |
d865c296 FB |
1551 | if (is_null($this->orderby)) { |
1552 | $orders = array(); | |
1553 | foreach ($this->sort as $sort) { | |
1554 | $orders = array_merge($orders, $sort->buildSort($this)); | |
1555 | } | |
1556 | if (count($orders) == 0) { | |
1557 | $this->orderby = ''; | |
1558 | } else { | |
1559 | $this->orderby = 'ORDER BY ' . implode(', ', $orders); | |
1560 | } | |
1561 | } | |
784745ce FB |
1562 | if (is_null($this->query)) { |
1563 | $where = $this->root->buildCondition($this); | |
f7ea7450 RB |
1564 | if ($this->with_forced_sn) { |
1565 | $this->requireProfiles(); | |
1566 | $from = 'search_name AS sn'; | |
1567 | } else if ($this->with_accounts) { | |
b8dcf62d RB |
1568 | $from = 'accounts AS a'; |
1569 | } else { | |
1570 | $this->requireProfiles(); | |
1571 | $from = 'profiles AS p'; | |
1572 | } | |
f7ea7450 | 1573 | $joins = $this->buildJoins(); |
b8dcf62d | 1574 | $this->query = 'FROM ' . $from . ' |
784745ce FB |
1575 | ' . $joins . ' |
1576 | WHERE (' . $where . ')'; | |
1577 | } | |
1578 | } | |
1579 | ||
7ca75030 | 1580 | private function getUIDList($uids = null, PlLimit &$limit) |
d865c296 | 1581 | { |
b8dcf62d | 1582 | $this->requireAccounts(); |
d865c296 | 1583 | $this->buildQuery(); |
7ca75030 | 1584 | $lim = $limit->getSql(); |
d865c296 FB |
1585 | $cond = ''; |
1586 | if (!is_null($uids)) { | |
07eb5b0e | 1587 | $cond = ' AND a.uid IN ' . XDB::formatArray($uids); |
d865c296 FB |
1588 | } |
1589 | $fetched = XDB::fetchColumn('SELECT SQL_CALC_FOUND_ROWS a.uid | |
1590 | ' . $this->query . $cond . ' | |
1591 | GROUP BY a.uid | |
1592 | ' . $this->orderby . ' | |
7ca75030 | 1593 | ' . $lim); |
d865c296 FB |
1594 | $this->lastcount = (int)XDB::fetchOneCell('SELECT FOUND_ROWS()'); |
1595 | return $fetched; | |
1596 | } | |
1597 | ||
043b104b RB |
1598 | private function getPIDList($pids = null, PlLimit &$limit) |
1599 | { | |
1600 | $this->requireProfiles(); | |
1601 | $this->buildQuery(); | |
1602 | $lim = $limit->getSql(); | |
1603 | $cond = ''; | |
1604 | if (!is_null($pids)) { | |
1605 | $cond = ' AND p.pid IN ' . XDB::formatArray($pids); | |
1606 | } | |
1607 | $fetched = XDB::fetchColumn('SELECT SQL_CALC_FOUND_ROWS p.pid | |
1608 | ' . $this->query . $cond . ' | |
1609 | GROUP BY p.pid | |
1610 | ' . $this->orderby . ' | |
1611 | ' . $lim); | |
1612 | $this->lastcount = (int)XDB::fetchOneCell('SELECT FOUND_ROWS()'); | |
1613 | return $fetched; | |
1614 | } | |
1615 | ||
434570c4 FB |
1616 | private static function defaultLimit($limit) { |
1617 | if ($limit == null) { | |
1618 | return new PlLimit(); | |
1619 | } else { | |
1620 | return $limit; | |
1621 | } | |
1622 | } | |
1623 | ||
a087cc8d FB |
1624 | /** Check that the user match the given rule. |
1625 | */ | |
1626 | public function checkUser(PlUser &$user) | |
1627 | { | |
b8dcf62d | 1628 | $this->requireAccounts(); |
784745ce FB |
1629 | $this->buildQuery(); |
1630 | $count = (int)XDB::fetchOneCell('SELECT COUNT(*) | |
1631 | ' . $this->query . XDB::format(' AND a.uid = {?}', $user->id())); | |
1632 | return $count == 1; | |
a087cc8d FB |
1633 | } |
1634 | ||
043b104b RB |
1635 | /** Check that the profile match the given rule. |
1636 | */ | |
1637 | public function checkProfile(Profile &$profile) | |
1638 | { | |
1639 | $this->requireProfiles(); | |
1640 | $this->buildQuery(); | |
1641 | $count = (int)XDB::fetchOneCell('SELECT COUNT(*) | |
1642 | ' . $this->query . XDB::format(' AND p.pid = {?}', $profile->id())); | |
1643 | return $count == 1; | |
1644 | } | |
1645 | ||
1646 | /** Default filter is on users | |
a087cc8d | 1647 | */ |
434570c4 | 1648 | public function filter(array $users, $limit = null) |
a087cc8d | 1649 | { |
434570c4 | 1650 | return $this->filterUsers($users, self::defaultLimit($limit)); |
043b104b RB |
1651 | } |
1652 | ||
1653 | /** Filter a list of users to extract the users matching the rule. | |
1654 | */ | |
434570c4 | 1655 | public function filterUsers(array $users, $limit = null) |
043b104b | 1656 | { |
434570c4 | 1657 | $limit = self::defaultLimit($limit); |
b8dcf62d | 1658 | $this->requireAccounts(); |
4927ee54 FB |
1659 | $this->buildQuery(); |
1660 | $table = array(); | |
1661 | $uids = array(); | |
1662 | foreach ($users as $user) { | |
07eb5b0e FB |
1663 | if ($user instanceof PlUser) { |
1664 | $uid = $user->id(); | |
1665 | } else { | |
1666 | $uid = $user; | |
1667 | } | |
1668 | $uids[] = $uid; | |
1669 | $table[$uid] = $user; | |
4927ee54 | 1670 | } |
7ca75030 | 1671 | $fetched = $this->getUIDList($uids, $limit); |
a087cc8d | 1672 | $output = array(); |
4927ee54 FB |
1673 | foreach ($fetched as $uid) { |
1674 | $output[] = $table[$uid]; | |
a087cc8d FB |
1675 | } |
1676 | return $output; | |
1677 | } | |
1678 | ||
043b104b RB |
1679 | /** Filter a list of profiles to extract the users matching the rule. |
1680 | */ | |
434570c4 | 1681 | public function filterProfiles(array $profiles, $limit = null) |
043b104b | 1682 | { |
434570c4 | 1683 | $limit = self::defaultLimit($limit); |
043b104b RB |
1684 | $this->requireProfiles(); |
1685 | $this->buildQuery(); | |
1686 | $table = array(); | |
1687 | $pids = array(); | |
1688 | foreach ($profiles as $profile) { | |
1689 | if ($profile instanceof Profile) { | |
1690 | $pid = $profile->id(); | |
1691 | } else { | |
1692 | $pid = $profile; | |
1693 | } | |
1694 | $pids[] = $pid; | |
1695 | $table[$pid] = $profile; | |
1696 | } | |
1697 | $fetched = $this->getPIDList($pids, $limit); | |
1698 | $output = array(); | |
1699 | foreach ($fetched as $pid) { | |
1700 | $output[] = $table[$pid]; | |
1701 | } | |
1702 | return $output; | |
1703 | } | |
1704 | ||
434570c4 | 1705 | public function getUIDs($limit = null) |
7ca75030 | 1706 | { |
833a6e86 FB |
1707 | $limit = self::defaultLimit($limit); |
1708 | return $this->getUIDList(null, $limit); | |
7ca75030 RB |
1709 | } |
1710 | ||
ad27b22e FB |
1711 | public function getUID($pos = 0) |
1712 | { | |
1713 | $uids =$this->getUIDList(null, new PlFilter(1, $pos)); | |
1714 | if (count($uids) == 0) { | |
1715 | return null; | |
1716 | } else { | |
1717 | return $uids[0]; | |
1718 | } | |
1719 | } | |
1720 | ||
434570c4 | 1721 | public function getPIDs($limit = null) |
043b104b | 1722 | { |
833a6e86 FB |
1723 | $limit = self::defaultLimit($limit); |
1724 | return $this->getPIDList(null, $limit); | |
043b104b RB |
1725 | } |
1726 | ||
ad27b22e FB |
1727 | public function getPID($pos = 0) |
1728 | { | |
1729 | $pids =$this->getPIDList(null, new PlFilter(1, $pos)); | |
1730 | if (count($pids) == 0) { | |
1731 | return null; | |
1732 | } else { | |
1733 | return $pids[0]; | |
1734 | } | |
1735 | } | |
1736 | ||
434570c4 | 1737 | public function getUsers($limit = null) |
4927ee54 | 1738 | { |
7ca75030 | 1739 | return User::getBulkUsersWithUIDs($this->getUIDs($limit)); |
d865c296 FB |
1740 | } |
1741 | ||
ad27b22e FB |
1742 | public function getUser($pos = 0) |
1743 | { | |
1744 | $uid = $this->getUID($pos); | |
1745 | if ($uid == null) { | |
1746 | return null; | |
1747 | } else { | |
1748 | return User::getWithUID($uid); | |
1749 | } | |
1750 | } | |
1751 | ||
0d906109 RB |
1752 | public function iterUsers($limit = null) |
1753 | { | |
1754 | return User::iterOverUIDs($this->getUIDs($limit)); | |
1755 | } | |
1756 | ||
434570c4 | 1757 | public function getProfiles($limit = null) |
043b104b RB |
1758 | { |
1759 | return Profile::getBulkProfilesWithPIDs($this->getPIDs($limit)); | |
1760 | } | |
1761 | ||
ad27b22e FB |
1762 | public function getProfile($pos = 0) |
1763 | { | |
1764 | $pid = $this->getPID($pos); | |
1765 | if ($pid == null) { | |
1766 | return null; | |
1767 | } else { | |
1768 | return Profile::get($pid); | |
1769 | } | |
1770 | } | |
1771 | ||
0d906109 RB |
1772 | public function iterProfiles($limit = null) |
1773 | { | |
1774 | return Profile::iterOverPIDs($this->getPIDs($limit)); | |
1775 | } | |
1776 | ||
434570c4 | 1777 | public function get($limit = null) |
d865c296 | 1778 | { |
7ca75030 | 1779 | return $this->getUsers($limit); |
4927ee54 FB |
1780 | } |
1781 | ||
d865c296 | 1782 | public function getTotalCount() |
4927ee54 | 1783 | { |
38c6fe96 | 1784 | if (is_null($this->lastcount)) { |
aa21c568 | 1785 | $this->buildQuery(); |
2b9ca54d | 1786 | if ($this->with_accounts) { |
b8dcf62d RB |
1787 | $field = 'a.uid'; |
1788 | } else { | |
1789 | $field = 'p.pid'; | |
1790 | } | |
1791 | return (int)XDB::fetchOneCell('SELECT COUNT(DISTINCT ' . $field . ') | |
7e735012 | 1792 | ' . $this->query); |
38c6fe96 FB |
1793 | } else { |
1794 | return $this->lastcount; | |
1795 | } | |
4927ee54 FB |
1796 | } |
1797 | ||
9b8e5fb4 | 1798 | public function setCondition(PlFilterCondition &$cond) |
a087cc8d FB |
1799 | { |
1800 | $this->root =& $cond; | |
784745ce | 1801 | $this->query = null; |
a087cc8d FB |
1802 | } |
1803 | ||
9b8e5fb4 | 1804 | public function addSort(PlFilterOrder &$sort) |
24e08e33 | 1805 | { |
d865c296 FB |
1806 | $this->sort[] = $sort; |
1807 | $this->orderby = null; | |
24e08e33 FB |
1808 | } |
1809 | ||
a087cc8d FB |
1810 | static public function getLegacy($promo_min, $promo_max) |
1811 | { | |
a087cc8d | 1812 | if ($promo_min != 0) { |
784745ce | 1813 | $min = new UFC_Promo('>=', self::GRADE_ING, intval($promo_min)); |
5dd9d823 | 1814 | } else { |
88c31faf | 1815 | $min = new PFC_True(); |
a087cc8d | 1816 | } |
a087cc8d | 1817 | if ($promo_max != 0) { |
784745ce | 1818 | $max = new UFC_Promo('<=', self::GRADE_ING, intval($promo_max)); |
a087cc8d | 1819 | } else { |
88c31faf | 1820 | $max = new PFC_True(); |
a087cc8d | 1821 | } |
9b8e5fb4 | 1822 | return new UserFilter(new PFC_And($min, $max)); |
a087cc8d | 1823 | } |
784745ce | 1824 | |
07eb5b0e FB |
1825 | static public function sortByName() |
1826 | { | |
913a4e90 | 1827 | return array(new UFO_Name(Profile::LASTNAME), new UFO_Name(Profile::FIRSTNAME)); |
07eb5b0e FB |
1828 | } |
1829 | ||
1830 | static public function sortByPromo() | |
1831 | { | |
913a4e90 | 1832 | return array(new UFO_Promo(), new UFO_Name(Profile::LASTNAME), new UFO_Name(Profile::FIRSTNAME)); |
07eb5b0e FB |
1833 | } |
1834 | ||
aa21c568 FB |
1835 | static private function getDBSuffix($string) |
1836 | { | |
1837 | return preg_replace('/[^a-z0-9]/i', '', $string); | |
1838 | } | |
1839 | ||
1840 | ||
2d83cac9 RB |
1841 | /** Stores a new (and unique) table alias in the &$table table |
1842 | * @param &$table Array in which the table alias must be stored | |
1843 | * @param $val Value which will then be used to build the join | |
1844 | * @return Name of the newly created alias | |
1845 | */ | |
aa21c568 FB |
1846 | private $option = 0; |
1847 | private function register_optional(array &$table, $val) | |
1848 | { | |
1849 | if (is_null($val)) { | |
1850 | $sub = $this->option++; | |
1851 | $index = null; | |
1852 | } else { | |
1853 | $sub = self::getDBSuffix($val); | |
1854 | $index = $val; | |
1855 | } | |
1856 | $sub = '_' . $sub; | |
1857 | $table[$sub] = $index; | |
1858 | return $sub; | |
1859 | } | |
784745ce | 1860 | |
b8dcf62d RB |
1861 | /** PROFILE VS ACCOUNT |
1862 | */ | |
f7ea7450 RB |
1863 | private $with_profiles = false; |
1864 | private $with_accounts = false; | |
1865 | private $with_forced_sn = false; | |
b8dcf62d RB |
1866 | public function requireAccounts() |
1867 | { | |
1868 | $this->with_accounts = true; | |
1869 | } | |
1870 | ||
1871 | public function requireProfiles() | |
1872 | { | |
1873 | $this->with_profiles = true; | |
1874 | } | |
1875 | ||
f7ea7450 RB |
1876 | /** Forces the "FROM" to use search_name instead of accounts or profiles */ |
1877 | public function forceSearchName() | |
1878 | { | |
1879 | $this->with_forced_sn = true; | |
1880 | } | |
1881 | ||
b8dcf62d RB |
1882 | protected function accountJoins() |
1883 | { | |
1884 | $joins = array(); | |
f7ea7450 RB |
1885 | /** Quick search is much more efficient with sn first and PID second */ |
1886 | if ($this->with_forced_sn) { | |
1887 | $joins['p'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profiles', '$PID = sn.uid'); | |
1888 | if ($this->with_accounts) { | |
1889 | $joins['ap'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'account_profiles', '$ME.pid = $PID'); | |
1890 | $joins['a'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'accounts', '$UID = ap.uid'); | |
1891 | } | |
1892 | } else if ($this->with_profiles && $this->with_accounts) { | |
b8dcf62d RB |
1893 | $joins['ap'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'account_profiles', '$ME.uid = $UID AND FIND_IN_SET(\'owner\', ap.perms)'); |
1894 | $joins['p'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profiles', '$PID = ap.pid'); | |
1895 | } | |
1896 | return $joins; | |
1897 | } | |
1898 | ||
d865c296 FB |
1899 | /** DISPLAY |
1900 | */ | |
38c6fe96 | 1901 | const DISPLAY = 'display'; |
d865c296 FB |
1902 | private $pd = false; |
1903 | public function addDisplayFilter() | |
1904 | { | |
b8dcf62d | 1905 | $this->requireProfiles(); |
d865c296 FB |
1906 | $this->pd = true; |
1907 | return ''; | |
1908 | } | |
1909 | ||
9b8e5fb4 | 1910 | protected function displayJoins() |
d865c296 FB |
1911 | { |
1912 | if ($this->pd) { | |
7ca75030 | 1913 | return array('pd' => new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_display', '$ME.pid = $PID')); |
d865c296 FB |
1914 | } else { |
1915 | return array(); | |
1916 | } | |
1917 | } | |
1918 | ||
f73a4f1b RB |
1919 | /** LOGGER |
1920 | */ | |
1921 | ||
1922 | private $with_logger = false; | |
1923 | public function addLoggerFilter() | |
1924 | { | |
1925 | $this->with_logger = true; | |
1926 | $this->requireAccounts(); | |
1927 | return 'ls'; | |
1928 | } | |
1929 | protected function loggerJoins() | |
1930 | { | |
1931 | $joins = array(); | |
1932 | if ($this->with_logger) { | |
1933 | $joins['ls'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'log_sessions', '$ME.uid = $UID'); | |
1934 | } | |
1935 | return $joins; | |
1936 | } | |
1937 | ||
784745ce FB |
1938 | /** NAMES |
1939 | */ | |
784745ce FB |
1940 | |
1941 | static public function assertName($name) | |
1942 | { | |
1943 | if (!Profile::getNameTypeId($name)) { | |
9b8e5fb4 | 1944 | Platal::page()->kill('Invalid name type: ' . $name); |
784745ce FB |
1945 | } |
1946 | } | |
1947 | ||
1948 | private $pn = array(); | |
784745ce FB |
1949 | public function addNameFilter($type, $variant = null) |
1950 | { | |
b8dcf62d | 1951 | $this->requireProfiles(); |
784745ce FB |
1952 | if (!is_null($variant)) { |
1953 | $ft = $type . '_' . $variant; | |
1954 | } else { | |
1955 | $ft = $type; | |
1956 | } | |
1957 | $sub = '_' . $ft; | |
1958 | self::assertName($ft); | |
1959 | ||
1960 | if (!is_null($variant) && $variant == 'other') { | |
aa21c568 | 1961 | $sub .= $this->option++; |
784745ce FB |
1962 | } |
1963 | $this->pn[$sub] = Profile::getNameTypeId($ft); | |
1964 | return $sub; | |
1965 | } | |
1966 | ||
9b8e5fb4 | 1967 | protected function nameJoins() |
784745ce FB |
1968 | { |
1969 | $joins = array(); | |
1970 | foreach ($this->pn as $sub => $type) { | |
7ca75030 | 1971 | $joins['pn' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_name', '$ME.pid = $PID AND $ME.typeid = ' . $type); |
784745ce FB |
1972 | } |
1973 | return $joins; | |
1974 | } | |
1975 | ||
40585144 RB |
1976 | /** NAMETOKENS |
1977 | */ | |
1978 | private $with_sn = false; | |
f7ea7450 RB |
1979 | // Set $doingQuickSearch to true if you wish to optimize the query |
1980 | public function addNameTokensFilter($doingQuickSearch = false) | |
40585144 RB |
1981 | { |
1982 | $this->requireProfiles(); | |
f7ea7450 | 1983 | $this->with_forced_sn = ($this->with_forced_sn || $doingQuickSearch); |
40585144 RB |
1984 | $this->with_sn = true; |
1985 | return 'sn'; | |
1986 | } | |
1987 | ||
1988 | protected function nameTokensJoins() | |
1989 | { | |
f7ea7450 RB |
1990 | /* We don't return joins, since with_sn forces the SELECT to run on search_name first */ |
1991 | if ($this->with_sn && !$this->with_forced_sn) { | |
1992 | return array( | |
1993 | 'sn' => new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'search_name', '$ME.uid = $PID') | |
1994 | ); | |
1995 | } else { | |
1996 | return array(); | |
40585144 | 1997 | } |
40585144 RB |
1998 | } |
1999 | ||
a7f8e48a RB |
2000 | /** NATIONALITY |
2001 | */ | |
2002 | ||
2003 | private $with_nat = false; | |
2004 | public function addNationalityFilter() | |
2005 | { | |
2006 | $this->with_nat = true; | |
2007 | return 'ngc'; | |
2008 | } | |
2009 | ||
2010 | protected function nationalityJoins() | |
2011 | { | |
2012 | $joins = array(); | |
2013 | if ($this->with_nat) { | |
2014 | $joins['ngc'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'geoloc_countries', '$ME.iso_3166_1_a2 = p.nationality1 OR $ME.iso_3166_1_a2 = p.nationality2 OR $ME.iso_3166_1_a2 = p.nationality3'); | |
2015 | } | |
2016 | return $joins; | |
2017 | } | |
2018 | ||
784745ce FB |
2019 | /** EDUCATION |
2020 | */ | |
2021 | const GRADE_ING = 'Ing.'; | |
2022 | const GRADE_PHD = 'PhD'; | |
2023 | const GRADE_MST = 'M%'; | |
2024 | static public function isGrade($grade) | |
2025 | { | |
38c6fe96 | 2026 | return $grade == self::GRADE_ING || $grade == self::GRADE_PHD || $grade == self::GRADE_MST; |
784745ce FB |
2027 | } |
2028 | ||
2029 | static public function assertGrade($grade) | |
2030 | { | |
2031 | if (!self::isGrade($grade)) { | |
ad27b22e | 2032 | Platal::page()->killError("Diplôme non valide: $grade"); |
784745ce FB |
2033 | } |
2034 | } | |
2035 | ||
d865c296 FB |
2036 | static public function promoYear($grade) |
2037 | { | |
2038 | // XXX: Definition of promotion for phds and masters might change in near future. | |
2039 | return ($grade == UserFilter::GRADE_ING) ? 'entry_year' : 'grad_year'; | |
2040 | } | |
2041 | ||
784745ce FB |
2042 | private $pepe = array(); |
2043 | private $with_pee = false; | |
784745ce FB |
2044 | public function addEducationFilter($x = false, $grade = null) |
2045 | { | |
b8dcf62d | 2046 | $this->requireProfiles(); |
784745ce | 2047 | if (!$x) { |
aa21c568 FB |
2048 | $index = $this->option; |
2049 | $sub = $this->option++; | |
784745ce FB |
2050 | } else { |
2051 | self::assertGrade($grade); | |
2052 | $index = $grade; | |
2053 | $sub = $grade[0]; | |
2054 | $this->with_pee = true; | |
2055 | } | |
2056 | $sub = '_' . $sub; | |
2057 | $this->pepe[$index] = $sub; | |
2058 | return $sub; | |
2059 | } | |
2060 | ||
9b8e5fb4 | 2061 | protected function educationJoins() |
784745ce FB |
2062 | { |
2063 | $joins = array(); | |
2064 | if ($this->with_pee) { | |
7ca75030 | 2065 | $joins['pee'] = new PlSqlJoin(PlSqlJoin::MODE_INNER, 'profile_education_enum', 'pee.abbreviation = \'X\''); |
784745ce FB |
2066 | } |
2067 | foreach ($this->pepe as $grade => $sub) { | |
2068 | if ($this->isGrade($grade)) { | |
ce0b2c6f | 2069 | $joins['pe' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_education', '$ME.eduid = pee.id AND $ME.pid = $PID'); |
7ca75030 | 2070 | $joins['pede' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_INNER, 'profile_education_degree_enum', '$ME.id = pe' . $sub . '.degreeid AND $ME.abbreviation LIKE ' . |
784745ce FB |
2071 | XDB::format('{?}', $grade)); |
2072 | } else { | |
ce0b2c6f | 2073 | $joins['pe' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_education', '$ME.pid = $PID'); |
7ca75030 RB |
2074 | $joins['pee' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_INNER, 'profile_education_enum', '$ME.id = pe' . $sub . '.eduid'); |
2075 | $joins['pede' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_INNER, 'profile_education_degree_enum', '$ME.id = pe' . $sub . '.degreeid'); | |
784745ce FB |
2076 | } |
2077 | } | |
2078 | return $joins; | |
2079 | } | |
4927ee54 FB |
2080 | |
2081 | ||
2082 | /** GROUPS | |
2083 | */ | |
2084 | private $gpm = array(); | |
4927ee54 FB |
2085 | public function addGroupFilter($group = null) |
2086 | { | |
b8dcf62d | 2087 | $this->requireAccounts(); |
4927ee54 FB |
2088 | if (!is_null($group)) { |
2089 | if (ctype_digit($group)) { | |
2090 | $index = $sub = $group; | |
2091 | } else { | |
2092 | $index = $group; | |
aa21c568 | 2093 | $sub = self::getDBSuffix($group); |
4927ee54 FB |
2094 | } |
2095 | } else { | |
aa21c568 | 2096 | $sub = 'group_' . $this->option++; |
4927ee54 FB |
2097 | $index = null; |
2098 | } | |
2099 | $sub = '_' . $sub; | |
2100 | $this->gpm[$sub] = $index; | |
2101 | return $sub; | |
2102 | } | |
2103 | ||
9b8e5fb4 | 2104 | protected function groupJoins() |
4927ee54 FB |
2105 | { |
2106 | $joins = array(); | |
2107 | foreach ($this->gpm as $sub => $key) { | |
2108 | if (is_null($key)) { | |
eb41eda9 FB |
2109 | $joins['gpa' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_INNER, 'groups'); |
2110 | $joins['gpm' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'group_members', '$ME.uid = $UID AND $ME.asso_id = gpa' . $sub . '.id'); | |
4927ee54 | 2111 | } else if (ctype_digit($key)) { |
eb41eda9 | 2112 | $joins['gpm' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'group_members', '$ME.uid = $UID AND $ME.asso_id = ' . $key); |
4927ee54 | 2113 | } else { |
eb41eda9 FB |
2114 | $joins['gpa' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_INNER, 'groups', XDB::format('$ME.diminutif = {?}', $key)); |
2115 | $joins['gpm' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'group_members', '$ME.uid = $UID AND $ME.asso_id = gpa' . $sub . '.id'); | |
4927ee54 FB |
2116 | } |
2117 | } | |
2118 | return $joins; | |
0fb3713c RB |
2119 | } |
2120 | ||
2121 | /** BINETS | |
2122 | */ | |
2123 | ||
a7f8e48a RB |
2124 | private $with_bi = false; |
2125 | private $with_bd = false; | |
d7ddf29b | 2126 | public function addBinetsFilter($with_enum = false) |
0fb3713c RB |
2127 | { |
2128 | $this->requireProfiles(); | |
a7f8e48a RB |
2129 | $this->with_bi = true; |
2130 | if ($with_enum) { | |
2131 | $this->with_bd = true; | |
2132 | return 'bd'; | |
2133 | } else { | |
2134 | return 'bi'; | |
2135 | } | |
0fb3713c RB |
2136 | } |
2137 | ||
2138 | protected function binetsJoins() | |
2139 | { | |
2140 | $joins = array(); | |
a7f8e48a | 2141 | if ($this->with_bi) { |
bdd977d7 | 2142 | $joins['bi'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_binets', '$ME.pid = $PID'); |
0fb3713c | 2143 | } |
a7f8e48a | 2144 | if ($this->with_bd) { |
5c8a71f2 | 2145 | $joins['bd'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_binet_enum', '$ME.id = bi.binet_id'); |
a7f8e48a | 2146 | } |
0fb3713c | 2147 | return $joins; |
4927ee54 | 2148 | } |
aa21c568 FB |
2149 | |
2150 | /** EMAILS | |
2151 | */ | |
2152 | private $e = array(); | |
2153 | public function addEmailRedirectFilter($email = null) | |
2154 | { | |
b8dcf62d | 2155 | $this->requireAccounts(); |
aa21c568 FB |
2156 | return $this->register_optional($this->e, $email); |
2157 | } | |
2158 | ||
2159 | private $ve = array(); | |
2160 | public function addVirtualEmailFilter($email = null) | |
2161 | { | |
21401768 | 2162 | $this->addAliasFilter(self::ALIAS_FORLIFE); |
aa21c568 FB |
2163 | return $this->register_optional($this->ve, $email); |
2164 | } | |
2165 | ||
21401768 FB |
2166 | const ALIAS_BEST = 'bestalias'; |
2167 | const ALIAS_FORLIFE = 'forlife'; | |
aa21c568 FB |
2168 | private $al = array(); |
2169 | public function addAliasFilter($alias = null) | |
2170 | { | |
b8dcf62d | 2171 | $this->requireAccounts(); |
aa21c568 FB |
2172 | return $this->register_optional($this->al, $alias); |
2173 | } | |
2174 | ||
9b8e5fb4 | 2175 | protected function emailJoins() |
aa21c568 FB |
2176 | { |
2177 | global $globals; | |
2178 | $joins = array(); | |
2179 | foreach ($this->e as $sub=>$key) { | |
2180 | if (is_null($key)) { | |
7ca75030 | 2181 | $joins['e' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'emails', '$ME.uid = $UID AND $ME.flags != \'filter\''); |
aa21c568 | 2182 | } else { |
7ca75030 | 2183 | $joins['e' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'emails', XDB::format('$ME.uid = $UID AND $ME.flags != \'filter\' AND $ME.email = {?}', $key)); |
aa21c568 FB |
2184 | } |
2185 | } | |
21401768 | 2186 | foreach ($this->al as $sub=>$key) { |
aa21c568 | 2187 | if (is_null($key)) { |
fe13bc1d | 2188 | $joins['al' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'aliases', '$ME.uid = $UID AND $ME.type IN (\'alias\', \'a_vie\')'); |
21401768 | 2189 | } else if ($key == self::ALIAS_BEST) { |
fe13bc1d | 2190 | $joins['al' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'aliases', '$ME.uid = $UID AND $ME.type IN (\'alias\', \'a_vie\') AND FIND_IN_SET(\'bestalias\', $ME.flags)'); |
21401768 | 2191 | } else if ($key == self::ALIAS_FORLIFE) { |
fe13bc1d | 2192 | $joins['al' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'aliases', '$ME.uid = $UID AND $ME.type = \'a_vie\''); |
aa21c568 | 2193 | } else { |
fe13bc1d | 2194 | $joins['al' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'aliases', XDB::format('$ME.uid = $UID AND $ME.type IN (\'alias\', \'a_vie\') AND $ME.alias = {?}', $key)); |
aa21c568 | 2195 | } |
aa21c568 | 2196 | } |
21401768 | 2197 | foreach ($this->ve as $sub=>$key) { |
aa21c568 | 2198 | if (is_null($key)) { |
7ca75030 | 2199 | $joins['v' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'virtual', '$ME.type = \'user\''); |
aa21c568 | 2200 | } else { |
7ca75030 | 2201 | $joins['v' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'virtual', XDB::format('$ME.type = \'user\' AND $ME.alias = {?}', $key)); |
aa21c568 | 2202 | } |
7ca75030 | 2203 | $joins['vr' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'virtual_redirect', XDB::format('$ME.vid = v' . $sub . '.vid |
21401768 FB |
2204 | AND ($ME.redirect IN (CONCAT(al_forlife.alias, \'@\', {?}), |
2205 | CONCAT(al_forlife.alias, \'@\', {?}), | |
2206 | a.email))', | |
2207 | $globals->mail->domain, $globals->mail->domain2)); | |
aa21c568 FB |
2208 | } |
2209 | return $joins; | |
2210 | } | |
3f42a6ad FB |
2211 | |
2212 | ||
c4b24511 RB |
2213 | /** ADDRESSES |
2214 | */ | |
036d1637 | 2215 | private $with_pa = false; |
c4b24511 RB |
2216 | public function addAddressFilter() |
2217 | { | |
b8dcf62d | 2218 | $this->requireProfiles(); |
036d1637 RB |
2219 | $this->with_pa = true; |
2220 | return 'pa'; | |
c4b24511 RB |
2221 | } |
2222 | ||
2b9ca54d RB |
2223 | private $with_pac = false; |
2224 | public function addAddressCountryFilter() | |
2225 | { | |
2226 | $this->requireProfiles(); | |
2227 | $this->addAddressFilter(); | |
2228 | $this->with_pac = true; | |
2229 | return 'gc'; | |
2230 | } | |
2231 | ||
d7ddf29b | 2232 | private $with_pal = false; |
2b9ca54d RB |
2233 | public function addAddressLocalityFilter() |
2234 | { | |
2235 | $this->requireProfiles(); | |
2236 | $this->addAddressFilter(); | |
2237 | $this->with_pal = true; | |
2238 | return 'gl'; | |
2239 | } | |
2240 | ||
9b8e5fb4 | 2241 | protected function addressJoins() |
c4b24511 RB |
2242 | { |
2243 | $joins = array(); | |
036d1637 | 2244 | if ($this->with_pa) { |
d7ddf29b | 2245 | $joins['pa'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_addresses', '$ME.pid = $PID'); |
c4b24511 | 2246 | } |
2b9ca54d RB |
2247 | if ($this->with_pac) { |
2248 | $joins['gc'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'geoloc_countries', '$ME.iso_3166_1_a2 = pa.countryID'); | |
2249 | } | |
2250 | if ($this->with_pal) { | |
2251 | $joins['gl'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'geoloc_localities', '$ME.id = pa.localityID'); | |
2252 | } | |
c4b24511 RB |
2253 | return $joins; |
2254 | } | |
2255 | ||
2256 | ||
4083b126 RB |
2257 | /** CORPS |
2258 | */ | |
2259 | ||
2260 | private $pc = false; | |
2261 | private $pce = array(); | |
2262 | private $pcr = false; | |
2263 | public function addCorpsFilter($type) | |
2264 | { | |
b8dcf62d | 2265 | $this->requireProfiles(); |
4083b126 RB |
2266 | $this->pc = true; |
2267 | if ($type == UFC_Corps::CURRENT) { | |
2268 | $pce['pcec'] = 'current_corpsid'; | |
2269 | return 'pcec'; | |
2270 | } else if ($type == UFC_Corps::ORIGIN) { | |
2271 | $pce['pceo'] = 'original_corpsid'; | |
2272 | return 'pceo'; | |
2273 | } | |
2274 | } | |
2275 | ||
2276 | public function addCorpsRankFilter() | |
2277 | { | |
b8dcf62d | 2278 | $this->requireProfiles(); |
4083b126 RB |
2279 | $this->pc = true; |
2280 | $this->pcr = true; | |
2281 | return 'pcr'; | |
2282 | } | |
2283 | ||
9b8e5fb4 | 2284 | protected function corpsJoins() |
4083b126 RB |
2285 | { |
2286 | $joins = array(); | |
2287 | if ($this->pc) { | |
ce0b2c6f | 2288 | $joins['pc'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_corps', '$ME.pid = $PID'); |
4083b126 RB |
2289 | } |
2290 | if ($this->pcr) { | |
7ca75030 | 2291 | $joins['pcr'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_corps_rank_enum', '$ME.id = pc.rankid'); |
4083b126 RB |
2292 | } |
2293 | foreach($this->pce as $sub => $field) { | |
7ca75030 | 2294 | $joins[$sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_corps_enum', '$ME.id = pc.' . $field); |
4083b126 RB |
2295 | } |
2296 | return $joins; | |
2297 | } | |
2298 | ||
6a99c3ac RB |
2299 | /** JOBS |
2300 | */ | |
2301 | ||
61f61261 RB |
2302 | const JOB_SECTOR = 0x0001; |
2303 | const JOB_SUBSECTOR = 0x0002; | |
2304 | const JOB_SUBSUBSECTOR = 0x0004; | |
2305 | const JOB_ALTERNATES = 0x0008; | |
2306 | const JOB_USERDEFINED = 0x0010; | |
2307 | const JOB_CV = 0x0020; | |
2308 | ||
2309 | const JOB_SECTORIZATION = 0x000F; | |
2310 | const JOB_ANY = 0x003F; | |
6a99c3ac RB |
2311 | |
2312 | /** Joins : | |
2313 | * pj => profile_job | |
2314 | * pje => profile_job_enum | |
2315 | * pjse => profile_job_sector_enum | |
2316 | * pjsse => profile_job_subsector_enum | |
2317 | * pjssse => profile_job_subsubsector_enum | |
2318 | * pja => profile_job_alternates | |
2319 | */ | |
2320 | private $with_pj = false; | |
2321 | private $with_pje = false; | |
2322 | private $with_pjse = false; | |
2323 | private $with_pjsse = false; | |
2324 | private $with_pjssse = false; | |
2325 | private $with_pja = false; | |
2326 | ||
2327 | public function addJobFilter() | |
2328 | { | |
b8dcf62d | 2329 | $this->requireProfiles(); |
6a99c3ac RB |
2330 | $this->with_pj = true; |
2331 | return 'pj'; | |
2332 | } | |
2333 | ||
2334 | public function addJobCompanyFilter() | |
2335 | { | |
2336 | $this->addJobFilter(); | |
2337 | $this->with_pje = true; | |
2338 | return 'pje'; | |
2339 | } | |
2340 | ||
2341 | public function addJobSectorizationFilter($type) | |
2342 | { | |
2343 | $this->addJobFilter(); | |
2344 | if ($type == self::JOB_SECTOR) { | |
2345 | $this->with_pjse = true; | |
2346 | return 'pjse'; | |
2347 | } else if ($type == self::JOB_SUBSECTOR) { | |
2348 | $this->with_pjsse = true; | |
2349 | return 'pjsse'; | |
2350 | } else if ($type == self::JOB_SUBSUBSECTOR) { | |
2351 | $this->with_pjssse = true; | |
2352 | return 'pjssse'; | |
2353 | } else if ($type == self::JOB_ALTERNATES) { | |
2354 | $this->with_pja = true; | |
2355 | return 'pja'; | |
2356 | } | |
2357 | } | |
2358 | ||
9b8e5fb4 | 2359 | protected function jobJoins() |
6a99c3ac RB |
2360 | { |
2361 | $joins = array(); | |
2362 | if ($this->with_pj) { | |
ce0b2c6f | 2363 | $joins['pj'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_job', '$ME.pid = $PID'); |
6a99c3ac RB |
2364 | } |
2365 | if ($this->with_pje) { | |
7ca75030 | 2366 | $joins['pje'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_job_enum', '$ME.id = pj.jobid'); |
6a99c3ac RB |
2367 | } |
2368 | if ($this->with_pjse) { | |
7ca75030 | 2369 | $joins['pjse'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_job_sector_enum', '$ME.id = pj.sectorid'); |
6a99c3ac RB |
2370 | } |
2371 | if ($this->with_pjsse) { | |
7ca75030 | 2372 | $joins['pjsse'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_job_subsector_enum', '$ME.id = pj.subsectorid'); |
6a99c3ac RB |
2373 | } |
2374 | if ($this->with_pjssse) { | |
7ca75030 | 2375 | $joins['pjssse'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_job_subsubsector_enum', '$ME.id = pj.subsubsectorid'); |
6a99c3ac RB |
2376 | } |
2377 | if ($this->with_pja) { | |
7ca75030 | 2378 | $joins['pja'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_job_alternates', '$ME.subsubsectorid = pj.subsubsectorid'); |
6a99c3ac RB |
2379 | } |
2380 | return $joins; | |
2381 | } | |
2382 | ||
0a2e9c74 RB |
2383 | /** NETWORKING |
2384 | */ | |
2385 | ||
2386 | private $with_pnw = false; | |
2387 | public function addNetworkingFilter() | |
2388 | { | |
b8dcf62d | 2389 | $this->requireAccounts(); |
0a2e9c74 RB |
2390 | $this->with_pnw = true; |
2391 | return 'pnw'; | |
2392 | } | |
2393 | ||
9b8e5fb4 | 2394 | protected function networkingJoins() |
0a2e9c74 RB |
2395 | { |
2396 | $joins = array(); | |
2397 | if ($this->with_pnw) { | |
ce0b2c6f | 2398 | $joins['pnw'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_networking', '$ME.pid = $PID'); |
0a2e9c74 RB |
2399 | } |
2400 | return $joins; | |
2401 | } | |
2402 | ||
6d62969e RB |
2403 | /** PHONE |
2404 | */ | |
2405 | ||
2d83cac9 | 2406 | private $with_ptel = false; |
6d62969e RB |
2407 | |
2408 | public function addPhoneFilter() | |
2409 | { | |
b8dcf62d | 2410 | $this->requireAccounts(); |
2d83cac9 | 2411 | $this->with_ptel = true; |
6d62969e RB |
2412 | return 'ptel'; |
2413 | } | |
2414 | ||
9b8e5fb4 | 2415 | protected function phoneJoins() |
6d62969e RB |
2416 | { |
2417 | $joins = array(); | |
2d83cac9 | 2418 | if ($this->with_ptel) { |
ce0b2c6f | 2419 | $joins['ptel'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_phones', '$ME.pid = $PID'); |
6d62969e RB |
2420 | } |
2421 | return $joins; | |
2422 | } | |
2423 | ||
ceb512d2 RB |
2424 | /** MEDALS |
2425 | */ | |
2426 | ||
2d83cac9 | 2427 | private $with_pmed = false; |
ceb512d2 RB |
2428 | public function addMedalFilter() |
2429 | { | |
b8dcf62d | 2430 | $this->requireProfiles(); |
2d83cac9 | 2431 | $this->with_pmed = true; |
ceb512d2 RB |
2432 | return 'pmed'; |
2433 | } | |
2434 | ||
9b8e5fb4 | 2435 | protected function medalJoins() |
ceb512d2 RB |
2436 | { |
2437 | $joins = array(); | |
2d83cac9 | 2438 | if ($this->with_pmed) { |
bdd977d7 | 2439 | $joins['pmed'] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'profile_medals', '$ME.pid = $PID'); |
ceb512d2 RB |
2440 | } |
2441 | return $joins; | |
2442 | } | |
2443 | ||
671b7073 RB |
2444 | /** MENTORING |
2445 | */ | |
2446 | ||
2447 | private $pms = array(); | |
2448 | const MENTOR_EXPERTISE = 1; | |
2449 | const MENTOR_COUNTRY = 2; | |
2450 | const MENTOR_SECTOR = 3; | |
2451 | ||
2452 | public function addMentorFilter($type) | |
2453 | { | |
b8dcf62d | 2454 | $this->requireAccounts(); |
671b7073 | 2455 | switch($type) { |
4a93c3a3 RB |
2456 | case self::MENTOR_EXPERTISE: |
2457 | $this->pms['pme'] = 'profile_mentor'; | |
671b7073 | 2458 | return 'pme'; |
4a93c3a3 RB |
2459 | case self::MENTOR_COUNTRY: |
2460 | $this->pms['pmc'] = 'profile_mentor_country'; | |
671b7073 | 2461 | return 'pmc'; |
4a93c3a3 RB |
2462 | case self::MENTOR_SECTOR: |
2463 | $this->pms['pms'] = 'profile_mentor_sector'; | |
671b7073 RB |
2464 | return 'pms'; |
2465 | default: | |
5d2e55c7 | 2466 | Platal::page()->killError("Undefined mentor filter."); |
671b7073 RB |
2467 | } |
2468 | } | |
2469 | ||
9b8e5fb4 | 2470 | protected function mentorJoins() |
671b7073 RB |
2471 | { |
2472 | $joins = array(); | |
2473 | foreach ($this->pms as $sub => $tab) { | |
ce0b2c6f | 2474 | $joins[$sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, $tab, '$ME.pid = $PID'); |
671b7073 RB |
2475 | } |
2476 | return $joins; | |
2477 | } | |
2478 | ||
3f42a6ad FB |
2479 | /** CONTACTS |
2480 | */ | |
2481 | private $cts = array(); | |
2482 | public function addContactFilter($uid = null) | |
2483 | { | |
b8dcf62d | 2484 | $this->requireAccounts(); |
3f42a6ad FB |
2485 | return $this->register_optional($this->cts, is_null($uid) ? null : 'user_' . $uid); |
2486 | } | |
2487 | ||
9b8e5fb4 | 2488 | protected function contactJoins() |
3f42a6ad FB |
2489 | { |
2490 | $joins = array(); | |
2491 | foreach ($this->cts as $sub=>$key) { | |
2492 | if (is_null($key)) { | |
7ca75030 | 2493 | $joins['c' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'contacts', '$ME.contact = $UID'); |
3f42a6ad | 2494 | } else { |
7ca75030 | 2495 | $joins['c' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'contacts', XDB::format('$ME.uid = {?} AND $ME.contact = $UID', substr($key, 5))); |
3f42a6ad FB |
2496 | } |
2497 | } | |
2498 | return $joins; | |
2499 | } | |
4e7bf1e0 FB |
2500 | |
2501 | ||
2502 | /** CARNET | |
2503 | */ | |
2504 | private $wn = array(); | |
2505 | public function addWatchRegistrationFilter($uid = null) | |
2506 | { | |
b8dcf62d | 2507 | $this->requireAccounts(); |
4e7bf1e0 FB |
2508 | return $this->register_optional($this->wn, is_null($uid) ? null : 'user_' . $uid); |
2509 | } | |
2510 | ||
2511 | private $wp = array(); | |
2512 | public function addWatchPromoFilter($uid = null) | |
2513 | { | |
b8dcf62d | 2514 | $this->requireAccounts(); |
4e7bf1e0 FB |
2515 | return $this->register_optional($this->wp, is_null($uid) ? null : 'user_' . $uid); |
2516 | } | |
2517 | ||
2518 | private $w = array(); | |
2519 | public function addWatchFilter($uid = null) | |
2520 | { | |
b8dcf62d | 2521 | $this->requireAccounts(); |
4e7bf1e0 FB |
2522 | return $this->register_optional($this->w, is_null($uid) ? null : 'user_' . $uid); |
2523 | } | |
2524 | ||
9b8e5fb4 | 2525 | protected function watchJoins() |
4e7bf1e0 FB |
2526 | { |
2527 | $joins = array(); | |
2528 | foreach ($this->w as $sub=>$key) { | |
2529 | if (is_null($key)) { | |
7ca75030 | 2530 | $joins['w' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'watch'); |
4e7bf1e0 | 2531 | } else { |
7ca75030 | 2532 | $joins['w' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'watch', XDB::format('$ME.uid = {?}', substr($key, 5))); |
4e7bf1e0 FB |
2533 | } |
2534 | } | |
2535 | foreach ($this->wn as $sub=>$key) { | |
2536 | if (is_null($key)) { | |
7ca75030 | 2537 | $joins['wn' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'watch_nonins', '$ME.ni_id = $UID'); |
4e7bf1e0 | 2538 | } else { |
7ca75030 | 2539 | $joins['wn' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'watch_nonins', XDB::format('$ME.uid = {?} AND $ME.ni_id = $UID', substr($key, 5))); |
4e7bf1e0 FB |
2540 | } |
2541 | } | |
2542 | foreach ($this->wn as $sub=>$key) { | |
2543 | if (is_null($key)) { | |
7ca75030 | 2544 | $joins['wn' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'watch_nonins', '$ME.ni_id = $UID'); |
4e7bf1e0 | 2545 | } else { |
7ca75030 | 2546 | $joins['wn' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'watch_nonins', XDB::format('$ME.uid = {?} AND $ME.ni_id = $UID', substr($key, 5))); |
4e7bf1e0 FB |
2547 | } |
2548 | } | |
2549 | foreach ($this->wp as $sub=>$key) { | |
2550 | if (is_null($key)) { | |
7ca75030 | 2551 | $joins['wp' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'watch_promo'); |
4e7bf1e0 | 2552 | } else { |
7ca75030 | 2553 | $joins['wp' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'watch_promo', XDB::format('$ME.uid = {?}', substr($key, 5))); |
4e7bf1e0 FB |
2554 | } |
2555 | } | |
2556 | return $joins; | |
2557 | } | |
a087cc8d | 2558 | } |
8363588b | 2559 | // }}} |
3f42a6ad | 2560 | |
a7d9ab89 RB |
2561 | // {{{ class ProfileFilter |
2562 | class ProfileFilter extends UserFilter | |
2563 | { | |
434570c4 | 2564 | public function get($limit = null) |
a7d9ab89 RB |
2565 | { |
2566 | return $this->getProfiles($limit); | |
2567 | } | |
2568 | } | |
2569 | // }}} | |
2570 | ||
a087cc8d FB |
2571 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
2572 | ?> |