Code

Some additional functions for mail_queue
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 22 Nov 2005 13:35:44 +0000 (13:35 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 22 Nov 2005 13:35:44 +0000 (13:35 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2008 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/addons/mailqueue/class_mailqueue.inc
plugins/addons/mailqueue/class_parseMailQueue.inc
plugins/addons/mailqueue/contents.tpl

index 086bfc1583c7f6c38530355704683e25d01c57ff..a296c68afe39cbbf30e71faf51e141c62bf17e6a 100644 (file)
@@ -10,8 +10,7 @@ class mailqueue extends plugin
   var $attributes= array();
   var $objectclasses= array();
 
-  var $QueryCommand = "";
-  var $RemoveCommand= "";
+  var $mailQueueScript = "";    
 
   var $Server         = "all";
   var $Time           = 0;
@@ -28,9 +27,8 @@ class mailqueue extends plugin
     $this->config= $config;
 
     /* get the query cmd */
-    $this->QueryCommand = search_config($this->config->data['MENU'], "mailqueue", "MAILQUEUE_QUERY_COMMAND");
-    $this->RemoveCommand= search_config($this->config->data['MENU'], "mailqueue", "MAILQUEUE_REMOVE_COMMAND");
-
+    $this->mailQueueScript = $this->config->current['MAILQUEUESCRIPTPATH'];    
+  
     $this->Server = "all";
   }
 
@@ -42,7 +40,7 @@ class mailqueue extends plugin
 
     $error =false;
 
-    if(empty($this->QueryCommand)){
+    if(empty($this->mailQueueScript)){
       print_red(_("Please check your 'gosa.conf', there is no 'MAILQUEUE_QUERY_COMMAND' specified."));
       $error = true;
     }else{
@@ -54,7 +52,9 @@ class mailqueue extends plugin
       if($this->Server != "all"){    
 
         /* Create Query cmd */ 
-        $q_cmd = preg_replace("/%server/",$this->Server,$this->QueryCommand);
+        $q_cmd = preg_replace("/%action/" ,"query"      ,$this->mailQueueScript);
+        $q_cmd = preg_replace("/%server/" ,$this->Server,$q_cmd);
+        $q_cmd = preg_replace("/%id/"     ,""           ,$q_cmd);
 
         /* Only display this if the query cmd is executeable */
         if($str = @shell_exec ($q_cmd)){
@@ -75,7 +75,9 @@ class mailqueue extends plugin
         foreach($this->getServer() as $ServerID=>$ServerName){
           if($ServerID == "all") continue;
 
-          $q_cmd = preg_replace("/%server/",$ServerName,$this->QueryCommand);
+          $q_cmd = preg_replace("/%action/" ,"query"      ,$this->mailQueueScript);
+          $q_cmd = preg_replace("/%server/" ,$ServerName  ,$q_cmd);
+          $q_cmd = preg_replace("/%id/"     ,""           ,$q_cmd);
 
           if($str = @shell_exec ($q_cmd)){
             if($mailQueueParser == NULL){
@@ -92,16 +94,58 @@ class mailqueue extends plugin
       }     
 
       if(!$error){
-
         /* Delete entry if requested */
-        if(isset($_GET['del'])){
-          if($mailQueueParser->IDExists($_GET['del'])){
-            $r_cmd = preg_replace("/%server/", $this->Server,$this->RemoveCommand);  
-            $r_cmd = preg_replace("/%id/",     $_GET['del'] ,$r_cmd);  
+        if((isset($_GET['act']))&&($_GET['act']=="del")){
+          if($mailQueueParser->IDExists($_GET['id'])){
+            $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;
           }
         }
 
+        /* Hold entry if requested */
+        if((isset($_GET['act']))&&($_GET['act']=="hold")){
+          if($mailQueueParser->IDExists($_GET['id'])){
+            $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;
+          }
+        }
+
+        /* Requeue entry if requested */
+        if((isset($_GET['act']))&&($_GET['act']=="requeue")){
+          if($mailQueueParser->IDExists($_GET['id'])){
+            $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(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;
+
+        }
+        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;
+
+        }
+        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;
+
+        }
+
         /* Filter data with the given */
         $mailQueueParser->OrderBy($this->OrderBy,$this->SortType);
         $mailQueueParser->OnlyDaysAgo($this->Time);
index c7f687e8d0281bbaf1c6d5b33184c0671604db7f..0d0b6def4076f5a651b038dfe0c203b6beb7478f 100644 (file)
@@ -116,7 +116,10 @@ class parseMailQueue
   /* Checks if the given MailID exists */
   function IDExists($id)
   {
-    return(((isset($this->a_parsedData[$id]))&&(is_array($this->a_parsedData[$id]))));
+    foreach($this->a_parsedData as $entry){
+      if($entry['MailID'] == $id) return(true);
+    }
+    return(false);
   }
 
   function parseAdditionalQueue($str, $server)
index 0100fafb77b42a4c81c0f2adb6d64d11b356ce3f..c950f53fd2269fb29fac1d61caa2f6a85920b507 100644 (file)
@@ -17,6 +17,9 @@
        </select>
        &nbsp;
        <input name="search" value="Search" type="submit">
+       <input name="remove_all"        value="{t}Remove all{/t}" type="submit">
+       <input name="requeue_all"       value="{t}Requeue all{/t}" type="submit">
+       <input name="hold_all"          value="{t}Hold all{/t}" type="submit">
  </p>
 </div>
 <br>
@@ -36,6 +39,8 @@
                <td><a href="{$plug}&sort=Recipient"    >{t}Recipient{/t}       {if $OrderBy == "Recipient"}{$SortType}{/if}</a></td>
                <td><a href="{$plug}&sort=Error"                >{t}Error{/t}           {if $OrderBy == "Error"}        {$SortType}{/if}</a></td>
                <td>&nbsp;</td>
+               <td>&nbsp;</td>
+               <td>&nbsp;</td>
        </tr>
 
 {counter start=0 assign=i start=1}
@@ -53,7 +58,9 @@
                <td>{$entries[$key].Sender}</td>
                <td>{$entries[$key].Recipient}</td>
                <td titel="{$entries[$key].Error}">{$entries[$key].Error}</td>
-               <td><a href="{$plug}&del={$key}"><img src="images/edittrash.png" border=0 alt="deleted"></a></td>
+               <td><a href="{$plug}&act=del&id={$entries[$key].MailID}&server={$entries[$key].Server}"><img src="images/edittrash.png" border=0 alt="deleted"></a></td>
+               <td><a href="{$plug}&act=hold&id={$entries[$key].MailID}&server={$entries[$key].Server}"><img src="images/edittrash.png" border=0 alt="deleted"></a></td>
+               <td><a href="{$plug}&act=requeue&id={$entries[$key].MailID}&server={$entries[$key].Server}"><img src="images/edittrash.png" border=0 alt="deleted"></a></td>
        </tr>
        {counter}
 {/foreach}