Code

Keep entries sorted while list data is modified.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 6 Apr 2010 14:01:24 +0000 (14:01 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 6 Apr 2010 14:01:24 +0000 (14:01 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17485 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_sortableListing.inc

index 63f04ffc66f8bb58fe8ca0e2a378e396318633d8..f545cb74ec3e764d2a23cc15fd854c6eb199b6e1 100644 (file)
@@ -95,7 +95,7 @@ class sortableListing {
   private function setDisplayData($data)
   {
     if (!is_array($data)) {
-      die ("sortableList needs an array as data!");
+      trigger_error ("sortableList needs an array as data!");
     }
 
     // Transfer information
@@ -126,8 +126,9 @@ class sortableListing {
     }
 
     // Preset sort orders to 'down'
+    if(!count($this->sortDirection))
     for ($column= 0; $column<$this->columns; $column++) {
-      $this->sortDirection[]= true;
+      $this->sortDirection[$column]= true;
     }
   }
 
@@ -323,20 +324,23 @@ class sortableListing {
     }
 
     // Filter GET with "act" attributes
-    if (!$this->reorderable && isset($_GET['act'])) {
-      $key= validate($_GET['act']);
-      if (preg_match('/^SORT_([0-9]+)$/', $key, $match)) {
-        // Switch to new column or invert search order?
-        $column= $match[1];
-        if ($this->sortColumn != $column) {
-          $this->sortColumn= $column;
-        } else {
-          $this->sortDirection[$column]= !$this->sortDirection[$column];
-        }
+    if (!$this->reorderable){
+      if(isset($_GET['act'])) {
+        $key= validate($_GET['act']);
+        if (preg_match('/^SORT_([0-9]+)$/', $key, $match)) {
+          // Switch to new column or invert search order?
+          $column= $match[1];
+          if ($this->sortColumn != $column) {
+            $this->sortColumn= $column;
+          } else {
+            $this->sortDirection[$column]= !$this->sortDirection[$column];
+          }
 
-        // Update mapping according to sort parameters
-        $this->sortData();
+        }
       }
+
+      // Update mapping according to sort parameters
+      $this->sortData();
     }
   }