summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4d23f0a)
raw | patch | inline | side by side (parent: 4d23f0a)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 4 Nov 2005 10:22:13 +0000 (10:22 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 4 Nov 2005 10:22:13 +0000 (10:22 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1829 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/plugins/addons/mailqueue/class_mailqueue.inc b/plugins/addons/mailqueue/class_mailqueue.inc
index a07c5330416d875946be6041c40d0dc091d12151..f14094f318154fa4879b8ad245358c6ccf4c9539 100644 (file)
var $QueryCommand = "";
var $RemoveCommand= "";
+ var $Server = "none";
+ var $Time = 0;
+ var $Search = "*";
+ var $Page = 0;
+ var $EntriesPerPage = 20;
+
+ var $OrderBy = "Arrival";
+ var $SortType = "up";
+
function mailqueue($config, $dn= NULL)
{
- /* Include config object */
- $this->config= $config;
+ /* Include config object */
+ $this->config= $config;
+
+ $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->QueryCommand = search_config($this->config->data['MENU'], "mailqueue", "MAILQUEUE_QUERY_COMMAND");
- $this->RemoveCommand= search_config($this->config->data['MENU'], "mailqueue", "MAILQUEUE_REMOVE_COMMAND");
+ $this->Server = "none";
}
function execute()
{
- /* Call parent execute */
- plugin::execute();
- $smarty= get_smarty();
- print search_config($this->config->data['MENU'], "mailqueue", "MAILQUEUE_QUERY_COMMAND");
- print search_config($this->config->data['MENU'], "mailqueue", "MAILQUEUE_REMOVE_COMMAND");
- return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
+ /* Call parent execute */
+ plugin::execute();
+ $smarty= get_smarty();
+
+ if($str = @shell_exec ($this->QueryCommand)){
+ $mailQueueParser = new parseMailQueue($str);
+ $mailQueueParser->OrderBy($this->OrderBy,$this->SortType);
+ $mailQueueParser->OnlyDaysAgo($this->Time);
+ $mailQueueParser->CreateDate();
+ $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("p_server",$this->Server);
+ $smarty->assign("p_servers",$this->getServer());
+ $smarty->assign("p_time", $this->Time);
+ $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, 20));
+ $smarty->assign("OrderBy",$this->OrderBy);
+ if($this->SortType == "up"){
+ $smarty->assign("SortType","<img src='images/sort_up.png' alt='"._("up")."' border='0'>");
+ }else{
+ $smarty->assign("SortType","<img src='images/sort_down.png' alt='"._("down")."' border='0'>");
+ }
+
+ }else{
+ $smarty->assign("entries",array());
+ print_red(_("Please check your 'gosa.conf' the value for 'MAILQUEUE_QUERY_COMMAND' can't be executed."));
+ }
+ return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
}
-}
+ function getServer()
+ {
+ $ret= array("none",_("none"));
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(objectClass=goMailServer)",array("cn"));
+ while($tmp = $ldap->fetch()){
+ $ret[$tmp['cn'][0]]= $tmp['cn'][0];
+ }
+ return($ret);
+ }
+ function getTimes()
+ {
+ $ret = array("all"=>_("all"));
+ for($i = 0 ; $i < 10 ; $i ++ ){
+ if($i == 1){
+ $ret[$i] = $i." "._("day ago");
+ }else{
+ $ret[$i] = $i." "._("days ago");
+ }
+ }
+ return($ret);
+ }
+
+ function save_object($save_current= FALSE)
+ {
+ if(isset($_POST['p_server'])){
+ $this->Server = $_POST['p_server'];
+ }
+ if(isset($_POST['p_time'])){
+ $this->Time = $_POST['p_time'];
+ }
+ if(isset($_POST['search_for'])){
+ $this->Search = $_POST['search_for'];
+ }
+ if((isset($_GET['start']))&&(is_numeric($_GET['start']))&&($_GET['start']>=0)){
+ $this->Page = $_GET['start'];
+ }
+
+ if((isset($_GET['sort']))&&(!empty($_GET['sort']))){
+ $old = $this->OrderBy;
+ $this->OrderBy = $_GET['sort'];
+ if($this->OrderBy == $old)
+ {
+ if($this->SortType== "up"){
+ $this->SortType = "down";
+ }else{
+ $this->SortType = "up";
+ }
+ }
+ }
+
+ }
+
+}
+// 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
--- /dev/null
@@ -0,0 +1,174 @@
+<?php
+
+class parseMailQueue
+{
+ var $s_dataToParse;
+ var $a_parsedData;
+ var $i_count;
+
+ /* Contructor
+ * $s_data specifies the data that shuold be parse
+ */
+ function parseMailQueue($s_data)
+ {
+ $this->s_dataToParse = $s_data;
+ $this->_parse();
+ }
+
+ function OnlyDaysAgo($str)
+ {
+ $cur = time();
+ if(is_numeric($str)){
+ $cur = $cur - ($str*(60*60*24));
+ foreach($this->a_parsedData as $key => $data){
+ if($data['Arrival'] < $cur){
+ unset($this->a_parsedData[$key]);
+ }
+ }
+ }
+ }
+
+ function Search($filter,$fields)
+ {
+ foreach($this->a_parsedData as $key => $data){
+ $found = false;
+
+ foreach($fields as $attr){
+ if(preg_match("/".str_replace("*",".*",$filter)."/i",$data[$attr])){
+ $found= true;
+ }
+ }
+ if($found == false){
+ unset($this->a_parsedData[$key]);
+ }
+ }
+ }
+
+ function CreateDate()
+ {
+ foreach($this->a_parsedData as $key => $data){
+ $this->a_parsedData[$key]['Arrival'] = date("d.m.Y H:i:s",$data['Arrival']);
+ }
+ }
+
+ function OrderBy($str = "Arrival",$type = "up" )
+ {
+ $tmp = array();
+ if(!in_array($str,array("MailID","Size","Sender","Recipient","Arrival","Error"))){
+ return(false);
+ }
+
+ if($str == "Size"){
+ foreach($this->a_parsedData as $data){
+ $struse = "";
+ for($i = strlen($data['Size']); $i < 10 ; $i++ ){
+ $struse .="0";
+ }
+ $struse .= $data[$str].$data['MailID'];
+ $tmp[$struse]= $data;
+ }
+ }else{
+ foreach($this->a_parsedData as $data){
+ $tmp[strtolower($data[$str]).$data['MailID']]= $data;
+ }
+ }
+ ksort($tmp);
+ if($type != "up"){
+ $tmp = array_reverse($tmp);
+ }
+ $this->a_parsedData = array();
+ foreach($tmp as $data){
+ $this->a_parsedData[$data['MailID']] = $data;
+ }
+ }
+
+ function GetAll()
+ {
+ return($this->a_parsedData);
+ }
+
+ function IDExists($id)
+ {
+ return(((isset($this->a_parsedData[$id]))&&(is_array($this->a_parsedData[$id]))));
+ }
+
+ /* This function parses the given data
+ * it creates an array with all given queue entries
+ */
+ function _parse()
+ {
+ $i = 0; // Temp var
+ $entries = array(); // Contains an array with the raw data for every single entry
+ $s_tmp = ""; // Buffer
+
+ $s_mailID = ""; // Queue ID
+ $s_Size = ""; // Mail size
+ $s_Arrival = ""; // Arrival time
+ $s_Sender = ""; // Sender
+ $s_Recipient = ""; // Recipient
+ $s_Error = ""; // Occured error
+
+ /* Remove header
+ */
+ $this->s_dataToParse = preg_replace("/^.*------\n/","",$this->s_dataToParse);
+
+ /* Create array with single entries
+ */
+ $entries = split("\n\n",$this->s_dataToParse);
+
+ /* The last entry in this array is not realy an valid entry, its some kind of status.
+ * It would be something like this : -- 795 Kbytes in 124 Requests.
+ */
+ $this->i_count = (count($entries))-1;
+
+ for($i = 0 ; $i < $this->i_count; $i ++ ){
+
+ while(strstr($entries[$i]," ")){
+ $entries[$i] = str_replace(" "," ",$entries[$i]);
+ }
+
+ $s_buffer = split("\n",preg_replace("/[\\n\\r\\t]/s","\n",$entries[$i]));
+
+ /* Get mailID */
+ $tmp = split(" ",$s_buffer[0]);
+
+ /* Get values */
+ $s_mailID = $tmp[0];
+ $s_Size = $tmp[1];
+ $s_Sender = $tmp[6];
+
+ /* Parse time */
+ $tmp3 = split(":",$tmp[5]);
+ $tmp2 = strtotime($tmp[4]." ".$tmp[3]." ".date("Y"));
+ $s_Arrival= mktime($tmp3[0],$tmp3[1],$tmp3[2],date("d",$tmp2),date("m",$tmp2),date("Y",$tmp2));
+
+ $s_Error = $s_buffer[1];
+ $s_Recipient = $s_buffer[2];
+
+ $this->a_parsedData[$s_mailID]['MailID'] = $s_mailID;
+ $this->a_parsedData[$s_mailID]['Size'] = $s_Size;
+ $this->a_parsedData[$s_mailID]['Arrival'] = $s_Arrival;
+ $this->a_parsedData[$s_mailID]['Sender'] = $s_Sender;
+ $this->a_parsedData[$s_mailID]['Recipient'] = $s_Recipient;
+ $this->a_parsedData[$s_mailID]['Error'] = $this->_parseError($s_Error);
+ }
+ return($this->a_parsedData);
+ }
+
+ function _parseError($str)
+ {
+ $str = trim(preg_replace("/[()]/","",$str));
+ $tmp2 = split(":",$str);
+ $tmp = array_reverse($tmp2);
+ $err = preg_replace("/#.*$/","",$tmp[0]);
+ $text = preg_replace("/said$/i","",trim($tmp2[0]));
+ return($err);
+ }
+
+}
+
+
+
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
index 527f9116b3abf5a3f39d93badb679c744ffabf83..438b861fa638024bf4c528b7eba3005bca32e888 100644 (file)
-Class MailQueue
+<div style="height: 5px;"> </div>
+<div class="contentboxh">
+ <p class="contentboxh"><img src="images/launch.png" alt="[F]" align="right">Filter</p>
+</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">
+ {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()">
+ in
+ <select size="1" name="p_server" title="{t}Select a server{/t}" onchange="mainform.submit()">
+ {html_options values=$p_servers output=$p_servers selected=$p_server}
+ </select>
+ {t}Select time periode{/t}
+ <select size="1" name="p_time" onchange="mainform.submit()">
+ {html_options values=$p_timeKeys output=$p_times selected=$p_time}
+ </select>
+
+ <input name="search" value="Search" type="submit">
+ </p>
+</div>
+<br>
+<table style="border: 1px solid rgb(176, 176, 176); width: 100%; vertical-align: top; text-align: left;"
+ border="0" cellpadding="2" cellspacing="1" rules="cols">
+ <tr style="background-color: rgb(232, 232, 232); height: 26px; font-weight: bold;">
+ <td><a href="{$plug}&sort=MailID" >{t}ID{/t} {if $OrderBy == "MailID"} {$SortType}{/if}</a></td>
+ <td><a href="{$plug}&sort=Size" >{t}Size{/t} {if $OrderBy == "Size"} {$SortType}{/if}</a></td>
+ <td><a href="{$plug}&sort=Arrival" >{t}Arrival{/t} {if $OrderBy == "Arrival"} {$SortType}{/if}</a></td>
+ <td><a href="{$plug}&sort=Sender" >{t}Sender{/t} {if $OrderBy == "Sender"} {$SortType}{/if}</a></td>
+ <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>
+ </tr>
+
+{counter start=0 assign=i start=1}
+{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>{$entries[$key].MailID}</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>
+ </tr>
+ {counter}
+{/foreach}
+</table>
+
+ <table summary="" style="width:100%; vertical-align:top; text-align:center;" cellpadding=4 cellspacing=0 border=0>
+ <tr>
+ <td>{$range_selector}</td>
+ </tr>
+ </table>
+<p class="plugbottom">
+
+</p>
+
+
index 1069618a6e16b46b76a35e9e139a30ff6d008413..1c0b3fcdc73baac664bde1a9c5f936b62f35556a 100644 (file)
$mailqueue= $_SESSION['mailqueue'];
/* Execute formular */
+ $mailqueue->save_object();
$display.= $mailqueue->execute ();
$display.= "<input type=\"hidden\" name=\"ignore\">\n";
diff --git a/plugins/admin/systems/class_servService.inc b/plugins/admin/systems/class_servService.inc
index 66e2b58717f9be424d7d1b42e27dabd8f7d864e0..627cb5a95d82761ebcf50177a666ad19dcb18892 100644 (file)
var $goTerminalServer = "";
var $goSyslogServer = "";
var $goCupsServer = "";
+ var $goMailServer = "";
var $o_subWindow = NULL;
/* attribute list for save action */
var $ignore_account= TRUE;
var $attributes = array("goLdapBase","goXdmcpIsEnabled","goFontPath");
var $possible_objectclasses= array( "goShareServer", "goNtpServer", "goServer", "goLdapServer",
- "goTerminalServer", "goSyslogServer", "goCupsServer");
+ "goTerminalServer", "goSyslogServer", "goCupsServer","goMailServer");
var $objectclasses = array( "top","goServer");
var $additionaloc = array( "goShareServer" => array("goExportEntry"),
"goNtpServer" => array("goTimeSource"),
"goLdapServer" => array("goLdapBase"),
"goTerminalServer"=> array("goXdmcpIsEnabled", "goFontPath"),
"goSyslogServer" => array(),
+ "goMailServer" => array(),
"goCupsServer" => array());
function servservice ($config, $dn= NULL)
index f0b1c5a210e98858af9515e69f3192993d8b63fd..8bde624321e9f6a42aba88007c605388ee1f5ab5 100644 (file)
<input type=checkbox name="goCupsServer" value="1" {$goCupsServer} {$goCupsServerACL}>
<b>{t}Print Service{/t}</b>
+
+ <p class="seperator"> </p>
+ <br>
+
+
+ <input type=checkbox name="goMailServer" value="1" {$goMailServer} {$goMailServerACL}>
+
+ <b>{t}Mail server{/t}</b>
</td>
</tr>
</table>