}
// }}}
+// {{{ 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
$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');
}
// }}}
+// {{{ 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
* 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;
}
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';