Code

Updated mailQ
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 9 Sep 2008 13:51:19 +0000 (13:51 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 9 Sep 2008 13:51:19 +0000 (13:51 +0000)
-You can now vie Header informations
-Page selector works now
-Server name is correctly displyed.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12380 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/mail/addons/mailqueue/class_mailqueue.inc
gosa-plugins/mail/addons/mailqueue/class_si_mailqueue.inc
gosa-plugins/mail/addons/mailqueue/contents.tpl
gosa-plugins/mail/addons/mailqueue/header.tpl

index b9dc7cf0f05891fa5e5f6b8483ca05c72d7281cb..a4ced417a762b3423ae6cb6713138efd6d2d05da 100644 (file)
@@ -77,7 +77,11 @@ class mailqueue extends plugin
     if($action == "header"){
 
       /* Create table which displays the header informations */
-      $this->disp_header = $this->si_queue->header($entry);
+      $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);
+      }
     }
 
     /* Back is posted from the header display page */
@@ -100,20 +104,27 @@ class mailqueue extends plugin
       $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,$this->range));
+        $entries = array_merge($entries,$this->si_queue->query_mailqueue($mac,$this->OrderBy,$this->SortType));
         if($this->si_queue->is_error()){
-          unset($this->ServerList[$mac]);
-          msg_dialog::display(_("Error"),sprintf(_("The server '%s' was removed from the server list, due to communication problems with the GOsa daemon, the error was: %s"),$name,"<b>".msgPool::siError($this->si_queue->get_error()."</b>")),ERROR_DIALOG);
+          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,$this->Limit);
+      $entries = $this->si_queue->query_mailqueue($this->Server,$this->OrderBy,$this->SortType);
       if($this->si_queue->is_error()){
         msg_dialog::display(_("Error"),msgPool::siError($this->si_queue->get_error()),ERROR_DIALOG);
       }
     }
 
-    
+    $count = count($entries);
+    $entries = array_slice($entries,$this->Page,$this->range);
+
+    /* Add ServerName to results 
+     */
+    foreach($entries as $key => $data){
+      $entries[$key]['ServerName'] = $this->ServerList[$data['Server']];
+    }   
     /******************
       create html output 
      ******************/
@@ -133,7 +144,7 @@ class mailqueue extends plugin
     $smarty->assign("p_times"       , $this->getTimes());
     $smarty->assign("p_timeKeys"    , array_flip($this->getTimes()));
     $smarty->assign("search_for"    , $this->Search);
-    $smarty->assign("range_selector", range_selector(count($entries), $this->Page, $this->range,"EntriesPerPage")); 
+    $smarty->assign("range_selector", range_selector($count, $this->Page, $this->range,"EntriesPerPage")); 
     $smarty->assign("OrderBy"       , $this->OrderBy);
 
     /* Display sort arrow */
index 5f5721f38a09ea316a473b782efb298707c3e3e2..58443fbad0558559462d30aa495effad2c2e55b3 100644 (file)
@@ -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, $Limit)
+  public function query_mailqueue($server,$sortby,$direction)
   {
     $attrs = array("Size","Recipient","Sender","Arrival","MailID","Hold","Active","Error","Server");
 
@@ -50,15 +50,9 @@ class si_mailqueue extends gosaSupportDaemon
       $direction = "down";
     }
 
-    /* Check entry limit 
-     */  
-    if(!is_numeric($Limit) || $Limit < 1){
-      trigger_error("Invalid entry limt '".$Limit."'.");
-      $Limit = 20;
-    }
-
     /* Query mailqueue 
      */
+    $ids = array();
     $res = $this->send_data("gosa_mailqueue_query",$server,array(),TRUE);
     $items = array(); 
     if(isset($res['XML'][0])){
@@ -74,6 +68,7 @@ class si_mailqueue extends gosaSupportDaemon
           foreach($attrs as $source => $dest){
             $val[$dest] = $entry[0][$source][0]['VALUE'];
           }
+          $ids[] = $val['MailID'];
           $attrs = array(  
               "MSG_HOLD"   => "Hold",
               "MSG_ACTIVE" => "Active",
@@ -88,7 +83,11 @@ class si_mailqueue extends gosaSupportDaemon
 
           $val['Server'] = $server;
           $val['Arrival'] = strtotime($val['Arrival']);
-          $items[$val[$sortby]] = $val;
+          $n = $val[$sortby]."-".microtime(1);
+          while(isset($items[$n])){
+            $n = $val[$sortby]."-".microtime(1);
+          }
+          $items[$n] = $val;
         }
       }
     }   
@@ -100,7 +99,6 @@ class si_mailqueue extends gosaSupportDaemon
     }else{
       krsort($items);
     }
-
     return($items);
   }
 
@@ -109,8 +107,23 @@ class si_mailqueue extends gosaSupportDaemon
   {
     $data = array();
     $data['msg_id'] = $msg_id;
-    $res = $this->send_data("gosa_mailqueue_header",$this->target,$data,TRUE);
-    print_a($res);
+    $res = $this->send_data("gosa_mailqueue_header",$server,$data,TRUE);
+  
+    $attrs = array(
+        "RECIPIENT",
+        "SENDER",
+        "SUBJECT");
+
+    $data = array();
+    if(isset($res['XML'])){
+      foreach($attrs as $attr){
+        $data[$attr] = "";
+        if(isset($res['XML'][0][$attr])){
+          $data[$attr] = $res['XML'][0][$attr][0]['VALUE'];
+        }
+      }  
+    }
+    return($data);
   }
 
  
index 5afe743cf51997b51a920e66ddf910b7ead8e4a2..81acb66711c78e102f30f5527e2e84b60f6f2eb5 100644 (file)
@@ -79,7 +79,8 @@
                        {$entries[$key].MailID}</td>
                <td> 
 <!-- onclick="javascript: document.location.href='{$plug}&amp;act=header&amp;id={$entries[$key].MailID}&amp;server={$entries[$key].Server}'"-->
-                       {$entries[$key].Server}</td>
+                       {$entries[$key].ServerName}
+               </td>
                <td>
                        {$entries[$key].Size}</td>
                <td>
index 7e90c1159ff8493da286538e9f8700a633fec458..fe88ee2d3fa363c3042644c842088736c5af2d2c 100644 (file)
@@ -1,6 +1,19 @@
-{$header}
+<table>
+       <tr>
+               <td>{t}Sender{/t}&nbsp;:</td>
+               <td>{$header.SENDER}</td>
+       </tr>
+       <tr>
+               <td>{t}Recipient{/t}&nbsp;:</td>
+               <td>{$header.RECIPIENT}</td>
+       </tr>
+       <tr>
+               <td>{t}Subject{/t}&nbsp;:</td>
+               <td><i>{$header.SUBJECT}</i></td>
+       </tr>
+</table>
 
 <p class="seperator">&nbsp;</p>
-<div style='text-align:right;'>
+<div style='text-align:right; padding:5px;'>
        <input type="submit" name="back" value="{msgPool type=backButton}"> 
 </div>