Code

Updated mailqueue
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 12 Sep 2008 09:41:20 +0000 (09:41 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 12 Sep 2008 09:41:20 +0000 (09:41 +0000)
-Fixed sorting
-Fixed search filter

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12443 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/mail/addons/mailqueue/class_mailqueue.inc
gosa-plugins/mail/addons/mailqueue/class_si_mailqueue.inc

index 6dd6bfe999ed9e391ca1a4d41d2d7beccb3bac37..15b8f10451c5d2dd8c6ebe0a6a2168ea9f71f69a 100644 (file)
@@ -133,22 +133,36 @@ class mailqueue extends plugin
       $entries = array();
       foreach($this->ServerList as $mac => $name){
         if(!tests::is_mac($mac)) continue;
-        $entries = array_merge($entries,$this->si_queue->query_mailqueue(
-              $mac,$this->OrderBy,$this->SortType,$this->Search,$within_minutes));
+        $entries = array_merge($entries,$this->si_queue->query_mailqueue($mac,$this->Search,$within_minutes));
         if($this->si_queue->is_error()){
           msg_dialog::display(_("Error"),msgPool::siError($this->si_queue->get_error()),ERROR_DIALOG);
         }
       }
     }else{
-      $entries = $this->si_queue->query_mailqueue(
-          $this->Server,$this->OrderBy,$this->SortType,$this->Search,$within_minutes);
+      $entries = $this->si_queue->query_mailqueue($this->Server,$this->Search,$within_minutes);
       if($this->si_queue->is_error()){
         msg_dialog::display(_("Error"),msgPool::siError($this->si_queue->get_error()),ERROR_DIALOG);
       }
     }
 
-    $count = count($entries);
-    $entries = array_slice($entries,$this->Page,$this->range);
+    /* Sort entries 
+     */ 
+    $data = array();
+    foreach($entries as $entry){
+      $data[uniqid($entry[$this->OrderBy])] = $entry;
+    }
+
+    /* Sort entries by given direction 
+     */
+    if($this->SortType == "down"){
+      uksort($data, 'strnatcasecmp');
+    }else{
+      uksort($data, 'strnatcasecmp');
+      $data = array_reverse($data);
+    }
+
+    $count = count($data);
+    $entries = array_slice($data,$this->Page,$this->range);
 
     /* Add ServerName to results 
      */
index f73e2ca009eaff54a46cdd321945b47c37f9c36c..958822d6cd9adc5f7cfc706a5408ea79e06812b5 100644 (file)
@@ -32,24 +32,10 @@ class si_mailqueue extends gosaSupportDaemon
   /*! \brief  Returns a list of all mail queue entries 
       @return Array   s.a.
    */
-  public function query_mailqueue($server,$sortby,$direction,$search_str,$time)
+  public function query_mailqueue($server,$search_str,$time)
   {
     $attrs = array("Size","Recipient","Sender","Arrival","MailID","Hold","Active","Error","Server");
 
-    /* Check sorting paramter 
-     */
-    if(!in_array($sortby,$attrs)){
-      trigger_error("Invalid sorting option '".$sortby."'.");
-      $sortby = "Arrival";
-    }
-
-    /* Check sorting direction 
-     */
-    if(!in_array($direction,array("down","up"))){
-      trigger_error("Invalid sorting direction '".$direction."'.");
-      $direction = "down";
-    }
-
     /* Prepare search filter 
      */
     $search_str = preg_replace("/\\\\\*/",".*",normalizePreg($search_str));
@@ -106,22 +92,12 @@ class si_mailqueue extends gosaSupportDaemon
               break;
             }
           }
-       
-          if($found){ 
-            $n = uniqid($val[$sortby]);
-            $items[$n] = $val;
+          if($found){
+            $items[] = $val;
           }
         }
       }
     }   
-
-    /* Sort entries by given direction 
-     */
-    if($direction == "down"){
-      ksort($items);
-    }else{
-      krsort($items);
-    }
     return($items);
   }