Code

Some changes for mailQueue plugin.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 23 Nov 2005 06:58:10 +0000 (06:58 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 23 Nov 2005 06:58:10 +0000 (06:58 +0000)
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

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

index a296c68afe39cbbf30e71faf51e141c62bf17e6a..b464958535970ae2b568744627685cce583a578e 100644 (file)
@@ -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:
 ?>
index 0d0b6def4076f5a651b038dfe0c203b6beb7478f..b510cb3a7922294a90df9393a88cbb1cbf2efade 100644 (file)
@@ -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);
index c950f53fd2269fb29fac1d61caa2f6a85920b507..6875357bd3a989ab1d4108939f14d5c01960c44e 100644 (file)
@@ -4,26 +4,46 @@
 </div>
 <div class="contentboxb">
  <p class="contentboxb" style="border-top: 1px solid rgb(176, 176, 176); padding-top: 5px;">
-       <img alt="" src="images/search.png" align="middle" border="0">
-               &nbsp;{t}Search for{/t}
-       <input name="search_for" size="25" maxlength="60" value="{$search_for}" title="{t}Please enter a search string here.{/t}" onchange="mainform.submit()">
-               &nbsp;in 
+  <div >
+       <table width="100%">
+               <tr>
+                       <td>
+       <img alt="{t}Search{/t}" src="images/search.png" align="middle" border="0">
+        &nbsp;{t}Search for{/t}
+    <input name="search_for" size="25" maxlength="60" value="{$search_for}" title="{t}Please enter a search string here.{/t}" onchange="mainform.submit()">
+        &nbsp;in 
        <select size="1" name="p_server" title="{t}Select a server{/t}" onchange="mainform.submit()">
-               {html_options values=$p_serverKeys output=$p_servers selected=$p_server}
+        {html_options values=$p_serverKeys output=$p_servers selected=$p_server}
        </select>
-               &nbsp;{t}within the last{/t}&nbsp;
+       {t}with status{/t} : 
+       <select size="1" name="Stat" onchange="mainform.submit()">
+        {html_options values=$stats output=$r_stats selected=$stat}
+       </select>
+        &nbsp;{t}within the last{/t}&nbsp;
        <select size="1" name="p_time" onchange="mainform.submit()">
-               {html_options values=$p_timeKeys output=$p_times selected=$p_time}
-       </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">
+        {html_options values=$p_timeKeys output=$p_times selected=$p_time}
+       </select>
+        &nbsp;
+       <input name="search" value="Search" type="submit">
+                       </td>
+                       <td width="10%">        
+                               <input name="remove_all"  src="images/edittrash.png"            value="{t}Remove all{/t}"       type="image" 
+                                       title="{t}Remove all shown entries from queue.{/t}">
+                               <input name="requeue_all" src="images/mailq_requeue.png"        value="{t}Requeue all{/t}"      type="image"
+                                       title="{t}Requeue all shown entries.{/t}">
+                               <input name="hold_all"    src="images/mailq_hold.png"           value="{t}Hold all{/t}"         type="image"
+                                       title="{t}Set all shown entries to status hold.{/t}">
+                               <input name="unhold_all"    src="images/mailq_unhold.png"               value="{t}Hold all{/t}"         type="image"
+                                       title="{t}Set all shown entries to status unhold.{/t}">
+                       </td>
+               <tr>
+       </table>
+       </div>
  </p>
 </div>
 <br>
 
+
 {if $all_ok != "true"}
 <b>{t}Search returned no results{/t}...</b>
 {else}
        {else}
                <tr style="height: 22px; background-color: rgb(245, 245, 245);">
        {/if}
-               <td>{$entries[$key].MailID}</td>
+               <td>{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 titel="{$entries[$key].Error}">{$entries[$key].Error}</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>
+               <td>
+                       <a href="{$plug}&act=del&id={$entries[$key].MailID}&server={$entries[$key].Server}">
+                               <img src="images/edittrash.png" border=0 alt="{t}delete{/t}">
+                       </a>
+               </td>
+               {if $entries[$key].Hold == true}
+               <td>
+                       <a href="{$plug}&act=unhold&id={$entries[$key].MailID}&server={$entries[$key].Server}">
+                               <img src="images/mailq_unhold.png" border=0 alt="{t}unhold{/t}">
+                       </a>
+               </td>
+               {else}
+               <td>
+                       <a href="{$plug}&act=hold&id={$entries[$key].MailID}&server={$entries[$key].Server}">
+                               <img src="images/mailq_hold.png" border=0 alt="{t}hold{/t}">
+                       </a>
+               </td>
+               {/if}
+               <td>
+                       <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}">
+                       </a>
+               </td>
        </tr>
        {counter}
 {/foreach}