From 0a2e9c74b1ad0e5b0e5d045513850447fad03686 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Sun, 17 Jan 2010 02:46:05 +0100 Subject: [PATCH] Add UFC_Networking MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit For filtering users by network ID (IRC, ICQ, jabber, ...) Signed-off-by: Raphaël Barrois --- classes/userfilter.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) 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(); -- 2.1.4