From: Raphaël Barrois Date: Mon, 28 Feb 2011 21:05:19 +0000 (+0100) Subject: Enable a 'UFC_Deltaten' used for the N N-10 operation. X-Git-Tag: xorg/1.1.1~12 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=49707d3b04a83af8f2c0c053f09a0b023f231452;p=platal.git Enable a 'UFC_Deltaten' used for the N N-10 operation. Signed-off-by: Raphaël Barrois --- 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 */