}
// }}}
+// {{{ 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
{
// Groups have AX visibility.
if ($uf->getVisibilityLevel() == ProfileVisibility::VIS_PUBLIC) {
- return '';
+ return PlFilter::COND_TRUE;
}
$sub = $uf->addGroupFilter($this->group);
$where = 'gpm' . $sub . '.perms IS NOT NULL';
{
// Binets are private.
if ($uf->getVisibilityLevel() != ProfileVisibility::VIS_PRIVATE) {
- return '';
+ return PlFilter::COND_TRUE;
}
$sub = $uf->addBinetsFilter();
return XDB::format($sub . '.binet_id IN {?}', $this->val);
{
// Sections are private.
if ($uf->getVisibilityLevel() != ProfileVisibility::VIS_PRIVATE) {
- return '';
+ return PlFilter::COND_TRUE;
}
$uf->requireProfiles();
return XDB::format('p.section IN {?}', $this->section);
$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');
$jsub = $uf->addJobFilter();
// CV is private => if only CV requested, and not private,
// don't do anything. Otherwise restrict to standard job visibility.
- if ($this->fields != UserFilter::JOB_CV || $uf->getVisibilityLevel() == ProfileVisibility::VIS_PRIVATE) {
+ if ($this->fields == UserFilter::JOB_CV) {
+ if ($uf->getVisibilityLevel() != ProfileVisibility::VIS_PRIVATE) {
+ return PlFilter::COND_TRUE;
+ }
+ } else {
$conds[] = $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';