From 333140f31a42045b46698baaaac0cfd106d0e073 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 12 Sep 2008 09:41:20 +0000 Subject: [PATCH] Updated mailqueue -Fixed sorting -Fixed search filter git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12443 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../mail/addons/mailqueue/class_mailqueue.inc | 26 ++++++++++++---- .../addons/mailqueue/class_si_mailqueue.inc | 30 ++----------------- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/gosa-plugins/mail/addons/mailqueue/class_mailqueue.inc b/gosa-plugins/mail/addons/mailqueue/class_mailqueue.inc index 6dd6bfe99..15b8f1045 100644 --- a/gosa-plugins/mail/addons/mailqueue/class_mailqueue.inc +++ b/gosa-plugins/mail/addons/mailqueue/class_mailqueue.inc @@ -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 */ diff --git a/gosa-plugins/mail/addons/mailqueue/class_si_mailqueue.inc b/gosa-plugins/mail/addons/mailqueue/class_si_mailqueue.inc index f73e2ca00..958822d6c 100644 --- a/gosa-plugins/mail/addons/mailqueue/class_si_mailqueue.inc +++ b/gosa-plugins/mail/addons/mailqueue/class_si_mailqueue.inc @@ -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); } -- 2.30.2