- return '(' . implode(') OR (', $cond) . ')';
- }
-}
-// }}}
-
-// {{{ class UFC_Address
-/** Filters users based on their address
- * @param $field Field of the address used for filtering (city, street, ...)
- * @param $text Text for filter
- * @param $mode Mode for search (PREFIX, SUFFIX, ...)
- */
-class UFC_Address implements UserFilterCondition
-{
- const PREFIX = 1;
- const SUFFIX = 2;
- const CONTAINS = 3;
-
- private $field;
- private $text;
- private $mode;
-
- public function __construct($field, $text, $mode)
- {
- $this->field = $field;
- $this->text = $text;
- $this->mode = $mode;
- }
-
- public function buildCondition(UserFilter &$uf)
- {
- $left = 'pa.' . $field;
- $op = ' LIKE ';
- if (($this->mode & self::CONTAINS) == 0) {
- $right = XDB::format('{?}', $this->text);
- $op = ' = ';
- } else if (($this->mode & self::CONTAINS) == self::PREFIX) {
- $right = XDB::format('CONCAT({?}, \'%\')', $this->text);
- } else if (($this->mode & self::CONTAINS) == self::SUFFIX) {
- $right = XDB::format('CONCAT(\'%\', {?})', $this->text);
- } else {
- $right = XDB::format('CONCAT(\'%\', {?}, \'%\')', $this->text);
- }
- $cond = $left . $op . $right;
- $uf->addAddressFilter();
- return $cond;
- }
-}
-// }}}
-
-// {{{ class UFC_Corps
-/** Filters users based on the corps they belong to
- * @param $corps Corps we are looking for (abbreviation)
- * @param $type Whether we search for original or current corps
- */
-class UFC_Corps implements UserFilterCondition
-{
- const CURRENT=1;
- const ORIGIN=2;
-
- private $corps;
- private $type;
-
- public function __construct($corps, $type = self::CURRENT)
- {
- $this->corps = $corps;
- $this->type = $type;
- }
-
- public function buildCondition(UserFilter &$uf)
- {
- /** Tables shortcuts :
- * pc for profile corps,
- * pceo for profile_corps_enum - orginal
- * pcec for profile_corps_enum - current
- */
- $sub = $uf->addCorpsFilter($this->type);
- $cond = $sub . '.abbreviation = ' . $corps;
- return $cond;
- }
-}
-// }}}
-
-// {{{ class UFC_Corps_Rank
-/** Filters users based on their rank in the corps
- * @param $rank Rank we are looking for (abbreviation)
- */
-class UFC_Corps_Rank implements UserFilterCondition
-{
- private $rank;
- public function __construct($rank)
- {
- $this->rank = $rank;
- }
-
- public function buildCondition(UserFilter &$uf)
- {
- /** Tables shortcuts :
- * pcr for profile_corps_rank
- */
- $sub = $uf->addCorpsRankFilter();
- $cond = $sub . '.abbreviation = ' . $rank;
- return $cond;
- }
-}
-// }}}
-
-// {{{ class UFC_Job_Company
-/** Filters users based on the company they belong to
- * @param $type The field being searched (self::JOBID, self::JOBNAME or self::JOBACRONYM)
- * @param $value The searched value
- */
-class UFC_Job_Company extends UserFilterCondition
-{
- const JOBID = 'id';
- const JOBNAME = 'name';
- const JOBACRONYM = 'acronym';
-
- private $type;
- private $value;
-
- public function __construct($type, $value)
- {
- $this->assertType($type);
- $this->type = $type;
- $this->value = $value;
- }
-
- private function assertType($type)
- {
- if ($type != self::JOBID && $type != self::JOBNAME && $type != self::JOBACRONYM) {
- Platal::page()->killError("Type de recherche non valide");
- }
- }
-
- public function buildCondition(UserFilter &$uf)
- {
- $sub = $uf->addJobCompanyFilter();
- $cond = $sub . '.' . $this->type . ' = ' . XDB::format('{?}', $this->value);
- return $cond;
- }
-}
-// }}}
-
-// {{{ class UFC_Job_Sectorization
-/** Filters users based on the ((sub)sub)sector they work in
- * @param $sector The sector searched
- * @param $subsector The subsector
- * @param $subsubsector The subsubsector
- */
-class UFC_Job_Sectorization extends UserFilterCondition
-{
-
- private $sector;
- private $subsector;
- private $subsubsector;
-
- public function __construct($sector = null, $subsector = null, $subsubsector = null)
- {
- $this->sector = $sector;
- $this->subsector = $subsector;
- $this->subsubsector = $subsubsector;
- }
-
- public function buildCondition(UserFilter &$uf)
- {
- // No need to add the JobFilter, it will be done by addJobSectorizationFilter
- $conds = array();
- if ($this->sector !== null) {
- $sub = $uf->addJobSectorizationFilter(UserFilter::JOB_SECTOR);
- $conds[] = $sub . '.id = ' . XDB::format('{?}', $this->sector);
- }
- if ($this->subsector !== null) {
- $sub = $uf->addJobSectorizationFilter(UserFilter::JOB_SUBSECTOR);
- $conds[] = $sub . '.id = ' . XDB::format('{?}', $this->subsector);
- }
- if ($this->subsubsector !== null) {
- $sub = $uf->addJobSectorizationFilter(UserFilter::JOB_SUBSUBSECTOR);
- $conds[] = $sub . '.id = ' . XDB::format('{?}', $this->subsubsector);