summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 30c2d6d)
raw | patch | inline | side by side (parent: 30c2d6d)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 24 Nov 2005 06:03:43 +0000 (06:03 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 24 Nov 2005 06:03:43 +0000 (06:03 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2025 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/addons/mailqueue/class_mailqueue.inc | patch | blob | history | |
plugins/addons/mailqueue/contents.tpl | patch | blob | history |
diff --git a/plugins/addons/mailqueue/class_mailqueue.inc b/plugins/addons/mailqueue/class_mailqueue.inc
index 14c881d619cb7ff376a494c5ba8af97061cb737c..b995d101a19da81955b22d87d545aeb83546790d 100644 (file)
var $plDescription= "This does something";
/* attribute list for save action */
- var $attributes= array();
- var $objectclasses= array();
-
- var $mailQueueScript = "";
-
+ var $attributes = array();
+ var $objectclasses = array();
+ var $mailQueueScript= "";
var $Server = "all";
var $Time = 0;
var $Search = "*";
var $Page = 0;
var $EntriesPerPage = 20;
-
var $Stat = "all";
var $OrderBy = "Arrival";
var $SortType = "up";
+ var $disp_header = false;
+
function mailqueue($config, $dn= NULL)
{
- /* Include config object */
- $this->config= $config;
+ $this->config = $config;
+ $this->mailQueueScript = $this->config->current['MAILQUEUESCRIPTPATH'];
+ $this->Server = "all";
+ }
- /* get the query cmd */
- $this->mailQueueScript = $this->config->current['MAILQUEUESCRIPTPATH'];
- $this->Server = "all";
+ function pass_cmd($str)
+ {
+ return(shell_exec($str));
}
+
function execute()
{
/* Call parent execute */
plugin::execute();
$smarty= get_smarty();
-
$error =false;
if(empty($this->mailQueueScript)){
$error = true;
}else{
+ /* If we have more than one server selected (all),
+ create a string with all servers separated by ', '
+ */
+ if($this->Server=="all"){
+ $se = $this->getServer();
+ unset($se['all']);
+ $se_str = "";
+ foreach($se as $server) {
+ $se_str .= $server." ";
+ }
+ }else{
+ /* We have only one server selected */
+ $se_str = $this->Server;
+ }
+
+ /* Check all post that will effect all entries */
+ $only_once = true;
+ foreach(array("unhold_all","hold_all","remove_all","requeue_all") as $attr){
+ foreach($_POST as $name => $value){
+ if((preg_match("/".$attr."/",$name))&&($only_once)){
+ $only_once = false;
+ $act = preg_replace("/_.*$/i","",$attr);
+ $r_cmd = preg_replace("/%action/" , $act ,$this->mailQueueScript);
+ $r_cmd = preg_replace("/%server/" , $se_str ,$r_cmd);
+ $r_cmd = preg_replace("/%id/" , "all" ,$r_cmd);
+ if(!$this->pass_cmd($r_cmd)){
+ print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$r_cmd));
+ }
+ }
+ }
+ }
+
+ /* Check single entry manipulation posts */
+ $only_once = true;
+
+ /* act specifies the command to execute */
+ if(isset($_GET['act'])){
+ $opt = $_GET['act'];
+
+ /* The option to exec should be one of these */
+ if(in_array($opt,array("unhold","hold","del","requeue","query","header"))){
+ $only_once = false;
+
+ /* Create cmd */
+ $r_cmd = preg_replace("/%action/" , $opt ,$this->mailQueueScript);
+ $r_cmd = preg_replace("/%server/" , $this->Server ,$r_cmd);
+ $r_cmd = preg_replace("/%id/" , $_GET['id'] ,$r_cmd);
+
+ /* Execute cmd */
+ if(!$str = $this->pass_cmd($r_cmd)){
+ print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$r_cmd));
+ }else{
+
+ /* Special handling for option='header' */
+ if($opt == "header"){
+
+ /* Create table which displays the header informations */
+ $this->disp_header ="\n<table width='80%'>";
+ foreach(split("\n",$str) as $line){
+ $line = trim($line);
+ if(empty($line)) {
+ continue;
+ }
+ $this->disp_header .= "\n<tr>";
+ $tmp0 = preg_replace("/:.*$/","",$line);
+ $tmp1 = preg_replace("/^.*:/","",$line);
+ $this->disp_header .= "\n<td style='background-color:#EEEEEE;'>".$tmp0."</td><td>".$tmp1."</td>";
+ $this->disp_header .= "\n</tr>";
+ }
+ $this->disp_header .= "\n</table>";
+ }
+ }
+ }
+ }
+
+
+ /* Back is posted from the header display page */
+ if(isset($_POST['back'])){
+ $this->disp_header = false;
+ }
+
+ /* If there is a header in disp_header, then display it */
+ if($this->disp_header){
+ $smarty->assign("header",$this->disp_header);
+ return ($smarty->fetch (get_template_path('header.tpl', TRUE)));
+ }
+
/* tell smarty to display the search results*/
$smarty->assign("all_ok" , "true");
-
+
/* A single server is selected */
if($this->Server != "all"){
$q_cmd = preg_replace("/%id/" ,"all" ,$q_cmd);
/* Only display this if the query cmd is executeable */
- if($str = @shell_exec ($q_cmd)){
-
+ if($str = @$this->pass_cmd ($q_cmd)){
/* Parse returned data */
$mailQueueParser = new parseMailQueue($str,$this->Server);
-
}else{
-
- /* Can't Execute cmd */
+ /* On error/ no return value / false return value */
print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$q_cmd));
$error = true;
}
}else{
-
$mailQueueParser = NULL;
foreach($this->getServer() as $ServerID=>$ServerName){
+
+ /* Don't query the server named all :) */
if($ServerID == "all") continue;
+ /* Prepare query cmd */
$q_cmd = preg_replace("/%action/" ,"query" ,$this->mailQueueScript);
$q_cmd = preg_replace("/%server/" ,$ServerName ,$q_cmd);
$q_cmd = preg_replace("/%id/" ,"ALL" ,$q_cmd);
- if($str = @shell_exec ($q_cmd)){
+ /* Shell exec this cmd */
+ if($str = @$this->pass_cmd ($q_cmd)){
+
+ /* If there is no parser available, create one */
if($mailQueueParser == NULL){
$mailQueueParser = new parseMailQueue($str,$ServerID);
}else{
$mailQueueParser->parseAdditionalQueue($str,$ServerID);
}
+ /* On error/ no return value / false return value */
}else{
print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$q_cmd));
$error = true;
if(!$error){
- /* Check for actions */
- foreach (array("requeue", "unhold", "hold", "del") as $type){
- if((isset($_GET['act']))&&($_GET['act']=="$type")){
- if($mailQueueParser->IDExists($_GET['id'])){
- $r_cmd = preg_replace("/%action/" ,"$type" ,$this->mailQueueScript);
- $r_cmd = preg_replace("/%server/" ,$_GET['server'] ,$r_cmd);
- $r_cmd = preg_replace("/%id/" ,$_GET['id'] ,$r_cmd);
- if(!shell_exec($r_cmd)){
- print_red(sprintf(_("Please check your 'gosa.conf' the given '%s' can't be executed."),$r_cmd));
- }
- }
- }
- }
-
- $se = $this->getServer();
- unset($se['all']);
- $se_str = "";
- foreach($se as $server) {
- $se_str .= $server." ";
- }
-
- foreach (array("requeue", "unhold", "hold", "del") as $type){
- if(isset($_POST[$type.'_all'])){
- $r_cmd = preg_replace("/%action/" , "$type" ,$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->Search($this->Search,array("MailID","Size","Sender","Recipient","Error","Arrival"));
/* */
- $entries = $mailQueueParser->GetAll();
+ $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("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());
}
}
+ /* In case of an error */
if($error){
$smarty->assign("all_ok" , "false");
- $smarty->assign("r_stats" , $this->getStats());
- $smarty->assign("stats" , array_flip($this->getStats()));
+ $smarty->assign("r_stats" , $this->getStats());
+ $smarty->assign("stats" , array_flip($this->getStats()));
$smarty->assign("stat" , $this->Stat);
$smarty->assign("plug" , "?plug=".$_GET['plug']);
$smarty->assign("p_server" , $this->Server);
return($ret);
}
+
/* Return selectable times*/
function getTimes()
{
return($ret);
}
+
/* Save post values*/
function save_object($save_current= FALSE)
{
}
+ /* Return stats */
function getStats()
{
return(array(
- "all" =>_("All"),
- "hold" =>_("Hold"),
- "unhold" =>_("Un hold"),
- "active" =>_("Active"),
- "nonactive" =>_("Not active")
- ));
+ "all" =>_("All"),
+ "hold" =>_("Hold"),
+ "unhold" =>_("Un hold"),
+ "active" =>_("Active"),
+ "nonactive" =>_("Not active")
+ ));
}
}
index 6c432c6255dd61f19dd32f2c7cac2662b854a3b0..049a7b9b275d2f3caa4378ca8bb5812fb4cb3ccc 100644 (file)
<input name="search" value="{t}Search{/t}" type="submit">
</td>
<td style="border-left:1px solid #A0A0A0; text-align:right;">
- <input name="remove_all" src="images/edittrash.png" value="{t}Remove all messages{/t}" type="image"
+ <input name="remove_all" src="images/edittrash.png" value="{t}Remove all messages{/t}" type="image"
title="{t}Remove all messages from selected servers queue{/t}">
- <input name="hold_all" src="images/mailq_hold.png" value="{t}Hold all messages{/t}" type="image"
+ <input name="hold_all" src="images/mailq_hold.png" value="{t}Hold all messages{/t}" type="image"
title="{t}Hold all messages in selected servers queue{/t}">
<input name="unhold_all" src="images/mailq_unhold.png" value="{t}Release all messages{/t}" type="image"
title="{t}Release all messages in selected servers queue{/t}">
- <input name="requeue_all" src="images/mailq_requeue.png" value="{t}Requeue all messages{/t}" type="image"
+ <input name="requeue_all" src="images/mailq_requeue.png" value="{t}Requeue all messages{/t}" type="image"
title="{t}Requeue all messages in selected servers queue{/t}">
</td>
<tr>
</tr>
{counter start=0 assign=i start=1}
+ <input type="hidden" name="header_server" value="">
+ <input type="hidden" name="header_id" value="">
{foreach from=$entries item=val key=key}
-
+
{if ($i%2)== 0 }
<tr style="height: 22px; background-color: rgb(236, 236, 236);">
{else}
<tr style="height: 22px; background-color: rgb(245, 245, 245);">
{/if}
- <td>{if $entries[$key].Active == true}
+ <td onlick="javascript: document.mainform.header_server.value='{$entries[$key].Server}';
+ document.mainform.header_id.value='{$entries[$key].MailID}';
+ document.mainform.submit();">
+ {if $entries[$key].Active == true}
<img src="images/mailq_active.png" border=0 alt="{t}Active{/t}">
{/if}
+
{$entries[$key].MailID}</td>
- <td>{$entries[$key].Server}</td>
- <td>{$entries[$key].Size}</td>
- <td>{$entries[$key].Arrival}</td>
- <td>{$entries[$key].Sender}</td>
- <td>{$entries[$key].Recipient}</td>
+ <td onclick="javascript: document.location.href='{$plug}&act=header&id={$entries[$key].MailID}&server={$entries[$key].Server}'">
+ {$entries[$key].Server}</td>
+ <td>
+ {$entries[$key].Size}</td>
+ <td>
+ {$entries[$key].Arrival}</td>
+ <td>
+ {$entries[$key].Sender}</td>
+ <td>
+ {$entries[$key].Recipient}</td>
<td titel="{$entries[$key].Error}">{$entries[$key].Error}</td>
<td style="text-align:right">
<a href="{$plug}&act=del&id={$entries[$key].MailID}&server={$entries[$key].Server}">
<a href="{$plug}&act=requeue&id={$entries[$key].MailID}&server={$entries[$key].Server}">
<img src="images/mailq_requeue.png" border=0 alt="{t}requeue{/t}" title="{t}Requeue this message{/t}">
</a>
+ <a href="{$plug}&act=header&id={$entries[$key].MailID}&server={$entries[$key].Server}">
+ <img src="images/mailq_header.png" border=0 alt="{t}header{/t}" title="{t}Display header from this message{/t}">
+ </a>
</td>
</tr>
{counter}