From: Raphaël Barrois Date: Sun, 17 Jan 2010 01:46:05 +0000 (+0100) Subject: Add UFC_Networking X-Git-Tag: xorg/1.0.0~332^2~300 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=0a2e9c74b1ad0e5b0e5d045513850447fad03686;p=platal.git Add UFC_Networking For filtering users by network ID (IRC, ICQ, jabber, ...) Signed-off-by: Raphaël Barrois --- diff --git a/classes/userfilter.php b/classes/userfilter.php index 972cffe..5470d05 100644 --- a/classes/userfilter.php +++ b/classes/userfilter.php @@ -747,6 +747,35 @@ class UFC_Job_Description extends UserFilterCondition } // }}} +// {{{ class UFC_Networking +/** Filters users based on network identity (IRC, ...) + * @param $type Type of network (-1 for any) + * @param $value Value to search + */ +class UFC_Networking extends UserFilterCondition +{ + private $type; + private $value; + + public function __construct($type, $value) + { + $this->type = $type; + $this->value = $value; + } + + public function buildCondition(UserFilter &$uf) + { + $sub = $uf->addNetworkingFilter(); + $conds = array(); + $conds[] = $sub . '.address = ' . XDB::format('CONCAT(\'%\', {?}, \'%\')', $this->value); + if ($this->type != -1) { + $conds[] = $sub . '.network_type = ' . XDB::format('{?}', $this->type); + } + return implode(' AND ', $conds); + } +} +// }}} + // {{{ class UFC_UserRelated /** Filters users based on a relation toward on user * @param $user User to which searched users are related @@ -1609,6 +1638,25 @@ class UserFilter return $joins; } + /** NETWORKING + */ + + private $with_pnw = false; + public function addNetworkingFilter() + { + $this->with_pnw = true; + return 'pnw'; + } + + private function networkingJoins() + { + $joins = array(); + if ($this->with_pnw) { + $joins['pnw'] = array('left', 'profile_networking', '$ME.uid = $UID'); + } + return $joins; + } + /** CONTACTS */ private $cts = array();