From: hickert Date: Wed, 23 Nov 2005 06:58:10 +0000 (+0000) Subject: Some changes for mailQueue plugin. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e95b80dda11e35a535ac46653fef574824f26adb;p=gosa.git Some changes for mailQueue plugin. Added status selection. new icons unsed for hold unhold active ... git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2012 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/addons/mailqueue/class_mailqueue.inc b/plugins/addons/mailqueue/class_mailqueue.inc index a296c68af..b46495853 100644 --- a/plugins/addons/mailqueue/class_mailqueue.inc +++ b/plugins/addons/mailqueue/class_mailqueue.inc @@ -18,6 +18,7 @@ class mailqueue extends plugin var $Page = 0; var $EntriesPerPage = 20; + var $Stat = "all"; var $OrderBy = "Arrival"; var $SortType = "up"; @@ -28,7 +29,7 @@ class mailqueue extends plugin /* get the query cmd */ $this->mailQueueScript = $this->config->current['MAILQUEUESCRIPTPATH']; - + $this->Server = "all"; } @@ -100,7 +101,9 @@ class mailqueue extends plugin $r_cmd = preg_replace("/%action/" ,"remove" ,$this->mailQueueScript); $r_cmd = preg_replace("/%server/" ,$_GET['server'] ,$r_cmd); $r_cmd = preg_replace("/%id/" ,$_GET['id'] ,$r_cmd); - print $r_cmd; + if(!shell_exec($r_cmd)){ + print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$r_cmd)); + } } } @@ -110,7 +113,9 @@ class mailqueue extends plugin $r_cmd = preg_replace("/%action/" ,"hold" ,$this->mailQueueScript); $r_cmd = preg_replace("/%server/" ,$_GET['server'] ,$r_cmd); $r_cmd = preg_replace("/%id/" ,$_GET['id'] ,$r_cmd); - print $r_cmd; + if(!shell_exec($r_cmd)){ + print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$r_cmd)); + } } } @@ -120,42 +125,80 @@ class mailqueue extends plugin $r_cmd = preg_replace("/%action/" ,"requeue" ,$this->mailQueueScript); $r_cmd = preg_replace("/%server/" ,$_GET['server'] ,$r_cmd); $r_cmd = preg_replace("/%id/" ,$_GET['id'] ,$r_cmd); - print $r_cmd; + if(!shell_exec($r_cmd)){ + print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$r_cmd)); + } } } - if(isset($_POST['requeue_all'])){ - $r_cmd = preg_replace("/%action/" ,"requeue" ,$this->mailQueueScript); - $r_cmd = preg_replace("/%server/" ,$this->Server ,$r_cmd); - $r_cmd = preg_replace("/%id/" ,"all" ,$r_cmd); - print $r_cmd; + $se = $this->getServer(); + unset($se['all']); + $se_str = ""; + foreach($se as $server) { + $se_str .= $server." "; + } + if(isset($_POST['requeue_all'])){ + $r_cmd = preg_replace("/%action/" , "requeue" ,$this->mailQueueScript); + $r_cmd = preg_replace("/%server/" , $se_str ,$r_cmd); + $r_cmd = preg_replace("/%id/" , "all" ,$r_cmd); + if(!shell_exec($r_cmd)){ + print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$r_cmd)); + } } if(isset($_POST['hold_all'])){ - $r_cmd = preg_replace("/%action/" ,"hold" ,$this->mailQueueScript); - $r_cmd = preg_replace("/%server/" ,$this->Server ,$r_cmd); - $r_cmd = preg_replace("/%id/" ,"all" ,$r_cmd); - print $r_cmd; + $r_cmd = preg_replace("/%action/" , "hold" ,$this->mailQueueScript); + $r_cmd = preg_replace("/%server/" , $se_str ,$r_cmd); + $r_cmd = preg_replace("/%id/" , "all" ,$r_cmd); + if(!shell_exec($r_cmd)){ + print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$r_cmd)); + } } + if(isset($_POST['unhold_all'])){ + $r_cmd = preg_replace("/%action/" , "unhold" ,$this->mailQueueScript); + $r_cmd = preg_replace("/%server/" , $se_str ,$r_cmd); + $r_cmd = preg_replace("/%id/" , "all" ,$r_cmd); + if(!shell_exec($r_cmd)){ + print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$r_cmd)); + } + } if(isset($_POST['remove_all'])){ - $r_cmd = preg_replace("/%action/" ,"remove" ,$this->mailQueueScript); - $r_cmd = preg_replace("/%server/" ,$this->Server,$r_cmd); - $r_cmd = preg_replace("/%id/" ,"" ,$r_cmd); - print $r_cmd; - + $r_cmd = preg_replace("/%action/" , "remove" ,$this->mailQueueScript); + $r_cmd = preg_replace("/%server/" , $se_str ,$r_cmd); + $r_cmd = preg_replace("/%id/" , "all" ,$r_cmd); + if(!shell_exec($r_cmd)){ + print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$r_cmd)); + } } /* Filter data with the given */ $mailQueueParser->OrderBy($this->OrderBy,$this->SortType); $mailQueueParser->OnlyDaysAgo($this->Time); $mailQueueParser->CreateDate(); + + if($this->Stat == "hold"){ + $mailQueueParser->Search(true,array("Hold"),true); + } + if($this->Stat == "unhold"){ + $mailQueueParser->Search(false,array("Hold"),true); + } + if($this->Stat == "active"){ + $mailQueueParser->Search(true,array("Active"),true); + } + if($this->Stat == "nonactive"){ + $mailQueueParser->Search(false,array("Active"),true); + } + $mailQueueParser->Search($this->Search,array("MailID","Size","Sender","Recipient","Error","Arrival")); /* */ $entries = $mailQueueParser->GetAll(); $smarty->assign("entries" , array_slice($entries,$this->Page,20)); $smarty->assign("plug" , "?plug=".$_GET['plug']); + $smarty->assign("r_stats" , $this->getStats()); + $smarty->assign("stats" , array_flip($this->getStats())); + $smarty->assign("stat" , $this->Stat); $smarty->assign("p_server" , $this->Server); $smarty->assign("p_servers" , $this->getServer()); $smarty->assign("p_serverKeys" , array_flip($this->getServer())); @@ -199,7 +242,7 @@ class mailqueue extends plugin $ldap->cd($this->config->current['BASE']); $ldap->search("(objectClass=goMailServer)",array("cn")); while($tmp = $ldap->fetch()){ - $ret[$tmp['cn'][0]]= $tmp['cn'][0]; + $ret[$tmp['cn'][0]]= $tmp['cn'][0]; } return($ret); } @@ -231,6 +274,9 @@ class mailqueue extends plugin if(isset($_POST['search_for'])){ $this->Search = $_POST['search_for']; } + if(isset($_POST['Stat'])){ + $this->Stat = $_POST['Stat']; + } if((isset($_GET['start']))&&(is_numeric($_GET['start']))&&($_GET['start']>=0)){ $this->Page = $_GET['start']; } @@ -250,6 +296,17 @@ class mailqueue extends plugin } + function getStats() + { + return(array( + "all" =>_("All"), + "hold" =>_("Hold"), + "unhold" =>_("Un hold"), + "active" =>_("Active"), + "nonactive" =>_("Not active") + )); + } + } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> diff --git a/plugins/addons/mailqueue/class_parseMailQueue.inc b/plugins/addons/mailqueue/class_parseMailQueue.inc index 0d0b6def4..b510cb3a7 100644 --- a/plugins/addons/mailqueue/class_parseMailQueue.inc +++ b/plugins/addons/mailqueue/class_parseMailQueue.inc @@ -43,7 +43,7 @@ class parseMailQueue /* Only keep entries that contains the $filter * in any of the given $fields */ - function Search($filter,$fields) + function Search($filter,$fields,$bool = false) { /* Go through all entries */ foreach($this->a_parsedData as $key => $data){ @@ -52,7 +52,9 @@ class parseMailQueue $found = false; foreach($fields as $attr){ - if(preg_match("/".str_replace("*",".*",$filter)."/i",$data[$attr])){ + if(($bool)&&($data[$attr]==$filter)){ + $found = true; + }elseif(preg_match("/".str_replace("*",".*",$filter)."/i",$data[$attr])){ $found= true; } } @@ -180,6 +182,27 @@ class parseMailQueue $s_Error = $s_buffer[1]; $s_Recipient = $s_buffer[2]; + /* + * The message is in the active queue, i.e. the message is + selected for delivery. + + ! The message is in the hold queue, i.e. no further deliv-delivery + ery attempt will be made until the mail is taken off + hold. + */ + + $s_Hold = false; + if(preg_match("/\!/",$s_mailID)){ + $s_mailID = preg_replace("/\!/","",$s_mailID); + $s_Hold = "true"; + } + + $s_Active = false; + if(preg_match("/\*/",$s_mailID)){ + $s_mailID = preg_replace("/\*/","",$s_mailID); + $s_Active = true; + } + /* Append data */ $this->a_parsedData[$s_mailID."-".$server]['Server'] = $server; $this->a_parsedData[$s_mailID."-".$server]['MailID'] = $s_mailID; @@ -187,6 +210,8 @@ class parseMailQueue $this->a_parsedData[$s_mailID."-".$server]['Arrival'] = $s_Arrival; $this->a_parsedData[$s_mailID."-".$server]['Sender'] = $s_Sender; $this->a_parsedData[$s_mailID."-".$server]['Recipient'] = $s_Recipient; + $this->a_parsedData[$s_mailID."-".$server]['Hold'] = $s_Hold; + $this->a_parsedData[$s_mailID."-".$server]['Active'] = $s_Active; $this->a_parsedData[$s_mailID."-".$server]['Error'] = $this->_parseError($s_Error); } return($this->a_parsedData); diff --git a/plugins/addons/mailqueue/contents.tpl b/plugins/addons/mailqueue/contents.tpl index c950f53fd..6875357bd 100644 --- a/plugins/addons/mailqueue/contents.tpl +++ b/plugins/addons/mailqueue/contents.tpl @@ -4,26 +4,46 @@

- -  {t}Search for{/t} - -  in +

+ + + + + +
+ {t}Search{/t} +  {t}Search for{/t} + +  in -  {t}within the last{/t}  + {t}with status{/t} : + +  {t}within the last{/t}  -   - - - - + {html_options values=$p_timeKeys output=$p_times selected=$p_time} + +   + + + + + + +
+


+ {if $all_ok != "true"} {t}Search returned no results{/t}... {else} @@ -51,16 +71,39 @@ {else} {/if} - {$entries[$key].MailID} + {if $entries[$key].Active == true} + {t}active{/t} + {/if} + {$entries[$key].MailID} {$entries[$key].Server} {$entries[$key].Size} {$entries[$key].Arrival} {$entries[$key].Sender} {$entries[$key].Recipient} {$entries[$key].Error} - deleted - deleted - deleted + + + {t}delete{/t} + + + {if $entries[$key].Hold == true} + + + {t}unhold{/t} + + + {else} + + + {t}hold{/t} + + + {/if} + + + {t}requeue{/t} + + {counter} {/foreach}