Enable a 'UFC_Deltaten' used for the N N-10 operation.
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Mon, 28 Feb 2011 21:05:19 +0000 (22:05 +0100)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Sun, 8 May 2011 23:28:54 +0000 (01:28 +0200)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
classes/userfilter.php
classes/userfilter/conditions.inc.php

index 026e7e9..2834636 100644 (file)
@@ -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';
index 896e12e..729c911 100644 (file)
@@ -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
  */