From 49707d3b04a83af8f2c0c053f09a0b023f231452 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Mon, 28 Feb 2011 22:05:19 +0100 Subject: [PATCH] Enable a 'UFC_Deltaten' used for the N N-10 operation. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- classes/userfilter.php | 33 ++++++++++++++++++++++++++++++++- classes/userfilter/conditions.inc.php | 30 ++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/classes/userfilter.php b/classes/userfilter.php index 026e7e9..2834636 100644 --- a/classes/userfilter.php +++ b/classes/userfilter.php @@ -1201,6 +1201,37 @@ class UserFilter extends PlFilter return $joins; } + /** DELTATEN + */ + private $dts = array(); + const DELTATEN = 1; + const DELTATEN_MESSAGE = 2; + // TODO: terms + + public function addDeltaTenFilter($type) + { + $this->requireProfiles(); + switch ($type) { + case self::DELTATEN: + $this->dts['pdt'] = 'profile_deltaten'; + return 'pdt'; + case self::DELTATEN_MESSAGE: + $this->dts['pdtm'] = 'profile_deltaten'; + return 'pdtm'; + default: + Platal::page()->killError("Undefined DeltaTen filter."); + } + } + + protected function deltatenJoins() + { + $joins = array(); + foreach ($this->dts as $sub => $tab) { + $joins[$sub] = PlSqlJoin::left($tab, '$ME.pid = $PID'); + } + return $joins; + } + /** MENTORING */ @@ -1213,7 +1244,7 @@ class UserFilter extends PlFilter public function addMentorFilter($type) { - $this->requireAccounts(); + $this->requireProfiles(); switch($type) { case self::MENTOR: $this->pms['pm'] = 'profile_mentor'; diff --git a/classes/userfilter/conditions.inc.php b/classes/userfilter/conditions.inc.php index 896e12e..729c911 100644 --- a/classes/userfilter/conditions.inc.php +++ b/classes/userfilter/conditions.inc.php @@ -1584,6 +1584,36 @@ abstract class UFC_UserRelated extends UserFilterCondition } } // }}} +// {{{ class UFC_DeltaTen +class UFC_DeltaTen extends UserFilterCondition +{ + public function buildCondition(PlFilter $uf) + { + $sub = $uf->addDeltaTenFilter(UserFilter::DELTATEN); + return $sub . '.message IS NOT NULL'; + } +} +// }}} +// {{{ class UFC_DeltaTen_Message +/** Filters users by deltaten message + * @param $message Message for the DeltaTen program + */ +class UFC_DeltaTen_Message extends UserFilterCondition +{ + private $message; + + public function __construct($message) + { + $this->message = $message; + } + + public function buildCondition(PlFilter $uf) + { + $sub = $uf->addDeltaTenFilter(UserFilter::DELTATEN_MESSAGE); + return $sub . '.message ' . XDB::formatWildcards(XDB::WILDCARD_CONTAINS, $this->message); + } +} +// }}} // {{{ class UFC_Contact /** Filters users who belong to selected user's contacts */ -- 2.1.4