Update the UFO_Promo and UFO_Name to work cleanly with the new MultiPageView grouping...
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Thu, 14 Apr 2011 21:04:27 +0000 (23:04 +0200)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Fri, 22 Apr 2011 08:51:31 +0000 (10:51 +0200)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
classes/userfilter/orders.inc.php
core

index f640e00..ad41bb3 100644 (file)
@@ -89,6 +89,11 @@ class UFO_Promo extends PlFilterGroupableOrder
         }
     }
 
+    public function getCondition($promo)
+    {
+        return new UFC_Promo(UserFilterCondition::OP_EQUALS, $this->grade, $promo);
+    }
+
     public function export()
     {
         $export = $this->buildExport('promo');
@@ -106,7 +111,7 @@ class UFO_Promo extends PlFilterGroupableOrder
  * @param $particle Set to true if particles should be included in the sorting order
  * @param $desc If sort order should be descending
  */
-class UFO_Name extends PlFilterOrder
+class UFO_Name extends PlFilterGroupableOrder
 {
     private $type;
     private $variant;
@@ -141,6 +146,28 @@ class UFO_Name extends PlFilterOrder
         }
     }
 
+    public function getGroupToken(PlFilter $pf)
+    {
+        return 'SUBSTRING(' . $this->_tokens . ', 1, 1)';
+    }
+
+    public function getCondition($initial)
+    {
+        if (Profile::isDisplayName($this->type)) {
+            switch ($this->type) {
+            case Profile::DN_PRIVATE:
+            case Profile::DN_SHORT:
+            case Profile::DN_YOURSELF:
+                $type = Profile::FIRSTNAME;
+            default:
+                $type = Profile::LASTNAME;
+            }
+        } else {
+            $type = $this->type;
+        }
+        return new UFC_Name($type, $initial, UFC_Name::PREFIX);
+    }
+
     public function export()
     {
         $export = $this->buildExport($this->type);
diff --git a/core b/core
index 36b41c6..852e640 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 36b41c6c79c3a434b7e5b374befb3090105dd3aa
+Subproject commit 852e6400e7b7dbc0c0d4c8b4e72ca009954056cb