X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fuserfilter.php;h=f78635b29f1bff36ffb45f695386dddc4181c93a;hb=c76545c351fae4e2298624ff9ee5bf854dc5a5b6;hp=1c757b707be883e90ce2a589656bfd412ee4ed71;hpb=9f169a65993780eaee226924e6dfd148b398bdb9;p=platal.git diff --git a/classes/userfilter.php b/classes/userfilter.php index 1c757b7..f78635b 100644 --- a/classes/userfilter.php +++ b/classes/userfilter.php @@ -52,6 +52,25 @@ class UFC_HasProfile implements UserFilterCondition } // }}} +// {{{ class UFC_AccountType +/** Filters users who have the given account types + */ +class UFC_AccountType implements UserFilterCondition +{ + private $types; + + public function __construct() + { + $this->types = pl_flatten(func_get_args()); + } + + public function buildCondition(PlFilter &$uf) + { + $uf->requireAccounts(); + return XDB::format('a.type IN {?}', $this->types); + } +} + // {{{ class UFC_Hruid /** Filters users based on their hruid * @param $val Either an hruid, or a list of those @@ -1025,7 +1044,7 @@ class UFC_Job_Terms implements UserFilterCondition $sub = $uf->addJobTermsFilter(count($this->val)); $conditions = array(); foreach ($this->val as $i => $jtid) { - $conditions[] = $sub[$i] . ' = ' . XDB::escape($jtid); + $conditions[] = $sub[$i] . '.jtid_1 = ' . XDB::escape($jtid); } $jsub = $uf->addJobFilter(); $conditions[] = $uf->getVisibilityCondition($jsub . '.pub'); @@ -1219,6 +1238,18 @@ class UFC_Photo implements UserFilterCondition } // }}} +// {{{ class UFC_Mentor +class UFC_Mentor implements UserFilterCondition +{ + public function buildCondition(PlFilter &$uf) + { + $sub = $uf->addMentorFilter(UserFilter::MENTOR); + return $sub . '.expertise IS NOT NULL'; + } +} +// }}} + + // {{{ class UFC_Mentor_Expertise /** Filters users by mentoring expertise * @param $expertise Domain of expertise @@ -2640,14 +2671,13 @@ class UserFilter extends PlFilter * Adds a filter on job terms of profile. * @param $nb the number of job terms to use * @return an array of the fields to filter (one for each term). - * Code using this function should used returned field as is (contains table and field name). */ public function addJobTermsFilter($nb = 1) { $this->with_pjt = $nb; $jobtermstable = array(); for ($i = 1; $i <= $nb; ++$i) { - $jobtermstable[] = 'pjtr_'.$i.'.jtid_1'; + $jobtermstable[] = 'pjtr_'.$i; } return $jobtermstable; } @@ -2748,15 +2778,19 @@ class UserFilter extends PlFilter private $pms = array(); private $mjtr = false; - const MENTOR_EXPERTISE = 1; - const MENTOR_COUNTRY = 2; - const MENTOR_SECTOR = 3; - const MENTOR_TERM = 4; + const MENTOR = 1; + const MENTOR_EXPERTISE = 2; + const MENTOR_COUNTRY = 3; + const MENTOR_SECTOR = 4; + const MENTOR_TERM = 5; public function addMentorFilter($type) { $this->requireAccounts(); switch($type) { + case self::MENTOR: + $this->pms['pm'] = 'profile_mentor'; + return 'pm'; case self::MENTOR_EXPERTISE: $this->pms['pme'] = 'profile_mentor'; return 'pme';