From: hickert Date: Wed, 10 Sep 2008 09:07:21 +0000 (+0000) Subject: Updated mailqueue X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=eace43bad875a46ec090a6594ce270a493979a0b;p=gosa.git Updated mailqueue -Still not finished. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12389 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/mail/addons/mailqueue/class_mailqueue.inc b/gosa-plugins/mail/addons/mailqueue/class_mailqueue.inc index a4ced417a..8030879ad 100644 --- a/gosa-plugins/mail/addons/mailqueue/class_mailqueue.inc +++ b/gosa-plugins/mail/addons/mailqueue/class_mailqueue.inc @@ -52,21 +52,41 @@ class mailqueue extends plugin ******************/ $action = $server = $entry = ""; - $types = array("delete","hold","unhold","header","requeue"); + $types = array( + "all_del" => "del", + "all_hold" => "hold", + "all_unhold" => "unhold", + "all_requeue" => "requeue"); + foreach($_POST as $name => $value){ + foreach($types as $type => $target){ + if(preg_match("/^".$type."/",$name)){ + $entry = $this->list_get_selected_items(); + $action = $target; + break; + } + } + if(!empty($action)) break; + } + + + $types = array("del","hold","unhold","header","requeue"); foreach($_POST as $name => $value){ foreach($types as $type){ if(preg_match("/^".$type."__/",$name)){ $action = $type; - $entry = preg_replace("/^".$type."__([^_]*)__.*/","\\1",$name); $server = preg_replace("/^".$type."__[^_]*__([^_]*)_.*/","\\1",$name); + $entry[$server][] = preg_replace("/^".$type."__([^_]*)__.*/","\\1",$name); break; } } + if(!empty($action)) break; } /* Send action for given mail id */ - if(in_array($action,array("hold","unhold","requeue"))){ - $this->si_queue->send_queue_action(array($entry),$server,$action); + if(in_array($action,array("del","hold","unhold","requeue"))){ + foreach($entry as $server => $entries){ + $this->si_queue->send_queue_action($entries,$server,$action); + } } @@ -75,12 +95,15 @@ class mailqueue extends plugin ******************/ if($action == "header"){ + $server = key($entry); + $entry = $entry[$server]; /* Create table which displays the header informations */ $data = $this->si_queue->header($entry,$server); $this->disp_header = $data; if($this->si_queue->is_error()){ msg_dialog::display(_("Error"),msgPool::siError($this->si_queue->get_error()),ERROR_DIALOG); + $this->disp_header = FALSE; } } @@ -100,17 +123,24 @@ class mailqueue extends plugin Query mailqueues ******************/ + $within_minutes = -1; + if($this->Time != "nolimit"){ + $within_minutes = 60*60*$this->Time; + } + if($this->Server == "all"){ $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)); + $entries = array_merge($entries,$this->si_queue->query_mailqueue( + $mac,$this->OrderBy,$this->SortType,$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); + $entries = $this->si_queue->query_mailqueue( + $this->Server,$this->OrderBy,$this->SortType,$this->Search,$within_minutes); if($this->si_queue->is_error()){ msg_dialog::display(_("Error"),msgPool::siError($this->si_queue->get_error()),ERROR_DIALOG); } @@ -297,6 +327,18 @@ class mailqueue extends plugin )); } + function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^selected_*/",$name)){ + $server = preg_replace("/^selected_.*_/","",$name) ; + $ids[$server][] = preg_replace("/^selected_([^_]*)_.*$/","\\1",$name); + } + } + return($ids); + } + } diff --git a/gosa-plugins/mail/addons/mailqueue/class_si_mailqueue.inc b/gosa-plugins/mail/addons/mailqueue/class_si_mailqueue.inc index 58443fbad..3ef982717 100644 --- a/gosa-plugins/mail/addons/mailqueue/class_si_mailqueue.inc +++ b/gosa-plugins/mail/addons/mailqueue/class_si_mailqueue.inc @@ -32,7 +32,7 @@ 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) + public function query_mailqueue($server,$sortby,$direction,$search_str,$time) { $attrs = array("Size","Recipient","Sender","Arrival","MailID","Hold","Active","Error","Server"); @@ -50,6 +50,10 @@ class si_mailqueue extends gosaSupportDaemon $direction = "down"; } + /* Prepare search filter + */ + $search_str = preg_replace("/\\\\\*/",".*",normalizePreg($search_str)); + /* Query mailqueue */ $ids = array(); @@ -57,6 +61,7 @@ class si_mailqueue extends gosaSupportDaemon $items = array(); if(isset($res['XML'][0])){ foreach($res['XML'][0] as $name => $entry){ + if(preg_match("/^ANSWER[0-9]*$/",$name)){ $attrs = array( "MSG_SIZE" => "Size", @@ -83,11 +88,29 @@ class si_mailqueue extends gosaSupportDaemon $val['Server'] = $server; $val['Arrival'] = strtotime($val['Arrival']); - $n = $val[$sortby]."-".microtime(1); - while(isset($items[$n])){ - $n = $val[$sortby]."-".microtime(1); + + /* Check arrival time. + */ + if($time != -1 && !empty($val['Arrival'])){ + if( ! ($val['Arrival'] > (time() - $time))){ + continue; + } + } + + /* Check if search string matches + */ + $found = FALSE; + foreach($val as $name => $value){ + if(preg_match("/^".$search_str."$/",$value)){ + $found =TRUE; + break; + } + } + + if($found){ + $n = uniqid($val[$sortby]); + $items[$n] = $val; } - $items[$n] = $val; } } } @@ -150,7 +173,9 @@ class si_mailqueue extends gosaSupportDaemon } $data['msg_id'] = $msg_ids; - $this->send_data("gosa_mailqueue_".$action,$this->target,$data,FALSE); + + print_a(array("gosa_mailqueue_".$action,$server,$data));; + $this->send_data("gosa_mailqueue_".$action,$server,$data,FALSE); // There is no answer for this requests } } diff --git a/gosa-plugins/mail/addons/mailqueue/contents.tpl b/gosa-plugins/mail/addons/mailqueue/contents.tpl index 81acb6671..dbd5c5988 100644 --- a/gosa-plugins/mail/addons/mailqueue/contents.tpl +++ b/gosa-plugins/mail/addons/mailqueue/contents.tpl @@ -26,13 +26,17 @@   - - - - @@ -49,6 +53,9 @@ + @@ -67,31 +74,20 @@ {else} {/if} + - - - - - + + + + +
+ {t}ID{/t} {if $OrderBy == "MailID"} {$SortType}{/if} {t}Server{/t} {if $OrderBy == "Server"} {$SortType}{/if} {t}Size{/t} {if $OrderBy == "Size"} {$SortType}{/if}
- {if $entries[$key].Active == true} {t}Active{/t} {/if} - {$entries[$key].MailID} - - {$entries[$key].ServerName} - - {$entries[$key].Size} - {$entries[$key].Arrival} - {$entries[$key].Sender} - {$entries[$key].Recipient}{$entries[$key].ServerName}{$entries[$key].Size}{$entries[$key].Arrival}{$entries[$key].Sender}{$entries[$key].Recipient} {$entries[$key].Error} - {if $entries[$key].Hold == true}