summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 56c2b7c)
raw | patch | inline | side by side (parent: 56c2b7c)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 17 Jan 2008 08:32:38 +0000 (08:32 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 17 Jan 2008 08:32:38 +0000 (08:32 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8432 594d385d-05f5-0310-b6e9-bd551577e9d8
44 files changed:
diff --git a/gosa-core/plugins/addons/mailqueue/class_mailqueue.inc b/gosa-core/plugins/addons/mailqueue/class_mailqueue.inc
+++ /dev/null
@@ -1,417 +0,0 @@
-<?php
-
-class mailqueue extends plugin
-{
- /* Definitions */
- var $plHeadline= "Mail queue";
- var $plDescription= "This does something";
-
- /* attribute list for save action */
- var $attributes = array();
- var $objectclasses = array();
- var $mailQueueScript= "";
- var $Server = "all";
- var $Time = 0;
- var $Search = "*";
- var $Page = 0;
- var $Stat = "all";
- var $OrderBy = "Arrival";
- var $SortType = "up";
- var $disp_header = false;
- var $range = 20;
- var $view_logged = FALSE;
-
- function mailqueue(&$config, $dn= NULL)
- {
- $this->config = &$config;
- if (isset($this->config->current['MAILQUEUESCRIPTPATH'])){
- $this->mailQueueScript = $this->config->current['MAILQUEUESCRIPTPATH'];
- }
-
- if(isset($this->config->data['MAIN']['MAILQUEUESCRIPTPATH'])){
- $this->mailQueueScript = $this->config->data['MAIN']['MAILQUEUESCRIPTPATH'];
- }
-
- $this->Server = "all";
- }
-
-
- function pass_cmd($str)
- {
- return(shell_exec($str));
- }
-
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- /* Log view */
- if(!$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","mailqueue/".get_class($this),$this->dn);
- }
-
- if(isset($_POST['EntriesPerPage'])){
- $this->range = $_POST['EntriesPerPage'];
- }
-
- $smarty= get_smarty();
- $error =false;
-
- if(empty($this->mailQueueScript)){
- msg_dialog::display(_("Configuration error"), sprintf(_("Missing '%s' directive in configuration!"), "mailqueuescriptpath"), ERROR_DIALOG);
- $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","del_all","requeue_all") as $attr){
- foreach($_POST as $name => $value){
- if((preg_match("/".$attr."/",$name))&&($only_once)){
- if(!$this->acl_is_readable($attr)){
- $only_once = false;
- msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to submit a '%s' command!"), $attr), ERROR_DIALOG);
- }else{
- $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)==false){
- msg_dialog::display(_("Configuration error"), sprintf(_("'%s' defined for the '%s' directive cannot be executed!"), $r_cmd, "mailqueuescriptpath"), ERROR_DIALOG);
- }
- }
- }
- }
- }
-
- /* 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;
-
- if(!$this->acl_is_readable($opt)){
- msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to submit a '%s' command!"), $opt), ERROR_DIALOG);
- }else{
- /* 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)){
- msg_dialog::display(_("Configuration error"), sprintf(_("'%s' defined for the '%s' directive cannot be executed!"), $r_cmd, "mailqueuescriptpath"), ERROR_DIALOG);
- }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"){
-
- /* Create Query cmd */
- $q_cmd = preg_replace("/%action/" ,"query" ,$this->mailQueueScript);
- $q_cmd = preg_replace("/%server/" ,$this->Server,$q_cmd);
- $q_cmd = preg_replace("/%id/" ,"all" ,$q_cmd);
-
- if(!$this->acl_is_readable("query")){
- msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to submit a '%s' command!"), "query"), ERROR_DIALOG);
- $mailQueueParser = new parseMailQueue("",$this->Server);
- }else{
-
- /* Only display this if the query cmd is executeable */
- if($str = @$this->pass_cmd ($q_cmd)){
- /* Parse returned data */
- $mailQueueParser = new parseMailQueue($str,$this->Server);
- }else{
- /* On error/ no return value / false return value */
- msg_dialog::display(_("Configuration error"), sprintf(_("'%s' defined for the '%s' directive cannot be executed!"), $q_cmd, "mailqueuescriptpath"), ERROR_DIALOG);
- $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(!$this->acl_is_readable("query")){
- msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to submit a '%s' command!"), "query"), ERROR_DIALOG);
- $mailQueueParser = new parseMailQueue("",$this->Server);
- }else{
-
- /* 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{
- msg_dialog::display(_("Configuration error"), sprintf(_("'%s' defined for the '%s' directive cannot be executed!"), $q_cmd, "mailqueuescriptpath"), ERROR_DIALOG);
- $error = true;
- }
- }
- }
- }
-
- /* Check for existing servers
- objectClass=goMailServer is required at least for one server.
- Else display error */
- $server = $this->getServer();
- if((count($server) == 1 ) && (isset($server['all']))){
- msg_dialog::display(_("Configuration error"), _("No mail servers sepcified!"), ERROR_DIALOG);
- $error = true;
- }
-
- if(!$error){
-
- /* 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();
-
- if(count($entries) ==0 ){
- $smarty->assign("all_ok",false);
- }
-
- $smarty->assign("entries" , array_slice($entries,$this->Page,$this->range));
- $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()));
- $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, $this->range,"EntriesPerPage"));
- $smarty->assign("OrderBy" , $this->OrderBy);
-
- /* Display sort arrow */
- 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'>");
- }
- }
- }
-
- /* 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("stat" , $this->Stat);
- $smarty->assign("plug" , "?plug=".$_GET['plug']);
- $smarty->assign("p_server" , $this->Server);
- $smarty->assign("p_servers" , $this->getServer());
- $smarty->assign("p_serverKeys" , array_flip($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("OrderBy" , $this->OrderBy);
- }
- return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
- }
-
-
- /* return selectable server */
- function getServer()
- {
- $ret= array("all"=>_("All"));
- $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);
- }
-
-
- /* Return selectable times*/
- function getTimes()
- {
- $ret = array();
- $ret['nolimit']=_("no limit");
- foreach(array(1,2,4,8,12,24,36,48) as $i){
- if($i == 1){
- $ret[$i] = $i." "._("hour");
- }else{
- $ret[$i] = $i." "._("hours");
- }
- }
- return($ret);
- }
-
-
- /* Save post values*/
- 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($_POST['Stat'])){
- $this->Stat = $_POST['Stat'];
- }
- 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";
- }
- }
- }
-
- }
-
- /* Return stats */
- function getStats()
- {
- return(array(
- "all" =>_("All"),
- "hold" =>_("Hold"),
- "unhold" =>_("Un hold"),
- "active" =>_("Active"),
- "nonactive" =>_("Not active")
- ));
- }
-
- /* Return plugin informations for acl handling
- #FIXME You can only read attributes within this report plugin */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Mailqueue"),
- "plDescription" => _("Mailqueue addon"),
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 1,
- "plSection" => array("addon"),
- "plCategory" => array("mailqueue" => array("objectClass" => "none", "description" => _("Mail queue addon"))),
-
- "plProvidedAcls" => array(
- "unhold_all" => _("Unhold all messages"),
- "hold_all" => _("Hold all messages"),
- "del_all" => _("Delete all messages"),
- "requeue_all" => _("Requeue all messages"),
- "unhold" => _("Unhold message"),
- "hold" => _("Hold message"),
- "del" => _("Delete message"),
- "requeue" => _("Requeue message"),
- "query" => _("Gathering queue data"),
- "header" => _("Get header information")
- )
- ));
- }
-
-
-
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/addons/mailqueue/class_parseMailQueue.inc b/gosa-core/plugins/addons/mailqueue/class_parseMailQueue.inc
+++ /dev/null
@@ -1,237 +0,0 @@
-<?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,$server)
- {
- $this->s_dataToParse = $s_data;
- $this->a_parsedData = array();
- $this->_parse($s_data,$server);
- }
-
-
- /* Remove all entries which are older than the last x hours
- */
- function OnlyDaysAgo($str)
- {
- /* Get current time */
- $cur = time();
-
- /* Only perform this filter, if the given parameter is valid */
- if((is_numeric($str))&&($str != 0)){
-
- /* hours are given as parameter */
- $cur = $cur - ($str*(60*60));
-
- /* Remove old entries */
- foreach($this->a_parsedData as $key => $data){
- if($data['Arrival'] < $cur){
- unset($this->a_parsedData[$key]);
- }
- }
- }
- }
-
-
- /* Only keep entries that contains the $filter
- * in any of the given $fields
- */
- function Search($filter,$fields,$bool = false)
- {
- /* Go through all entries */
- foreach($this->a_parsedData as $key => $data){
-
- /* not found yet */
- $found = false;
-
- foreach($fields as $attr){
- if(($bool)&&($data[$attr]==$filter)){
- $found = true;
- }elseif(preg_match("/".str_replace("*",".*",$filter)."/i",$data[$attr])){
- $found= true;
- }
- }
-
- /* if nothing found, delete this entry */
- if($found == false){
- unset($this->a_parsedData[$key]);
- }
- }
- }
-
- /* Convert date from timestamp to human readable */
- function CreateDate()
- {
- foreach($this->a_parsedData as $key => $data){
- $this->a_parsedData[$key]['Arrival'] = date("d.m.Y H:i:s",$data['Arrival']);
- }
- }
-
- /* Order by specified field */
- function OrderBy($str = "Arrival",$type = "up" )
- {
- $tmp = array();
- /* If the given field is not valid */
- if(!in_array($str,array("MailID","Size","Sender","Recipient","Arrival","Error","Server"))){
- return(false);
- }
-
- /* Size need special handling, cause it contains numbers
- */
- 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'].$data['Server'];
- $tmp[$struse]= $data;
- }
- }else{
- foreach($this->a_parsedData as $data){
- $tmp[strtolower($data[$str]).$data['MailID']."-".$data['Server']]= $data;
- }
- }
- ksort($tmp);
- if($type != "up"){
- $tmp = array_reverse($tmp);
- }
- $this->a_parsedData = array();
- foreach($tmp as $data){
- $this->a_parsedData[$data['MailID']."-".$data['Server']] = $data;
- }
- return(true);
- }
-
- function GetAll()
- {
- return($this->a_parsedData);
- }
-
- /* Checks if the given MailID exists */
- function IDExists($id)
- {
- foreach($this->a_parsedData as $entry){
- if($entry['MailID'] == $id) return(true);
- }
- return(false);
- }
-
- function parseAdditionalQueue($str, $server)
- {
- $this->_parse($str, $server);
- }
-
- /* This function parses the given data
- * it creates an array with all given queue entries
- */
- function _parse($str, $server)
- {
- $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/","",$str);
-
- /* 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];
-
- /*
- * 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;
- $this->a_parsedData[$s_mailID."-".$server]['Size'] = $s_Size;
- $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);
- }
-
- /* Parse Error part of the entry */
- 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:
-?>
diff --git a/gosa-core/plugins/addons/mailqueue/contents.tpl b/gosa-core/plugins/addons/mailqueue/contents.tpl
+++ /dev/null
@@ -1,130 +0,0 @@
-<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">
- <div >
- <table width="100%" summary="">
- <tr>
- <td>
- <img class="center" alt="{t}Search{/t}" src="images/search.png" align="middle" border="0">
- {t}Search for{/t}
- <input name="search_for" size="12" 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_serverKeys output=$p_servers selected=$p_server}
- </select>
- {t}with status{/t} :
- <select size="1" name="Stat" onchange="mainform.submit()">
- {html_options values=$stats output=$r_stats selected=$stat}
- </select>
- {t}within the last{/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="{t}Search{/t}" type="submit">
- </td>
- <td style="border-left:1px solid #A0A0A0; text-align:right;">
- <input name="del_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"
- 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"
- title="{t}Requeue all messages in selected servers queue{/t}">
- </td>
- </tr>
- </table>
- </div>
-</div>
-<br>
-
-
-{if $all_ok != "true"}
-<b>{t}Search returned no results{/t}...</b>
-{else}
-
-<table style="border: 1px solid rgb(176, 176, 176); width: 100%; vertical-align: top; text-align: left;" summary=""
- 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=Server" >{t}Server{/t} {if $OrderBy == "Server"} {$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>
- <td> </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 >
-<!-- 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 class="center" src="images/mailq_active.png" border=0 alt="{t}Active{/t}">
- {/if}
-
- {$entries[$key].MailID}</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 >{$entries[$key].Error}</td>
- <td style="text-align:right">
- <a href="{$plug}&act=del&id={$entries[$key].MailID}&server={$entries[$key].Server}">
- <img class="center" src="images/edittrash.png" border=0 alt="{t}delete{/t}" title="{t}Delete this message{/t}">
- </a>
- {if $entries[$key].Hold == true}
- <a href="{$plug}&act=unhold&id={$entries[$key].MailID}&server={$entries[$key].Server}">
- <img class="center" src="images/mailq_unhold.png" border=0 alt="{t}unhold{/t}" title="{t}Release message{/t}">
- </a>
- {else}
- <a href="{$plug}&act=hold&id={$entries[$key].MailID}&server={$entries[$key].Server}">
- <img class="center" src="images/mailq_hold.png" border=0 alt="{t}hold{/t}" title="{t}Hold message{/t}">
- </a>
- {/if}
- <a href="{$plug}&act=requeue&id={$entries[$key].MailID}&server={$entries[$key].Server}">
- <img class="center" 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 class="center" src="images/mailq_header.png" border=0 alt="{t}header{/t}" title="{t}Display header from this message{/t}">
- </a>
- </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>
-
-{/if}
-
-<script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('search_for');
- -->
-</script>
diff --git a/gosa-core/plugins/addons/mailqueue/header.tpl b/gosa-core/plugins/addons/mailqueue/header.tpl
+++ /dev/null
@@ -1,6 +0,0 @@
-{$header}
-
-<p class="seperator"> </p>
-<div style='text-align:right;'>
- <input type="submit" name="back" value="{t}Back{/t}">
-</div>
diff --git a/gosa-core/plugins/addons/mailqueue/main.inc b/gosa-core/plugins/addons/mailqueue/main.inc
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2003 Cajus Pollmeier
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-if (!$remove_lock){
- /* Create mailqueue object on demand */
- if (!session::is_set('mailqueue') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
- $ui = get_userinfo();
- $mailqueue= new mailqueue ($config);
- $mailqueue->set_acl_category("mailqueue");
-
- /* Check root dn and user dn for acl informations */
- $mailqueue->set_acl_base($config->current['BASE']);
- if($mailqueue->getacl("") == ""){
- $mailqueue->set_acl_base($ui->dn);
- }
- session::set('mailqueue',$mailqueue);
- }
- $mailqueue = session::get('mailqueue');
-
- /* Execute formular */
- $mailqueue->save_object();
- $display= $mailqueue->execute ();
- $display.= "<input type=\"hidden\" name=\"ignore\">\n";
-
- /* Page header*/
- $display= print_header(get_template_path('images/mailqueue.png'), _("Mail queue")).$display;
-
- /* Store changes in session */
- session::set('mailqueue',$mailqueue);
-}
-?>
diff --git a/gosa-core/plugins/admin/systems/services/mail/class_goMailServer.inc b/gosa-core/plugins/admin/systems/services/mail/class_goMailServer.inc
+++ /dev/null
@@ -1,725 +0,0 @@
-<?php
-
-class goMailServer extends goService{
-
- var $cli_summary = "This pluign is used within the ServerService Pluign \nand indicates that this server supports mailqueue listings and so on.";
- var $cli_description = "Some longer text\nfor help";
- var $cli_parameters = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* This plugin only writes its objectClass */
- var $objectclasses = array("goMailServer");
-
- /* This class can't be assigned twice so it conflicts with itsself */
- var $DisplayName = "";
- var $dn = NULL;
- var $StatusFlag = "goMailServerStatus";
- var $attributes = array("description","postfixHeaderSizeLimit",
- "postfixMailboxSizeLimit","postfixMessageSizeLimit",
- "postfixMyDestinations","postfixMyDomain","postfixMyhostname",
- "postfixMyNetworks","postfixRelayhost","postfixTransportTable",
- "postfixSenderRestrictions","postfixRecipientRestrictions");
-
- var $goMailServerStatus ;
- var $postfixHeaderSizeLimit = 0;
- var $postfixMailboxSizeLimit = 0;
- var $postfixMessageSizeLimit = 0;
- var $postfixMyDestinations = array();
- var $postfixMyDomain = "";
- var $postfixMyhostname = "";
- var $postfixMyNetworks = array();
- var $postfixRelayhost = "";
- var $postfixTransportTable = array();
- var $postfixSenderRestrictions = array();
- var $postfixRecipientRestrictions = array();
- var $description = "";
- var $RestrictionFilters = array();
- var $TransportProtocols = array();
- var $Actions = array();
- var $cn = "";
- var $conflicts = array("goMailServer","kolab");
- var $view_logged =FALSE;
-
- function goMailServer(&$config,$dn)
- {
- goService::goService($config,$dn);
- $this->DisplayName = _("Mail smtp service (Postfix)");
-
- $this->Actions = array( SERVICE_STOPPED=>SERVICE_STOPPED,
- SERVICE_STARTED => SERVICE_STARTED,
- SERVICE_RESTARTED=>SERVICE_RESTARTED);
-
- /* Fill RestrictionFilters TransportProtocols from external hooks */
- $str = $this->config->data['TABS']['SERVERSERVICE'];
- $this->TransportProtocols =array("smtp"=>"SMTP");
- $this->RestrictionFilters = array("FILTER"=>"FILTER");
- foreach(array("ADDITIONALRESTRICTIONFILTERS"=>"RestrictionFilters",
- "ADDITIONALPROTOCOLLS" =>"TransportProtocols") as $file => $var){
- if(isset($this->config->data['MAIN'][$file])){
- $file = $this->config->data['MAIN'][$file];
- if((isset($file)) && is_readable($file)){
- $tmp = file_get_contents($file);
- $tmp2= split("\n",$tmp);
- foreach($tmp2 as $entry){
- if(empty($entry)) continue;
- if(preg_match("/:/",$entry)){
- $tmp3 = split(":",$entry);
- $r = $this->$var;
- $r[$tmp3[0]]=$tmp3[1];
- $this->$var = $r;
- }else{
- $r = $this->$var;
- $r[$entry] =$entry;
- $this->$var = $r;
- }
- }
- }
- }
- }
-
-
- /* Get postfix my networks */
- $this->postfixMyNetworks = array();
- $tmp = array();
- if(isset($this->attrs['postfixMyNetworks'][0])){
- $tmp = split(",",$this->attrs['postfixMyNetworks'][0]);
- foreach($tmp as $str){
- if(!empty($str)){
- $this->postfixMyNetworks[base64_encode($str)] = $str;
- }
- }
- }
-
-
- /* Create full name */
- if(isset($this->attrs['postfixMyDomain'][0])){
- $this->postfixMyhostname .= ".".$this->attrs['postfixMyDomain'][0];
- }
-
-
- /* Get postfix my domains */
- $this->postfixMyDestinations = array();
- if(isset($this->attrs['postfixMyDestinations'][0])){
- unset($this->attrs['postfixMyDestinations']['count']);
- foreach($this->attrs['postfixMyDestinations'] as $str){
- $this->postfixMyDestinations[base64_encode($str)] = $str;
- }
- }
-
-
- /* Get transport tables */
- $tmp = array();
- $this->postfixTransportTable = array();
- if(isset($this->attrs['postfixTransportTable'])){
- $tmp = array();
- unset($this->attrs['postfixTransportTable']['count']);
- foreach($this->attrs['postfixTransportTable'] as $entry){
-
- //0: offshore.vip.ms-europa.lhsystems.com smtp:172.28.0.2
-
- $Number = preg_replace('/^([^:]+):.*$/', '\\1', $entry);
- $Rest = trim(preg_replace("/^[0-9]*:/","",$entry));
-
- $Protocol_Destination = preg_replace("/^.*\ /","",$Rest);
- $Source = preg_replace("/\ .*$/","",$Rest);
-
- $Protocol = preg_replace ('/^([^:]+):.*$/', '\\1' ,trim($Protocol_Destination));
- $Destination = preg_replace ('/^[^:]+:(.*)$/', '\\1' ,trim($Protocol_Destination));
-
- $Destination = preg_replace ("/[\[\]]/","",$Destination);
-
- $tmp[$Number]['src'] = $Source;
- $tmp[$Number]['dst'] = $Destination;
- $tmp[$Number]['prt'] = $Protocol;
- }
- ksort($tmp);
- foreach($tmp as $entry){
- $this->postfixTransportTable[] = $entry;
- }
- }
-
-
- /* Get sender restrictions */
- $tmp = array();
- $this->postfixSenderRestrictions = array();
- if(isset($this->attrs['postfixSenderRestrictions'])){
- unset($this->attrs['postfixSenderRestrictions']['count']);
- foreach($this->attrs['postfixSenderRestrictions'] as $entry){
- $nr = preg_replace("/:.*$/","",$entry);
- $rest= trim(preg_replace("/^[^:]+:/","",$entry));
- $src = preg_replace("/ .*$/","",$rest);
- $rest= preg_replace("/^[^ ]+ /","",$rest);
- $dst = preg_replace("/^.* /","",$rest);
- $prt = preg_replace("/ .*$/","",$rest);
-
- $tmp[$nr]['src'] = $src;
- $tmp[$nr]['dst'] = $dst;
- $tmp[$nr]['filter'] = $prt;
- }
- ksort($tmp);
- foreach($tmp as $entry){
- $this->postfixSenderRestrictions[] = $entry;
- }
- }
-
-
- /* Get sender restrictions */
- $tmp = array();
- $this->postfixRecipientRestrictions = array();
- if(isset($this->attrs['postfixRecipientRestrictions'])){
- unset($this->attrs['postfixRecipientRestrictions']['count']);
- foreach($this->attrs['postfixRecipientRestrictions'] as $entry){
- $nr = preg_replace("/:.*$/","",$entry);
- $rest= trim(preg_replace("/^[^:]+:/","",$entry));
- $src = preg_replace("/ .*$/","",$rest);
- $rest= preg_replace("/^[^ ]+ /","",$rest);
- $dst = preg_replace("/^.* /","",$rest);
- $prt = preg_replace("/ .*$/","",$rest);
-
- $tmp[$nr]['src'] = $src;
- $tmp[$nr]['dst'] = $dst;
- $tmp[$nr]['filter'] = $prt;
- }
- ksort($tmp);
- foreach($tmp as $entry){
- $this->postfixRecipientRestrictions[] = $entry;
- }
- }
-
- }
-
- function execute()
- {
- $smarty = get_smarty();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation){
- $smarty->assign($name."ACL",$this->getacl($name));
- }
-
- $delAr = array(
- "TranslationDel_"=>"TranslationDel",
- "SenderRestrictDel_"=>"SenderRestrictDel",
- "RecipientRestrictDel_"=>"RecipientRestrictDel");
-
- $once = true;
- $s_action = "";
- $s_entry = "";
-
- /* Check posts for some intruductions */
- foreach($_POST as $name => $value){
- foreach($delAr as $preg => $type){
- if((preg_match("/^".$preg."/",$name)) && ($once)){
- $once = false;
- $s_action = $type;
- $s_entry = preg_replace("/^".$preg."/","",$name);
- $s_entry = preg_replace("/_[xy]$/","",$s_entry);
- }
- }
-
-
- if(preg_match("/^TranslationUp_/",$name) && $once && ($this->acl_is_writeablei("postfixTransportTableACL"))){
- $once = false;
- $key = preg_replace("/^TranslationUp_/","",$name);
- $key = preg_replace("/_[xy]$/","",$key);
- $this->postfixTransportTable = $this->ArrayUp($key,$this->postfixTransportTable) ;
- }
- if(preg_match("/^TranslationDown_/",$name) && $once && ($this->acl_is_writeable("postfixTransportTableACL"))){
- $once = false;
- $key = preg_replace("/^TranslationDown_/","",$name);
- $key = preg_replace("/_[xy]$/","",$key);
- $this->postfixTransportTable = $this->ArrayDown($key,$this->postfixTransportTable) ;
- }
- if(preg_match("/^SenderRestrictUp_/",$name) && $once && ($this->acl_is_writeable("postfixSenderRestrictionsACL"))){
- $once = false;
- $key = preg_replace("/^SenderRestrictUp_/","",$name);
- $key = preg_replace("/_[xy]$/","",$key);
- $this->postfixSenderRestrictions = $this->ArrayUp($key,$this->postfixSenderRestrictions) ;
- }
- if(preg_match("/^SenderRestrictDown_/",$name) && $once && ($this->acl_is_writeable("postfixSenderRestrictionsACL"))){
- $once = false;
- $key = preg_replace("/^SenderRestrictDown_/","",$name);
- $key = preg_replace("/_[xy]$/","",$key);
- $this->postfixSenderRestrictions = $this->ArrayDown($key,$this->postfixSenderRestrictions) ;
- }
- if(preg_match("/^RecipientRestrictUp_/",$name) && $once && ($this->acl_is_writeable("postfixRecipientRestrictionsACL"))){
- $once = false;
- $key = preg_replace("/^RecipientRestrictUp_/","",$name);
- $key = preg_replace("/_[xy]$/","",$key);
- $this->postfixRecipientRestrictions = $this->ArrayUp($key,$this->postfixRecipientRestrictions) ;
- }
- if(preg_match("/^RecipientRestrictDown_/",$name) && $once && ($this->acl_is_writeable("postfixRecipientRestrictionsACL"))){
- $once = false;
- $key = preg_replace("/^RecipientRestrictDown_/","",$name);
- $key = preg_replace("/_[xy]$/","",$key);
- $this->postfixRecipientRestrictions = $this->ArrayDown($key,$this->postfixRecipientRestrictions) ;
- }
- }
-
-
- /* Add delete my network entry */
- if((isset($_POST['AddpostfixMyNetworks'])) && (!empty($_POST['NewString_postfixMyNetworks']))){
- $str = $_POST['NewString_postfixMyNetworks'];
- $this->postfixMyNetworks[base64_encode($str)] = $str;
- }
-
- if((isset($_POST['DelpostfixMyNetworks'])) && isset($_POST['Select_postfixMyNetworks']) &&(count($_POST['Select_postfixMyNetworks']))){
- foreach($_POST['Select_postfixMyNetworks'] as $str ){
- unset($this->postfixMyNetworks[$str]);
- }
- }
-
-
- /* Add delete my domain entry */
- if($this->acl_is_writeable("postfixMyDestinations")){
- if((isset($_POST['AddpostfixMyDestinations'])) && (!empty($_POST['NewString_postfixMyDestinations']))){
- $str = $_POST['NewString_postfixMyDestinations'];
- $this->postfixMyDestinations[base64_encode($str)] = $str;
- }
-
- if((isset($_POST['DelpostfixMyDestinations'])) && isset($_POST['Select_postfixMyDestinations']) &&(count($_POST['Select_postfixMyDestinations']))){
- foreach($_POST['Select_postfixMyDestinations'] as $str ){
- unset($this->postfixMyDestinations[$str]);
- }
- }
- }
-
-
- /* Add sender restriction */
- if($this->acl_is_writeable("postfixSenderRestrictions")){
- if(($s_action == "SenderRestrictDel") && (isset($this->postfixSenderRestrictions[$s_entry]))){
- unset($this->postfixSenderRestrictions[$s_entry]);
- }
-
- if(isset($_POST['AddpostfixSenderRestrictions'])){
- $src = $_POST['Source_postfixSenderRestrictions'];
- $dst = $_POST['Destination_postfixSenderRestrictions'];
- $Filter = $_POST['SenderRestrictionFilter'];
- $tmp['src'] = $src;
- $tmp['dst'] = $dst;
- $tmp['filter'] = $Filter;
- $this->postfixSenderRestrictions[] = $tmp;
- }
- }
-
-
- /* Add sender restriction */
- if($this->acl_is_writeable("postfixRecipientRestrictions")){
- if(($s_action == "RecipientRestrictDel") && (isset($this->postfixRecipientRestrictions[$s_entry]))){
- unset($this->postfixRecipientRestrictions[$s_entry]);
- }
-
- if(isset($_POST['AddpostfixRecipientRestrictions'])){
- $src = $_POST['Source_postfixRecipientRestrictions'];
- $dst = $_POST['Destination_postfixRecipientRestrictions'];
- $Filter = $_POST['RecipientRestrictionFilter'];
- $tmp['src'] = $src;
- $tmp['dst'] = $dst;
- $tmp['filter'] = $Filter;
- $this->postfixRecipientRestrictions[] = $tmp;
- }
- }
-
- /* Handle transports */
- if($this->acl_is_writeable("postfixTransportTable")){
- if(($s_action == "TranslationDel") && (isset($this->postfixTransportTable[$s_entry]))){
- unset($this->postfixTransportTable[$s_entry]);
- }
-
- if(isset($_POST['AddpostfixTransportTable'])){
- $src = trim($_POST['Source_postfixTransportTable']);
- $dst = trim($_POST['Destination_postfixTransportTable']);
- $prt = trim($_POST['TransportProtocol']);
-
- if((!empty($src)) && (!empty($dst))){
- if(preg_match("/:/",$dst)){
- $tmp = split("\:",$dst);
- $port = trim($tmp[1]);
- $ip = trim($tmp[0]);
-
- if((tests::is_ip($ip)) && (is_numeric($port))){
- $dst = "[".$ip."]:".$port;
- }
- }
- if(tests::is_ip($dst)){
- $dst = "[".$dst."]";
- }
- $tmp2 ['src'] = $src;
- $tmp2 ['dst'] = $dst;
- $tmp2 ['prt'] = $prt;
-
- $this->postfixTransportTable[] = $tmp2;
- }
- }
- }
-
- /* Set attributes */
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
-
-
- /* Create divList for translation tables */
- $divTranslation = new divSelectBox("TransportProtocols");
- $divTranslation->SetHeight(90);
- foreach($this->postfixTransportTable as $key => $entry){
- $img = "";
-
- if($key != 0 && $this->acl_is_writeable("postfixTransportTable")){
- $img.= "<input type='image' src='images/sort_up.png' name='TranslationUp_".$key."' class='center'> ";
- }else{
- $img.= "<img src='images/empty.png' style='width:10px;'>";
- }
- if(($key+1) < count($this->postfixTransportTable) && $this->acl_is_writeable("postfixTransportTable")){
- $img.= "<input type='image' src='images/sort_down.png' name='TranslationDown_".$key."' class='center'> ";
- }else{
- $img.= "<img src='images/empty.png' style='width:10px;'>";
- }
-
- if($this->acl_is_writeable("postfixTransportTable")){
- $img.= "<input type='image' src='images/edittrash.png' name='TranslationDel_".$key."' class='center'> ";
- }
- $field1 = array("string"=> $entry['src']);
- $field2 = array("string"=> $entry['dst']);
- $field3 = array("string"=> $entry['prt'],"attach"=>"style='width:120px;'");
- $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
- $divTranslation->AddEntry(array($field1,$field2,$field3,$field4,));
- }
- $smarty->assign("Div_postfixTransportTable" ,$divTranslation->DrawList());
-
-
- /* Create divList for sender restrictions */
- $DivSenderRestrict = new divSelectBox("postfixSenderRestrictions");
- $DivSenderRestrict->SetHeight(90);
- foreach($this->postfixSenderRestrictions as $key => $entry){
- $img ="";
-
- if($key != 0 && $this->acl_is_writeable("postfixSenderRestrictions")){
- $img.= "<input type='image' src='images/sort_up.png' name='SenderRestrictUp_".$key."' class='center'> ";
- }else{
- $img.= "<img src='images/empty.png' style='width:10px;'>";
- }
- if(($key+1) < count($this->postfixSenderRestrictions) && $this->acl_is_writeable("postfixSenderRestrictions")){
- $img.= "<input type='image' src='images/sort_down.png' name='SenderRestrictDown_".$key."' class='center'> ";
- }else{
- $img.= "<img src='images/empty.png' style='width:10px;'>";
- }
-
- if($this->acl_is_writeable("postfixSenderRestrictions")){
- $img.= "<input type='image' src='images/edittrash.png' name='SenderRestrictDel_".$key."' class='center'> ";
- }
-
- $field1 = array("string"=> $entry['src']);
- $field2 = array("string"=> $entry['dst']);
- $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'");
- $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
- $DivSenderRestrict->AddEntry(array($field1,$field2,$field3,$field4,));
- }
- $smarty->assign("Div_postfixSenderRestrictions" ,$DivSenderRestrict->DrawList());
-
-
- /* Create divList for translation tables */
- $DivRecipientRestrict = new divSelectBox("postfixRecipientRestrictions");
- $DivRecipientRestrict->SetHeight(90);
-
- foreach($this->postfixRecipientRestrictions as $key => $entry){
- $img = "";
- if($key != 0 && $this->acl_is_writeable("postfixRecipientRestrictions")){
- $img.= "<input type='image' src='images/sort_up.png' name='RecipientRestrictUp_".$key."' class='center'> ";
- }else{
- $img.= "<img src='images/empty.png' style='width:10px;'>";
- }
- if(($key+1) < count($this->postfixRecipientRestrictions) && $this->acl_is_writeable("postfixRecipientRestrictions")){
- $img.= "<input type='image' src='images/sort_down.png' name='RecipientRestrictDown_".$key."' class='center'> ";
- }else{
- $img.= "<img src='images/empty.png' style='width:10px;'>";
- }
-
- if($this->acl_is_writeable("postfixRecipientRestrictions")){
- $img.= "<input type='image' src='images/edittrash.png' name='RecipientRestrictDel_".$key."' class='center'> ";
- }
- $field1 = array("string"=> $entry['src']);
- $field2 = array("string"=> $entry['dst']);
- $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'");
- $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
- $DivRecipientRestrict->AddEntry(array($field1,$field2,$field3,$field4,));
- }
- $smarty->assign("Div_postfixRecipientRestrictions" ,$DivRecipientRestrict->DrawList());
-
-
- /* set new status */
- if(isset($_POST['ExecAction'])){
- if(isset($this->Actions[$_POST['action']])){
- $this->setStatus($_POST['action']);
- }
- }
-
-
- $smarty->assign("is_new", $this->dn);
- $smarty->assign("is_acc", $this->initially_was_account);
- $smarty->assign("TransportProtocols", $this->TransportProtocols);
- $smarty->assign("Actions", $this->Actions);
- $smarty->assign("RestrictionFilters", $this->RestrictionFilters);
- $smarty->assign("postfixTransportTable" , $this->getTransports());
- $smarty->assign("postfixSenderRestrictions" , $this->getSenderRestrictions());
- $smarty->assign("postfixRecipientRestrictions" ,$this->getRecipientRestrictions());
-
- return($smarty->fetch(get_template_path("goMailServer.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- /* return transports formated for select box */
- function getTransports()
- {
- $ret = array();
- foreach($this->postfixTransportTable as $key => $vals){
- $ret[$key] = $vals['src']." -> ".$vals['prt'].":".$vals['dst'];
- }
- return($ret);
- }
-
-
- /* return sender restriction formated for select box */
- function getSenderRestrictions()
- {
- $ret = array();
- foreach($this->postfixSenderRestrictions as $key => $vals){
- $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
- }
- return($ret);
- }
-
-
- /* return recipient restriction formated for select box */
- function getRecipientRestrictions()
- {
- $ret = array();
- foreach($this->postfixRecipientRestrictions as $key => $vals){
- $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
- }
- return($ret);
- }
-
-
- /* Return list entry */
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("Mail smtp service (Postfix)");
- $fields['AllowEdit'] = true;
- return($fields);
- }
-
-
- function save()
- {
- $this->postfixMyDomain = preg_replace("/^[^\.]+\./","",$this->postfixMyhostname);
- $this->postfixMyhostname = preg_replace("/\..*$/","",$this->postfixMyhostname);
-
- plugin::save();
-
- /* Fix transport table*/
- $i = 0 ;
- $this->attrs['postfixTransportTable'] = array();
- foreach($this->postfixTransportTable as $key => $entry){
- $this->attrs['postfixTransportTable'][] = $i.": ".$entry['src']." ".$entry['prt'].":".$entry['dst'];
- $i ++;
- }
-
-
- /* Fix sender restrictions */
- $i = 0;
- $this->attrs['postfixSenderRestrictions'] =array();
- foreach($this->postfixSenderRestrictions as $key => $entry){
- $this->attrs['postfixSenderRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst'];
- $i ++;
- }
-
-
- /* Fix recipient restrictions */
- $i = 0;
- $this->attrs['postfixRecipientRestrictions'] =array();
- foreach($this->postfixRecipientRestrictions as $key => $entry){
- $this->attrs['postfixRecipientRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst'];
- $i ++;
- }
-
-
- /* Fix mydomains */
- $this->attrs['postfixMyDestinations'] = array();
- foreach($this->postfixMyDestinations as $entry){
- $this->attrs['postfixMyDestinations'][] =$entry;
- }
-
-
- /* Fix mydomains */
- if(count($this->postfixMyNetworks)){
- $this->attrs['postfixMyNetworks'] = "";
- foreach($this->postfixMyNetworks as $entry){
- $this->attrs['postfixMyNetworks'] .=$entry.",";
- }
- $this->attrs['postfixMyNetworks'] = preg_replace("/,$/","",$this->attrs['postfixMyNetworks']);
- }else{
- $this->attrs['postfixMyNetworks'] = array();
- }
-
-
- /* Check if this is a new entry ... add/modify */
- $ldap = $this->config->get_ldap_link();
- $ldap->cat($this->dn,array("objectClass"));
- if($ldap->count()){
- $ldap->cd($this->dn);
- $ldap->modify($this->attrs);
- }else{
- $ldap->cd($this->dn);
- $ldap->add($this->attrs);
- }
- show_ldap_error($ldap->get_error(), sprintf(_("Saving server services/mail with dn '%s' failed."),$this->dn));
- if($this->initially_was_account){
- $this->handle_post_events("modify");
- new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }else{
- $this->handle_post_events("add");
- new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }
-
- }
-
-
- function check()
- {
- $message =plugin::check();
-
- if(!is_numeric($this->postfixHeaderSizeLimit)){
- $message[] = _("Please specify a numeric value for header size limit.");
- }
-
- if(!is_numeric($this->postfixMailboxSizeLimit)){
- $message[] = _("Please specify a numeric value for mailbox size limit.");
- }
-
- if(!is_numeric($this->postfixMessageSizeLimit)){
- $message[] = _("Please specify a numeric value for message size limit.");
- }
-
- return $message;
- }
-
-
- /* Combine new array */
- function combineArrays($ar0,$ar1,$ar2)
- {
- $ret = array();
- if(is_array($ar0))
- foreach($ar0 as $ar => $a){
- $ret[]=$a;
- }
- if(is_array($ar1))
- foreach($ar1 as $ar => $a){
- $ret[]=$a;
- }
- if(is_array($ar2))
- foreach($ar2 as $ar => $a){
- $ret[]=$a;
- }
- return($ret);
- }
-
-
- function getpos($atr,$attrs)
- {
- $i = 0;
- foreach($attrs as $attr => $name) {
- $i++;
- if($attr == $atr){
- return($i);
- }
- }
-
- return(-1);
- }
-
-
- /* TRansports the geiven Arraykey one position up*/
- function ArrayUp($atr,$attrs)
- {
- $ret = $attrs;
- $pos = $this->getpos($atr,$attrs) ;
- $cn = count($attrs);
- if(!(($pos == -1)||($pos == 1))){
- $before = array_slice($attrs,0,($pos-2));
- $mitte = array_reverse(array_slice($attrs,($pos-2),2));
- $unten = array_slice($attrs,$pos);
- $ret = array();
- $ret = $this->combineArrays($before,$mitte,$unten);
- }
- return($ret);
- }
-
-
- /* TRansports the geiven Arraykey one position up*/
- function ArrayDown($atr,$attrs)
- {
- $ret = $attrs;
- $pos = $this->getpos($atr,$attrs) ;
- $cn = count($attrs);
- if(!(($pos == -1)||($pos == $cn))){
- $before = array_slice($attrs,0,($pos-1));
- $mitte = array_reverse(array_slice($attrs,($pos-1),2));
- $unten = array_slice($attrs,($pos+1));
- $ret = array();
- $ret = $this->combineArrays($before,$mitte,$unten);
- }
- return($ret);
- }
-
- function save_object()
- {
- plugin::save_object();
- }
-
-
- function PrepareForCopyPaste($source)
- {
- plugin::PrepareForCopyPaste($source);
-
- $source_o = new goMailServer($this->config,$source['dn']);
- foreach(array("postfixMyDomain","postfixMyhostname","postfixMyNetworks","postfixTransportTable","postfixSenderRestrictions","postfixRecipientRestrictions","postfixMyDestinations") as $attr){
- $this->$attr = $source_o->$attr;
- }
- }
-
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Mail smtp (Postfix)"),
- "plDescription" => _("Mail smtp - Postfix")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 98,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array(
- "postfixMyhostname" => _("Visible full qualified hostname"),
- "description" => _("Description"),
- "postfixHeaderSizeLimit" => _("Header size limit"),
- "postfixMailboxSizeLimit" => _("Max mailbox size"),
- "postfixMessageSizeLimit" => _("Max message size"),
- "postfixMyDestinations" => _("Domains to accept mail for"),
- "postfixMyNetworks" => _("Local networks"),
- "postfixRelayhost" => _("Relay host"),
- "postfixTransportTable" => _("Transport table"),
- "postfixSenderRestrictions" => _("Restrictions for sender"),
- "postfixRecipientRestrictions"=> _("Restrictions for recipient"))
- ));
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/mail/goMailServer.tpl b/gosa-core/plugins/admin/systems/services/mail/goMailServer.tpl
+++ /dev/null
@@ -1,225 +0,0 @@
-<h2><img class="center" alt="" align="middle" src="images/rightarrow.png" /> {t}Generic{/t}</h2>
-<table style="width:100%;">
- <tr>
- <td width="50%" style="vertical-align:top">
- <table >
- <tr>
- <td>{t}Visible full qualified hostname{/t}
- </td>
- <td>
-{render acl=$postfixMyhostnameACL}
- <input type="text" name='postfixMyhostname' value='{$postfixMyhostname}' title='{t}The full qualified host name.{/t}'>
-{/render}
- </td>
- </tr>
- <tr>
- <td>{t}Max mail header size{/t}
- </td>
- <td>
-{render acl=$postfixMyhostnameACL}
- <input type="text" name='postfixHeaderSizeLimit' value='{$postfixHeaderSizeLimit}'
- title='{t}This value specifies the maximal header size.{/t}'> {t}KB{/t}
-{/render}
- </td>
- </tr>
- <tr>
- <td>{t}Max mailbox size{/t}
- </td>
- <td>
-{render acl=$postfixMailboxSizeLimitACL}
- <input type="text" name='postfixMailboxSizeLimit' value='{$postfixMailboxSizeLimit}'
- title='{t}Defines the maximal size of mail box.{/t}'> {t}KB{/t}
-{/render} </td>
- </tr>
- <tr>
- <td>{t}Max message size{/t}
- </td>
- <td>
-{render acl=$postfixMessageSizeLimitACL}
- <input type="text" name='postfixMessageSizeLimit' value='{$postfixMessageSizeLimit}'
- title='{t}Specify the maximal size of a message.{/t}'> {t}KB{/t}
-{/render}
- </td>
- </tr>
- <tr>
- <td>{t}Relay host{/t}
- </td>
- <td>
-{render acl=$postfixRelayhostACL}
- <input type="text" name='postfixRelayhost' value='{$postfixRelayhost}'
- title='{t}Relay messages to following host:{/t}'>
-{/render}
- </td>
- </tr>
- </table>
- </td>
- <td style="border-left:1px solid #A0A0A0; ">
- <table style="width:100%;">
- <tr>
- <td>
- {t}Local networks{/t}<br>
-{render acl=$postfixMyNetworksACL}
- <select name='Select_postfixMyNetworks[]' multiple size=6 style='width:100%;' title='{t}Postfix networks{/t}'>
- {html_options options=$postfixMyNetworks}
- </select>
-{/render}
-{render acl=$postfixMyNetworksACL}
- <input type="text" name="NewString_postfixMyNetworks" value="">
-{/render}
-{render acl=$postfixMyNetworksACL}
- <input type="submit" name="AddpostfixMyNetworks" value="{t}Add{/t}">
-{/render}
-{render acl=$postfixMyNetworksACL}
- <input type="submit" name="DelpostfixMyNetworks" value="{t}Remove{/t}">
-{/render}
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td colspan="2">
- <p class='seperator'> </p>
- <h2>{t}Domains and routing{/t}</h2>
- </td>
- </tr>
- <tr>
- <td>
- <table style="width:100%;">
- <tr>
- <td>
- {t}Domains to accept mail for{/t}<br>
-{render acl=$postfixMyDestinationsACL}
- <select name='Select_postfixMyDestinations[]' multiple size=6 style='width:100%;' title='{t}Postfix is responsible for the following domains:{/t}'>
-{/render}
- {html_options options=$postfixMyDestinations}
- </select>
-{render acl=$postfixMyDestinationsACL}
- <input type="text" name="NewString_postfixMyDestinations" value="">
-{/render}
-{render acl=$postfixMyDestinationsACL}
- <input type="submit" name="AddpostfixMyDestinations" value="{t}Add{/t}">
-{/render}
-{render acl=$postfixMyDestinationsACL}
- <input type="submit" name="DelpostfixMyDestinations" value="{t}Remove{/t}">
-{/render}
- </td>
- </tr>
- </table>
- </td>
- <td style="border-left:1px solid #A0A0A0; ">
- <table style="width:100%;">
- <tr>
- <td>
- {t}Transports{/t}<br>
-{render acl=$postfixTransportTableACL}
- {$Div_postfixTransportTable}
-{/render}
-
-{render acl=$postfixTransportTableACL}
- <input type="text" name="Source_postfixTransportTable" value="">
-{/render}
-{render acl=$postfixTransportTableACL}
- <select name='TransportProtocol' title='{t}Select a transport protocol.{/t}'>
- {html_options options=$TransportProtocols}
- </select>
-{/render}
-{render acl=$postfixTransportTableACL}
- <input type="text" name="Destination_postfixTransportTable" value="">
-{/render}
-{render acl=$postfixTransportTableACL}
- <input type="submit" name="AddpostfixTransportTable" value="{t}Add{/t}">
-{/render}
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td colspan="2">
- <p class='seperator'> </p>
- <h2>{t}Restrictions{/t}</h2>
- </td>
- </tr>
- <tr>
- <td>
- <table style="width:100%;">
- <tr>
- <td>
- {t}Restrictions for sender{/t}<br>
-{render acl=$postfixSenderRestrictionsACL}
- {$Div_postfixSenderRestrictions}
-{/render}
-{render acl=$postfixSenderRestrictionsACL}
- <input type="text" name="Source_postfixSenderRestrictions" value="">
-{/render}
-{render acl=$postfixSenderRestrictionsACL}
- <select name='SenderRestrictionFilter' title='{t}Restriction filter{/t}'>
- {html_options options=$RestrictionFilters}
- </select>
-{/render}
-{render acl=$postfixSenderRestrictionsACL}
- <input type="text" name="Destination_postfixSenderRestrictions" value="">
-{/render}
-{render acl=$postfixSenderRestrictionsACL}
- <input type="submit" name="AddpostfixSenderRestrictions" value="{t}Add{/t}">
-{/render}
- </td>
- </tr>
- </table>
- </td>
- <td style="border-left:1px solid #A0A0A0;">
- <table style="width:100%;">
- <tr>
- <td>
- {t}Restrictions for recipient{/t}<br>
-{render acl=$postfixRecipientRestrictionsACL}
- {$Div_postfixRecipientRestrictions}
-{/render}
-{render acl=$postfixRecipientRestrictionsACL}
- <input type="text" name="Source_postfixRecipientRestrictions" value="">
-{/render}
-{render acl=$postfixRecipientRestrictionsACL}
- <select name='RecipientRestrictionFilter' title='{t}Restriction filter{/t}'>
- {html_options options=$RestrictionFilters}
- </select>
-{/render}
-{render acl=$postfixRecipientRestrictionsACL}
- <input type="text" name="Destination_postfixRecipientRestrictions" value="">
-{/render}
-{render acl=$postfixRecipientRestrictionsACL}
- <input type="submit" name="AddpostfixRecipientRestrictions" value="{t}Add{/t}">
-{/render}
- </td>
- </tr>
- </table>
- </td>
- </tr>
-</table>
-
-<p class='seperator'> </p>
-<br>
-<h2><img class="center" alt="" src="images/rocket.png" align="middle"> Action</h2>
-{if $is_new == "new"}
- {t}The server must be saved before you can use the status flag.{/t}
-{elseif !$is_acc}
- {t}The service must be saved before you can use the status flag.{/t}
-{/if}
-<br>
-<select name="action" title='{t}Set new status{/t}'
- {if $is_new == "new" || $is_acc == false} disabled {/if}
->
- <option value="none"> </option>
- {html_options options=$Actions}
-</select>
-<input type='submit' name='ExecAction' title='{t}Set status{/t}' value='{t}Execute{/t}'
- {if $is_new == "new" || $is_acc == false} disabled {/if}
->
-
-<p class="seperator"> </p>
-<div style="width:100%; text-align:right;padding-top:10px;padding-bottom:3px;">
- <input type='submit' name='SaveService' value='{t}Save{/t}'>
-
- <input type='submit' name='CancelService' value='{t}Cancel{/t}'>
-</p>
-
diff --git a/gosa-core/plugins/personal/mail/class_mail-methods-cyrus.inc b/gosa-core/plugins/personal/mail/class_mail-methods-cyrus.inc
+++ /dev/null
@@ -1,366 +0,0 @@
-<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2004 Cajus Pollmeier
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-class mailMethodCyrus extends mailMethod
-{
- var $mbox= "-";
- var $config;
- var $gosaMailServer= "";
- var $uattrib= "uid";
-
- function mailMethodCyrus(&$config)
- {
- $this->config= $config->data['SERVERS']['IMAP'];
- }
-
- function connect($gosaMailServer)
- {
- $cfg=array();
-
- /* Connect to IMAP server. I don't want to see these warning here... */
- $this->gosaMailServer= $gosaMailServer;
- if (!isset($this->config[$gosaMailServer])){
- msg_dialog::display(_("Warning"), _("Mail server for this account is invalid!"), WARNING_DIALOG);
- } else {
- $cfg= $this->config[$gosaMailServer];
- }
- /* For some reason, hiding errors with @ does not wor here... */
- if(!isset($cfg['connect'])) $cfg['connect']="";
- if(!isset($cfg['admin'])) $cfg['admin']="";
- if(!isset($cfg['password'])) $cfg['password']="";
-
- /* Setting connect timeout to 10 seconds,
- else the GOsa UI may freeze for 60 seconds.
- (PHP default is 'default_socket_timeout = 60') */
- imap_timeout(1, 10 );
-
- $this->mbox = @imap_open($cfg['connect'], $cfg['admin'], $cfg['password'], OP_HALFOPEN);
-
- /* Mailbox reachable? */
- if ($this->mbox === FALSE){
- msg_dialog::display(_("IMAP error"), _("Cannot store mail settings on IMAP server!"), ERROR_DIALOG);
- return (FALSE);
- }
- return (TRUE);
- }
-
- function disconnect()
- {
- imap_close ($this->mbox);
- }
-
- function getQuota($folder)
- {
- $result= array('quotaUsage' => '', 'gosaMailQuota' => '');
-
- /* Load quota settings */
- error_reporting (0);
- $quota_value = @imap_get_quota($this->mbox, $folder);
- if(is_array($quota_value)) {
- if (isset($quota_value["STORAGE"]) && is_array($quota_value["STORAGE"])){
- /* use for PHP >= 4.3 */
- if($quota_value["STORAGE"]['limit'] == 2147483647){
- $result['quotaUsage']= (int) ($quota_value["STORAGE"]['usage'] / 1024);
- $result['gosaMailQuota']= (int) ($quota_value["STORAGE"]['limit'] );
- }else{
- $result['quotaUsage']= (int) ($quota_value["STORAGE"]['usage'] / 1024);
- $result['gosaMailQuota']= (int) ($quota_value["STORAGE"]['limit'] / 1024);
- }
- } else {
- /* backward icompatible */
- if($quota_value['usage'] == 2147483647){
- $result['quotaUsage']= (int) ($quota_value['usage'] / 1024);
- $result['gosaMailQuota']= (int) ($quota_value['limit'] );
- }else{
- $result['quotaUsage']= (int) ($quota_value['usage'] / 1024);
- $result['gosaMailQuota']= (int) ($quota_value['limit'] / 1024);
- }
- }
- }elseif(!$quota_value){
- /* If there is no quota defined for this account, the function imap_get_quota returns false. */
- return(array("quotaUsage"=>"","gosaMailQuota"=>""));
- }
-
- error_reporting (E_ALL | E_STRICT);
- return ($result);
- }
-
-
- /* return all folders of the users mailbox*/
- function getMailboxList($folder, $uid)
- {
- global $config;
- $result = array();
-
- /* Get domain an mail address if uid is an mail address */
- $domain = "";
- if(preg_match("/@/",$folder)){
- $domain = "@".preg_replace("/^.*@/","",$folder);
- $folder = preg_replace("/@.*$/","",$folder);
- }
-
- /* Get list of mailboxes for combo box */
- $cfg= $this->config[$this->gosaMailServer];
-
- /* Create search pattern
- (user/kekse*@domain.de
- user.kekse*@domain.de
- user.kekse* )
- depending on given folder name) */
- $q = $folder."*".$domain;
- $list = imap_listmailbox($this->mbox, $cfg["connect"], $q);
-
- /* Create list of returned folder names */
- if (is_array($list)){
- foreach ($list as $val){
-
- /* Cut domain name */
- $val = preg_replace("/@.*$/","",$val);
- $result[]=preg_replace ("/^.*".normalizePreg($folder)."/","INBOX", mb_convert_encoding($val, "UTF-8", "UTF7-IMAP"));
- }
- }
-
- /* Append "INBOX" to the folder array if result is empty and request comes from user dialog */
- if(empty($result) && !empty($uid)){
- $result[] = "INBOX";
- }
-
- return ($result);
- }
-
-
- function updateMailbox($folder)
- {
- /* Check if mailbox exists */
- $cfg= $this->config[$this->gosaMailServer];
- $list = imap_listmailbox($this->mbox, $cfg["connect"], $folder);
- if ($list === FALSE){
- if (!imap_createmailbox($this->mbox, $cfg["connect"]. $folder)){
- msg_dialog::display(_("IMAP error"), sprintf(_("Cannot create IMAP mailbox: %s"), '<br><br><i>'.imap_last_error().'</i>'), ERROR_DIALOG);
- return;
- }
- }
- }
-
-
- function setQuota($folder, $gosaMailQuota)
- {
- /* Workaround for the php imap extension */
- if (($gosaMailQuota == "") || ($gosaMailQuota== "2147483647")){
- $gosaMailQuota= "2147483647";
- }elseif($gosaMailQuota > 0){
- $gosaMailQuota = $gosaMailQuota *1024;
- }
-
-
- /* Write mail quota */
- if (!imap_set_quota($this->mbox, $folder, $gosaMailQuota)){
- msg_dialog::display(_("IMAP error"), sprintf(_("Cannot modify IMAP mailbox quota: %s"), '<br><br><i>'.imap_last_error().'</i>'), ERROR_DIALOG);
- return (FALSE);
- }
- return (TRUE);
- }
-
-
- function setSharedFolderPermissions($folder, $permissions)
- {
- /* Get list of subfolders */
- $folders= $this->getMailboxList($folder, "");
- $folders[]= $folder;
-
- foreach ($folders as $subfolder){
-
- /* Set shared folder acl's */
- if (function_exists('imap_getacl')){
-
- /* Remove all acl's for this folder */
- $users= @imap_getacl ($this->mbox, $subfolder);
- if(is_array($users)){
- foreach ($users as $userid => $perms){
- imap_setacl ($this->mbox, $subfolder, $userid, "");
- }
- }
- } else {
- msg_dialog::display(_("Internal error"), _("Cannot remove IMAP ACL: imap_getacl not implemented!"), ERROR_DIALOG);
- }
-
- /* Set permissions for this folder */
- foreach ($permissions as $user => $acl){
- imap_setacl ($this->mbox, $subfolder, $user, $acl);
- }
- }
-
- }
-
-
- function getSharedFolderPermissions($folder)
- {
- $result= array();
-
- /* imap_getacl available? */
- if (!function_exists('imap_getacl')){
- msg_dialog::display(_("Internal error"), _("Cannot retrieve IMAP ACL: imap_getacl not implemented!"), ERROR_DIALOG);
- }
-
- /* Get permissions in case of shared folders */
- else {
- $users= imap_getacl ($this->mbox, $folder);
-
- foreach ($users as $userid => $perms){
- $result[preg_replace('/^user\./', '', $userid)]= $perms;
- }
-
- }
-
- return ($result);
- }
-
-
- function deleteMailbox($folder)
- {
- $cfg= $this->config[$this->gosaMailServer];
- imap_setacl ($this->mbox, $folder, $cfg["admin"], "lrswipcda");
- if (!imap_deletemailbox($this->mbox, $cfg["connect"].$folder)){
- msg_dialog::display(_("IMAP error"), sprintf(_('Cannot remove IMAP mailbox: %s'), '<br><br><i>'.imap_last_error().'</i>'), ERROR_DIALOG);
- return (FALSE);
- }
- return (TRUE);
- }
-
-
- function configureFilter($user, $gosaMailDeliveryMode,
- $mail, $gosaMailAlternateAddress,
- $gosaMailMaxSize,
- $gosaSpamMailbox, $gosaSpamSortLevel,
- $gosaVacationMessage)
- {
- $cfg= $this->config[$this->gosaMailServer];
-
- /* Build spamlevel. Spamassassin tags mails with "*" for each integer
- point of spam. So a spam level of 5.3 gets "*****" which can be
- checked easily by spam filters */
- $spamlevel= "";
- for ($i= 0; $i<$gosaSpamSortLevel; $i++){
- $spamlevel .= "*";
- }
-
- /* Log into the mail server */
- $sieve= new sieve($cfg["sieve_server"], $cfg["sieve_port"], $user,
- $cfg["password"], $cfg["admin"]);
-
- if (!$sieve->sieve_login()){
- msg_dialog::display(_("SIEVE error"), sprintf(_("Cannot log into SIEVE server: %s"), '<br><br><i>'.to_string($sieve->error_raw).'</i>'), ERROR_DIALOG);
- return;
- }
-
- /* Load current script from server and remove everything between the comments
- "###GOSA" */
- $script= "";
- if($sieve->sieve_listscripts()){
- if (in_array("gosa", $sieve->response)){
-
- /* get old GOsa script */
- if(!$sieve->sieve_getscript("gosa")){
- msg_dialog::display(_("SIEVE error"), sprintf(_("Cannot retrieve SIEVE script: %s"), '<br><br><i>'.to_string($sieve->error_raw).'</i>'), ERROR_DIALOG);
- return;
- }
-
- foreach ($sieve->response as $line){
- if (preg_match ("/^###GOSA/", $line)){
- break;
- }
- $line= rtrim($line);
- if (!preg_match ('/^\s*$/', $line)){
- $script .= $line."\n";
- }
- }
-
- }
- }
-
- /* Only create a new one, if it is not empty */
- if (is_integer(strpos($gosaMailDeliveryMode, "R")) ||
- is_integer(strpos($gosaMailDeliveryMode, "C")) ||
- !is_integer(strpos($gosaMailDeliveryMode, "L")) ||
- is_integer(strpos($gosaMailDeliveryMode, "V")) ||
- is_integer(strpos($gosaMailDeliveryMode, "S"))){
-
- $text= preg_replace('/"/', '\\"', implode ("", file(CONFIG_DIR."/sieve-header.txt")));
- eval ("\$script.=\"$text\";");
- }
-
- /* Add anti-spam code */
- if (is_integer(strpos($gosaMailDeliveryMode, "S"))){
- $spambox= $gosaSpamMailbox;
- $text= preg_replace('/"/', '\\"', implode ("", file(CONFIG_DIR."/sieve-spam.txt")));
- eval ("\$script.=\"$text\";");
- }
-
- /* Add "reject due to mailsize" code, message is currently not
- adjustable through GOsa. */
- if (is_integer(strpos($gosaMailDeliveryMode, "R"))){
- $maxsize= $gosaMailMaxSize;
- $text= preg_replace('/"/', '\\"', implode ("", file(CONFIG_DIR."/sieve-mailsize.txt")));
- eval ("\$script.=\"$text\";");
- }
-
- /* Add vacation information */
- if (is_integer(strpos($gosaMailDeliveryMode, "V"))){
-
- /* Sieve wants all destination addresses for the
- vacation message, so we've to assemble them from
- mail and mailAlternateAddress */
- $addrlist= "\"".$mail."\"";
- foreach ($gosaMailAlternateAddress as $val){
- $addrlist .= ", \"$val\"";
- }
- $vacmsg= $gosaVacationMessage;
- $text= preg_replace('/"/', '\\"', implode ("", file(CONFIG_DIR."/sieve-vacation.txt")));
- eval ("\$script.=\"$text\";");
- }
-
- /* If no local delivery is wanted, tell the script to discard the mail */
- if (!is_integer(strpos($gosaMailDeliveryMode, "L"))){
- $text= preg_replace('/"/', '\\"', implode ("", file(CONFIG_DIR."/sieve-discard.txt")));
- eval ("\$script.=\"$text\";");
- }
-
- /* Just be aware of null scripts... */
- if (!isset ($script)){
- $script= "";
- }
-
- /* Upload script and make it the default one */
- if (!$sieve->sieve_sendscript("gosa", $script)){
- msg_dialog::display(_("SIEVE error"), sprintf(_("Cannot store SIEVE script: %s"), '<br><br><i>'.to_string($sieve->error_raw).'</i>'), ERROR_DIALOG);
- return;
- }
- if(!$sieve->sieve_setactivescript("gosa")){
- msg_dialog::display(_("SIEVE error"), sprintf(_("Cannot activate SIEVE script: %s"), '<br><br><i>'.to_string($sieve->error_raw).'</i>'), ERROR_DIALOG);
- return;
- }
-
- $sieve->sieve_logout();
- }
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/personal/mail/class_mail-methods-golab.inc b/gosa-core/plugins/personal/mail/class_mail-methods-golab.inc
+++ /dev/null
@@ -1,261 +0,0 @@
-<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2004 Cajus Pollmeier
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-class mailMethodGolab extends mailMethodCyrus
-{
- var $mbox= "-";
- var $config;
- var $gosaMailServer= "";
- var $uattrib= "mail";
-
- var $attribute_map= array("gosaMailAlternateAddress" => "alias",
- "gosaMailQuota" => "cyrus-userquota",
- "gosaMailServer" => "kolabHomeServer");
-
- function mailMethodGolab(&$config)
- {
- $this->config= $config->data['SERVERS']['IMAP'];
- }
-
- function updateMailbox($folder)
- {
- }
-
- function setQuota($folder, $gosaMailQuota)
- {
- return (TRUE);
- }
-
- /* Get quota and divide it by 1024, because in gosa we display in MB
- but we get Kb */
- function getQuota($folder)
- {
- $result= array('quotaUsage' => '', 'gosaMailQuota' => '');
-
- /* Only use lower case folder names, if folder name is like "@domain.com" */
- if(preg_match("/@/",$folder)){
- $folder = strtolower($folder);
- }
-
- error_reporting(0);
-
- /* Load quota settings */
- $quota_value = @imap_get_quota($this->mbox, $folder);
- if(is_array($quota_value)) {
- if (isset($quota_value["STORAGE"]) && is_array($quota_value["STORAGE"])){
- /* use for PHP >= 4.3 */
- $result['quotaUsage']= (int) ($quota_value["STORAGE"]['usage'] / 1024);
- $result['gosaMailQuota']= (int) ($quota_value["STORAGE"]['limit'] / 1024);
- } else {
- /* backward icompatible */
- $result['quotaUsage']= (int) ($quota_value['usage'] / 1024);
- $result['gosaMailQuota']= (int) ($quota_value['limit'] / 1024);
- }
- }elseif(!$quota_value){
- return(false);
- }
-
- error_reporting(E_ALL | E_STRICT);
-
- return ($result);
- }
-
-
- function fixAttributesOnLoad(&$mailObject)
- {
- /* Kolab shared folder names are like ' shared.uid@server.de '
- So overwrite uid to match these folder names. Else we can't read quota settings etc.
- #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
- if(get_class($mailObject) == "mailgroup"){
- $mailObject->uid = $mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
- }
-
- /* Convert attributes and objectClasses */
- foreach ($this->attribute_map as $dest => $source){
- /* Hickert 11.11.05 : Alternate email addresses were saved, but not displayed again.
- if (isset($mailObject->attrs[$source])){
- $mailObject->attrs[$dest]= $mailObject->attrs[$source];
- unset ($mailObject->attrs[$source]);
- */
-
- if (isset($mailObject->attrs[$source])){
- unset($mailObject->attrs[$source]['count']);
- $mailObject->attrs[$dest]= $mailObject->attrs[$source];
- $mailObject->$dest= $mailObject->attrs[$source];
-
- unset ($mailObject->$dest['count']);
- unset ($mailObject->attrs[$source]);
- }
- }
-
- /* Adjust server name if needed */
- foreach ($mailObject->config->data['SERVERS']['IMAP'] as $srv => $dummy){
- if (preg_match("%".$mailObject->attrs['gosaMailServer'][0]."$%", $srv)){
- $mailObject->attrs['gosaMailServer']= array(0 => $srv, "count" => 1);
- break;
- }
- }
- }
-
-
- function fixAttributesOnStore(&$mailObject)
- {
- global $config;
-
- /* If quota is empty, remove quota restrictions by setting quota to 0 */
- if(isset($mailObject->gosaMailQuota) && (empty($mailObject->gosaMailQuota))){
- $mailObject->attrs['gosaMailQuota'] = 0;
- }
-
- /* Convert attributes and objectClasses */
- foreach ($this->attribute_map as $source => $dest){
- if (isset($mailObject->attrs[$source])){
- $mailObject->attrs[$dest]= $mailObject->attrs[$source];
- unset ($mailObject->attrs[$source]);
- }
- }
- $objectclasses= array();
- foreach ($mailObject->attrs['objectClass'] as $oc){
- if ($oc != 'kolabInetOrgPerson' && $oc != 'kolabSharedFolder'){
- $objectclasses[]= $oc;
- }
- }
- $mailObject->attrs['objectClass']= $objectclasses;
- if (in_array("posixGroup", $mailObject->attrs['objectClass'])){
-
- /* Add kolabSharedFoleder Class */
- $mailObject->attrs['objectClass'][]= 'kolabSharedFolder';
-
- /* Work on acl attribute */
- $new_acl= array();
- foreach ($mailObject->attrs['acl'] as $uacl){
-
- /* Get user=(mail) & acls */
- list($user, $acl) = split(" ", $uacl);
-
- /* Add al users which have seperated acls
- %members% are all users in this group,
- which have the standard group acl
- */
- if ($user != "%members%"){
- $new_acl[$user]= $uacl;
- } else {
-
- /* All groupmembers will be added */
- $ldap = $config->get_ldap_link();
- $ldap->cd($config->current['BASE']);
- foreach ($mailObject->members as $member){
-
- /* Get user mail address .... */
- $ldap->search("(&(objectClass=person)(|(uid=".$member.")(mail=".$member.")))",array("mail"));
- $res = $ldap->fetch();
-
- /* Default mail address is set to uid -
- So if there is no mail address defined the uid is added
- */
- $mail = $member;
-
- /* Use mail address if it is available */
- if(isset($res['mail'][0])){
- $mail = $res['mail'][0];
- }
-
- /* only append this mail/permission string to acl,
- if there arn't already some (special) configs for this user */
- $found =false;
- foreach($mailObject->imapacl as $mailA => $acl){
- if(strtolower(trim($mailA))==strtolower(trim($mail))){
- $found = true;
- }
- }
-
- /* Skipp user, with no email adress too */
- if($member == $mail){
- $found = true;
- }
-
- /* Append new user acl */
- if(!$found){
- $new_acl[$member]= "$mail $acl";
- }
-
- /* Old line */
- // $new_acl[$member]= "$member $acl";
- }
- }
- }
-
- /* Save shared folder target */
- $mailObject->attrs['gosaSharedFolderTarget']= "kolab+".$mailObject->mail;
-
- /* Kolab shared folder names are like ' shared.uid@server.de '
- So overwrite uid to match these folder names. Else we can't read quota settings etc.
- #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
- $mailObject->uid = $mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
-
- /* Assign new acls */
- $mailObject->attrs['acl']= array();
- foreach ($new_acl as $key => $value){
- $mailObject->attrs['acl'][]= $value;
- }
- } else {
- $mailObject->attrs['objectClass'][]= 'kolabInetOrgPerson';
- }
-
- /* Remove imap:// tagging */
- $mailObject->attrs['kolabHomeServer']= preg_replace('%imap://%', '', $mailObject->attrs['kolabHomeServer']);
- $mailObject->attrs['gosaMailServer']= $mailObject->attrs['kolabHomeServer'];
- $mailObject->attrs['kolabDeleteFlag']= array();
- }
-
- function fixAttributesOnRemove(&$mailObject)
- {
- /* Add attribute for object deletion and remove GOsa specific
- values from entry. */
- foreach($this->attribute_map as $kolabAttr){
- $mailObject->attrs[$kolabAttr] = array();
- }
-
- /* Only add kolab delete Flag in case of an user.mailAccount */
- if(!in_array("posixGroup", $mailObject->attrs['objectClass'])){
- $mailObject->attrs['kolabDeleteFlag']= preg_replace('%imap://%', '', $mailObject->gosaMailServer);
- }else{
- /* Kolab shared folder names are like ' shared.uid@server.de '
- So overwrite uid to match these folder names. Else we can't read quota settings etc.
- #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
- $mailObject->uid = $mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
-
- }
- }
-
-
- function deleteMailbox($folder)
- {
- /* Remove shared folders and skip removing users.
- KolabD is not able to remove shared folders yet, so we do it instead */
- if(!(preg_match("/^user\//",$folder))){
- return mailMethodCyrus::deleteMailbox($folder);
- }
- return (TRUE);
- }
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/personal/mail/class_mail-methods-kolab.inc b/gosa-core/plugins/personal/mail/class_mail-methods-kolab.inc
+++ /dev/null
@@ -1,267 +0,0 @@
-<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2004 Cajus Pollmeier
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-class mailMethodKolab extends mailMethodCyrus
-{
- var $mbox= "-";
- var $config;
- var $gosaMailServer= "";
- var $uattrib= "mail";
-
- var $attribute_map= array("gosaMailAlternateAddress" => "alias",
- "gosaMailQuota" => "cyrus-userquota",
- "gosaMailServer" => "kolabHomeServer");
-
- function mailMethodKolab(&$config)
- {
- $this->config= $config->data['SERVERS']['IMAP'];
- }
-
- function updateMailbox($folder)
- {
- }
-
- function setQuota($folder, $gosaMailQuota)
- {
- return (TRUE);
- }
-
- /* Get quota and divide it by 1024, because in gosa we display in MB
- but we get Kb */
- function getQuota($folder)
- {
- $result= array('quotaUsage' => '', 'gosaMailQuota' => '');
-
- /* Only use lower case folder names, if folder name is like "@domain.com" */
- if(preg_match("/@/",$folder)){
- $folder = strtolower($folder);
- }
-
- error_reporting(0);
-
- /* Load quota settings */
- $quota_value = @imap_get_quota($this->mbox, $folder);
- if(is_array($quota_value)) {
- if (isset($quota_value["STORAGE"]) && is_array($quota_value["STORAGE"])){
- /* use for PHP >= 4.3 */
- $result['quotaUsage']= (int) ($quota_value["STORAGE"]['usage'] / 1024);
- $result['gosaMailQuota']= (int) ($quota_value["STORAGE"]['limit'] / 1024);
- } else {
- /* backward icompatible */
- $result['quotaUsage']= (int) ($quota_value['usage'] / 1024);
- $result['gosaMailQuota']= (int) ($quota_value['limit'] / 1024);
- }
- }elseif(!$quota_value){
- return(false);
- }
-
- error_reporting(E_ALL | E_STRICT);
-
- return ($result);
- }
-
-
- function fixAttributesOnLoad(&$mailObject)
- {
- /* Kolab shared folder names are like ' shared.uid@server.de '
- So overwrite uid to match these folder names. Else we can't read quota settings etc.
- #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
- if(get_class($mailObject) == "mailgroup"){
- $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
- }
-
- /* Convert attributes and objectClasses */
- foreach ($this->attribute_map as $dest => $source){
- /* Hickert 11.11.05 : Alternate email addresses were saved, but not displayed again.
- if (isset($mailObject->attrs[$source])){
- $mailObject->attrs[$dest]= $mailObject->attrs[$source];
- unset ($mailObject->attrs[$source]);
- */
-
- if (isset($mailObject->attrs[$source])){
- unset($mailObject->attrs[$source]['count']);
- $mailObject->attrs[$dest]= $mailObject->attrs[$source];
- $mailObject->$dest= $mailObject->attrs[$source];
-
- /* Ensure that cleanup will recognize the ampped attributes too */
- if(isset($mailObject->saved_attributes)){
- $mailObject->saved_attributes[$dest] = $mailObject->attrs[$source];
- $mailObject->saved_attributes[$source] = $mailObject->attrs[$source];
- }
-
- unset ($mailObject->$dest['count']);
- unset ($mailObject->attrs[$source]);
- }
- }
-
- /* Adjust server name if needed */
- foreach ($mailObject->config->data['SERVERS']['IMAP'] as $srv => $dummy){
- if (preg_match("%".$mailObject->attrs['gosaMailServer'][0]."$%", $srv)){
- $mailObject->attrs['gosaMailServer']= array(0 => $srv, "count" => 1);
- break;
- }
- }
- }
-
-
- function fixAttributesOnStore(&$mailObject)
- {
- global $config;
-
- /* If quota is empty, remove quota restrictions by setting quota to 0 */
- if(isset($mailObject->gosaMailQuota) && (empty($mailObject->gosaMailQuota))){
- $mailObject->attrs['gosaMailQuota'] = 0;
- }
-
- /* Convert attributes and objectClasses */
- foreach ($this->attribute_map as $source => $dest){
- if (isset($mailObject->attrs[$source])){
- $mailObject->attrs[$dest]= $mailObject->attrs[$source];
- unset ($mailObject->attrs[$source]);
- }
- }
- $objectclasses= array();
- foreach ($mailObject->attrs['objectClass'] as $oc){
- if ($oc != 'kolabInetOrgPerson' && $oc != 'kolabSharedFolder'){
- $objectclasses[]= $oc;
- }
- }
- $mailObject->attrs['objectClass']= $objectclasses;
- if (in_array("posixGroup", $mailObject->attrs['objectClass'])){
-
- /* Add kolabSharedFoleder Class */
- $mailObject->attrs['objectClass'][]= 'kolabSharedFolder';
-
- /* Work on acl attribute */
- $new_acl= array();
- foreach ($mailObject->attrs['acl'] as $uacl){
-
- /* Get user=(mail) & acls */
- list($user, $acl) = split(" ", $uacl);
-
- /* Add al users which have seperated acls
- %members% are all users in this group,
- which have the standard group acl
- */
- if ($user != "%members%"){
- $new_acl[$user]= $uacl;
- } else {
-
- /* All groupmembers will be added */
- $ldap = $config->get_ldap_link();
- $ldap->cd($config->current['BASE']);
- foreach ($mailObject->members as $member){
-
- /* Get user mail address .... */
- $ldap->search("(&(objectClass=person)(|(uid=".$member.")(mail=".$member.")))",array("mail"));
- $res = $ldap->fetch();
-
- /* Default mail address is set to uid -
- So if there is no mail address defined the uid is added
- */
- $mail = $member;
-
- /* Use mail address if it is available */
- if(isset($res['mail'][0])){
- $mail = $res['mail'][0];
- }
-
- /* only append this mail/permission string to acl,
- if there arn't already some (special) configs for this user */
- $found =false;
- foreach($mailObject->imapacl as $mailA => $acl){
- if(strtolower(trim($mailA))==strtolower(trim($mail))){
- $found = true;
- }
- }
-
- /* Skipp user, with no email adress too */
- if($member == $mail){
- $found = true;
- }
-
- /* Append new user acl */
- if(!$found){
- $new_acl[$member]= "$mail $acl";
- }
-
- /* Old line */
- // $new_acl[$member]= "$member $acl";
- }
- }
- }
-
- /* Save shared folder target */
- $mailObject->attrs['gosaSharedFolderTarget']= "kolab+shared.".$mailObject->mail;
-
- /* Kolab shared folder names are like ' shared.uid@server.de '
- So overwrite uid to match these folder names. Else we can't read quota settings etc.
- #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
- $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
-
- /* Assign new acls */
- $mailObject->attrs['acl']= array();
- foreach ($new_acl as $key => $value){
- $mailObject->attrs['acl'][]= $value;
- }
- } else {
- $mailObject->attrs['objectClass'][]= 'kolabInetOrgPerson';
- }
-
- /* Remove imap:// tagging */
- $mailObject->attrs['kolabHomeServer']= preg_replace('%imap://%', '', $mailObject->attrs['kolabHomeServer']);
- $mailObject->attrs['gosaMailServer']= $mailObject->attrs['kolabHomeServer'];
- $mailObject->attrs['kolabDeleteFlag']= array();
- }
-
- function fixAttributesOnRemove(&$mailObject)
- {
- /* Add attribute for object deletion and remove GOsa specific
- values from entry. */
- foreach($this->attribute_map as $kolabAttr){
- $mailObject->attrs[$kolabAttr] = array();
- }
-
- /* Only add kolab delete Flag in case of an user.mailAccount */
- if(!in_array("posixGroup", $mailObject->attrs['objectClass'])){
- $mailObject->attrs['kolabDeleteFlag']= preg_replace('%imap://%', '', $mailObject->gosaMailServer);
- }else{
- /* Kolab shared folder names are like ' shared.uid@server.de '
- So overwrite uid to match these folder names. Else we can't read quota settings etc.
- #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
- $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
-
- }
- }
-
-
- function deleteMailbox($folder)
- {
- /* Remove shared folders and skip removing users.
- KolabD is not able to remove shared folders yet, so we do it instead */
- if(preg_match("/^shared/",$folder)){
- return mailMethodCyrus::deleteMailbox($folder);
- }
- return (TRUE);
- }
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/personal/mail/class_mail-methods-sendmail-cyrus.inc b/gosa-core/plugins/personal/mail/class_mail-methods-sendmail-cyrus.inc
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2004 Cajus Pollmeier
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-class mailMethodSendmailCyrus extends mailMethodCyrus
-{
-
- function mailMethodSendmailCyrus(&$config)
- {
- $this->config= $config->data['SERVERS']['IMAP'];
- }
-
- function fixAttributesOnLoad(&$mailObject)
- {
- /* Remove possible local alias from forwarders */
- $newForwarder= array();
- foreach ($mailObject->gosaMailForwardingAddress as $addr){
- if (!preg_match('/^\\\\/', $addr)){
- $newForwarder[]= $addr;
- }
- }
- $mailObject->gosaMailForwardingAddress= $newForwarder;
- }
-
- function fixAttributesOnStore(&$mailObject)
- {
- /* Add local user if checked */
- if (preg_match("/L/", $mailObject->gosaMailDeliveryMode)) {
- $mailObject->gosaMailForwardingAddress[]= "\\".$mailObject->uid;
- }
- }
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/personal/mail/class_mail-methods.inc b/gosa-core/plugins/personal/mail/class_mail-methods.inc
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2004 Cajus Pollmeier
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-
-class mailMethod
-{
- var $uattrib= "uid";
-
- function mailMethod(&$config)
- {
- }
-
- function connect($gosaMailServer)
- {
- return (TRUE);
- }
-
- function disconnect()
- {
- }
-
- function getQuota($folder)
- {
- return (array('quotaUsage' => 0, 'gosaMailQuota' => 0));
- }
-
- function getMailboxList($folder, $uid)
- {
- return (array("INBOX"));
- }
-
- function setQuota($folder, $gosaMailQuota)
- {
- return (TRUE);
- }
-
- function updateMailbox($folder)
- {
- }
-
- function deleteMailbox($folder)
- {
- return (TRUE);
- }
-
- function setSharedFolderPermissions($folder, $permissions)
- {
- }
-
- function configureFilter($user, $gosaMailDeliveryMode,
- $mail, $gosaMailAlternateAddress,
- $gosaMailMaxSize,
- $gosaSpamMailbox, $gosaSpamSortLevel,
- $gosaVacationMessage)
- {
- }
-
- function fixAttributesOnLoad(&$mailObject)
- {
- }
-
- function fixAttributesOnStore(&$mailObject)
- {
- }
-
- function fixAttributesOnRemove(&$mailObject)
- {
- }
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/personal/mail/class_mailAccount.inc b/gosa-core/plugins/personal/mail/class_mailAccount.inc
+++ /dev/null
@@ -1,1386 +0,0 @@
-<?php
-/*! \brief mail plugin
- \author Cajus Pollmeier <pollmeier@gonicus.de>
- \version 2.00
- \date 24.07.2003
-
- This class provides the functionality to read and write all attributes
- relevant for gosaMailAccounts from/to the LDAP. It does syntax checking
- and displays the formulars required.
- */
-
-class mailAccount extends plugin
-{
- /* Definitions */
- var $plHeadline = "Mail";
- var $plDescription = "This does something";
- var $method = "mailMethod";
-
- var $gosaVacationStart = 0;
- var $gosaVacationStop = 0;
- var $view_logged = FALSE;
-
- /* plugin specific values */
- var $mail = "";
- var $gosaMailAlternateAddress = array();
- var $gosaMailForwardingAddress = array();
- var $gosaMailDeliveryMode = "[L ]";
- var $gosaMailServer = "";
- var $gosaMailQuota = "";
- var $gosaMailMaxSize = "";
- var $gosaVacationMessage = "";
- var $gosaSpamSortLevel = "";
- var $gosaSpamMailbox = "";
-
- var $quotaUsage = 0;
- var $forward_dialog = FALSE;
- var $folder_prefix = "";
- var $mailboxList = array("INBOX");
- var $default_permissions = "none";
- var $member_permissions = "post";
- var $members = array();
- var $admins = array();
- var $vacations = array();
- var $perms = array( "lrs" => "read",
- "lrsp" => "post",
- "lrsip" => "append",
- "lrswipcd" => "write",
- "lrswipcda" => "all" );
-
- /* attribute list for save action */
- var $attributes= array("mail", "gosaMailServer", "gosaMailQuota", "gosaMailMaxSize","gosaMailForwardingAddress",
- "gosaMailDeliveryMode", "gosaSpamSortLevel", "gosaSpamMailbox","gosaMailAlternateAddress","gosaVacationStart","gosaVacationStop",
- "gosaVacationMessage", "gosaMailAlternateAddress", "gosaMailForwardingAddress");
- var $objectclasses= array("gosaMailAccount");
- var $uid = "";
-
- var $sieve_management = NULL;
- var $multiple_support = TRUE;
-
- /* constructor, if 'dn' is set, the node loads the given
- 'dn' from LDAP */
- function mailAccount (&$config, $dn= NULL)
- {
- global $class_mapping;
-
- $this->gosaVacationStart = time();
- $this->gosaVacationStop = time();
-
- /* Load bases attributes */
- plugin::plugin($config, $dn);
-
- /* Set uid */
- if(isset($this->attrs['uid'])){
- $this->uid = $this->attrs['uid'][0];
- }
-
- if(is_array($this->gosaMailServer) && isset($this->gosaMailServer[0])){
- $this->gosaMailServer = $this->gosaMailServer[0];
- }
-
- /* Save initial account state */
- $this->initially_was_account= $this->is_account;
-
- /* Set mailMethod to the one defined in gosa.conf */
- if (isset($this->config->current['MAILMETHOD'])){
- $method= $this->config->current['MAILMETHOD'];
-
- $cls = get_correct_class_name("mailMethod$method");
- if ($cls && class_exists($cls)){
- $this->method= $cls;
- } else {
- msg_dialog::display(_("Configuration error"), sprintf(_("Unkown mail method '%s' specified!"), $method), ERROR_DIALOG);
- }
- }
-
-
- /* Create the account prefix user. user/
- Preset folder prefix. Will change it later to respect
- altnamespace. */
- if (isset($this->config->current['CYRUSUNIXSTYLE']) && $this->config->current['CYRUSUNIXSTYLE'] == "true"){
- $this->folder_prefix= "user/";
- }elseif (isset($this->config->data['MAIN']['CYRUSUNIXSTYLE']) && $this->config->data['MAIN']['CYRUSUNIXSTYLE'] == "true"){
- $this->folder_prefix= "user/";
- } else {
- $this->folder_prefix= "user.";
- }
-
- /* This is not a new account, parse additional attributes */
- if (($dn !== NULL) && ($dn != "new") && $this->is_account){
-
- /* Load attributes containing arrays */
- foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
- $this->$val= array();
- if (isset($this->attrs["$val"]["count"])){
- for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){
- array_push($this->$val, $this->attrs["$val"][$i]);
- }
- }
- }
-
-
- /* Only do IMAP actions if gosaMailServer attribute is set */
- if (isset ($this->attrs["gosaMailServer"][0])){
-
- $method = new $this->method($this->config);
- $id = $method->uattrib;
-
- /* Adapt attributes if needed */
- $method->fixAttributesOnLoad($this);
-
- /* FixAttributesOnLoad possibly creates an array out of gosaMailServer.
- If the mail tab wasn't opened once before saving, the account can't be saved */
- if(is_array($this->gosaMailServer)){
- $this->gosaMailServer = $this->gosaMailServer[0];
- }
-
- if ($method->connect($this->attrs["gosaMailServer"][0])){
-
- /* Update quota values */
- $quota= $method->getQuota($this->folder_prefix.$this->$id);
-
- if($quota){
- if ($quota['gosaMailQuota'] == 2147483647){
- $this->quotaUsage = "";
- $this->gosaMailQuota = "";
- } else {
- $this->quotaUsage = $quota['quotaUsage'];
- $this->gosaMailQuota = $quota['gosaMailQuota'];
- }
- }else{
- $this->quotaUsage = "";
- $this->gosaMailQuota = "";
- }
-
- /* Get mailboxes / folder like INBOX ..*/
- $this->mailboxList= $method->getMailboxList($this->folder_prefix.$this->$id,$this->$id);
-
- $method->disconnect();
- }else{
- /* Could not connect to ldap.
- */
- if (isset($this->attrs['gosaMailQuota'][0])){
- $this->gosaMailQuota = $this->attrs['gosaMailQuota'][0];
- }
- }
- }
- }
-
- /* Fill vacation array */
- $this->vacation= array();
- if (isset($this->config->current['VACATIONDIR'])){
- $dir= $this->config->current['VACATIONDIR'];
- if (is_dir($dir) && is_readable($dir)){
-
- /* Look for files and build the vacation array */
- $dh= opendir($dir);
- while ($file = readdir($dh)){
- $description= $this->parse_vacation("$dir/$file");
- if ($description != ""){
- $this->vacation["$dir/$file"]= $description;
- }
- }
- closedir($dh);
- }
- }
-
- /* Create sieve management class */
- $method = new $this->method($this->config);
- $id = $method->uattrib;
- $this->sieve_management = new sieveManagement($this->config,$this->dn,$this,$id);
-
- /* Get global filter config */
- if (!session::is_set("mailfilter")){
- $ui= get_userinfo();
- $base= get_base_from_people($ui->dn);
- $mailfilter= array( "depselect" => $base,
- "muser" => "",
- "regex" => "*");
- session::set("mailfilter", $mailfilter);
- }
- }
-
-
- function parse_vacation($file)
- {
- $desc= "";
-
- if (is_file($file)){
- $fh = fopen($file, "r");
- $line= fgets($fh, 256);
-
- if (!preg_match('/^DESC:/', $line)){
- msg_dialog::display(_("Configuration error"), sprintf(_("No DESC tag in vacation template '%s'!"), $file), ERROR_DIALOG);
- return $desc;
- }
- fclose ($fh);
-
- $desc= trim(preg_replace('/^DESC:\s*/', '', $line));
- }
-
- return $desc;
- }
-
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- /* Log view */
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","users/".get_class($this),$this->dn);
- }
-
- /* Initialise vars */
-
- /* Load templating engine */
- $smarty= get_smarty();
- $display= "";
-
- /* Get available mailserver */
- $mailserver= array();
- foreach ($this->config->data['SERVERS']['IMAP'] as $key => $val){
- $mailserver[]= $key;
- }
-
- /*
- * Sieve Management
- */
- if(isset($_POST['sieveManagement'])
- && preg_match("/C/",$this->gosaMailDeliveryMode)
- && $this->acl_is_writeable("sieveManagement")) {
-
- $this->dialog = $this->sieve_management;
- }
-
- /* Cancel sieve edit */
- if(isset($_POST['sieve_cancel'])){
- $this->dialog = FALSE;
- }
-
- /* Save sieve changes */
- if(isset($_POST['sieve_finish'])){
- $this->sieve_management = $this->dialog;
- $this->dialog = FALSE;
- }
-
- if(is_object($this->dialog)){
- $this->dialog->save_object();
- return($this->dialog->execute());
- }
-
-
- /* Handle account state */
- /* Do we need to flip is_account state? */
- if(isset($_POST['modify_state'])){
- if($this->is_account && $this->acl_is_removeable()){
- $this->is_account= FALSE;
- }elseif(!$this->is_account && $this->acl_is_createable()){
- $this->is_account= TRUE;
- }
- }
-
- /* Do we represent a valid account? */
- if(!$this->multiple_support_active){
- if (!$this->is_account && $this->parent === NULL){
- $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\"> <b>".
- _("This account has no mail extensions.")."</b>";
-
- $display.= back_to_main();
- return ($display);
- }
-
- /* Show tab dialog headers */
- if ($this->parent !== NULL){
- if ($this->is_account){
- if($this->accountDelegationsConfigured()){
- $display= $this->show_disable_header(_("Remove mail account"),
- _("This account can't be removed while there are delegations configured. Remove those delegations first."),TRUE,TRUE);
- }else{
- $display= $this->show_disable_header(_("Remove mail account"),
- _("This account has mail features enabled. You can disable them by clicking below."));
- }
- } else {
- $display= $this->show_enable_header(_("Create mail account"), _("This account has mail features disabled. You can enable them by clicking below."));
- return ($display);
- }
- }
- }
-
- /* Forwarder subdialog */
-
- /* Trigger forward add dialog? */
- if (isset($_POST['add_local_forwarder'])){
- $this->forward_dialog= TRUE;
- $this->dialog= TRUE;
- }
-
- /* Cancel forward add dialog? */
- if (isset($_POST['add_locals_cancel'])){
- $this->forward_dialog= FALSE;
- $this->dialog= FALSE;
- }
-
- /* Finished adding of locals? */
- if (isset($_POST['add_locals_finish'])){
-
- /* Check if we are able to write gosaMailForwardingAddress */
- if($this->acl_is_writeable("gosaMailForwardingAddress")){
-
- /* Walk through list of forwarders, ignore own addresses */
- foreach ($_POST['local_list'] as $val){
- if (!in_array ($val, $this->gosaMailAlternateAddress) &&
- $val != $this->mail){
-
- $this->addForwarder($val);
- $this->is_modified= TRUE;
- }
- }
- }
- $this->forward_dialog= FALSE;
- $this->dialog= FALSE;
- }
-
- /* Add forward email addresses */
- if (isset($_POST['add_forwarder'])){
- if ($_POST['forward_address'] != ""){
-
- /* Valid email address specified? */
- $address= $_POST['forward_address'];
- $valid= FALSE;
- if (!tests::is_email($address)){
- if (!tests::is_email($address, TRUE)){
- if ($this->is_template){
- $valid= TRUE;
- } else {
- msg_dialog::display(_("Error"), _("Cannot add invalid mail address!"), ERROR_DIALOG);
- }
- }
- } elseif ($address == $this->mail
- || in_array($address, $this->gosaMailAlternateAddress)) {
-
- msg_dialog::display(_("Error"),_("Cannot add your primary address to the list of forwarders.") , ERROR_DIALOG);
-
- } else {
- $valid= TRUE;
- }
-
- if ($valid){
-
- /* Add it, if we are able to write gosaMailForwardingAddress */
- if($this->acl_is_writeable("gosaMailForwardingAddress")){
- $this->addForwarder ($address);
- $this->is_modified= TRUE;
- }
- }
- }
- }
-
- /* Delete forward email addresses */
- if (isset($_POST['delete_forwarder'])){
- $this->delForwarder ($_POST['forwarder_list']);
- }
-
-
- /* Add alternate email addresses */
- if (isset($_POST['add_alternate'])){
-
- $valid= FALSE;
- if (!tests::is_email($_POST['alternate_address'])){
- if ($this->is_template){
- if (!(tests::is_email($_POST['alternate_address'], TRUE))){
- msg_dialog::display(_("Error"), _("Cannot add invalid mail address!"), ERROR_DIALOG);
- } else {
- $valid= TRUE;
- }
- } else {
- msg_dialog::display(_("Error"), _("Cannot add invalid mail address!"), ERROR_DIALOG);
- }
-
- } else {
- $valid= TRUE;
- }
-
- if ($valid && ($user= $this->addAlternate ($_POST['alternate_address'])) != ""){
- $ui= get_userinfo();
- if ($user != $ui->username){
- msg_dialog::display(_("Error"), sprintf(_("Cannot add mail address: it is already used by user '%s'."), $user), ERROR_DIALOG);
- }
- }
- }
-
- /* Delete alternate email addresses */
- if (isset($_POST['delete_alternate']) && isset($_POST['alternates_list'])){
- $this->delAlternate ($_POST['alternates_list']);
- }
-
-
- /* Vacation message */
-
- /* Import vacation message? */
- if (isset($_POST["import_vacation"]) && isset($this->vacation[$_POST["vacation_template"]])){
-
-
- /* Save message */
- if($this->multiple_support_active){
- $contents = file_get_contents($_POST["vacation_template"]);
- }else{
- $contents = $this->prepare_vacation_template(file_get_contents($_POST["vacation_template"]));
- }
- $this->gosaVacationMessage= htmlspecialchars($contents);
- }
-
-
- /* Display forward dialog if requested above */
-
- /* Show forward add dialog */
- if ($this->forward_dialog){
- $ldap= $this->config->get_ldap_link();
-
- /* Save data */
- $mailfilter= session::get("mailfilter");
- foreach( array("depselect", "muser", "regex") as $type){
- if (isset($_POST[$type])){
- $mailfilter[$type]= $_POST[$type];
- }
- }
- if (isset($_GET['search'])){
- $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
- if ($s == "**"){
- $s= "*";
- }
- $mailfilter['regex']= $s;
- }
- session::set("mailfilter", $mailfilter);
-
- /* Get actual list */
- $mailusers= array ();
- if ($mailfilter['regex'] != '*' && $mailfilter['regex'] != ""){
- $regex= $mailfilter['regex'];
- $filter= "(|(mail=$regex)(gosaMailAlternateAddress=$regex))";
- } else {
- $filter= "";
- }
- if ($mailfilter['muser'] != ""){
- $user= $mailfilter['muser'];
- $filter= "$filter(|(uid=$user)(cn=$user)(givenName=$user)(sn=$user))";
- }
-
- /* Add already present people to the filter */
- $exclude= "";
- foreach ($this->gosaMailForwardingAddress as $mail){
- $exclude.= "(mail=$mail)";
- }
- if ($exclude != ""){
- $filter.= "(!(|$exclude))";
- }
-
- $res= get_list("(&(objectClass=gosaMailAccount)$filter)", "users", $mailfilter['depselect'],
- array("sn", "mail", "givenName"), GL_SIZELIMIT | GL_SUBSEARCH);
- $ldap->cd($mailfilter['depselect']);
- $ldap->search ("(&(objectClass=gosaMailAccount)$filter)", array("sn", "mail", "givenName"));
- error_reporting (0);
- while ($attrs= $ldap->fetch()){
- if(preg_match('/%/', $attrs['mail'][0])){
- continue;
- }
- $name= $this->make_name($attrs);
- $mailusers[$attrs['mail'][0]]= $name."<".
- $attrs['mail'][0].">";
- }
- error_reporting (E_ALL | E_STRICT);
- natcasesort ($mailusers);
- reset ($mailusers);
-
- /* Show dialog */
- $smarty->assign("search_image", get_template_path('images/search.png'));
- $smarty->assign("usearch_image", get_template_path('images/search_user.png'));
- $smarty->assign("tree_image", get_template_path('images/tree.png'));
- $smarty->assign("infoimage", get_template_path('images/info.png'));
- $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
- $smarty->assign("mailusers", $mailusers);
- if (isset($_POST['depselect'])){
- $smarty->assign("depselect", $_POST['depselect']);
- }
- $smarty->assign("deplist", $this->config->idepartments);
- $smarty->assign("apply", apply_filter());
- $smarty->assign("alphabet", generate_alphabet());
- $smarty->assign("hint", print_sizelimit_warning());
- foreach( array("depselect", "muser", "regex") as $type){
- $smarty->assign("$type", $mailfilter[$type]);
- }
- $smarty->assign("hint", print_sizelimit_warning());
-
- $display.= $smarty->fetch (get_template_path('mail_locals.tpl', TRUE, dirname(__FILE__)));
- return ($display);
- }
-
- /* Display mail account tab */
-
- $smarty->assign("mailServers", $mailserver);
- $SkipWrite = (!isset($this->parent) || !$this->parent) && !session::is_set('edit');
-
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $transl){
- $smarty->assign("$name"."ACL", $this->getacl($name,$SkipWrite));
- }
-
- foreach(array("gosaMailServer", "gosaMailQuota", "perms", "mail",
- "gosaMailAlternateAddress", "gosaMailForwardingAddress",
- "gosaVacationMessage", "gosaMailDeliveryMode", "gosaVacationStart",
- "gosaVacationStop", "gosaMailMaxSize", "gosaSpamSortLevel", "gosaSpamMailbox") as $val){
- $smarty->assign("$val", $this->$val);
- }
-
- if (is_numeric($this->gosaMailQuota) && $this->gosaMailQuota != 0){
- $smarty->assign("quotausage", progressbar(round(($this->quotaUsage * 100)/ $this->gosaMailQuota),100,15,true));
- $smarty->assign("quotadefined", "true");
- } else {
- $smarty->assign("quotadefined", "false");
- }
-
- /* Disable mail field if needed */
- $method= new $this->method($this->config);
- if ($method->uattrib == "mail" && $this->initially_was_account){
- $smarty->assign("mailACL", preg_replace("/w/","",$this->getacl("mail",$SkipWrite)));
- }
-
- /* Disable/Enable range select, but do not disable them twice
- * if they are already diabled by "use own sieve script"
- */
- if (preg_match('/V/', $this->gosaMailDeliveryMode) || preg_match("/C/",$this->gosaMailDeliveryMode)){
- $smarty->assign('rangeEnabled', "");
- } else {
- $smarty->assign('rangeEnabled', "disabled");
- }
-
- if (!preg_match("/L/", $this->gosaMailDeliveryMode)) {
- $smarty->assign("only_local", "checked");
- } else {
- $smarty->assign("only_local", "");
- }
-
- $types = array(
- "V"=>"use_vacation",
- "S"=>"use_spam_filter",
- "R"=>"use_mailsize_limit",
- "I"=>"drop_own_mails",
- "C"=>"own_script");
-
- /* Fill checkboxes */
- foreach($types as $option => $varname){
- if (preg_match("/".$option."/", $this->gosaMailDeliveryMode)) {
- $smarty->assign($varname, "checked");
- } else {
- $smarty->assign($varname, "");
- }
- }
-
- /* Display mail account tab */
- if($this->gosaVacationStart ==0){
- $date= getdate(time());
- }else{
- $date= getdate($this->gosaVacationStart);
- }
- $days= array();
- for($d= 1; $d<32; $d++){
- $days[$d]= $d;
- }
- $years= array();
- for($y= $date['year']-10; $y<$date['year']+10; $y++){
- $years[]= $y;
- }
- $months= array(_("January"), _("February"), _("March"), _("April"),
- _("May"), _("June"), _("July"), _("August"), _("September"),
- _("October"), _("November"), _("December"));
- $smarty->assign("start_day", $date["mday"]);
- $smarty->assign("days", $days);
- $smarty->assign("months", $months);
- $smarty->assign("start_month", $date["mon"]-1);
- $smarty->assign("years", $years);
- $smarty->assign("start_year", $date["year"]);
-
- if($this->gosaVacationStop ==0){
- $date= getdate(time());
- $date["mday"]++;
- }else{
- $date= getdate($this->gosaVacationStop);
- }
- $smarty->assign("end_day", $date["mday"]);
- $smarty->assign("end_month", $date["mon"]-1);
- $smarty->assign("end_year", $date["year"]);
-
-
-
- /* Have vacation templates? */
- $smarty->assign("template", "");
- if (count($this->vacation)){
- $smarty->assign("show_templates", "true");
- $smarty->assign("vacationtemplates", $this->vacation);
- if (isset($_POST['vacation_template'])){
- $smarty->assign("template", $_POST['vacation_template']);
- }
- } else {
- $smarty->assign("show_templates", "false");
- }
-
- /* Fill spam selector */
- $spamlevel= array();
- for ($i= 0; $i<21; $i++){
- $spamlevel[]= $i;
- }
- $smarty->assign("spamlevel", $spamlevel);
- $smarty->assign("spambox", $this->mailboxList);
-
- foreach($this->attributes as $attr){
- $u_attr = "use_".$attr;
- $smarty->assign($u_attr,in_array($attr,$this->multi_boxes));
- }
-
- foreach(array("only_local","gosaMailForwardingAddress","use_mailsize_limit","drop_own_mails","use_vacation","use_spam_filter") as $attr){
- $u_attr = "use_".$attr;
- $smarty->assign($u_attr,in_array($attr,$this->multi_boxes));
- }
-
- $smarty->assign("multiple_support",$this->multiple_support_active);
- $display.= $smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__)));
- return ($display);
- }
-
-
- /* remove object from parent */
- function remove_from_parent()
- {
- /* Cancel if there's nothing to do here */
- if (!$this->initially_was_account){
- return;
- }
-
- /* include global link_info */
- $ldap= $this->config->get_ldap_link();
-
- /* Remove and write to LDAP */
- plugin::remove_from_parent();
-
- /* Zero arrays */
- $this->attrs['gosaMailAlternateAddress']= array();
- $this->attrs['gosaMailForwardingAddress']= array();
-
- /* Adapt attributes if needed */
- $method= new $this->method($this->config);
- $method->fixAttributesOnRemove($this);
-
- @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,$this->attributes, "Save");
- $ldap->cd($this->dn);
- $this->cleanup();
-
- $ldap->modify ($this->attrs);
-
- /* Add "view" to logging class */
- new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-
- show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/mail account with dn '%s' failed."),$this->dn));
-
- /* Connect to IMAP server for account deletion */
- if ($this->gosaMailServer != ""){
- $method= new $this->method($this->config);
- $id= $method->uattrib;
- if ($method->connect($this->gosaMailServer)){
-
- /* Remove account from IMAP server */
- $method->deleteMailbox($this->folder_prefix.$this->$id);
- $method->disconnect();
- }
- }
-
- /* Update shared folder membership, ACL may need to be updated */
- $this->updateSharedFolder();
-
- /* Optionally execute a command after we're done */
- $this->handle_post_events("remove",array("uid" => $this->uid));
- }
-
-
- /* check if we have some delegations configured, those delegations must be removed first */
- function accountDelegationsConfigured()
- {
- /* We are in administrational edit mode.
- Check tab configurations directly */
- if(isset($this->attrs)){
- $checkArray = array("kolabInvitationPolicy","unrestrictedMailSize", "calFBURL","kolabDelegate","kolabFreeBusyFuture");
- foreach($checkArray as $index){
- if(isset($this->attrs[$index])){
- return(true);
- }
- }
- }
- return(false);
- }
-
-
- /* Save data to object */
- function save_object()
- {
- if (isset($_POST['mailTab'])){
-
- /* Save ldap attributes */
- plugin::save_object();
-
-
- if(isset($_POST['own_script'])){
-
- if(!preg_match("/C/",$this->gosaMailDeliveryMode)){
- $str= preg_replace("/[\[\]]/","",$this->gosaMailDeliveryMode);
- $this->gosaMailDeliveryMode = "[".$str."C]";
- }
-
- }else{
-
- /* Assemble mail delivery mode
- The mode field in ldap consists of values between braces, this must
- be called when 'mail' is set, because checkboxes may not be set when
- we're in some other dialog.
-
- Example for gosaMailDeliveryMode [LR ]
- L: Local delivery
- R: Reject when exceeding mailsize limit
- S: Use spam filter
- V: Use vacation message
- C: Use custm sieve script
- I: Only insider delivery */
-
- $tmp= preg_replace("/[^a-z]/i","",$this->gosaMailDeliveryMode);
-
-
- /* Handle delivery flags */
- if($this->acl_is_writeable("gosaMailDeliveryModeL")){
- if(!preg_match("/L/",$tmp) && !isset($_POST['only_local'])){
- $tmp.="L";
- }elseif(preg_match("/L/",$tmp) && isset($_POST['only_local'])){
- $tmp = preg_replace("/L/","",$tmp);
- }
- }
-
- $opts = array(
- "R" => "use_mailsize_limit",
- "S" => "use_spam_filter",
- "V" => "use_vacation",
- "C" => "own_script",
- "I" => "drop_own_mails");
-
- foreach($opts as $flag => $post){
- if($this->acl_is_writeable("gosaMailDeliveryMode".$flag)){
- if(!preg_match("/".$flag."/",$tmp) && isset($_POST[$post])){
- $tmp.= $flag;
- }elseif(preg_match("/".$flag."/",$tmp) && !isset($_POST[$post])){
- $tmp = preg_replace("/".$flag."/","",$tmp);
- }
- }
- }
-
- $tmp= "[$tmp]";
- if ($this->gosaMailDeliveryMode != $tmp){
- $this->is_modified= TRUE;
- }
- $this->gosaMailDeliveryMode= $tmp;
-
-
- if($this->acl_is_writeable("gosaVacationMessage") && preg_match("/V/",$this->gosaMailDeliveryMode)){
- if(isset($_POST['gosaVacationStart'])){
- $this->gosaVacationStart = $_POST['gosaVacationStart'];
- }
- if(isset($_POST['gosaVacationStop'])){
- $this->gosaVacationStop = $_POST['gosaVacationStop'];
- }
- }
- }
- }
- }
-
-
- /* Save data to LDAP, depending on is_account we save or delete */
- function save()
- {
- $ldap= $this->config->get_ldap_link();
-
- /* Call parents save to prepare $this->attrs */
- plugin::save();
-
- /* Save arrays */
- $this->attrs['gosaMailAlternateAddress']= $this->gosaMailAlternateAddress;
- $this->attrs['gosaMailForwardingAddress']= $this->gosaMailForwardingAddress;
-
- /* Adapt attributes if needed */
- $method= new $this->method($this->config);
- $id= $method->uattrib;
-
- $method->fixAttributesOnStore($this);
-
- /* Remove Mailquota if = "" or "0" */
- if((isset($this->attrs['gosaMailQuota']))&&(!$this->attrs['gosaMailQuota'])) {
- $this->attrs['gosaMailQuota']=0;
- }
-
- if(empty($this->attrs['gosaSpamMailbox'])){
- unset($this->attrs['gosaSpamMailbox']);
- }
-
- $this->attrs['mail'] = strtolower($this->attrs['mail']);
-
- /* Remove attributes - if not needed */
- if (!preg_match('/V/', $this->gosaMailDeliveryMode)){
- unset($this->attrs['gosaVacationStart']);
- unset($this->attrs['gosaVacationStop']);
- }
-
-
- /* Remove attributes - if not needed */
- if (!preg_match('/V/', $this->gosaMailDeliveryMode)){
- unset($this->attrs['gosaVacationStart']);
- unset($this->attrs['gosaVacationStop']);
- }
-
- /* Save data to LDAP */
- $ldap->cd($this->dn);
- $this->cleanup();
- $ldap->modify ($this->attrs);
-
- show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/mail account with dn '%s' failed."),$this->dn));
-
- /* Log last action */
- if($this->initially_was_account){
- new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }else{
- new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }
-
- /* Only do IMAP actions if we are not a template */
- if (!$this->is_template){
-
- if ($method->connect($this->gosaMailServer)){
- $method->updateMailbox($this->folder_prefix.$this->$id);
-
- $method->setQuota($this->folder_prefix.$this->$id, $this->gosaMailQuota);
- $method->disconnect();
-
- /* Ensure that this is an existing account */
- if(1==1 || $this->initially_was_account){
-
- /* Write sieve information only if not in C mode */
- if (!is_integer(strpos($this->gosaMailDeliveryMode, "C"))){
- $method->configureFilter($this->$id,
- $this->gosaMailDeliveryMode,
- $this->mail,
- $this->gosaMailAlternateAddress,
- $this->gosaMailMaxSize,
- $this->gosaSpamMailbox,
- $this->gosaSpamSortLevel,
- $this->gosaVacationMessage);
- $this->is_modified = TRUE;
- }else{
- $this->sieve_management->save();
- }
- }
- }
- }
-
- /* Optionally execute a command after we're done */
- if ($this->initially_was_account == $this->is_account){
- if ($this->is_modified){
- $this->handle_post_events("modify", array("uid" => $this->uid));
- }
- } else {
- $this->handle_post_events("add", array("uid" => $this->uid));
- }
-
- $this->updateSharedFolder();
- }
-
-
- /* Check formular input */
- function check()
- {
- if(!$this->is_account) return(array());
-
- $ldap= $this->config->get_ldap_link();
-
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- if(empty($this->gosaMailServer)){
- $message[]= _("There is no valid mailserver specified, please add one in the system setup.");
- }
-
- /* must: mail */
- if ($this->mail == ""){
- $message[]= _("The required field 'Primary address' is not set.");
- }
- if ($this->is_template){
- if (!tests::is_email($this->mail, TRUE)){
- $message[]= _("Please enter a valid email address in 'Primary address' field.");
- }
- } else {
- if (!tests::is_email($this->mail)){
- $message[]= _("Please enter a valid email address in 'Primary address' field.");
- }
- }
- $ldap->cd($this->config->current['BASE']);
- $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=".$this->mail.")(gosaMailAlternateAddress=".$this->mail."))(!(uid=".$this->uid."))(!(cn=".$this->uid.")))", array("uid"));
- if ($ldap->count() != 0){
- $message[]= _("The primary address you've entered is already in use.");
- }
-
- /* Check quota */
- if ($this->gosaMailQuota != '' && $this->acl_is_writeable("gosaMailQuota")){
- if (!is_numeric($this->gosaMailQuota)) {
- $message[]= _("Value in 'Quota size' is not valid.");
- } else {
- $this->gosaMailQuota= (int) $this->gosaMailQuota;
- }
- }
-
- /* Check rejectsize for integer */
- if ($this->gosaMailMaxSize != '' && $this->acl_is_writeable("gosaMailMaxSize")){
- if (!is_numeric($this->gosaMailMaxSize)){
- $message[]= _("Please specify a vaild mail size for mails to be rejected.");
- } else {
- $this->gosaMailMaxSize= (int) $this->gosaMailMaxSize;
- }
- }
-
- /* Need gosaMailMaxSize if use_mailsize_limit is checked */
- if (is_integer(strpos($this->gosaMailDeliveryMode, "R")) &&
- $this->gosaMailMaxSize == ""){
-
- $message[]= _("You need to set the maximum mail size in order to reject anything.");
- }
-
- if((preg_match("/S/", $this->gosaMailDeliveryMode))&&(empty($this->gosaSpamMailbox))) {
- $message[]= _("You specified Spam settings, but there is no Folder specified.");
- }
-
- if (preg_match('/V/', $this->gosaMailDeliveryMode) && $this->gosaVacationStart > $this->gosaVacationStop){
- $message[]= _("Time interval to show vacation message is not valid.");
- }
-
- return ($message);
- }
-
-
- /* Adapt from template, using 'dn' */
- function adapt_from_template($dn)
- {
- plugin::adapt_from_template($dn);
-
- foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
- $this->$val= array();
- if (isset($this->attrs["$val"]["count"])){
- for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){
- $value= $this->attrs["$val"][$i];
- foreach (array("sn", "givenName", "uid") as $repl){
- if (preg_match("/%$repl/i", $value)){
- $value= preg_replace ("/%$repl/i", $this->parent->$repl, $value);
- }
- }
- array_push($this->$val, strtolower(rewrite($value)));
- }
- }
- }
- $this->mail= strtolower(rewrite($this->mail));
- }
-
-
- /* Add entry to forwarder list */
- function addForwarder($address)
- {
- if($this->acl_is_writeable("gosaMailForwardingAddress")){
- $this->gosaMailForwardingAddress[]= $address;
- $this->gosaMailForwardingAddress= array_unique ($this->gosaMailForwardingAddress);
- sort ($this->gosaMailForwardingAddress);
- reset ($this->gosaMailForwardingAddress);
- $this->is_modified= TRUE;
- }else{
- msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses."), ERROR_DIALOG);
- }
- }
-
-
- /* Remove list of addresses from forwarder list */
- function delForwarder($addresses)
- {
- if($this->acl_is_writeable("gosaMailForwardingAddress")){
- $this->gosaMailForwardingAddress= array_remove_entries ($addresses, $this->gosaMailForwardingAddress);
- $this->is_modified= TRUE;
- }else{
- msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses."), ERROR_DIALOG);
- }
- }
-
-
- /* Add given mail address to the list of alternate adresses ,
- check if this mal address is used, skip adding in this case */
- function addAlternate($address)
- {
- if($this->acl_is_writeable("gosaMailAlternateAddress")){
- $ldap= $this->config->get_ldap_link();
- $address= strtolower($address);
-
- /* Is this address already assigned in LDAP? */
- $ldap->cd ($this->config->current['BASE']);
- $ldap->search ("(&(objectClass=gosaMailAccount)(|(mail=$address)"."(gosaMailAlternateAddress=$address)))", array("uid"));
- $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=$address)"."(gosaMailAlternateAddress=$address)))", array("uid"));
-
- if ($ldap->count() > 0){
- $attrs= $ldap->fetch ();
- return ($attrs["uid"][0]);
- }
-
- /* Add to list of alternates */
- if (!in_array($address, $this->gosaMailAlternateAddress)){
- $this->gosaMailAlternateAddress[]= $address;
- $this->is_modified= TRUE;
- }
-
- sort ($this->gosaMailAlternateAddress);
- reset ($this->gosaMailAlternateAddress);
- return ("");
- }else{
- msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses."), ERROR_DIALOG);
- }
- }
-
-
- function delAlternate($addresses)
- {
- if($this->acl_is_writeable("gosaMailAlternateAddress")){
- $this->gosaMailAlternateAddress= array_remove_entries ($addresses,$this->gosaMailAlternateAddress);
- $this->is_modified= TRUE;
- }else{
- msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses."), ERROR_DIALOG);
- }
- }
-
- function make_name($attrs)
- {
- $name= "";
- if (isset($attrs['sn'][0])){
- $name= $attrs['sn'][0];
- }
- if (isset($attrs['givenName'][0])){
- if ($name != ""){
- $name.= ", ".$attrs['givenName'][0];
- } else {
- $name.= $attrs['givenName'][0];
- }
- }
- if ($name != ""){
- $name.= " ";
- }
-
- return ($name);
- }
-
-
- /* Create the mail part for the copy & paste dialog */
- function getCopyDialog()
- {
- if(!$this->is_account) return("");
- $smarty = get_smarty();
- $smarty->assign("mail",$this->mail);
- $smarty->assign("gosaMailAlternateAddress",$this->gosaMailAlternateAddress);
- $smarty->assign("gosaMailForwardingAddress",$this->gosaMailForwardingAddress);
- $str = $smarty->fetch(get_template_path("copypaste.tpl",TRUE, dirname(__FILE__)));
-
- $ret = array();
- $ret['status'] = "";
- $ret['string'] = $str;
- return($ret);
- }
-
- function saveCopyDialog()
- {
- if(!$this->is_account) return;
-
- /* Execute to save mailAlternateAddress && gosaMailForwardingAddress */
- $this->execute();
-
- if(isset($_POST['mail'])){
- $this->mail = $_POST['mail'];
- }
-
- }
-
- function allow_remove()
- {
- if (isset($this->config->current['MAILMETHOD'])){
- $method= $this->config->current['MAILMETHOD'];
- if(preg_match("/olab/i",$method)){
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->cat($this->dn);
- if($ldap->count()){
- $attrs = $ldap->fetch();
- if(isset($attrs['kolabDeleteFlag'])){
- return(_("Waiting for kolab to remove mail properties."));
- }elseif(in_array("gosaMailAccount",$attrs['objectClass'])){
- return(_("Please remove the mail account first, to allow kolab to call its remove methods."));
- }
- }
- }
- }
- }
-
-
- function PrepareForCopyPaste($source)
- {
- plugin::PrepareForCopyPaste($source);
-
- /* Reset alternate mail addresses */
- $this->gosaMailAlternateAddress = array();
- }
-
-
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Mail"),
- "plDescription" => _("Mail settings"),
- "plSelfModify" => TRUE,
- "plDepends" => array("user"), // This plugin depends on
- "plPriority" => 4, // Position in tabs
- "plSection" => array("personal" => _("My account")),
- "plCategory" => array("users"),
- "plOptions" => array(),
-
- "plProvidedAcls" => array(
- "mail" => _("Mail address"),
- "gosaMailServer" => _("Mail server"),
- "gosaMailQuota" => _("Quota size"),
-
- "gosaMailDeliveryModeV" => _("Add vacation information"), // This is flag of gosaMailDeliveryMode
- "gosaVacationMessage" => _("Vacation message"),
-
- "gosaMailDeliveryModeS" => _("Use spam filter"), // This is flag of gosaMailDeliveryMode
- "gosaSpamSortLevel" => _("Spam level"),
- "gosaSpamMailbox" => _("Spam mail box"),
-
- "sieveManagement" => _("Sieve management"),
-
- "gosaMailDeliveryModeR" => _("Reject due to mailsize"), // This is flag of gosaMailDeliveryMode
- "gosaMailMaxSize" => _("Mail max size"),
-
- "gosaMailForwardingAddress" => _("Forwarding address"),
- "gosaMailDeliveryModeL" => _("Local delivery"), // This is flag of gosaMailDeliveryMode
- "gosaMailDeliveryModeI" => _("No delivery to own mailbox "), // This is flag of gosaMailDeliveryMode
- "gosaMailAlternateAddress" => _("Mail alternative addresses"),
-
- "gosaMailForwardingAddress" => _("Forwarding address"),
- "gosaMailDeliveryModeC" => _("Use custom sieve script")) // This is flag of gosaMailDeliveryMode
- ));
- }
-
-
- /*! \brief Prepare importet vacation string. \
- Replace placeholder like %givenName a.s.o.
- @param string Vacation string
- @return string Completed vacation string
- */
- private function prepare_vacation_template($contents)
- {
- /* Replace attributes */
- $attrs = array();
- $obj = NULL;
- if(isset($this->parent->by_object['user'])){
- $attrs = $this->parent->by_object['user']->attributes;
- $obj = $this->parent->by_object['user'];
- }else{
- $obj = new user($this->config,$this->dn);
- $attrs = $obj->attributes;
- }
-
- if($obj){
- foreach ($attrs as $val){
- if(preg_match("/dateOfBirth/",$val)){
- if($obj->use_dob){
- $contents= preg_replace("/%$val/",date("Y-d-m",$obj->dateOfBirth),$contents);
- }
- }else {
- $contents= preg_replace("/%$val/",
- $obj->$val, $contents);
- }
-
- /* Replace vacation start and end time */
- if(preg_match("/%start/",$contents)){
- $contents = preg_replace("/%start/",date("d.m.Y",$this->gosaVacationStart),$contents);
- }
- if(preg_match("/%end/",$contents)){
- $contents = preg_replace("/%end/",date("d.m.Y",$this->gosaVacationStop),$contents);
- }
- }
- }
- return($contents);
- }
-
-
-
- /* Upated shared folder ACLs
- */
- function updateSharedFolder()
- {
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(&(objectClass=posixGroup)(objectClass=gosaMailAccount)(memberUid=".$this->uid."))",array('dn','cn'));
- if(class_exists("grouptabs")){
- while($attrs = $ldap->fetch()){
- $tmp = new grouptabs($this->config, $this->config->data['TABS']['GROUPTABS'], $attrs['dn']);
- if(isset($tmp->by_object['mailgroup'])){
- $tmp->by_object['mailgroup']->members= $tmp->by_object['group']->memberUid;
- if(!$this->is_account){
- $tmp->by_object['mailgroup']->removeUserAcl($this->uid);
- $tmp->by_object['mailgroup']->removeUserAcl($this->mail);
- }
- $tmp->by_object['mailgroup']->save();
- }
- }
- }
- }
-
- /* Initialize plugin with given atribute arrays
- */
- function init_multiple_support($attrs,$all)
- {
- plugin::init_multiple_support($attrs,$all);
-
- if(isset($this->multi_attrs['gosaMailQuota'])){
- $this->gosaMailQuota = $this->multi_attrs['gosaMailQuota'];
- }
- }
-
- function get_multi_init_values()
- {
- $attrs = plugin::get_multi_init_values();
- $attrs['gosaMailQuota'] = $this->gosaMailQuota;
- return($attrs);
- }
-
- function multiple_execute()
- {
- return($this->execute());
- }
-
- function multiple_save_object()
- {
- plugin::multiple_save_object();
-
- $this->save_object();
- foreach(array("only_local","gosaMailForwardingAddress","use_mailsize_limit","drop_own_mails","use_vacation","use_spam_filter") as $attr){
- if(isset($_POST["use_".$attr])){
- $this->multi_boxes[] = $attr;
- }
- }
- }
-
- function get_multi_edit_values()
- {
- $ret = plugin::get_multi_edit_values();
-
- if(in_array("gosaMailQuota",$this->multi_boxes)){
- $ret['gosaMailQuota'] = $this->gosaMailQuota;
- }
-
- $flag_add = $flag_remove = array();
- $tmp= preg_replace("/[^a-z]/i","",$this->gosaMailDeliveryMode);
- $opts = array(
- "R" => "use_mailsize_limit",
- "S" => "use_spam_filter",
- "L" => "only_local",
- "V" => "use_vacation",
- "C" => "own_script",
- "I" => "drop_own_mails");
-
- foreach($opts as $flag => $post){
- if(in_array($post, $this->multi_boxes)){
- if(preg_match("/".$flag."/",$tmp)){
- $flag_add[] = $flag;
- }else{
- $flag_remove[] = $flag;
- }
- }
- }
-
- $ret['flag_add'] = $flag_add;
- $ret['flag_remove'] = $flag_remove;
- return($ret);
- }
-
-
- function multiple_check()
- {
- $message = plugin::multiple_check();
-
- if(empty($this->gosaMailServer) && in_array("gosaMailServer",$this->multi_boxes)){
- $message[]= _("There is no valid mailserver specified, please add one in the system setup.");
- }
-
- /* Check quota */
- if ($this->gosaMailQuota != '' && in_array("gosaMailQuota",$this->multi_boxes)){
- if (!is_numeric($this->gosaMailQuota)) {
- $message[]= _("Value in 'Quota size' is not valid.");
- } else {
- $this->gosaMailQuota= (int) $this->gosaMailQuota;
- }
- }
-
- /* Check rejectsize for integer */
- if ($this->gosaMailMaxSize != '' && in_array("gosaMailMaxSize",$this->multi_boxes)){
- if (!is_numeric($this->gosaMailMaxSize)){
- $message[]= _("Please specify a vaild mail size for mails to be rejected.");
- } else {
- $this->gosaMailMaxSize= (int) $this->gosaMailMaxSize;
- }
- }
-
- if(empty($this->gosaSpamMailbox) && in_array("gosaSpamMailbox",$this->multi_boxes)){
- $message[]= _("You specified Spam settings, but there is no Folder specified.");
- }
-
- if ( in_array("use_vacation",$this->multi_boxes) &&
- preg_match('/V/', $this->gosaMailDeliveryMode) && $this->gosaVacationStart > $this->gosaVacationStop){
- $message[]= _("Time interval to show vacation message is not valid.");
- }
- return($message);
- }
-
-
- function set_multi_edit_values($values)
- {
- plugin::set_multi_edit_values($values);
- $tmp= preg_replace("/[^a-z]/i","",$this->gosaMailDeliveryMode);
- if(isset($values['flag_add'])){
- foreach($values['flag_add'] as $flag){
- if(!preg_match("/".$flag."/",$tmp)){
- $tmp .= $flag;
- }
- }
- }
- if(isset($values['flag_remove'])){
- foreach($values['flag_remove'] as $flag){
- if(preg_match("/".$flag."/",$tmp)){
- $tmp = preg_replace("/".$flag."/","",$tmp);
- }
- }
- }
- $this->gosaMailDeliveryMode = "[".$tmp."]";
-
- /* Set vacation message and replace placeholder like %givenName
- */
- if(isset($values['gosaVacationMessage'])){
- $this->gosaVacationMessage = $this->prepare_vacation_template($values['gosaVacationMessage']);
- }
- }
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/personal/mail/copypaste.tpl b/gosa-core/plugins/personal/mail/copypaste.tpl
+++ /dev/null
@@ -1,70 +0,0 @@
-<h2>{t}Mail settings{/t}</h2>
-<table style='width:100%;' cellspacing=0>
- <tr>
- <td style='width:50%;vertical-align:top; border-right:1px solid #AAA'>
- <table style="width:100%;">
- <tr>
- <td><label for="mail">{t}Primary address{/t}</label>{$must}</td>
- <td><input id="mail" name="mail" size=35 maxlength=65 value="{$mail}"></td>
- </tr>
- <tr>
- <td colspan="2">
- <p style="margin-bottom:0px;">
- <b><label for="forwarder_list">{t}Forward messages to{/t}</label></b>
- </p>
- </td>
- </tr>
- </table>
- </td>
- <td style="vertical-align:bottom;border-left:1px solid #A0A0A0">
- <table style="width:100%;">
- <tr>
- <td style="vertical-align:top;">
- <h2>
- <img class="center" alt="" align="middle" src="images/alternatemail.png" />
- <label for="alternates_list">{t}Alternative addresses{/t}</label>
- </h2>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td>
- <table style='width:100%;'>
- <tr>
- <td colspan="2">
- <select id="gosaMailForwardingAddress" style="width:100%; height:100px;" name="forwarder_list[]" size=15 multiple >
- {html_options values=$gosaMailForwardingAddress output=$gosaMailForwardingAddress}
- <option disabled> </option>
- </select>
- <br>
- <input name="forward_address" size=20 align="middle" maxlength=65 value="">
- <input type="submit" value="{t}Add{/t}" name="add_forwarder" >
- <input type="submit" value="{t}Add local{/t}" name="add_local_forwarder" >
- <input type="submit" value="{t}Delete{/t}" name="delete_forwarder" >
- </td>
- </tr>
- </table>
- </td>
- <td style="vertical-align:bottom;border-left:1px solid #A0A0A0">
- <table style='width:100%;'>
- <tr>
- <td colspan="2" >
- <select id="alternates_list" style="width:100%;height:100px;" name="alternates_list[]" size="15"
- multiple title="{t}List of alternative mail addresses{/t}">
- {html_options values=$gosaMailAlternateAddress output=$gosaMailAlternateAddress}
- <option disabled> </option>
- </select>
- <br/>
- <input name="alternate_address" size="30" align="middle" maxlength="65" value="">
- <input type=submit value="{t}Add{/t}" name="add_alternate">
- <input type=submit value="{t}Delete{/t}" name="delete_alternate">
- </td>
- </tr>
- </table>
- </td>
- </tr>
-</table>
-<br>
-<br>
diff --git a/gosa-core/plugins/personal/mail/generic.tpl b/gosa-core/plugins/personal/mail/generic.tpl
+++ /dev/null
@@ -1,339 +0,0 @@
-<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding="0" border="0">
- <tr>
- <td style="width:50%; vertical-align:top;">
-
- <h2><img class="center" alt="" align="middle" src="images/rightarrow.png" /> {t}Generic{/t}</h2>
- <table summary="">
- <tr>
- <td><label for="mail">{t}Primary address{/t}</label>{$must}</td>
- <td>
-{if $multiple_support}
- <input id="mail" name="dummy1" size=35 maxlength=65 value="{t}Multiple edit{/t}" disabled>
-{else}
-{render acl=$mailACL}
- <input id="mail" name="mail" size=35 maxlength=65 value="{$mail}">
-{/render}
-{/if}
- </td>
- </tr>
- <tr>
- <td><label for="gosaMailServer">{t}Server{/t}</label></td>
- <td>
-{render acl=$gosaMailServerACL checkbox=$multiple_support checked=$use_gosaMailServer}
- <select size="1" id="gosaMailServer" name="gosaMailServer" title="{t}Specify the mail server where the user will be hosted on{/t}">
- {html_options values=$mailServers output=$mailServers selected=$gosaMailServer}
- <option disabled> </option>
- </select>
-{/render}
- </td>
- </tr>
-{if !$multiple_support}
- <tr>
- <td>
- <br>
- {t}Quota usage{/t}
- </td>
- <td>
- <br>
- {if $quotadefined eq "true"}
- {$quotausage}
- {else}
- {t}not defined{/t}
- {/if}
- </td>
- </tr>
-{/if}
- <tr>
- <td><label for="gosaMailQuota">{t}Quota size{/t}</label></td>
- <td>
-{render acl=$gosaMailQuotaACL checkbox=$multiple_support checked=$use_gosaMailQuota}
- <input id="gosaMailQuota" name="gosaMailQuota" size="6" align="middle" maxlength="60"
- value="{$gosaMailQuota}"> MB
-{/render}
- </td>
- </tr>
- </table>
- </td>
-
-{if !$multiple_support}
-
- <td style="border-left:1px solid #A0A0A0;vertical-align:top;">
-
- </td>
- <td>
- <h2><img class="center" alt="" align="middle" src="images/alternatemail.png" /><label for="alternates_list"> {t}Alternative addresses{/t}</label></h2>
-{render acl=$gosaMailAlternateAddressACL}
- <select id="alternates_list" style="width:100%;height:100px;" name="alternates_list[]" size="15" multiple
- title="{t}List of alternative mail addresses{/t}">
- {html_options values=$gosaMailAlternateAddress output=$gosaMailAlternateAddress}
- <option disabled> </option>
-{/render}
- </select>
- <br />
-{render acl=$gosaMailAlternateAddressACL}
- <input name="alternate_address" size="30" align="middle" maxlength="65" value="">
-{/render}
-{render acl=$gosaMailAlternateAddressACL}
- <input type=submit value="{t}Add{/t}" name="add_alternate">
-{/render}
-{render acl=$gosaMailAlternateAddressACL}
- <input type=submit value="{t}Delete{/t}" name="delete_alternate">
-{/render}
- </td>
-
-{/if}
-
- </tr>
-</table>
-
-{if $multiple_support}
-
-<p class="seperator"> </p>
-<h2><img class="center" alt="" align="middle" src="images/envelope.png" /> {t}Mail options{/t}</h2>
-
-{else}
-
-<!-- SIEVE -->
-<p class="seperator"> </p>
-<table summary="" style="vertical-align:top; text-align:left;" cellpadding=4 border=0>
- <tr>
- <td>
-{render acl=$gosaMailDeliveryModeCACL}
- <input class="center" type=checkbox name="own_script" value="1" {$own_script}
- onClick="
- changeState('sieveManagement');
- changeState('drop_own_mails');
- changeState('use_vacation');
- changeState('use_spam_filter');
- changeState('use_mailsize_limit');
- changeState('import_vacation');
- changeState('vacation_template');
-// changeState('forward_address');
-// changeState('add_forwarder');
-// changeState('add_local_forwarder');
-// changeState('delete_forwarder');
- changeState('only_local');
- changeState('gosaVacationMessage');
- changeState('gosaSpamSortLevel');
- changeState('gosaSpamMailbox');
- changeState('gosaMailMaxSize');
- changeStates();
-
- "
-
-> {t}Use custom sieve script{/t} <b>({t}disables all Mail options!{/t})</b>
-{/render}
- </td>
- </tr>
- <tr>
- <td>
-{render acl=$sieveManagementACL}
- <input {if $own_script == ""} disabled {/if} id='sieveManagement' type='submit' name='sieveManagement' value='{t}Sieve Management{/t}'>
-{/render}
- </td>
- </tr>
-</table>
-
-<p class="seperator"> </p>
-{/if}
-
-<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4 border=0>
- <tr style="padding-bottom:0px;">
- <td style="width:50%">
-{render acl=$gosaMailDeliveryModeIACL checkbox=$multiple_support checked=$use_drop_own_mails}
- <input {if $own_script != ""} disabled {/if} class="center" id='drop_own_mails' type=checkbox name="drop_own_mails" value="1" {$drop_own_mails} title="{t}Select if you want to forward mails without getting own copies of them{/t}"> {t}No delivery to own mailbox{/t}
-{/render}
-
-<br>
-{render acl=$gosaMailDeliveryModeVACL checkbox=$multiple_support checked=$use_use_vacation}
- <input type=checkbox name="use_vacation" value="1" {$use_vacation} id="use_vacation" {if $own_script != ""} disabled {/if}
- title="{t}Select to automatically response with the vacation message defined below{/t}" class="center"
-onclick="changeState('day'); changeState('month'); changeState('year'); changeState('sday'); changeState('smonth'); changeState('syear');
-"> {t}Activate vacation message{/t}
-{/render}
-
- <br>
-
- <table>
- <tr>
- <td>
- {t}from{/t}
- </td>
- <td>
-{render acl=$gosaVacationMessageACL}
- <select {if $own_script != ""} disabled {/if} name=day id="day" onChange="createResult(this.form,this.form.gosaVacationStart);" {$rangeEnabled}>
- {html_options values=$days output=$days selected=$start_day}
- </select>
-{/render}
-{render acl=$gosaVacationMessageACL}
- <select {if $own_script != ""} disabled {/if} name=month id="month" onChange="populate(this.form,this.form.gosaVacationStart);" {$rangeEnabled}>
- {html_options options=$months selected=$start_month}
- </select>
-{/render}
-{render acl=$gosaVacationMessageACL}
- <select {if $own_script != ""} disabled {/if} name=year id="year" onChange="populate(this.form,this.form.gosaVacationStart);" {$rangeEnabled}>
- {html_options values=$years output=$years selected=$start_year}
- </select>
-{/render}
- <input type="hidden" name="gosaVacationStart" value="{$gosaVacationStart}">
- </td>
- </tr>
- <tr>
- <td>
- {t}till{/t}
- </td>
- <td>
-{render acl=$gosaVacationMessageACL}
- <select {if $own_script != ""} disabled {/if} name=sday id="sday" onChange="createResult2(this.form,this.form.gosaVacationStop);" {$rangeEnabled}>
- {html_options values=$days output=$days selected=$end_day}
- </select>
-{/render}
-{render acl=$gosaVacationMessageACL}
- <select {if $own_script != ""} disabled {/if} name=smonth id="smonth" onChange="populate2(this.form,this.form.gosaVacationStop);" {$rangeEnabled}>
- {html_options options=$months selected=$end_month}
- </select>
-{/render}
-{render acl=$gosaVacationMessageACL}
- <select {if $own_script != ""} disabled {/if} name=syear id="syear" onChange="populate2(this.form,this.form.gosaVacationStop);" {$rangeEnabled}>
- {html_options values=$years output=$years selected=$end_year}
- </select>
-{/render}
- <input type="hidden" name="gosaVacationStop" value="{$gosaVacationStop}">
- </td>
- </tr>
- </table>
-
-
- <td rowspan=2 style="border-left:1px solid #A0A0A0">
-
- </td>
- <td style="vertical-align:top;">
-{render acl=$gosaMailDeliveryModeSACL checkbox=$multiple_support checked=$use_use_spam_filter}
- <input {if $own_script != ""} disabled {/if} id='use_spam_filter' type=checkbox name="use_spam_filter" value="1" {$use_spam_filter} title="{t}Select if you want to filter this mails through spamassassin{/t}" class="center">
-{/render}
- <label for="gosaSpamSortLevel">{t}Move mails tagged with spam level greater than{/t}</label>
-
-{render acl=$gosaSpamSortLevelACL checkbox=$multiple_support checked=$use_gosaSpamSortLevel}
- <select {if $own_script != ""} disabled {/if} id="gosaSpamSortLevel" size="1" name="gosaSpamSortLevel" title="{t}Choose spam level - smaller values are more sensitive{/t}">
- {html_options values=$spamlevel output=$spamlevel selected=$gosaSpamSortLevel}
- </select>
-{/render}
- <label for="gosaSpamMailbox">{t}to folder{/t}</label>
-{render acl=$gosaSpamMailboxACL checkbox=$multiple_support checked=$use_gosaSpamMailbox}
- <select {if $own_script != ""} disabled {/if} size="1" id="gosaSpamMailbox" name="gosaSpamMailbox">
- {html_options values=$spambox output=$spambox selected=$gosaSpamMailbox}
- <option disabled> </option>
- </select>
-{/render}
- <br>
-{render acl=$gosaMailDeliveryModeRACL checkbox=$multiple_support checked=$use_use_mailsize_limit}
- <input {if $own_script != ""} disabled {/if} id='use_mailsize_limit' type=checkbox name="use_mailsize_limit" value="1" {$use_mailsize_limit} class="center">
-{/render}
- <label for="gosaMailMaxSize">{t}Reject mails bigger than{/t}</label>
-{render acl=$gosaMailMaxSizeACL checkbox=$multiple_support checked=$use_gosaMailMaxSize}
- <input {if $own_script != ""} disabled {/if} id="gosaMailMaxSize" name="gosaMailMaxSize" size="6" align="middle" maxlength="30" value="{$gosaMailMaxSize}" class="center"> {t}MB{/t}
-{/render}
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top; width:45%">
- <p style="margin-bottom:0px;">
- <b><label for="gosaVacationMessage">{t}Vacation message{/t}</label></b>
- </p>
-{render acl=$gosaVacationMessageACL checkbox=$multiple_support checked=$use_gosaVacationMessage}
- <textarea {if $own_script != ""} disabled {/if} id="gosaVacationMessage" style="width:99%; height:100px;" name="gosaVacationMessage" rows="4" cols="512">{$gosaVacationMessage}</textarea>
-{/render}
- <br>
-
- {if $show_templates eq "true"}
-{render acl=$gosaVacationMessageACL}
- <select id='vacation_template' name="vacation_template" {if $own_script != ""} disabled {/if}>
- {html_options options=$vacationtemplates selected=$template}
- <option disabled> </option>
- </select>
-{/render}
-{render acl=$gosaVacationMessageACL}
- <input {if $own_script != ""} disabled {/if} id='import_vacation' type="submit" value="{t}Import{/t}" name="import_vacation">
-{/render}
- {/if}
- </td>
- <td>
- <p style="margin-bottom:0px;">
- <b><label for="forwarder_list">{t}Forward messages to{/t}</label></b>
- </p>
-
-{if $multiple_support}
-<input type="checkbox" name="use_gosaMailForwardingAddress" onclick="changeState('gosaMailForwardingAddress');"
- class="center" {if $use_gosaMailForwardingAddress} checked {/if}>
-{/if}
-
-{render acl=$gosaMailForwardingAddressACL}
- <select {if $use_gosaMailForwardingAddress} checked {/if}
- id="gosaMailForwardingAddress" style="width:100%; height:100px;" name="forwarder_list[]" size=15 multiple>
- {html_options values=$gosaMailForwardingAddress output=$gosaMailForwardingAddress selected=$template}
- <option disabled> </option>
- </select>
-{/render}
- <br>
-{render acl=$gosaMailForwardingAddressACL}
- <input id='forward_address' name="forward_address" size=20 align="middle" maxlength=65 value="">
-{/render}
-{render acl=$gosaMailForwardingAddressACL}
- <input id='add_forwarder' type="submit" value="{t}Add{/t}" name="add_forwarder" >
-{/render}
-{render acl=$gosaMailForwardingAddressACL}
- <input id='add_local_forwarder' type="submit" value="{t}Add local{/t}" name="add_local_forwarder" >
-{/render}
-{render acl=$gosaMailForwardingAddressACL}
- <input id='delete_forwarder' type="submit" value="{t}Delete{/t}" name="delete_forwarder">
-{/render}
- </td>
- </tr>
-</table>
-<p class="seperator"> </p>
-
-<h2><img class="center" alt="" align="middle" src="images/false.png" /> {t}Advanced mail options{/t}</h2>
-
-<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding="4" border="0">
- <tr>
- <td>
-{render acl=$gosaMailDeliveryModeLACL checkbox=$multiple_support checked=$use_only_local}
- <input {if $own_script != ""} disabled {/if} id='only_local' type=checkbox name="only_local" value="1" {$only_local} title="{t}Select if user can only send and receive inside his own domain{/t}" class="center">
-{/render}
- {t}User is only allowed to send and receive local mails{/t}
- </td>
- </tr>
-</table>
-
-<input type="hidden" name="mailTab" value="mailTab">
-
-<!-- Place cursor -->
-<script language="JavaScript" type="text/javascript">
-
- {literal}
- function changeStates()
- {
-
- if(document.getElementById('use_vacation').checked){
- changeState('day');
- changeState('month');
- changeState('year');
- changeState('sday');
- changeState('smonth');
- changeState('syear');
- }else{
- changeSubselectState('use_vacation','day');
- changeSubselectState('use_vacation','month');
- changeSubselectState('use_vacation','year');
- changeSubselectState('use_vacation','sday');
- changeSubselectState('use_vacation','smonth');
- changeSubselectState('use_vacation','syear');
- }
- }
-
- {/literal}
-
-<!-- // First input field on page
- focus_field('mail');
- -->
-</script>
diff --git a/gosa-core/plugins/personal/mail/mail_locals.tpl b/gosa-core/plugins/personal/mail/mail_locals.tpl
+++ /dev/null
@@ -1,81 +0,0 @@
-<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
- <tr>
- <td style="vertical-align:top;width:600px">
- <div class="contentboxh" style="height:20px;">
- <p class="contentboxh" style="font-size:12px">
- <b>
- <LABEL for="local_list">{t}Select addresses to add{/t}</LABEL>
- {$hint}
- </b>
- <br>
- </p>
- </div>
- <div class="contentboxb">
- <p class="contentboxb" style="border-top:1px solid #B0B0B0;background-color:#F8F8F8">
- <select id="local_list" style="width:600px; margin-top:4px; height:450px;" name="local_list[]" size="15" multiple>
- {html_options options=$mailusers}
- </select>
- </p>
- </div>
- </td>
- <td style="vertical-align:top;">
- <div class="contentboxh" style="height:20px;">
- <p class="contentboxh" style="font-size:12px">
- <img src="{$launchimage}" align="right" alt="[F]">
- <b>{t}Filters{/t}</b>
- </p>
- </div>
- <div class="contentboxb" style="background-color:#F8F8F8">
- <table summary="" style="width:100%;border-top:1px solid #B0B0B0; background-color:#F8F8F8">
- {$alphabet}
- </table>
- <table summary="" width="100%" style="border-top:1px solid #B0B0B0;background-color:#F8F8F8">
- <tr>
- <td>
- <LABEL for="depselect">{t}Select department{/t}</LABEL>
- <img alt="" src="{$tree_image}" align=middle>
- <select id="depselect" name="depselect" size=1 onChange="mainform.submit()"
- title="{t}Choose the department the search will be based on{/t}">
- {html_options options=$deplist selected=$depselect}
- </select>
- </td>
- </tr>
- </table>
-
- <table summary="" width="100%" style="border-top:1px solid #B0B0B0;background-color:#F8F8F8">
- <tr>
- <td style="width:18px">
- <img alt="" src="{$search_image}" align="middle">
- </td>
- <td>
- <input type='text' name='regex' maxlength='20' style="width:99%" value='{$regex}'
- title='{t}Regular expression for matching addresses{/t}' onChange="mainform.submit()">
- </td>
- </tr>
- </table>
-
- <table summary="" width="100%" style="border-top:1px solid #B0B0B0;background-color:#F8F8F8">
- <tr>
- <td style="width:18px;">
- <img src="{$usearch_image}" align=middle alt="{t}Display addresses of user{/t}">
- </td>
- <td>
- <input type='text' name='muser' maxlength='20' style="width:99%" value='{$muser}'
- title='{t}User name of which addresses are shown{/t}' onChange="mainform.submit()">
- </td>
- </tr>
- </table>
- {$apply}
- </div>
- </td>
- </tr>
-</table>
-
-<p class="plugbottom">
- <input type=submit name="add_locals_finish" value="{t}Add{/t}">
-
- <input type=submit name="add_locals_cancel" value="{t}Cancel{/t}">
-</p>
-<!--
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
--->
diff --git a/gosa-core/plugins/personal/mail/main.inc b/gosa-core/plugins/personal/mail/main.inc
+++ /dev/null
@@ -1,131 +0,0 @@
-<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2003 Cajus Pollmeier
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-$lock_msg ="";
-$display ="";
-if (!$remove_lock){
- /* Reset requested? */
- if (isset($_POST['edit_cancel']) ||
- (isset($_GET['reset']) && $_GET['reset'] == 1)){
- del_lock ($ui->dn);
- session::un_set ('edit');
- session::un_set ('mailAccount');
- }
-
- /* Create mail object on demand */
- if (!session::is_set('mailAccount') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
- $mailAccount= new mailAccount ($config, $ui->dn);
- $mailAccount->enable_CSN_check();
- $mailAccount->set_acl_base($ui->dn);
- $mailAccount->set_acl_category("users");
- session::set('mailAccount',$mailAccount);
- }
- $mailAccount = session::get('mailAccount');
-
- /* save changes back to object */
- if (session::is_set('edit')){
- $mailAccount->save_object ();
- }
-
- /* Enter edit mode? */
- if (isset($_POST['edit']) && preg_match("/w/",$ui->get_permissions($ui->dn,"users/mailAccount"))){
-
- /* Check locking */
- if (($username= get_lock($ui->dn)) != ""){
- session::set('back_plugin',$plug);
- session::set('LOCK_VARS_TO_USE',array("/^edit$/","/^plug$/"));
- $lock_msg = gen_locked_message ($username, $ui->dn);
-
- }else{
-
- /* Lock the current entry */
- add_lock ($ui->dn, $ui->dn);
- session::set('dn',$ui->dn);
- session::set('edit',TRUE);
- }
- }
-
- /* save changes to LDAP and disable edit mode */
- if (isset($_POST['edit_finish'])){
-
- /* Perform checks */
- $message= $mailAccount->check ();
-
- /* No errors, save object */
- if (count ($message) == 0){
- $mailAccount->save ();
- del_lock ($ui->dn);
- session::un_set ('edit');
-
- /* Remove object */
- session::un_set ('mailAccount');
- } else {
- /* Errors found, show message */
- show_errors ($message);
- }
- }
-
- /* Execute formular */
- if($lock_msg){
- $display.= $lock_msg;
- }else{
- $display.= $mailAccount->execute ();
- }
-
- /* Store changes in session */
- if (session::is_set('edit')){
- session::set('mailAccount',$mailAccount);
- }
-
- $info= "";
- /* Show page footer depending on the mode */
- if (!$mailAccount->forward_dialog && $mailAccount->is_account && empty($lock_msg)){
- $display.= "<p class=\"plugbottom\">";
-
- /* Are we in edit mode? */
- if (session::is_set('edit')){
- $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
- $display.= " ";
- $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
- $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
- "\"> ".$ui->dn." ";
- } else {
- $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
- "\"> ".$ui->dn." ";
-
- $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png').
- "\"> "._("Click the 'Edit' button below to change informations in this dialog");
-
- if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/mailAccount"))){
- $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
- }
-
- $display.= "<input type=\"hidden\" name=\"ignore\">\n";
- }
- $display.= "</p>\n";
- }
-
- /* Page header*/
- $display= print_header(get_template_path('images/email.png'), _("User mail settings"), $info).$display;
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/personal/mail/sieve-discard.txt b/gosa-core/plugins/personal/mail/sieve-discard.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-# Do not deliver to own mailbox
-discard;
-
diff --git a/gosa-core/plugins/personal/mail/sieve-header.txt b/gosa-core/plugins/personal/mail/sieve-header.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-###GOSA
-require ["fileinto", "reject", "vacation"];
-
diff --git a/gosa-core/plugins/personal/mail/sieve-mailsize.txt b/gosa-core/plugins/personal/mail/sieve-mailsize.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-# Reject mails with bigger size
-if size :over {$maxsize}M{
- reject text:
-Dear sender,
-
-the mail you sent to our mailsystem has been rejected due
-to a user configured maximum mail size ($maxsize MB).
-
-Either ask the user to remove the sizelimit, or send smaller pieces.
-
-Thank you,
- the mailserver
-.
- ;
- discard;
-}
-
diff --git a/gosa-core/plugins/personal/mail/sieve-spam.txt b/gosa-core/plugins/personal/mail/sieve-spam.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-# Sort mails with higher spam level
-if header :contains "X-Spam-Level" "$spamlevel" {
- fileinto "$spambox";
-}
-
diff --git a/gosa-core/plugins/personal/mail/sieve-vacation.txt b/gosa-core/plugins/personal/mail/sieve-vacation.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# Vacation message
-vacation :addresses [$addrlist]
-"$vacmsg" ;
-
diff --git a/gosa-plugins/mail/addons/mailqueue/class_mailqueue.inc b/gosa-plugins/mail/addons/mailqueue/class_mailqueue.inc
--- /dev/null
@@ -0,0 +1,417 @@
+<?php
+
+class mailqueue extends plugin
+{
+ /* Definitions */
+ var $plHeadline= "Mail queue";
+ var $plDescription= "This does something";
+
+ /* attribute list for save action */
+ var $attributes = array();
+ var $objectclasses = array();
+ var $mailQueueScript= "";
+ var $Server = "all";
+ var $Time = 0;
+ var $Search = "*";
+ var $Page = 0;
+ var $Stat = "all";
+ var $OrderBy = "Arrival";
+ var $SortType = "up";
+ var $disp_header = false;
+ var $range = 20;
+ var $view_logged = FALSE;
+
+ function mailqueue(&$config, $dn= NULL)
+ {
+ $this->config = &$config;
+ if (isset($this->config->current['MAILQUEUESCRIPTPATH'])){
+ $this->mailQueueScript = $this->config->current['MAILQUEUESCRIPTPATH'];
+ }
+
+ if(isset($this->config->data['MAIN']['MAILQUEUESCRIPTPATH'])){
+ $this->mailQueueScript = $this->config->data['MAIN']['MAILQUEUESCRIPTPATH'];
+ }
+
+ $this->Server = "all";
+ }
+
+
+ function pass_cmd($str)
+ {
+ return(shell_exec($str));
+ }
+
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ /* Log view */
+ if(!$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","mailqueue/".get_class($this),$this->dn);
+ }
+
+ if(isset($_POST['EntriesPerPage'])){
+ $this->range = $_POST['EntriesPerPage'];
+ }
+
+ $smarty= get_smarty();
+ $error =false;
+
+ if(empty($this->mailQueueScript)){
+ msg_dialog::display(_("Configuration error"), sprintf(_("Missing '%s' directive in configuration!"), "mailqueuescriptpath"), ERROR_DIALOG);
+ $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","del_all","requeue_all") as $attr){
+ foreach($_POST as $name => $value){
+ if((preg_match("/".$attr."/",$name))&&($only_once)){
+ if(!$this->acl_is_readable($attr)){
+ $only_once = false;
+ msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to submit a '%s' command!"), $attr), ERROR_DIALOG);
+ }else{
+ $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)==false){
+ msg_dialog::display(_("Configuration error"), sprintf(_("'%s' defined for the '%s' directive cannot be executed!"), $r_cmd, "mailqueuescriptpath"), ERROR_DIALOG);
+ }
+ }
+ }
+ }
+ }
+
+ /* 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;
+
+ if(!$this->acl_is_readable($opt)){
+ msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to submit a '%s' command!"), $opt), ERROR_DIALOG);
+ }else{
+ /* 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)){
+ msg_dialog::display(_("Configuration error"), sprintf(_("'%s' defined for the '%s' directive cannot be executed!"), $r_cmd, "mailqueuescriptpath"), ERROR_DIALOG);
+ }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"){
+
+ /* Create Query cmd */
+ $q_cmd = preg_replace("/%action/" ,"query" ,$this->mailQueueScript);
+ $q_cmd = preg_replace("/%server/" ,$this->Server,$q_cmd);
+ $q_cmd = preg_replace("/%id/" ,"all" ,$q_cmd);
+
+ if(!$this->acl_is_readable("query")){
+ msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to submit a '%s' command!"), "query"), ERROR_DIALOG);
+ $mailQueueParser = new parseMailQueue("",$this->Server);
+ }else{
+
+ /* Only display this if the query cmd is executeable */
+ if($str = @$this->pass_cmd ($q_cmd)){
+ /* Parse returned data */
+ $mailQueueParser = new parseMailQueue($str,$this->Server);
+ }else{
+ /* On error/ no return value / false return value */
+ msg_dialog::display(_("Configuration error"), sprintf(_("'%s' defined for the '%s' directive cannot be executed!"), $q_cmd, "mailqueuescriptpath"), ERROR_DIALOG);
+ $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(!$this->acl_is_readable("query")){
+ msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to submit a '%s' command!"), "query"), ERROR_DIALOG);
+ $mailQueueParser = new parseMailQueue("",$this->Server);
+ }else{
+
+ /* 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{
+ msg_dialog::display(_("Configuration error"), sprintf(_("'%s' defined for the '%s' directive cannot be executed!"), $q_cmd, "mailqueuescriptpath"), ERROR_DIALOG);
+ $error = true;
+ }
+ }
+ }
+ }
+
+ /* Check for existing servers
+ objectClass=goMailServer is required at least for one server.
+ Else display error */
+ $server = $this->getServer();
+ if((count($server) == 1 ) && (isset($server['all']))){
+ msg_dialog::display(_("Configuration error"), _("No mail servers sepcified!"), ERROR_DIALOG);
+ $error = true;
+ }
+
+ if(!$error){
+
+ /* 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();
+
+ if(count($entries) ==0 ){
+ $smarty->assign("all_ok",false);
+ }
+
+ $smarty->assign("entries" , array_slice($entries,$this->Page,$this->range));
+ $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()));
+ $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, $this->range,"EntriesPerPage"));
+ $smarty->assign("OrderBy" , $this->OrderBy);
+
+ /* Display sort arrow */
+ 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'>");
+ }
+ }
+ }
+
+ /* 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("stat" , $this->Stat);
+ $smarty->assign("plug" , "?plug=".$_GET['plug']);
+ $smarty->assign("p_server" , $this->Server);
+ $smarty->assign("p_servers" , $this->getServer());
+ $smarty->assign("p_serverKeys" , array_flip($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("OrderBy" , $this->OrderBy);
+ }
+ return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
+ }
+
+
+ /* return selectable server */
+ function getServer()
+ {
+ $ret= array("all"=>_("All"));
+ $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);
+ }
+
+
+ /* Return selectable times*/
+ function getTimes()
+ {
+ $ret = array();
+ $ret['nolimit']=_("no limit");
+ foreach(array(1,2,4,8,12,24,36,48) as $i){
+ if($i == 1){
+ $ret[$i] = $i." "._("hour");
+ }else{
+ $ret[$i] = $i." "._("hours");
+ }
+ }
+ return($ret);
+ }
+
+
+ /* Save post values*/
+ 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($_POST['Stat'])){
+ $this->Stat = $_POST['Stat'];
+ }
+ 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";
+ }
+ }
+ }
+
+ }
+
+ /* Return stats */
+ function getStats()
+ {
+ return(array(
+ "all" =>_("All"),
+ "hold" =>_("Hold"),
+ "unhold" =>_("Un hold"),
+ "active" =>_("Active"),
+ "nonactive" =>_("Not active")
+ ));
+ }
+
+ /* Return plugin informations for acl handling
+ #FIXME You can only read attributes within this report plugin */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Mailqueue"),
+ "plDescription" => _("Mailqueue addon"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 1,
+ "plSection" => array("addon"),
+ "plCategory" => array("mailqueue" => array("objectClass" => "none", "description" => _("Mail queue addon"))),
+
+ "plProvidedAcls" => array(
+ "unhold_all" => _("Unhold all messages"),
+ "hold_all" => _("Hold all messages"),
+ "del_all" => _("Delete all messages"),
+ "requeue_all" => _("Requeue all messages"),
+ "unhold" => _("Unhold message"),
+ "hold" => _("Hold message"),
+ "del" => _("Delete message"),
+ "requeue" => _("Requeue message"),
+ "query" => _("Gathering queue data"),
+ "header" => _("Get header information")
+ )
+ ));
+ }
+
+
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/mail/addons/mailqueue/class_parseMailQueue.inc b/gosa-plugins/mail/addons/mailqueue/class_parseMailQueue.inc
--- /dev/null
@@ -0,0 +1,237 @@
+<?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,$server)
+ {
+ $this->s_dataToParse = $s_data;
+ $this->a_parsedData = array();
+ $this->_parse($s_data,$server);
+ }
+
+
+ /* Remove all entries which are older than the last x hours
+ */
+ function OnlyDaysAgo($str)
+ {
+ /* Get current time */
+ $cur = time();
+
+ /* Only perform this filter, if the given parameter is valid */
+ if((is_numeric($str))&&($str != 0)){
+
+ /* hours are given as parameter */
+ $cur = $cur - ($str*(60*60));
+
+ /* Remove old entries */
+ foreach($this->a_parsedData as $key => $data){
+ if($data['Arrival'] < $cur){
+ unset($this->a_parsedData[$key]);
+ }
+ }
+ }
+ }
+
+
+ /* Only keep entries that contains the $filter
+ * in any of the given $fields
+ */
+ function Search($filter,$fields,$bool = false)
+ {
+ /* Go through all entries */
+ foreach($this->a_parsedData as $key => $data){
+
+ /* not found yet */
+ $found = false;
+
+ foreach($fields as $attr){
+ if(($bool)&&($data[$attr]==$filter)){
+ $found = true;
+ }elseif(preg_match("/".str_replace("*",".*",$filter)."/i",$data[$attr])){
+ $found= true;
+ }
+ }
+
+ /* if nothing found, delete this entry */
+ if($found == false){
+ unset($this->a_parsedData[$key]);
+ }
+ }
+ }
+
+ /* Convert date from timestamp to human readable */
+ function CreateDate()
+ {
+ foreach($this->a_parsedData as $key => $data){
+ $this->a_parsedData[$key]['Arrival'] = date("d.m.Y H:i:s",$data['Arrival']);
+ }
+ }
+
+ /* Order by specified field */
+ function OrderBy($str = "Arrival",$type = "up" )
+ {
+ $tmp = array();
+ /* If the given field is not valid */
+ if(!in_array($str,array("MailID","Size","Sender","Recipient","Arrival","Error","Server"))){
+ return(false);
+ }
+
+ /* Size need special handling, cause it contains numbers
+ */
+ 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'].$data['Server'];
+ $tmp[$struse]= $data;
+ }
+ }else{
+ foreach($this->a_parsedData as $data){
+ $tmp[strtolower($data[$str]).$data['MailID']."-".$data['Server']]= $data;
+ }
+ }
+ ksort($tmp);
+ if($type != "up"){
+ $tmp = array_reverse($tmp);
+ }
+ $this->a_parsedData = array();
+ foreach($tmp as $data){
+ $this->a_parsedData[$data['MailID']."-".$data['Server']] = $data;
+ }
+ return(true);
+ }
+
+ function GetAll()
+ {
+ return($this->a_parsedData);
+ }
+
+ /* Checks if the given MailID exists */
+ function IDExists($id)
+ {
+ foreach($this->a_parsedData as $entry){
+ if($entry['MailID'] == $id) return(true);
+ }
+ return(false);
+ }
+
+ function parseAdditionalQueue($str, $server)
+ {
+ $this->_parse($str, $server);
+ }
+
+ /* This function parses the given data
+ * it creates an array with all given queue entries
+ */
+ function _parse($str, $server)
+ {
+ $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/","",$str);
+
+ /* 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];
+
+ /*
+ * 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;
+ $this->a_parsedData[$s_mailID."-".$server]['Size'] = $s_Size;
+ $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);
+ }
+
+ /* Parse Error part of the entry */
+ 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:
+?>
diff --git a/gosa-plugins/mail/addons/mailqueue/contents.tpl b/gosa-plugins/mail/addons/mailqueue/contents.tpl
--- /dev/null
@@ -0,0 +1,130 @@
+<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">
+ <div >
+ <table width="100%" summary="">
+ <tr>
+ <td>
+ <img class="center" alt="{t}Search{/t}" src="images/search.png" align="middle" border="0">
+ {t}Search for{/t}
+ <input name="search_for" size="12" 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_serverKeys output=$p_servers selected=$p_server}
+ </select>
+ {t}with status{/t} :
+ <select size="1" name="Stat" onchange="mainform.submit()">
+ {html_options values=$stats output=$r_stats selected=$stat}
+ </select>
+ {t}within the last{/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="{t}Search{/t}" type="submit">
+ </td>
+ <td style="border-left:1px solid #A0A0A0; text-align:right;">
+ <input name="del_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"
+ 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"
+ title="{t}Requeue all messages in selected servers queue{/t}">
+ </td>
+ </tr>
+ </table>
+ </div>
+</div>
+<br>
+
+
+{if $all_ok != "true"}
+<b>{t}Search returned no results{/t}...</b>
+{else}
+
+<table style="border: 1px solid rgb(176, 176, 176); width: 100%; vertical-align: top; text-align: left;" summary=""
+ 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=Server" >{t}Server{/t} {if $OrderBy == "Server"} {$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>
+ <td> </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 >
+<!-- 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 class="center" src="images/mailq_active.png" border=0 alt="{t}Active{/t}">
+ {/if}
+
+ {$entries[$key].MailID}</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 >{$entries[$key].Error}</td>
+ <td style="text-align:right">
+ <a href="{$plug}&act=del&id={$entries[$key].MailID}&server={$entries[$key].Server}">
+ <img class="center" src="images/edittrash.png" border=0 alt="{t}delete{/t}" title="{t}Delete this message{/t}">
+ </a>
+ {if $entries[$key].Hold == true}
+ <a href="{$plug}&act=unhold&id={$entries[$key].MailID}&server={$entries[$key].Server}">
+ <img class="center" src="images/mailq_unhold.png" border=0 alt="{t}unhold{/t}" title="{t}Release message{/t}">
+ </a>
+ {else}
+ <a href="{$plug}&act=hold&id={$entries[$key].MailID}&server={$entries[$key].Server}">
+ <img class="center" src="images/mailq_hold.png" border=0 alt="{t}hold{/t}" title="{t}Hold message{/t}">
+ </a>
+ {/if}
+ <a href="{$plug}&act=requeue&id={$entries[$key].MailID}&server={$entries[$key].Server}">
+ <img class="center" 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 class="center" src="images/mailq_header.png" border=0 alt="{t}header{/t}" title="{t}Display header from this message{/t}">
+ </a>
+ </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>
+
+{/if}
+
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ focus_field('search_for');
+ -->
+</script>
diff --git a/gosa-plugins/mail/addons/mailqueue/header.tpl b/gosa-plugins/mail/addons/mailqueue/header.tpl
--- /dev/null
@@ -0,0 +1,6 @@
+{$header}
+
+<p class="seperator"> </p>
+<div style='text-align:right;'>
+ <input type="submit" name="back" value="{t}Back{/t}">
+</div>
diff --git a/gosa-plugins/mail/addons/mailqueue/main.inc b/gosa-plugins/mail/addons/mailqueue/main.inc
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2003 Cajus Pollmeier
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+if (!$remove_lock){
+ /* Create mailqueue object on demand */
+ if (!session::is_set('mailqueue') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
+ $ui = get_userinfo();
+ $mailqueue= new mailqueue ($config);
+ $mailqueue->set_acl_category("mailqueue");
+
+ /* Check root dn and user dn for acl informations */
+ $mailqueue->set_acl_base($config->current['BASE']);
+ if($mailqueue->getacl("") == ""){
+ $mailqueue->set_acl_base($ui->dn);
+ }
+ session::set('mailqueue',$mailqueue);
+ }
+ $mailqueue = session::get('mailqueue');
+
+ /* Execute formular */
+ $mailqueue->save_object();
+ $display= $mailqueue->execute ();
+ $display.= "<input type=\"hidden\" name=\"ignore\">\n";
+
+ /* Page header*/
+ $display= print_header(get_template_path('images/mailqueue.png'), _("Mail queue")).$display;
+
+ /* Store changes in session */
+ session::set('mailqueue',$mailqueue);
+}
+?>
diff --git a/gosa-plugins/mail/admin/systems/services/mail/class_goMailServer.inc b/gosa-plugins/mail/admin/systems/services/mail/class_goMailServer.inc
--- /dev/null
@@ -0,0 +1,725 @@
+<?php
+
+class goMailServer extends goService{
+
+ var $cli_summary = "This pluign is used within the ServerService Pluign \nand indicates that this server supports mailqueue listings and so on.";
+ var $cli_description = "Some longer text\nfor help";
+ var $cli_parameters = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* This plugin only writes its objectClass */
+ var $objectclasses = array("goMailServer");
+
+ /* This class can't be assigned twice so it conflicts with itsself */
+ var $DisplayName = "";
+ var $dn = NULL;
+ var $StatusFlag = "goMailServerStatus";
+ var $attributes = array("description","postfixHeaderSizeLimit",
+ "postfixMailboxSizeLimit","postfixMessageSizeLimit",
+ "postfixMyDestinations","postfixMyDomain","postfixMyhostname",
+ "postfixMyNetworks","postfixRelayhost","postfixTransportTable",
+ "postfixSenderRestrictions","postfixRecipientRestrictions");
+
+ var $goMailServerStatus ;
+ var $postfixHeaderSizeLimit = 0;
+ var $postfixMailboxSizeLimit = 0;
+ var $postfixMessageSizeLimit = 0;
+ var $postfixMyDestinations = array();
+ var $postfixMyDomain = "";
+ var $postfixMyhostname = "";
+ var $postfixMyNetworks = array();
+ var $postfixRelayhost = "";
+ var $postfixTransportTable = array();
+ var $postfixSenderRestrictions = array();
+ var $postfixRecipientRestrictions = array();
+ var $description = "";
+ var $RestrictionFilters = array();
+ var $TransportProtocols = array();
+ var $Actions = array();
+ var $cn = "";
+ var $conflicts = array("goMailServer","kolab");
+ var $view_logged =FALSE;
+
+ function goMailServer(&$config,$dn)
+ {
+ goService::goService($config,$dn);
+ $this->DisplayName = _("Mail smtp service (Postfix)");
+
+ $this->Actions = array( SERVICE_STOPPED=>SERVICE_STOPPED,
+ SERVICE_STARTED => SERVICE_STARTED,
+ SERVICE_RESTARTED=>SERVICE_RESTARTED);
+
+ /* Fill RestrictionFilters TransportProtocols from external hooks */
+ $str = $this->config->data['TABS']['SERVERSERVICE'];
+ $this->TransportProtocols =array("smtp"=>"SMTP");
+ $this->RestrictionFilters = array("FILTER"=>"FILTER");
+ foreach(array("ADDITIONALRESTRICTIONFILTERS"=>"RestrictionFilters",
+ "ADDITIONALPROTOCOLLS" =>"TransportProtocols") as $file => $var){
+ if(isset($this->config->data['MAIN'][$file])){
+ $file = $this->config->data['MAIN'][$file];
+ if((isset($file)) && is_readable($file)){
+ $tmp = file_get_contents($file);
+ $tmp2= split("\n",$tmp);
+ foreach($tmp2 as $entry){
+ if(empty($entry)) continue;
+ if(preg_match("/:/",$entry)){
+ $tmp3 = split(":",$entry);
+ $r = $this->$var;
+ $r[$tmp3[0]]=$tmp3[1];
+ $this->$var = $r;
+ }else{
+ $r = $this->$var;
+ $r[$entry] =$entry;
+ $this->$var = $r;
+ }
+ }
+ }
+ }
+ }
+
+
+ /* Get postfix my networks */
+ $this->postfixMyNetworks = array();
+ $tmp = array();
+ if(isset($this->attrs['postfixMyNetworks'][0])){
+ $tmp = split(",",$this->attrs['postfixMyNetworks'][0]);
+ foreach($tmp as $str){
+ if(!empty($str)){
+ $this->postfixMyNetworks[base64_encode($str)] = $str;
+ }
+ }
+ }
+
+
+ /* Create full name */
+ if(isset($this->attrs['postfixMyDomain'][0])){
+ $this->postfixMyhostname .= ".".$this->attrs['postfixMyDomain'][0];
+ }
+
+
+ /* Get postfix my domains */
+ $this->postfixMyDestinations = array();
+ if(isset($this->attrs['postfixMyDestinations'][0])){
+ unset($this->attrs['postfixMyDestinations']['count']);
+ foreach($this->attrs['postfixMyDestinations'] as $str){
+ $this->postfixMyDestinations[base64_encode($str)] = $str;
+ }
+ }
+
+
+ /* Get transport tables */
+ $tmp = array();
+ $this->postfixTransportTable = array();
+ if(isset($this->attrs['postfixTransportTable'])){
+ $tmp = array();
+ unset($this->attrs['postfixTransportTable']['count']);
+ foreach($this->attrs['postfixTransportTable'] as $entry){
+
+ //0: offshore.vip.ms-europa.lhsystems.com smtp:172.28.0.2
+
+ $Number = preg_replace('/^([^:]+):.*$/', '\\1', $entry);
+ $Rest = trim(preg_replace("/^[0-9]*:/","",$entry));
+
+ $Protocol_Destination = preg_replace("/^.*\ /","",$Rest);
+ $Source = preg_replace("/\ .*$/","",$Rest);
+
+ $Protocol = preg_replace ('/^([^:]+):.*$/', '\\1' ,trim($Protocol_Destination));
+ $Destination = preg_replace ('/^[^:]+:(.*)$/', '\\1' ,trim($Protocol_Destination));
+
+ $Destination = preg_replace ("/[\[\]]/","",$Destination);
+
+ $tmp[$Number]['src'] = $Source;
+ $tmp[$Number]['dst'] = $Destination;
+ $tmp[$Number]['prt'] = $Protocol;
+ }
+ ksort($tmp);
+ foreach($tmp as $entry){
+ $this->postfixTransportTable[] = $entry;
+ }
+ }
+
+
+ /* Get sender restrictions */
+ $tmp = array();
+ $this->postfixSenderRestrictions = array();
+ if(isset($this->attrs['postfixSenderRestrictions'])){
+ unset($this->attrs['postfixSenderRestrictions']['count']);
+ foreach($this->attrs['postfixSenderRestrictions'] as $entry){
+ $nr = preg_replace("/:.*$/","",$entry);
+ $rest= trim(preg_replace("/^[^:]+:/","",$entry));
+ $src = preg_replace("/ .*$/","",$rest);
+ $rest= preg_replace("/^[^ ]+ /","",$rest);
+ $dst = preg_replace("/^.* /","",$rest);
+ $prt = preg_replace("/ .*$/","",$rest);
+
+ $tmp[$nr]['src'] = $src;
+ $tmp[$nr]['dst'] = $dst;
+ $tmp[$nr]['filter'] = $prt;
+ }
+ ksort($tmp);
+ foreach($tmp as $entry){
+ $this->postfixSenderRestrictions[] = $entry;
+ }
+ }
+
+
+ /* Get sender restrictions */
+ $tmp = array();
+ $this->postfixRecipientRestrictions = array();
+ if(isset($this->attrs['postfixRecipientRestrictions'])){
+ unset($this->attrs['postfixRecipientRestrictions']['count']);
+ foreach($this->attrs['postfixRecipientRestrictions'] as $entry){
+ $nr = preg_replace("/:.*$/","",$entry);
+ $rest= trim(preg_replace("/^[^:]+:/","",$entry));
+ $src = preg_replace("/ .*$/","",$rest);
+ $rest= preg_replace("/^[^ ]+ /","",$rest);
+ $dst = preg_replace("/^.* /","",$rest);
+ $prt = preg_replace("/ .*$/","",$rest);
+
+ $tmp[$nr]['src'] = $src;
+ $tmp[$nr]['dst'] = $dst;
+ $tmp[$nr]['filter'] = $prt;
+ }
+ ksort($tmp);
+ foreach($tmp as $entry){
+ $this->postfixRecipientRestrictions[] = $entry;
+ }
+ }
+
+ }
+
+ function execute()
+ {
+ $smarty = get_smarty();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+
+ $delAr = array(
+ "TranslationDel_"=>"TranslationDel",
+ "SenderRestrictDel_"=>"SenderRestrictDel",
+ "RecipientRestrictDel_"=>"RecipientRestrictDel");
+
+ $once = true;
+ $s_action = "";
+ $s_entry = "";
+
+ /* Check posts for some intruductions */
+ foreach($_POST as $name => $value){
+ foreach($delAr as $preg => $type){
+ if((preg_match("/^".$preg."/",$name)) && ($once)){
+ $once = false;
+ $s_action = $type;
+ $s_entry = preg_replace("/^".$preg."/","",$name);
+ $s_entry = preg_replace("/_[xy]$/","",$s_entry);
+ }
+ }
+
+
+ if(preg_match("/^TranslationUp_/",$name) && $once && ($this->acl_is_writeablei("postfixTransportTableACL"))){
+ $once = false;
+ $key = preg_replace("/^TranslationUp_/","",$name);
+ $key = preg_replace("/_[xy]$/","",$key);
+ $this->postfixTransportTable = $this->ArrayUp($key,$this->postfixTransportTable) ;
+ }
+ if(preg_match("/^TranslationDown_/",$name) && $once && ($this->acl_is_writeable("postfixTransportTableACL"))){
+ $once = false;
+ $key = preg_replace("/^TranslationDown_/","",$name);
+ $key = preg_replace("/_[xy]$/","",$key);
+ $this->postfixTransportTable = $this->ArrayDown($key,$this->postfixTransportTable) ;
+ }
+ if(preg_match("/^SenderRestrictUp_/",$name) && $once && ($this->acl_is_writeable("postfixSenderRestrictionsACL"))){
+ $once = false;
+ $key = preg_replace("/^SenderRestrictUp_/","",$name);
+ $key = preg_replace("/_[xy]$/","",$key);
+ $this->postfixSenderRestrictions = $this->ArrayUp($key,$this->postfixSenderRestrictions) ;
+ }
+ if(preg_match("/^SenderRestrictDown_/",$name) && $once && ($this->acl_is_writeable("postfixSenderRestrictionsACL"))){
+ $once = false;
+ $key = preg_replace("/^SenderRestrictDown_/","",$name);
+ $key = preg_replace("/_[xy]$/","",$key);
+ $this->postfixSenderRestrictions = $this->ArrayDown($key,$this->postfixSenderRestrictions) ;
+ }
+ if(preg_match("/^RecipientRestrictUp_/",$name) && $once && ($this->acl_is_writeable("postfixRecipientRestrictionsACL"))){
+ $once = false;
+ $key = preg_replace("/^RecipientRestrictUp_/","",$name);
+ $key = preg_replace("/_[xy]$/","",$key);
+ $this->postfixRecipientRestrictions = $this->ArrayUp($key,$this->postfixRecipientRestrictions) ;
+ }
+ if(preg_match("/^RecipientRestrictDown_/",$name) && $once && ($this->acl_is_writeable("postfixRecipientRestrictionsACL"))){
+ $once = false;
+ $key = preg_replace("/^RecipientRestrictDown_/","",$name);
+ $key = preg_replace("/_[xy]$/","",$key);
+ $this->postfixRecipientRestrictions = $this->ArrayDown($key,$this->postfixRecipientRestrictions) ;
+ }
+ }
+
+
+ /* Add delete my network entry */
+ if((isset($_POST['AddpostfixMyNetworks'])) && (!empty($_POST['NewString_postfixMyNetworks']))){
+ $str = $_POST['NewString_postfixMyNetworks'];
+ $this->postfixMyNetworks[base64_encode($str)] = $str;
+ }
+
+ if((isset($_POST['DelpostfixMyNetworks'])) && isset($_POST['Select_postfixMyNetworks']) &&(count($_POST['Select_postfixMyNetworks']))){
+ foreach($_POST['Select_postfixMyNetworks'] as $str ){
+ unset($this->postfixMyNetworks[$str]);
+ }
+ }
+
+
+ /* Add delete my domain entry */
+ if($this->acl_is_writeable("postfixMyDestinations")){
+ if((isset($_POST['AddpostfixMyDestinations'])) && (!empty($_POST['NewString_postfixMyDestinations']))){
+ $str = $_POST['NewString_postfixMyDestinations'];
+ $this->postfixMyDestinations[base64_encode($str)] = $str;
+ }
+
+ if((isset($_POST['DelpostfixMyDestinations'])) && isset($_POST['Select_postfixMyDestinations']) &&(count($_POST['Select_postfixMyDestinations']))){
+ foreach($_POST['Select_postfixMyDestinations'] as $str ){
+ unset($this->postfixMyDestinations[$str]);
+ }
+ }
+ }
+
+
+ /* Add sender restriction */
+ if($this->acl_is_writeable("postfixSenderRestrictions")){
+ if(($s_action == "SenderRestrictDel") && (isset($this->postfixSenderRestrictions[$s_entry]))){
+ unset($this->postfixSenderRestrictions[$s_entry]);
+ }
+
+ if(isset($_POST['AddpostfixSenderRestrictions'])){
+ $src = $_POST['Source_postfixSenderRestrictions'];
+ $dst = $_POST['Destination_postfixSenderRestrictions'];
+ $Filter = $_POST['SenderRestrictionFilter'];
+ $tmp['src'] = $src;
+ $tmp['dst'] = $dst;
+ $tmp['filter'] = $Filter;
+ $this->postfixSenderRestrictions[] = $tmp;
+ }
+ }
+
+
+ /* Add sender restriction */
+ if($this->acl_is_writeable("postfixRecipientRestrictions")){
+ if(($s_action == "RecipientRestrictDel") && (isset($this->postfixRecipientRestrictions[$s_entry]))){
+ unset($this->postfixRecipientRestrictions[$s_entry]);
+ }
+
+ if(isset($_POST['AddpostfixRecipientRestrictions'])){
+ $src = $_POST['Source_postfixRecipientRestrictions'];
+ $dst = $_POST['Destination_postfixRecipientRestrictions'];
+ $Filter = $_POST['RecipientRestrictionFilter'];
+ $tmp['src'] = $src;
+ $tmp['dst'] = $dst;
+ $tmp['filter'] = $Filter;
+ $this->postfixRecipientRestrictions[] = $tmp;
+ }
+ }
+
+ /* Handle transports */
+ if($this->acl_is_writeable("postfixTransportTable")){
+ if(($s_action == "TranslationDel") && (isset($this->postfixTransportTable[$s_entry]))){
+ unset($this->postfixTransportTable[$s_entry]);
+ }
+
+ if(isset($_POST['AddpostfixTransportTable'])){
+ $src = trim($_POST['Source_postfixTransportTable']);
+ $dst = trim($_POST['Destination_postfixTransportTable']);
+ $prt = trim($_POST['TransportProtocol']);
+
+ if((!empty($src)) && (!empty($dst))){
+ if(preg_match("/:/",$dst)){
+ $tmp = split("\:",$dst);
+ $port = trim($tmp[1]);
+ $ip = trim($tmp[0]);
+
+ if((tests::is_ip($ip)) && (is_numeric($port))){
+ $dst = "[".$ip."]:".$port;
+ }
+ }
+ if(tests::is_ip($dst)){
+ $dst = "[".$dst."]";
+ }
+ $tmp2 ['src'] = $src;
+ $tmp2 ['dst'] = $dst;
+ $tmp2 ['prt'] = $prt;
+
+ $this->postfixTransportTable[] = $tmp2;
+ }
+ }
+ }
+
+ /* Set attributes */
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+
+
+ /* Create divList for translation tables */
+ $divTranslation = new divSelectBox("TransportProtocols");
+ $divTranslation->SetHeight(90);
+ foreach($this->postfixTransportTable as $key => $entry){
+ $img = "";
+
+ if($key != 0 && $this->acl_is_writeable("postfixTransportTable")){
+ $img.= "<input type='image' src='images/sort_up.png' name='TranslationUp_".$key."' class='center'> ";
+ }else{
+ $img.= "<img src='images/empty.png' style='width:10px;'>";
+ }
+ if(($key+1) < count($this->postfixTransportTable) && $this->acl_is_writeable("postfixTransportTable")){
+ $img.= "<input type='image' src='images/sort_down.png' name='TranslationDown_".$key."' class='center'> ";
+ }else{
+ $img.= "<img src='images/empty.png' style='width:10px;'>";
+ }
+
+ if($this->acl_is_writeable("postfixTransportTable")){
+ $img.= "<input type='image' src='images/edittrash.png' name='TranslationDel_".$key."' class='center'> ";
+ }
+ $field1 = array("string"=> $entry['src']);
+ $field2 = array("string"=> $entry['dst']);
+ $field3 = array("string"=> $entry['prt'],"attach"=>"style='width:120px;'");
+ $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
+ $divTranslation->AddEntry(array($field1,$field2,$field3,$field4,));
+ }
+ $smarty->assign("Div_postfixTransportTable" ,$divTranslation->DrawList());
+
+
+ /* Create divList for sender restrictions */
+ $DivSenderRestrict = new divSelectBox("postfixSenderRestrictions");
+ $DivSenderRestrict->SetHeight(90);
+ foreach($this->postfixSenderRestrictions as $key => $entry){
+ $img ="";
+
+ if($key != 0 && $this->acl_is_writeable("postfixSenderRestrictions")){
+ $img.= "<input type='image' src='images/sort_up.png' name='SenderRestrictUp_".$key."' class='center'> ";
+ }else{
+ $img.= "<img src='images/empty.png' style='width:10px;'>";
+ }
+ if(($key+1) < count($this->postfixSenderRestrictions) && $this->acl_is_writeable("postfixSenderRestrictions")){
+ $img.= "<input type='image' src='images/sort_down.png' name='SenderRestrictDown_".$key."' class='center'> ";
+ }else{
+ $img.= "<img src='images/empty.png' style='width:10px;'>";
+ }
+
+ if($this->acl_is_writeable("postfixSenderRestrictions")){
+ $img.= "<input type='image' src='images/edittrash.png' name='SenderRestrictDel_".$key."' class='center'> ";
+ }
+
+ $field1 = array("string"=> $entry['src']);
+ $field2 = array("string"=> $entry['dst']);
+ $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'");
+ $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
+ $DivSenderRestrict->AddEntry(array($field1,$field2,$field3,$field4,));
+ }
+ $smarty->assign("Div_postfixSenderRestrictions" ,$DivSenderRestrict->DrawList());
+
+
+ /* Create divList for translation tables */
+ $DivRecipientRestrict = new divSelectBox("postfixRecipientRestrictions");
+ $DivRecipientRestrict->SetHeight(90);
+
+ foreach($this->postfixRecipientRestrictions as $key => $entry){
+ $img = "";
+ if($key != 0 && $this->acl_is_writeable("postfixRecipientRestrictions")){
+ $img.= "<input type='image' src='images/sort_up.png' name='RecipientRestrictUp_".$key."' class='center'> ";
+ }else{
+ $img.= "<img src='images/empty.png' style='width:10px;'>";
+ }
+ if(($key+1) < count($this->postfixRecipientRestrictions) && $this->acl_is_writeable("postfixRecipientRestrictions")){
+ $img.= "<input type='image' src='images/sort_down.png' name='RecipientRestrictDown_".$key."' class='center'> ";
+ }else{
+ $img.= "<img src='images/empty.png' style='width:10px;'>";
+ }
+
+ if($this->acl_is_writeable("postfixRecipientRestrictions")){
+ $img.= "<input type='image' src='images/edittrash.png' name='RecipientRestrictDel_".$key."' class='center'> ";
+ }
+ $field1 = array("string"=> $entry['src']);
+ $field2 = array("string"=> $entry['dst']);
+ $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'");
+ $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
+ $DivRecipientRestrict->AddEntry(array($field1,$field2,$field3,$field4,));
+ }
+ $smarty->assign("Div_postfixRecipientRestrictions" ,$DivRecipientRestrict->DrawList());
+
+
+ /* set new status */
+ if(isset($_POST['ExecAction'])){
+ if(isset($this->Actions[$_POST['action']])){
+ $this->setStatus($_POST['action']);
+ }
+ }
+
+
+ $smarty->assign("is_new", $this->dn);
+ $smarty->assign("is_acc", $this->initially_was_account);
+ $smarty->assign("TransportProtocols", $this->TransportProtocols);
+ $smarty->assign("Actions", $this->Actions);
+ $smarty->assign("RestrictionFilters", $this->RestrictionFilters);
+ $smarty->assign("postfixTransportTable" , $this->getTransports());
+ $smarty->assign("postfixSenderRestrictions" , $this->getSenderRestrictions());
+ $smarty->assign("postfixRecipientRestrictions" ,$this->getRecipientRestrictions());
+
+ return($smarty->fetch(get_template_path("goMailServer.tpl",TRUE,dirname(__FILE__))));
+ }
+
+
+ /* return transports formated for select box */
+ function getTransports()
+ {
+ $ret = array();
+ foreach($this->postfixTransportTable as $key => $vals){
+ $ret[$key] = $vals['src']." -> ".$vals['prt'].":".$vals['dst'];
+ }
+ return($ret);
+ }
+
+
+ /* return sender restriction formated for select box */
+ function getSenderRestrictions()
+ {
+ $ret = array();
+ foreach($this->postfixSenderRestrictions as $key => $vals){
+ $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
+ }
+ return($ret);
+ }
+
+
+ /* return recipient restriction formated for select box */
+ function getRecipientRestrictions()
+ {
+ $ret = array();
+ foreach($this->postfixRecipientRestrictions as $key => $vals){
+ $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
+ }
+ return($ret);
+ }
+
+
+ /* Return list entry */
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("Mail smtp service (Postfix)");
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+
+
+ function save()
+ {
+ $this->postfixMyDomain = preg_replace("/^[^\.]+\./","",$this->postfixMyhostname);
+ $this->postfixMyhostname = preg_replace("/\..*$/","",$this->postfixMyhostname);
+
+ plugin::save();
+
+ /* Fix transport table*/
+ $i = 0 ;
+ $this->attrs['postfixTransportTable'] = array();
+ foreach($this->postfixTransportTable as $key => $entry){
+ $this->attrs['postfixTransportTable'][] = $i.": ".$entry['src']." ".$entry['prt'].":".$entry['dst'];
+ $i ++;
+ }
+
+
+ /* Fix sender restrictions */
+ $i = 0;
+ $this->attrs['postfixSenderRestrictions'] =array();
+ foreach($this->postfixSenderRestrictions as $key => $entry){
+ $this->attrs['postfixSenderRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst'];
+ $i ++;
+ }
+
+
+ /* Fix recipient restrictions */
+ $i = 0;
+ $this->attrs['postfixRecipientRestrictions'] =array();
+ foreach($this->postfixRecipientRestrictions as $key => $entry){
+ $this->attrs['postfixRecipientRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst'];
+ $i ++;
+ }
+
+
+ /* Fix mydomains */
+ $this->attrs['postfixMyDestinations'] = array();
+ foreach($this->postfixMyDestinations as $entry){
+ $this->attrs['postfixMyDestinations'][] =$entry;
+ }
+
+
+ /* Fix mydomains */
+ if(count($this->postfixMyNetworks)){
+ $this->attrs['postfixMyNetworks'] = "";
+ foreach($this->postfixMyNetworks as $entry){
+ $this->attrs['postfixMyNetworks'] .=$entry.",";
+ }
+ $this->attrs['postfixMyNetworks'] = preg_replace("/,$/","",$this->attrs['postfixMyNetworks']);
+ }else{
+ $this->attrs['postfixMyNetworks'] = array();
+ }
+
+
+ /* Check if this is a new entry ... add/modify */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cat($this->dn,array("objectClass"));
+ if($ldap->count()){
+ $ldap->cd($this->dn);
+ $ldap->modify($this->attrs);
+ }else{
+ $ldap->cd($this->dn);
+ $ldap->add($this->attrs);
+ }
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving server services/mail with dn '%s' failed."),$this->dn));
+ if($this->initially_was_account){
+ $this->handle_post_events("modify");
+ new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }else{
+ $this->handle_post_events("add");
+ new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }
+
+ }
+
+
+ function check()
+ {
+ $message =plugin::check();
+
+ if(!is_numeric($this->postfixHeaderSizeLimit)){
+ $message[] = _("Please specify a numeric value for header size limit.");
+ }
+
+ if(!is_numeric($this->postfixMailboxSizeLimit)){
+ $message[] = _("Please specify a numeric value for mailbox size limit.");
+ }
+
+ if(!is_numeric($this->postfixMessageSizeLimit)){
+ $message[] = _("Please specify a numeric value for message size limit.");
+ }
+
+ return $message;
+ }
+
+
+ /* Combine new array */
+ function combineArrays($ar0,$ar1,$ar2)
+ {
+ $ret = array();
+ if(is_array($ar0))
+ foreach($ar0 as $ar => $a){
+ $ret[]=$a;
+ }
+ if(is_array($ar1))
+ foreach($ar1 as $ar => $a){
+ $ret[]=$a;
+ }
+ if(is_array($ar2))
+ foreach($ar2 as $ar => $a){
+ $ret[]=$a;
+ }
+ return($ret);
+ }
+
+
+ function getpos($atr,$attrs)
+ {
+ $i = 0;
+ foreach($attrs as $attr => $name) {
+ $i++;
+ if($attr == $atr){
+ return($i);
+ }
+ }
+
+ return(-1);
+ }
+
+
+ /* TRansports the geiven Arraykey one position up*/
+ function ArrayUp($atr,$attrs)
+ {
+ $ret = $attrs;
+ $pos = $this->getpos($atr,$attrs) ;
+ $cn = count($attrs);
+ if(!(($pos == -1)||($pos == 1))){
+ $before = array_slice($attrs,0,($pos-2));
+ $mitte = array_reverse(array_slice($attrs,($pos-2),2));
+ $unten = array_slice($attrs,$pos);
+ $ret = array();
+ $ret = $this->combineArrays($before,$mitte,$unten);
+ }
+ return($ret);
+ }
+
+
+ /* TRansports the geiven Arraykey one position up*/
+ function ArrayDown($atr,$attrs)
+ {
+ $ret = $attrs;
+ $pos = $this->getpos($atr,$attrs) ;
+ $cn = count($attrs);
+ if(!(($pos == -1)||($pos == $cn))){
+ $before = array_slice($attrs,0,($pos-1));
+ $mitte = array_reverse(array_slice($attrs,($pos-1),2));
+ $unten = array_slice($attrs,($pos+1));
+ $ret = array();
+ $ret = $this->combineArrays($before,$mitte,$unten);
+ }
+ return($ret);
+ }
+
+ function save_object()
+ {
+ plugin::save_object();
+ }
+
+
+ function PrepareForCopyPaste($source)
+ {
+ plugin::PrepareForCopyPaste($source);
+
+ $source_o = new goMailServer($this->config,$source['dn']);
+ foreach(array("postfixMyDomain","postfixMyhostname","postfixMyNetworks","postfixTransportTable","postfixSenderRestrictions","postfixRecipientRestrictions","postfixMyDestinations") as $attr){
+ $this->$attr = $source_o->$attr;
+ }
+ }
+
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Mail smtp (Postfix)"),
+ "plDescription" => _("Mail smtp - Postfix")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 98,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+ "postfixMyhostname" => _("Visible full qualified hostname"),
+ "description" => _("Description"),
+ "postfixHeaderSizeLimit" => _("Header size limit"),
+ "postfixMailboxSizeLimit" => _("Max mailbox size"),
+ "postfixMessageSizeLimit" => _("Max message size"),
+ "postfixMyDestinations" => _("Domains to accept mail for"),
+ "postfixMyNetworks" => _("Local networks"),
+ "postfixRelayhost" => _("Relay host"),
+ "postfixTransportTable" => _("Transport table"),
+ "postfixSenderRestrictions" => _("Restrictions for sender"),
+ "postfixRecipientRestrictions"=> _("Restrictions for recipient"))
+ ));
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/mail/admin/systems/services/mail/goMailServer.tpl b/gosa-plugins/mail/admin/systems/services/mail/goMailServer.tpl
--- /dev/null
@@ -0,0 +1,225 @@
+<h2><img class="center" alt="" align="middle" src="images/rightarrow.png" /> {t}Generic{/t}</h2>
+<table style="width:100%;">
+ <tr>
+ <td width="50%" style="vertical-align:top">
+ <table >
+ <tr>
+ <td>{t}Visible full qualified hostname{/t}
+ </td>
+ <td>
+{render acl=$postfixMyhostnameACL}
+ <input type="text" name='postfixMyhostname' value='{$postfixMyhostname}' title='{t}The full qualified host name.{/t}'>
+{/render}
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Max mail header size{/t}
+ </td>
+ <td>
+{render acl=$postfixMyhostnameACL}
+ <input type="text" name='postfixHeaderSizeLimit' value='{$postfixHeaderSizeLimit}'
+ title='{t}This value specifies the maximal header size.{/t}'> {t}KB{/t}
+{/render}
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Max mailbox size{/t}
+ </td>
+ <td>
+{render acl=$postfixMailboxSizeLimitACL}
+ <input type="text" name='postfixMailboxSizeLimit' value='{$postfixMailboxSizeLimit}'
+ title='{t}Defines the maximal size of mail box.{/t}'> {t}KB{/t}
+{/render} </td>
+ </tr>
+ <tr>
+ <td>{t}Max message size{/t}
+ </td>
+ <td>
+{render acl=$postfixMessageSizeLimitACL}
+ <input type="text" name='postfixMessageSizeLimit' value='{$postfixMessageSizeLimit}'
+ title='{t}Specify the maximal size of a message.{/t}'> {t}KB{/t}
+{/render}
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Relay host{/t}
+ </td>
+ <td>
+{render acl=$postfixRelayhostACL}
+ <input type="text" name='postfixRelayhost' value='{$postfixRelayhost}'
+ title='{t}Relay messages to following host:{/t}'>
+{/render}
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td style="border-left:1px solid #A0A0A0; ">
+ <table style="width:100%;">
+ <tr>
+ <td>
+ {t}Local networks{/t}<br>
+{render acl=$postfixMyNetworksACL}
+ <select name='Select_postfixMyNetworks[]' multiple size=6 style='width:100%;' title='{t}Postfix networks{/t}'>
+ {html_options options=$postfixMyNetworks}
+ </select>
+{/render}
+{render acl=$postfixMyNetworksACL}
+ <input type="text" name="NewString_postfixMyNetworks" value="">
+{/render}
+{render acl=$postfixMyNetworksACL}
+ <input type="submit" name="AddpostfixMyNetworks" value="{t}Add{/t}">
+{/render}
+{render acl=$postfixMyNetworksACL}
+ <input type="submit" name="DelpostfixMyNetworks" value="{t}Remove{/t}">
+{/render}
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <p class='seperator'> </p>
+ <h2>{t}Domains and routing{/t}</h2>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table style="width:100%;">
+ <tr>
+ <td>
+ {t}Domains to accept mail for{/t}<br>
+{render acl=$postfixMyDestinationsACL}
+ <select name='Select_postfixMyDestinations[]' multiple size=6 style='width:100%;' title='{t}Postfix is responsible for the following domains:{/t}'>
+{/render}
+ {html_options options=$postfixMyDestinations}
+ </select>
+{render acl=$postfixMyDestinationsACL}
+ <input type="text" name="NewString_postfixMyDestinations" value="">
+{/render}
+{render acl=$postfixMyDestinationsACL}
+ <input type="submit" name="AddpostfixMyDestinations" value="{t}Add{/t}">
+{/render}
+{render acl=$postfixMyDestinationsACL}
+ <input type="submit" name="DelpostfixMyDestinations" value="{t}Remove{/t}">
+{/render}
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td style="border-left:1px solid #A0A0A0; ">
+ <table style="width:100%;">
+ <tr>
+ <td>
+ {t}Transports{/t}<br>
+{render acl=$postfixTransportTableACL}
+ {$Div_postfixTransportTable}
+{/render}
+
+{render acl=$postfixTransportTableACL}
+ <input type="text" name="Source_postfixTransportTable" value="">
+{/render}
+{render acl=$postfixTransportTableACL}
+ <select name='TransportProtocol' title='{t}Select a transport protocol.{/t}'>
+ {html_options options=$TransportProtocols}
+ </select>
+{/render}
+{render acl=$postfixTransportTableACL}
+ <input type="text" name="Destination_postfixTransportTable" value="">
+{/render}
+{render acl=$postfixTransportTableACL}
+ <input type="submit" name="AddpostfixTransportTable" value="{t}Add{/t}">
+{/render}
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <p class='seperator'> </p>
+ <h2>{t}Restrictions{/t}</h2>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table style="width:100%;">
+ <tr>
+ <td>
+ {t}Restrictions for sender{/t}<br>
+{render acl=$postfixSenderRestrictionsACL}
+ {$Div_postfixSenderRestrictions}
+{/render}
+{render acl=$postfixSenderRestrictionsACL}
+ <input type="text" name="Source_postfixSenderRestrictions" value="">
+{/render}
+{render acl=$postfixSenderRestrictionsACL}
+ <select name='SenderRestrictionFilter' title='{t}Restriction filter{/t}'>
+ {html_options options=$RestrictionFilters}
+ </select>
+{/render}
+{render acl=$postfixSenderRestrictionsACL}
+ <input type="text" name="Destination_postfixSenderRestrictions" value="">
+{/render}
+{render acl=$postfixSenderRestrictionsACL}
+ <input type="submit" name="AddpostfixSenderRestrictions" value="{t}Add{/t}">
+{/render}
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td style="border-left:1px solid #A0A0A0;">
+ <table style="width:100%;">
+ <tr>
+ <td>
+ {t}Restrictions for recipient{/t}<br>
+{render acl=$postfixRecipientRestrictionsACL}
+ {$Div_postfixRecipientRestrictions}
+{/render}
+{render acl=$postfixRecipientRestrictionsACL}
+ <input type="text" name="Source_postfixRecipientRestrictions" value="">
+{/render}
+{render acl=$postfixRecipientRestrictionsACL}
+ <select name='RecipientRestrictionFilter' title='{t}Restriction filter{/t}'>
+ {html_options options=$RestrictionFilters}
+ </select>
+{/render}
+{render acl=$postfixRecipientRestrictionsACL}
+ <input type="text" name="Destination_postfixRecipientRestrictions" value="">
+{/render}
+{render acl=$postfixRecipientRestrictionsACL}
+ <input type="submit" name="AddpostfixRecipientRestrictions" value="{t}Add{/t}">
+{/render}
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+
+<p class='seperator'> </p>
+<br>
+<h2><img class="center" alt="" src="images/rocket.png" align="middle"> Action</h2>
+{if $is_new == "new"}
+ {t}The server must be saved before you can use the status flag.{/t}
+{elseif !$is_acc}
+ {t}The service must be saved before you can use the status flag.{/t}
+{/if}
+<br>
+<select name="action" title='{t}Set new status{/t}'
+ {if $is_new == "new" || $is_acc == false} disabled {/if}
+>
+ <option value="none"> </option>
+ {html_options options=$Actions}
+</select>
+<input type='submit' name='ExecAction' title='{t}Set status{/t}' value='{t}Execute{/t}'
+ {if $is_new == "new" || $is_acc == false} disabled {/if}
+>
+
+<p class="seperator"> </p>
+<div style="width:100%; text-align:right;padding-top:10px;padding-bottom:3px;">
+ <input type='submit' name='SaveService' value='{t}Save{/t}'>
+
+ <input type='submit' name='CancelService' value='{t}Cancel{/t}'>
+</p>
+
diff --git a/gosa-plugins/mail/personal/mail/class_mail-methods-cyrus.inc b/gosa-plugins/mail/personal/mail/class_mail-methods-cyrus.inc
--- /dev/null
@@ -0,0 +1,366 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2004 Cajus Pollmeier
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+class mailMethodCyrus extends mailMethod
+{
+ var $mbox= "-";
+ var $config;
+ var $gosaMailServer= "";
+ var $uattrib= "uid";
+
+ function mailMethodCyrus(&$config)
+ {
+ $this->config= $config->data['SERVERS']['IMAP'];
+ }
+
+ function connect($gosaMailServer)
+ {
+ $cfg=array();
+
+ /* Connect to IMAP server. I don't want to see these warning here... */
+ $this->gosaMailServer= $gosaMailServer;
+ if (!isset($this->config[$gosaMailServer])){
+ msg_dialog::display(_("Warning"), _("Mail server for this account is invalid!"), WARNING_DIALOG);
+ } else {
+ $cfg= $this->config[$gosaMailServer];
+ }
+ /* For some reason, hiding errors with @ does not wor here... */
+ if(!isset($cfg['connect'])) $cfg['connect']="";
+ if(!isset($cfg['admin'])) $cfg['admin']="";
+ if(!isset($cfg['password'])) $cfg['password']="";
+
+ /* Setting connect timeout to 10 seconds,
+ else the GOsa UI may freeze for 60 seconds.
+ (PHP default is 'default_socket_timeout = 60') */
+ imap_timeout(1, 10 );
+
+ $this->mbox = @imap_open($cfg['connect'], $cfg['admin'], $cfg['password'], OP_HALFOPEN);
+
+ /* Mailbox reachable? */
+ if ($this->mbox === FALSE){
+ msg_dialog::display(_("IMAP error"), _("Cannot store mail settings on IMAP server!"), ERROR_DIALOG);
+ return (FALSE);
+ }
+ return (TRUE);
+ }
+
+ function disconnect()
+ {
+ imap_close ($this->mbox);
+ }
+
+ function getQuota($folder)
+ {
+ $result= array('quotaUsage' => '', 'gosaMailQuota' => '');
+
+ /* Load quota settings */
+ error_reporting (0);
+ $quota_value = @imap_get_quota($this->mbox, $folder);
+ if(is_array($quota_value)) {
+ if (isset($quota_value["STORAGE"]) && is_array($quota_value["STORAGE"])){
+ /* use for PHP >= 4.3 */
+ if($quota_value["STORAGE"]['limit'] == 2147483647){
+ $result['quotaUsage']= (int) ($quota_value["STORAGE"]['usage'] / 1024);
+ $result['gosaMailQuota']= (int) ($quota_value["STORAGE"]['limit'] );
+ }else{
+ $result['quotaUsage']= (int) ($quota_value["STORAGE"]['usage'] / 1024);
+ $result['gosaMailQuota']= (int) ($quota_value["STORAGE"]['limit'] / 1024);
+ }
+ } else {
+ /* backward icompatible */
+ if($quota_value['usage'] == 2147483647){
+ $result['quotaUsage']= (int) ($quota_value['usage'] / 1024);
+ $result['gosaMailQuota']= (int) ($quota_value['limit'] );
+ }else{
+ $result['quotaUsage']= (int) ($quota_value['usage'] / 1024);
+ $result['gosaMailQuota']= (int) ($quota_value['limit'] / 1024);
+ }
+ }
+ }elseif(!$quota_value){
+ /* If there is no quota defined for this account, the function imap_get_quota returns false. */
+ return(array("quotaUsage"=>"","gosaMailQuota"=>""));
+ }
+
+ error_reporting (E_ALL | E_STRICT);
+ return ($result);
+ }
+
+
+ /* return all folders of the users mailbox*/
+ function getMailboxList($folder, $uid)
+ {
+ global $config;
+ $result = array();
+
+ /* Get domain an mail address if uid is an mail address */
+ $domain = "";
+ if(preg_match("/@/",$folder)){
+ $domain = "@".preg_replace("/^.*@/","",$folder);
+ $folder = preg_replace("/@.*$/","",$folder);
+ }
+
+ /* Get list of mailboxes for combo box */
+ $cfg= $this->config[$this->gosaMailServer];
+
+ /* Create search pattern
+ (user/kekse*@domain.de
+ user.kekse*@domain.de
+ user.kekse* )
+ depending on given folder name) */
+ $q = $folder."*".$domain;
+ $list = imap_listmailbox($this->mbox, $cfg["connect"], $q);
+
+ /* Create list of returned folder names */
+ if (is_array($list)){
+ foreach ($list as $val){
+
+ /* Cut domain name */
+ $val = preg_replace("/@.*$/","",$val);
+ $result[]=preg_replace ("/^.*".normalizePreg($folder)."/","INBOX", mb_convert_encoding($val, "UTF-8", "UTF7-IMAP"));
+ }
+ }
+
+ /* Append "INBOX" to the folder array if result is empty and request comes from user dialog */
+ if(empty($result) && !empty($uid)){
+ $result[] = "INBOX";
+ }
+
+ return ($result);
+ }
+
+
+ function updateMailbox($folder)
+ {
+ /* Check if mailbox exists */
+ $cfg= $this->config[$this->gosaMailServer];
+ $list = imap_listmailbox($this->mbox, $cfg["connect"], $folder);
+ if ($list === FALSE){
+ if (!imap_createmailbox($this->mbox, $cfg["connect"]. $folder)){
+ msg_dialog::display(_("IMAP error"), sprintf(_("Cannot create IMAP mailbox: %s"), '<br><br><i>'.imap_last_error().'</i>'), ERROR_DIALOG);
+ return;
+ }
+ }
+ }
+
+
+ function setQuota($folder, $gosaMailQuota)
+ {
+ /* Workaround for the php imap extension */
+ if (($gosaMailQuota == "") || ($gosaMailQuota== "2147483647")){
+ $gosaMailQuota= "2147483647";
+ }elseif($gosaMailQuota > 0){
+ $gosaMailQuota = $gosaMailQuota *1024;
+ }
+
+
+ /* Write mail quota */
+ if (!imap_set_quota($this->mbox, $folder, $gosaMailQuota)){
+ msg_dialog::display(_("IMAP error"), sprintf(_("Cannot modify IMAP mailbox quota: %s"), '<br><br><i>'.imap_last_error().'</i>'), ERROR_DIALOG);
+ return (FALSE);
+ }
+ return (TRUE);
+ }
+
+
+ function setSharedFolderPermissions($folder, $permissions)
+ {
+ /* Get list of subfolders */
+ $folders= $this->getMailboxList($folder, "");
+ $folders[]= $folder;
+
+ foreach ($folders as $subfolder){
+
+ /* Set shared folder acl's */
+ if (function_exists('imap_getacl')){
+
+ /* Remove all acl's for this folder */
+ $users= @imap_getacl ($this->mbox, $subfolder);
+ if(is_array($users)){
+ foreach ($users as $userid => $perms){
+ imap_setacl ($this->mbox, $subfolder, $userid, "");
+ }
+ }
+ } else {
+ msg_dialog::display(_("Internal error"), _("Cannot remove IMAP ACL: imap_getacl not implemented!"), ERROR_DIALOG);
+ }
+
+ /* Set permissions for this folder */
+ foreach ($permissions as $user => $acl){
+ imap_setacl ($this->mbox, $subfolder, $user, $acl);
+ }
+ }
+
+ }
+
+
+ function getSharedFolderPermissions($folder)
+ {
+ $result= array();
+
+ /* imap_getacl available? */
+ if (!function_exists('imap_getacl')){
+ msg_dialog::display(_("Internal error"), _("Cannot retrieve IMAP ACL: imap_getacl not implemented!"), ERROR_DIALOG);
+ }
+
+ /* Get permissions in case of shared folders */
+ else {
+ $users= imap_getacl ($this->mbox, $folder);
+
+ foreach ($users as $userid => $perms){
+ $result[preg_replace('/^user\./', '', $userid)]= $perms;
+ }
+
+ }
+
+ return ($result);
+ }
+
+
+ function deleteMailbox($folder)
+ {
+ $cfg= $this->config[$this->gosaMailServer];
+ imap_setacl ($this->mbox, $folder, $cfg["admin"], "lrswipcda");
+ if (!imap_deletemailbox($this->mbox, $cfg["connect"].$folder)){
+ msg_dialog::display(_("IMAP error"), sprintf(_('Cannot remove IMAP mailbox: %s'), '<br><br><i>'.imap_last_error().'</i>'), ERROR_DIALOG);
+ return (FALSE);
+ }
+ return (TRUE);
+ }
+
+
+ function configureFilter($user, $gosaMailDeliveryMode,
+ $mail, $gosaMailAlternateAddress,
+ $gosaMailMaxSize,
+ $gosaSpamMailbox, $gosaSpamSortLevel,
+ $gosaVacationMessage)
+ {
+ $cfg= $this->config[$this->gosaMailServer];
+
+ /* Build spamlevel. Spamassassin tags mails with "*" for each integer
+ point of spam. So a spam level of 5.3 gets "*****" which can be
+ checked easily by spam filters */
+ $spamlevel= "";
+ for ($i= 0; $i<$gosaSpamSortLevel; $i++){
+ $spamlevel .= "*";
+ }
+
+ /* Log into the mail server */
+ $sieve= new sieve($cfg["sieve_server"], $cfg["sieve_port"], $user,
+ $cfg["password"], $cfg["admin"]);
+
+ if (!$sieve->sieve_login()){
+ msg_dialog::display(_("SIEVE error"), sprintf(_("Cannot log into SIEVE server: %s"), '<br><br><i>'.to_string($sieve->error_raw).'</i>'), ERROR_DIALOG);
+ return;
+ }
+
+ /* Load current script from server and remove everything between the comments
+ "###GOSA" */
+ $script= "";
+ if($sieve->sieve_listscripts()){
+ if (in_array("gosa", $sieve->response)){
+
+ /* get old GOsa script */
+ if(!$sieve->sieve_getscript("gosa")){
+ msg_dialog::display(_("SIEVE error"), sprintf(_("Cannot retrieve SIEVE script: %s"), '<br><br><i>'.to_string($sieve->error_raw).'</i>'), ERROR_DIALOG);
+ return;
+ }
+
+ foreach ($sieve->response as $line){
+ if (preg_match ("/^###GOSA/", $line)){
+ break;
+ }
+ $line= rtrim($line);
+ if (!preg_match ('/^\s*$/', $line)){
+ $script .= $line."\n";
+ }
+ }
+
+ }
+ }
+
+ /* Only create a new one, if it is not empty */
+ if (is_integer(strpos($gosaMailDeliveryMode, "R")) ||
+ is_integer(strpos($gosaMailDeliveryMode, "C")) ||
+ !is_integer(strpos($gosaMailDeliveryMode, "L")) ||
+ is_integer(strpos($gosaMailDeliveryMode, "V")) ||
+ is_integer(strpos($gosaMailDeliveryMode, "S"))){
+
+ $text= preg_replace('/"/', '\\"', implode ("", file(CONFIG_DIR."/sieve-header.txt")));
+ eval ("\$script.=\"$text\";");
+ }
+
+ /* Add anti-spam code */
+ if (is_integer(strpos($gosaMailDeliveryMode, "S"))){
+ $spambox= $gosaSpamMailbox;
+ $text= preg_replace('/"/', '\\"', implode ("", file(CONFIG_DIR."/sieve-spam.txt")));
+ eval ("\$script.=\"$text\";");
+ }
+
+ /* Add "reject due to mailsize" code, message is currently not
+ adjustable through GOsa. */
+ if (is_integer(strpos($gosaMailDeliveryMode, "R"))){
+ $maxsize= $gosaMailMaxSize;
+ $text= preg_replace('/"/', '\\"', implode ("", file(CONFIG_DIR."/sieve-mailsize.txt")));
+ eval ("\$script.=\"$text\";");
+ }
+
+ /* Add vacation information */
+ if (is_integer(strpos($gosaMailDeliveryMode, "V"))){
+
+ /* Sieve wants all destination addresses for the
+ vacation message, so we've to assemble them from
+ mail and mailAlternateAddress */
+ $addrlist= "\"".$mail."\"";
+ foreach ($gosaMailAlternateAddress as $val){
+ $addrlist .= ", \"$val\"";
+ }
+ $vacmsg= $gosaVacationMessage;
+ $text= preg_replace('/"/', '\\"', implode ("", file(CONFIG_DIR."/sieve-vacation.txt")));
+ eval ("\$script.=\"$text\";");
+ }
+
+ /* If no local delivery is wanted, tell the script to discard the mail */
+ if (!is_integer(strpos($gosaMailDeliveryMode, "L"))){
+ $text= preg_replace('/"/', '\\"', implode ("", file(CONFIG_DIR."/sieve-discard.txt")));
+ eval ("\$script.=\"$text\";");
+ }
+
+ /* Just be aware of null scripts... */
+ if (!isset ($script)){
+ $script= "";
+ }
+
+ /* Upload script and make it the default one */
+ if (!$sieve->sieve_sendscript("gosa", $script)){
+ msg_dialog::display(_("SIEVE error"), sprintf(_("Cannot store SIEVE script: %s"), '<br><br><i>'.to_string($sieve->error_raw).'</i>'), ERROR_DIALOG);
+ return;
+ }
+ if(!$sieve->sieve_setactivescript("gosa")){
+ msg_dialog::display(_("SIEVE error"), sprintf(_("Cannot activate SIEVE script: %s"), '<br><br><i>'.to_string($sieve->error_raw).'</i>'), ERROR_DIALOG);
+ return;
+ }
+
+ $sieve->sieve_logout();
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/mail/personal/mail/class_mail-methods-golab.inc b/gosa-plugins/mail/personal/mail/class_mail-methods-golab.inc
--- /dev/null
@@ -0,0 +1,261 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2004 Cajus Pollmeier
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+class mailMethodGolab extends mailMethodCyrus
+{
+ var $mbox= "-";
+ var $config;
+ var $gosaMailServer= "";
+ var $uattrib= "mail";
+
+ var $attribute_map= array("gosaMailAlternateAddress" => "alias",
+ "gosaMailQuota" => "cyrus-userquota",
+ "gosaMailServer" => "kolabHomeServer");
+
+ function mailMethodGolab(&$config)
+ {
+ $this->config= $config->data['SERVERS']['IMAP'];
+ }
+
+ function updateMailbox($folder)
+ {
+ }
+
+ function setQuota($folder, $gosaMailQuota)
+ {
+ return (TRUE);
+ }
+
+ /* Get quota and divide it by 1024, because in gosa we display in MB
+ but we get Kb */
+ function getQuota($folder)
+ {
+ $result= array('quotaUsage' => '', 'gosaMailQuota' => '');
+
+ /* Only use lower case folder names, if folder name is like "@domain.com" */
+ if(preg_match("/@/",$folder)){
+ $folder = strtolower($folder);
+ }
+
+ error_reporting(0);
+
+ /* Load quota settings */
+ $quota_value = @imap_get_quota($this->mbox, $folder);
+ if(is_array($quota_value)) {
+ if (isset($quota_value["STORAGE"]) && is_array($quota_value["STORAGE"])){
+ /* use for PHP >= 4.3 */
+ $result['quotaUsage']= (int) ($quota_value["STORAGE"]['usage'] / 1024);
+ $result['gosaMailQuota']= (int) ($quota_value["STORAGE"]['limit'] / 1024);
+ } else {
+ /* backward icompatible */
+ $result['quotaUsage']= (int) ($quota_value['usage'] / 1024);
+ $result['gosaMailQuota']= (int) ($quota_value['limit'] / 1024);
+ }
+ }elseif(!$quota_value){
+ return(false);
+ }
+
+ error_reporting(E_ALL | E_STRICT);
+
+ return ($result);
+ }
+
+
+ function fixAttributesOnLoad(&$mailObject)
+ {
+ /* Kolab shared folder names are like ' shared.uid@server.de '
+ So overwrite uid to match these folder names. Else we can't read quota settings etc.
+ #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
+ if(get_class($mailObject) == "mailgroup"){
+ $mailObject->uid = $mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
+ }
+
+ /* Convert attributes and objectClasses */
+ foreach ($this->attribute_map as $dest => $source){
+ /* Hickert 11.11.05 : Alternate email addresses were saved, but not displayed again.
+ if (isset($mailObject->attrs[$source])){
+ $mailObject->attrs[$dest]= $mailObject->attrs[$source];
+ unset ($mailObject->attrs[$source]);
+ */
+
+ if (isset($mailObject->attrs[$source])){
+ unset($mailObject->attrs[$source]['count']);
+ $mailObject->attrs[$dest]= $mailObject->attrs[$source];
+ $mailObject->$dest= $mailObject->attrs[$source];
+
+ unset ($mailObject->$dest['count']);
+ unset ($mailObject->attrs[$source]);
+ }
+ }
+
+ /* Adjust server name if needed */
+ foreach ($mailObject->config->data['SERVERS']['IMAP'] as $srv => $dummy){
+ if (preg_match("%".$mailObject->attrs['gosaMailServer'][0]."$%", $srv)){
+ $mailObject->attrs['gosaMailServer']= array(0 => $srv, "count" => 1);
+ break;
+ }
+ }
+ }
+
+
+ function fixAttributesOnStore(&$mailObject)
+ {
+ global $config;
+
+ /* If quota is empty, remove quota restrictions by setting quota to 0 */
+ if(isset($mailObject->gosaMailQuota) && (empty($mailObject->gosaMailQuota))){
+ $mailObject->attrs['gosaMailQuota'] = 0;
+ }
+
+ /* Convert attributes and objectClasses */
+ foreach ($this->attribute_map as $source => $dest){
+ if (isset($mailObject->attrs[$source])){
+ $mailObject->attrs[$dest]= $mailObject->attrs[$source];
+ unset ($mailObject->attrs[$source]);
+ }
+ }
+ $objectclasses= array();
+ foreach ($mailObject->attrs['objectClass'] as $oc){
+ if ($oc != 'kolabInetOrgPerson' && $oc != 'kolabSharedFolder'){
+ $objectclasses[]= $oc;
+ }
+ }
+ $mailObject->attrs['objectClass']= $objectclasses;
+ if (in_array("posixGroup", $mailObject->attrs['objectClass'])){
+
+ /* Add kolabSharedFoleder Class */
+ $mailObject->attrs['objectClass'][]= 'kolabSharedFolder';
+
+ /* Work on acl attribute */
+ $new_acl= array();
+ foreach ($mailObject->attrs['acl'] as $uacl){
+
+ /* Get user=(mail) & acls */
+ list($user, $acl) = split(" ", $uacl);
+
+ /* Add al users which have seperated acls
+ %members% are all users in this group,
+ which have the standard group acl
+ */
+ if ($user != "%members%"){
+ $new_acl[$user]= $uacl;
+ } else {
+
+ /* All groupmembers will be added */
+ $ldap = $config->get_ldap_link();
+ $ldap->cd($config->current['BASE']);
+ foreach ($mailObject->members as $member){
+
+ /* Get user mail address .... */
+ $ldap->search("(&(objectClass=person)(|(uid=".$member.")(mail=".$member.")))",array("mail"));
+ $res = $ldap->fetch();
+
+ /* Default mail address is set to uid -
+ So if there is no mail address defined the uid is added
+ */
+ $mail = $member;
+
+ /* Use mail address if it is available */
+ if(isset($res['mail'][0])){
+ $mail = $res['mail'][0];
+ }
+
+ /* only append this mail/permission string to acl,
+ if there arn't already some (special) configs for this user */
+ $found =false;
+ foreach($mailObject->imapacl as $mailA => $acl){
+ if(strtolower(trim($mailA))==strtolower(trim($mail))){
+ $found = true;
+ }
+ }
+
+ /* Skipp user, with no email adress too */
+ if($member == $mail){
+ $found = true;
+ }
+
+ /* Append new user acl */
+ if(!$found){
+ $new_acl[$member]= "$mail $acl";
+ }
+
+ /* Old line */
+ // $new_acl[$member]= "$member $acl";
+ }
+ }
+ }
+
+ /* Save shared folder target */
+ $mailObject->attrs['gosaSharedFolderTarget']= "kolab+".$mailObject->mail;
+
+ /* Kolab shared folder names are like ' shared.uid@server.de '
+ So overwrite uid to match these folder names. Else we can't read quota settings etc.
+ #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
+ $mailObject->uid = $mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
+
+ /* Assign new acls */
+ $mailObject->attrs['acl']= array();
+ foreach ($new_acl as $key => $value){
+ $mailObject->attrs['acl'][]= $value;
+ }
+ } else {
+ $mailObject->attrs['objectClass'][]= 'kolabInetOrgPerson';
+ }
+
+ /* Remove imap:// tagging */
+ $mailObject->attrs['kolabHomeServer']= preg_replace('%imap://%', '', $mailObject->attrs['kolabHomeServer']);
+ $mailObject->attrs['gosaMailServer']= $mailObject->attrs['kolabHomeServer'];
+ $mailObject->attrs['kolabDeleteFlag']= array();
+ }
+
+ function fixAttributesOnRemove(&$mailObject)
+ {
+ /* Add attribute for object deletion and remove GOsa specific
+ values from entry. */
+ foreach($this->attribute_map as $kolabAttr){
+ $mailObject->attrs[$kolabAttr] = array();
+ }
+
+ /* Only add kolab delete Flag in case of an user.mailAccount */
+ if(!in_array("posixGroup", $mailObject->attrs['objectClass'])){
+ $mailObject->attrs['kolabDeleteFlag']= preg_replace('%imap://%', '', $mailObject->gosaMailServer);
+ }else{
+ /* Kolab shared folder names are like ' shared.uid@server.de '
+ So overwrite uid to match these folder names. Else we can't read quota settings etc.
+ #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
+ $mailObject->uid = $mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
+
+ }
+ }
+
+
+ function deleteMailbox($folder)
+ {
+ /* Remove shared folders and skip removing users.
+ KolabD is not able to remove shared folders yet, so we do it instead */
+ if(!(preg_match("/^user\//",$folder))){
+ return mailMethodCyrus::deleteMailbox($folder);
+ }
+ return (TRUE);
+ }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/mail/personal/mail/class_mail-methods-kolab.inc b/gosa-plugins/mail/personal/mail/class_mail-methods-kolab.inc
--- /dev/null
@@ -0,0 +1,267 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2004 Cajus Pollmeier
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+class mailMethodKolab extends mailMethodCyrus
+{
+ var $mbox= "-";
+ var $config;
+ var $gosaMailServer= "";
+ var $uattrib= "mail";
+
+ var $attribute_map= array("gosaMailAlternateAddress" => "alias",
+ "gosaMailQuota" => "cyrus-userquota",
+ "gosaMailServer" => "kolabHomeServer");
+
+ function mailMethodKolab(&$config)
+ {
+ $this->config= $config->data['SERVERS']['IMAP'];
+ }
+
+ function updateMailbox($folder)
+ {
+ }
+
+ function setQuota($folder, $gosaMailQuota)
+ {
+ return (TRUE);
+ }
+
+ /* Get quota and divide it by 1024, because in gosa we display in MB
+ but we get Kb */
+ function getQuota($folder)
+ {
+ $result= array('quotaUsage' => '', 'gosaMailQuota' => '');
+
+ /* Only use lower case folder names, if folder name is like "@domain.com" */
+ if(preg_match("/@/",$folder)){
+ $folder = strtolower($folder);
+ }
+
+ error_reporting(0);
+
+ /* Load quota settings */
+ $quota_value = @imap_get_quota($this->mbox, $folder);
+ if(is_array($quota_value)) {
+ if (isset($quota_value["STORAGE"]) && is_array($quota_value["STORAGE"])){
+ /* use for PHP >= 4.3 */
+ $result['quotaUsage']= (int) ($quota_value["STORAGE"]['usage'] / 1024);
+ $result['gosaMailQuota']= (int) ($quota_value["STORAGE"]['limit'] / 1024);
+ } else {
+ /* backward icompatible */
+ $result['quotaUsage']= (int) ($quota_value['usage'] / 1024);
+ $result['gosaMailQuota']= (int) ($quota_value['limit'] / 1024);
+ }
+ }elseif(!$quota_value){
+ return(false);
+ }
+
+ error_reporting(E_ALL | E_STRICT);
+
+ return ($result);
+ }
+
+
+ function fixAttributesOnLoad(&$mailObject)
+ {
+ /* Kolab shared folder names are like ' shared.uid@server.de '
+ So overwrite uid to match these folder names. Else we can't read quota settings etc.
+ #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
+ if(get_class($mailObject) == "mailgroup"){
+ $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
+ }
+
+ /* Convert attributes and objectClasses */
+ foreach ($this->attribute_map as $dest => $source){
+ /* Hickert 11.11.05 : Alternate email addresses were saved, but not displayed again.
+ if (isset($mailObject->attrs[$source])){
+ $mailObject->attrs[$dest]= $mailObject->attrs[$source];
+ unset ($mailObject->attrs[$source]);
+ */
+
+ if (isset($mailObject->attrs[$source])){
+ unset($mailObject->attrs[$source]['count']);
+ $mailObject->attrs[$dest]= $mailObject->attrs[$source];
+ $mailObject->$dest= $mailObject->attrs[$source];
+
+ /* Ensure that cleanup will recognize the ampped attributes too */
+ if(isset($mailObject->saved_attributes)){
+ $mailObject->saved_attributes[$dest] = $mailObject->attrs[$source];
+ $mailObject->saved_attributes[$source] = $mailObject->attrs[$source];
+ }
+
+ unset ($mailObject->$dest['count']);
+ unset ($mailObject->attrs[$source]);
+ }
+ }
+
+ /* Adjust server name if needed */
+ foreach ($mailObject->config->data['SERVERS']['IMAP'] as $srv => $dummy){
+ if (preg_match("%".$mailObject->attrs['gosaMailServer'][0]."$%", $srv)){
+ $mailObject->attrs['gosaMailServer']= array(0 => $srv, "count" => 1);
+ break;
+ }
+ }
+ }
+
+
+ function fixAttributesOnStore(&$mailObject)
+ {
+ global $config;
+
+ /* If quota is empty, remove quota restrictions by setting quota to 0 */
+ if(isset($mailObject->gosaMailQuota) && (empty($mailObject->gosaMailQuota))){
+ $mailObject->attrs['gosaMailQuota'] = 0;
+ }
+
+ /* Convert attributes and objectClasses */
+ foreach ($this->attribute_map as $source => $dest){
+ if (isset($mailObject->attrs[$source])){
+ $mailObject->attrs[$dest]= $mailObject->attrs[$source];
+ unset ($mailObject->attrs[$source]);
+ }
+ }
+ $objectclasses= array();
+ foreach ($mailObject->attrs['objectClass'] as $oc){
+ if ($oc != 'kolabInetOrgPerson' && $oc != 'kolabSharedFolder'){
+ $objectclasses[]= $oc;
+ }
+ }
+ $mailObject->attrs['objectClass']= $objectclasses;
+ if (in_array("posixGroup", $mailObject->attrs['objectClass'])){
+
+ /* Add kolabSharedFoleder Class */
+ $mailObject->attrs['objectClass'][]= 'kolabSharedFolder';
+
+ /* Work on acl attribute */
+ $new_acl= array();
+ foreach ($mailObject->attrs['acl'] as $uacl){
+
+ /* Get user=(mail) & acls */
+ list($user, $acl) = split(" ", $uacl);
+
+ /* Add al users which have seperated acls
+ %members% are all users in this group,
+ which have the standard group acl
+ */
+ if ($user != "%members%"){
+ $new_acl[$user]= $uacl;
+ } else {
+
+ /* All groupmembers will be added */
+ $ldap = $config->get_ldap_link();
+ $ldap->cd($config->current['BASE']);
+ foreach ($mailObject->members as $member){
+
+ /* Get user mail address .... */
+ $ldap->search("(&(objectClass=person)(|(uid=".$member.")(mail=".$member.")))",array("mail"));
+ $res = $ldap->fetch();
+
+ /* Default mail address is set to uid -
+ So if there is no mail address defined the uid is added
+ */
+ $mail = $member;
+
+ /* Use mail address if it is available */
+ if(isset($res['mail'][0])){
+ $mail = $res['mail'][0];
+ }
+
+ /* only append this mail/permission string to acl,
+ if there arn't already some (special) configs for this user */
+ $found =false;
+ foreach($mailObject->imapacl as $mailA => $acl){
+ if(strtolower(trim($mailA))==strtolower(trim($mail))){
+ $found = true;
+ }
+ }
+
+ /* Skipp user, with no email adress too */
+ if($member == $mail){
+ $found = true;
+ }
+
+ /* Append new user acl */
+ if(!$found){
+ $new_acl[$member]= "$mail $acl";
+ }
+
+ /* Old line */
+ // $new_acl[$member]= "$member $acl";
+ }
+ }
+ }
+
+ /* Save shared folder target */
+ $mailObject->attrs['gosaSharedFolderTarget']= "kolab+shared.".$mailObject->mail;
+
+ /* Kolab shared folder names are like ' shared.uid@server.de '
+ So overwrite uid to match these folder names. Else we can't read quota settings etc.
+ #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
+ $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
+
+ /* Assign new acls */
+ $mailObject->attrs['acl']= array();
+ foreach ($new_acl as $key => $value){
+ $mailObject->attrs['acl'][]= $value;
+ }
+ } else {
+ $mailObject->attrs['objectClass'][]= 'kolabInetOrgPerson';
+ }
+
+ /* Remove imap:// tagging */
+ $mailObject->attrs['kolabHomeServer']= preg_replace('%imap://%', '', $mailObject->attrs['kolabHomeServer']);
+ $mailObject->attrs['gosaMailServer']= $mailObject->attrs['kolabHomeServer'];
+ $mailObject->attrs['kolabDeleteFlag']= array();
+ }
+
+ function fixAttributesOnRemove(&$mailObject)
+ {
+ /* Add attribute for object deletion and remove GOsa specific
+ values from entry. */
+ foreach($this->attribute_map as $kolabAttr){
+ $mailObject->attrs[$kolabAttr] = array();
+ }
+
+ /* Only add kolab delete Flag in case of an user.mailAccount */
+ if(!in_array("posixGroup", $mailObject->attrs['objectClass'])){
+ $mailObject->attrs['kolabDeleteFlag']= preg_replace('%imap://%', '', $mailObject->gosaMailServer);
+ }else{
+ /* Kolab shared folder names are like ' shared.uid@server.de '
+ So overwrite uid to match these folder names. Else we can't read quota settings etc.
+ #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
+ $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
+
+ }
+ }
+
+
+ function deleteMailbox($folder)
+ {
+ /* Remove shared folders and skip removing users.
+ KolabD is not able to remove shared folders yet, so we do it instead */
+ if(preg_match("/^shared/",$folder)){
+ return mailMethodCyrus::deleteMailbox($folder);
+ }
+ return (TRUE);
+ }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/mail/personal/mail/class_mail-methods-sendmail-cyrus.inc b/gosa-plugins/mail/personal/mail/class_mail-methods-sendmail-cyrus.inc
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2004 Cajus Pollmeier
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+class mailMethodSendmailCyrus extends mailMethodCyrus
+{
+
+ function mailMethodSendmailCyrus(&$config)
+ {
+ $this->config= $config->data['SERVERS']['IMAP'];
+ }
+
+ function fixAttributesOnLoad(&$mailObject)
+ {
+ /* Remove possible local alias from forwarders */
+ $newForwarder= array();
+ foreach ($mailObject->gosaMailForwardingAddress as $addr){
+ if (!preg_match('/^\\\\/', $addr)){
+ $newForwarder[]= $addr;
+ }
+ }
+ $mailObject->gosaMailForwardingAddress= $newForwarder;
+ }
+
+ function fixAttributesOnStore(&$mailObject)
+ {
+ /* Add local user if checked */
+ if (preg_match("/L/", $mailObject->gosaMailDeliveryMode)) {
+ $mailObject->gosaMailForwardingAddress[]= "\\".$mailObject->uid;
+ }
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/mail/personal/mail/class_mail-methods.inc b/gosa-plugins/mail/personal/mail/class_mail-methods.inc
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2004 Cajus Pollmeier
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+class mailMethod
+{
+ var $uattrib= "uid";
+
+ function mailMethod(&$config)
+ {
+ }
+
+ function connect($gosaMailServer)
+ {
+ return (TRUE);
+ }
+
+ function disconnect()
+ {
+ }
+
+ function getQuota($folder)
+ {
+ return (array('quotaUsage' => 0, 'gosaMailQuota' => 0));
+ }
+
+ function getMailboxList($folder, $uid)
+ {
+ return (array("INBOX"));
+ }
+
+ function setQuota($folder, $gosaMailQuota)
+ {
+ return (TRUE);
+ }
+
+ function updateMailbox($folder)
+ {
+ }
+
+ function deleteMailbox($folder)
+ {
+ return (TRUE);
+ }
+
+ function setSharedFolderPermissions($folder, $permissions)
+ {
+ }
+
+ function configureFilter($user, $gosaMailDeliveryMode,
+ $mail, $gosaMailAlternateAddress,
+ $gosaMailMaxSize,
+ $gosaSpamMailbox, $gosaSpamSortLevel,
+ $gosaVacationMessage)
+ {
+ }
+
+ function fixAttributesOnLoad(&$mailObject)
+ {
+ }
+
+ function fixAttributesOnStore(&$mailObject)
+ {
+ }
+
+ function fixAttributesOnRemove(&$mailObject)
+ {
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/mail/personal/mail/class_mailAccount.inc b/gosa-plugins/mail/personal/mail/class_mailAccount.inc
--- /dev/null
@@ -0,0 +1,1386 @@
+<?php
+/*! \brief mail plugin
+ \author Cajus Pollmeier <pollmeier@gonicus.de>
+ \version 2.00
+ \date 24.07.2003
+
+ This class provides the functionality to read and write all attributes
+ relevant for gosaMailAccounts from/to the LDAP. It does syntax checking
+ and displays the formulars required.
+ */
+
+class mailAccount extends plugin
+{
+ /* Definitions */
+ var $plHeadline = "Mail";
+ var $plDescription = "This does something";
+ var $method = "mailMethod";
+
+ var $gosaVacationStart = 0;
+ var $gosaVacationStop = 0;
+ var $view_logged = FALSE;
+
+ /* plugin specific values */
+ var $mail = "";
+ var $gosaMailAlternateAddress = array();
+ var $gosaMailForwardingAddress = array();
+ var $gosaMailDeliveryMode = "[L ]";
+ var $gosaMailServer = "";
+ var $gosaMailQuota = "";
+ var $gosaMailMaxSize = "";
+ var $gosaVacationMessage = "";
+ var $gosaSpamSortLevel = "";
+ var $gosaSpamMailbox = "";
+
+ var $quotaUsage = 0;
+ var $forward_dialog = FALSE;
+ var $folder_prefix = "";
+ var $mailboxList = array("INBOX");
+ var $default_permissions = "none";
+ var $member_permissions = "post";
+ var $members = array();
+ var $admins = array();
+ var $vacations = array();
+ var $perms = array( "lrs" => "read",
+ "lrsp" => "post",
+ "lrsip" => "append",
+ "lrswipcd" => "write",
+ "lrswipcda" => "all" );
+
+ /* attribute list for save action */
+ var $attributes= array("mail", "gosaMailServer", "gosaMailQuota", "gosaMailMaxSize","gosaMailForwardingAddress",
+ "gosaMailDeliveryMode", "gosaSpamSortLevel", "gosaSpamMailbox","gosaMailAlternateAddress","gosaVacationStart","gosaVacationStop",
+ "gosaVacationMessage", "gosaMailAlternateAddress", "gosaMailForwardingAddress");
+ var $objectclasses= array("gosaMailAccount");
+ var $uid = "";
+
+ var $sieve_management = NULL;
+ var $multiple_support = TRUE;
+
+ /* constructor, if 'dn' is set, the node loads the given
+ 'dn' from LDAP */
+ function mailAccount (&$config, $dn= NULL)
+ {
+ global $class_mapping;
+
+ $this->gosaVacationStart = time();
+ $this->gosaVacationStop = time();
+
+ /* Load bases attributes */
+ plugin::plugin($config, $dn);
+
+ /* Set uid */
+ if(isset($this->attrs['uid'])){
+ $this->uid = $this->attrs['uid'][0];
+ }
+
+ if(is_array($this->gosaMailServer) && isset($this->gosaMailServer[0])){
+ $this->gosaMailServer = $this->gosaMailServer[0];
+ }
+
+ /* Save initial account state */
+ $this->initially_was_account= $this->is_account;
+
+ /* Set mailMethod to the one defined in gosa.conf */
+ if (isset($this->config->current['MAILMETHOD'])){
+ $method= $this->config->current['MAILMETHOD'];
+
+ $cls = get_correct_class_name("mailMethod$method");
+ if ($cls && class_exists($cls)){
+ $this->method= $cls;
+ } else {
+ msg_dialog::display(_("Configuration error"), sprintf(_("Unkown mail method '%s' specified!"), $method), ERROR_DIALOG);
+ }
+ }
+
+
+ /* Create the account prefix user. user/
+ Preset folder prefix. Will change it later to respect
+ altnamespace. */
+ if (isset($this->config->current['CYRUSUNIXSTYLE']) && $this->config->current['CYRUSUNIXSTYLE'] == "true"){
+ $this->folder_prefix= "user/";
+ }elseif (isset($this->config->data['MAIN']['CYRUSUNIXSTYLE']) && $this->config->data['MAIN']['CYRUSUNIXSTYLE'] == "true"){
+ $this->folder_prefix= "user/";
+ } else {
+ $this->folder_prefix= "user.";
+ }
+
+ /* This is not a new account, parse additional attributes */
+ if (($dn !== NULL) && ($dn != "new") && $this->is_account){
+
+ /* Load attributes containing arrays */
+ foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
+ $this->$val= array();
+ if (isset($this->attrs["$val"]["count"])){
+ for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){
+ array_push($this->$val, $this->attrs["$val"][$i]);
+ }
+ }
+ }
+
+
+ /* Only do IMAP actions if gosaMailServer attribute is set */
+ if (isset ($this->attrs["gosaMailServer"][0])){
+
+ $method = new $this->method($this->config);
+ $id = $method->uattrib;
+
+ /* Adapt attributes if needed */
+ $method->fixAttributesOnLoad($this);
+
+ /* FixAttributesOnLoad possibly creates an array out of gosaMailServer.
+ If the mail tab wasn't opened once before saving, the account can't be saved */
+ if(is_array($this->gosaMailServer)){
+ $this->gosaMailServer = $this->gosaMailServer[0];
+ }
+
+ if ($method->connect($this->attrs["gosaMailServer"][0])){
+
+ /* Update quota values */
+ $quota= $method->getQuota($this->folder_prefix.$this->$id);
+
+ if($quota){
+ if ($quota['gosaMailQuota'] == 2147483647){
+ $this->quotaUsage = "";
+ $this->gosaMailQuota = "";
+ } else {
+ $this->quotaUsage = $quota['quotaUsage'];
+ $this->gosaMailQuota = $quota['gosaMailQuota'];
+ }
+ }else{
+ $this->quotaUsage = "";
+ $this->gosaMailQuota = "";
+ }
+
+ /* Get mailboxes / folder like INBOX ..*/
+ $this->mailboxList= $method->getMailboxList($this->folder_prefix.$this->$id,$this->$id);
+
+ $method->disconnect();
+ }else{
+ /* Could not connect to ldap.
+ */
+ if (isset($this->attrs['gosaMailQuota'][0])){
+ $this->gosaMailQuota = $this->attrs['gosaMailQuota'][0];
+ }
+ }
+ }
+ }
+
+ /* Fill vacation array */
+ $this->vacation= array();
+ if (isset($this->config->current['VACATIONDIR'])){
+ $dir= $this->config->current['VACATIONDIR'];
+ if (is_dir($dir) && is_readable($dir)){
+
+ /* Look for files and build the vacation array */
+ $dh= opendir($dir);
+ while ($file = readdir($dh)){
+ $description= $this->parse_vacation("$dir/$file");
+ if ($description != ""){
+ $this->vacation["$dir/$file"]= $description;
+ }
+ }
+ closedir($dh);
+ }
+ }
+
+ /* Create sieve management class */
+ $method = new $this->method($this->config);
+ $id = $method->uattrib;
+ $this->sieve_management = new sieveManagement($this->config,$this->dn,$this,$id);
+
+ /* Get global filter config */
+ if (!session::is_set("mailfilter")){
+ $ui= get_userinfo();
+ $base= get_base_from_people($ui->dn);
+ $mailfilter= array( "depselect" => $base,
+ "muser" => "",
+ "regex" => "*");
+ session::set("mailfilter", $mailfilter);
+ }
+ }
+
+
+ function parse_vacation($file)
+ {
+ $desc= "";
+
+ if (is_file($file)){
+ $fh = fopen($file, "r");
+ $line= fgets($fh, 256);
+
+ if (!preg_match('/^DESC:/', $line)){
+ msg_dialog::display(_("Configuration error"), sprintf(_("No DESC tag in vacation template '%s'!"), $file), ERROR_DIALOG);
+ return $desc;
+ }
+ fclose ($fh);
+
+ $desc= trim(preg_replace('/^DESC:\s*/', '', $line));
+ }
+
+ return $desc;
+ }
+
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ /* Log view */
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","users/".get_class($this),$this->dn);
+ }
+
+ /* Initialise vars */
+
+ /* Load templating engine */
+ $smarty= get_smarty();
+ $display= "";
+
+ /* Get available mailserver */
+ $mailserver= array();
+ foreach ($this->config->data['SERVERS']['IMAP'] as $key => $val){
+ $mailserver[]= $key;
+ }
+
+ /*
+ * Sieve Management
+ */
+ if(isset($_POST['sieveManagement'])
+ && preg_match("/C/",$this->gosaMailDeliveryMode)
+ && $this->acl_is_writeable("sieveManagement")) {
+
+ $this->dialog = $this->sieve_management;
+ }
+
+ /* Cancel sieve edit */
+ if(isset($_POST['sieve_cancel'])){
+ $this->dialog = FALSE;
+ }
+
+ /* Save sieve changes */
+ if(isset($_POST['sieve_finish'])){
+ $this->sieve_management = $this->dialog;
+ $this->dialog = FALSE;
+ }
+
+ if(is_object($this->dialog)){
+ $this->dialog->save_object();
+ return($this->dialog->execute());
+ }
+
+
+ /* Handle account state */
+ /* Do we need to flip is_account state? */
+ if(isset($_POST['modify_state'])){
+ if($this->is_account && $this->acl_is_removeable()){
+ $this->is_account= FALSE;
+ }elseif(!$this->is_account && $this->acl_is_createable()){
+ $this->is_account= TRUE;
+ }
+ }
+
+ /* Do we represent a valid account? */
+ if(!$this->multiple_support_active){
+ if (!$this->is_account && $this->parent === NULL){
+ $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\"> <b>".
+ _("This account has no mail extensions.")."</b>";
+
+ $display.= back_to_main();
+ return ($display);
+ }
+
+ /* Show tab dialog headers */
+ if ($this->parent !== NULL){
+ if ($this->is_account){
+ if($this->accountDelegationsConfigured()){
+ $display= $this->show_disable_header(_("Remove mail account"),
+ _("This account can't be removed while there are delegations configured. Remove those delegations first."),TRUE,TRUE);
+ }else{
+ $display= $this->show_disable_header(_("Remove mail account"),
+ _("This account has mail features enabled. You can disable them by clicking below."));
+ }
+ } else {
+ $display= $this->show_enable_header(_("Create mail account"), _("This account has mail features disabled. You can enable them by clicking below."));
+ return ($display);
+ }
+ }
+ }
+
+ /* Forwarder subdialog */
+
+ /* Trigger forward add dialog? */
+ if (isset($_POST['add_local_forwarder'])){
+ $this->forward_dialog= TRUE;
+ $this->dialog= TRUE;
+ }
+
+ /* Cancel forward add dialog? */
+ if (isset($_POST['add_locals_cancel'])){
+ $this->forward_dialog= FALSE;
+ $this->dialog= FALSE;
+ }
+
+ /* Finished adding of locals? */
+ if (isset($_POST['add_locals_finish'])){
+
+ /* Check if we are able to write gosaMailForwardingAddress */
+ if($this->acl_is_writeable("gosaMailForwardingAddress")){
+
+ /* Walk through list of forwarders, ignore own addresses */
+ foreach ($_POST['local_list'] as $val){
+ if (!in_array ($val, $this->gosaMailAlternateAddress) &&
+ $val != $this->mail){
+
+ $this->addForwarder($val);
+ $this->is_modified= TRUE;
+ }
+ }
+ }
+ $this->forward_dialog= FALSE;
+ $this->dialog= FALSE;
+ }
+
+ /* Add forward email addresses */
+ if (isset($_POST['add_forwarder'])){
+ if ($_POST['forward_address'] != ""){
+
+ /* Valid email address specified? */
+ $address= $_POST['forward_address'];
+ $valid= FALSE;
+ if (!tests::is_email($address)){
+ if (!tests::is_email($address, TRUE)){
+ if ($this->is_template){
+ $valid= TRUE;
+ } else {
+ msg_dialog::display(_("Error"), _("Cannot add invalid mail address!"), ERROR_DIALOG);
+ }
+ }
+ } elseif ($address == $this->mail
+ || in_array($address, $this->gosaMailAlternateAddress)) {
+
+ msg_dialog::display(_("Error"),_("Cannot add your primary address to the list of forwarders.") , ERROR_DIALOG);
+
+ } else {
+ $valid= TRUE;
+ }
+
+ if ($valid){
+
+ /* Add it, if we are able to write gosaMailForwardingAddress */
+ if($this->acl_is_writeable("gosaMailForwardingAddress")){
+ $this->addForwarder ($address);
+ $this->is_modified= TRUE;
+ }
+ }
+ }
+ }
+
+ /* Delete forward email addresses */
+ if (isset($_POST['delete_forwarder'])){
+ $this->delForwarder ($_POST['forwarder_list']);
+ }
+
+
+ /* Add alternate email addresses */
+ if (isset($_POST['add_alternate'])){
+
+ $valid= FALSE;
+ if (!tests::is_email($_POST['alternate_address'])){
+ if ($this->is_template){
+ if (!(tests::is_email($_POST['alternate_address'], TRUE))){
+ msg_dialog::display(_("Error"), _("Cannot add invalid mail address!"), ERROR_DIALOG);
+ } else {
+ $valid= TRUE;
+ }
+ } else {
+ msg_dialog::display(_("Error"), _("Cannot add invalid mail address!"), ERROR_DIALOG);
+ }
+
+ } else {
+ $valid= TRUE;
+ }
+
+ if ($valid && ($user= $this->addAlternate ($_POST['alternate_address'])) != ""){
+ $ui= get_userinfo();
+ if ($user != $ui->username){
+ msg_dialog::display(_("Error"), sprintf(_("Cannot add mail address: it is already used by user '%s'."), $user), ERROR_DIALOG);
+ }
+ }
+ }
+
+ /* Delete alternate email addresses */
+ if (isset($_POST['delete_alternate']) && isset($_POST['alternates_list'])){
+ $this->delAlternate ($_POST['alternates_list']);
+ }
+
+
+ /* Vacation message */
+
+ /* Import vacation message? */
+ if (isset($_POST["import_vacation"]) && isset($this->vacation[$_POST["vacation_template"]])){
+
+
+ /* Save message */
+ if($this->multiple_support_active){
+ $contents = file_get_contents($_POST["vacation_template"]);
+ }else{
+ $contents = $this->prepare_vacation_template(file_get_contents($_POST["vacation_template"]));
+ }
+ $this->gosaVacationMessage= htmlspecialchars($contents);
+ }
+
+
+ /* Display forward dialog if requested above */
+
+ /* Show forward add dialog */
+ if ($this->forward_dialog){
+ $ldap= $this->config->get_ldap_link();
+
+ /* Save data */
+ $mailfilter= session::get("mailfilter");
+ foreach( array("depselect", "muser", "regex") as $type){
+ if (isset($_POST[$type])){
+ $mailfilter[$type]= $_POST[$type];
+ }
+ }
+ if (isset($_GET['search'])){
+ $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
+ if ($s == "**"){
+ $s= "*";
+ }
+ $mailfilter['regex']= $s;
+ }
+ session::set("mailfilter", $mailfilter);
+
+ /* Get actual list */
+ $mailusers= array ();
+ if ($mailfilter['regex'] != '*' && $mailfilter['regex'] != ""){
+ $regex= $mailfilter['regex'];
+ $filter= "(|(mail=$regex)(gosaMailAlternateAddress=$regex))";
+ } else {
+ $filter= "";
+ }
+ if ($mailfilter['muser'] != ""){
+ $user= $mailfilter['muser'];
+ $filter= "$filter(|(uid=$user)(cn=$user)(givenName=$user)(sn=$user))";
+ }
+
+ /* Add already present people to the filter */
+ $exclude= "";
+ foreach ($this->gosaMailForwardingAddress as $mail){
+ $exclude.= "(mail=$mail)";
+ }
+ if ($exclude != ""){
+ $filter.= "(!(|$exclude))";
+ }
+
+ $res= get_list("(&(objectClass=gosaMailAccount)$filter)", "users", $mailfilter['depselect'],
+ array("sn", "mail", "givenName"), GL_SIZELIMIT | GL_SUBSEARCH);
+ $ldap->cd($mailfilter['depselect']);
+ $ldap->search ("(&(objectClass=gosaMailAccount)$filter)", array("sn", "mail", "givenName"));
+ error_reporting (0);
+ while ($attrs= $ldap->fetch()){
+ if(preg_match('/%/', $attrs['mail'][0])){
+ continue;
+ }
+ $name= $this->make_name($attrs);
+ $mailusers[$attrs['mail'][0]]= $name."<".
+ $attrs['mail'][0].">";
+ }
+ error_reporting (E_ALL | E_STRICT);
+ natcasesort ($mailusers);
+ reset ($mailusers);
+
+ /* Show dialog */
+ $smarty->assign("search_image", get_template_path('images/search.png'));
+ $smarty->assign("usearch_image", get_template_path('images/search_user.png'));
+ $smarty->assign("tree_image", get_template_path('images/tree.png'));
+ $smarty->assign("infoimage", get_template_path('images/info.png'));
+ $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
+ $smarty->assign("mailusers", $mailusers);
+ if (isset($_POST['depselect'])){
+ $smarty->assign("depselect", $_POST['depselect']);
+ }
+ $smarty->assign("deplist", $this->config->idepartments);
+ $smarty->assign("apply", apply_filter());
+ $smarty->assign("alphabet", generate_alphabet());
+ $smarty->assign("hint", print_sizelimit_warning());
+ foreach( array("depselect", "muser", "regex") as $type){
+ $smarty->assign("$type", $mailfilter[$type]);
+ }
+ $smarty->assign("hint", print_sizelimit_warning());
+
+ $display.= $smarty->fetch (get_template_path('mail_locals.tpl', TRUE, dirname(__FILE__)));
+ return ($display);
+ }
+
+ /* Display mail account tab */
+
+ $smarty->assign("mailServers", $mailserver);
+ $SkipWrite = (!isset($this->parent) || !$this->parent) && !session::is_set('edit');
+
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $transl){
+ $smarty->assign("$name"."ACL", $this->getacl($name,$SkipWrite));
+ }
+
+ foreach(array("gosaMailServer", "gosaMailQuota", "perms", "mail",
+ "gosaMailAlternateAddress", "gosaMailForwardingAddress",
+ "gosaVacationMessage", "gosaMailDeliveryMode", "gosaVacationStart",
+ "gosaVacationStop", "gosaMailMaxSize", "gosaSpamSortLevel", "gosaSpamMailbox") as $val){
+ $smarty->assign("$val", $this->$val);
+ }
+
+ if (is_numeric($this->gosaMailQuota) && $this->gosaMailQuota != 0){
+ $smarty->assign("quotausage", progressbar(round(($this->quotaUsage * 100)/ $this->gosaMailQuota),100,15,true));
+ $smarty->assign("quotadefined", "true");
+ } else {
+ $smarty->assign("quotadefined", "false");
+ }
+
+ /* Disable mail field if needed */
+ $method= new $this->method($this->config);
+ if ($method->uattrib == "mail" && $this->initially_was_account){
+ $smarty->assign("mailACL", preg_replace("/w/","",$this->getacl("mail",$SkipWrite)));
+ }
+
+ /* Disable/Enable range select, but do not disable them twice
+ * if they are already diabled by "use own sieve script"
+ */
+ if (preg_match('/V/', $this->gosaMailDeliveryMode) || preg_match("/C/",$this->gosaMailDeliveryMode)){
+ $smarty->assign('rangeEnabled', "");
+ } else {
+ $smarty->assign('rangeEnabled', "disabled");
+ }
+
+ if (!preg_match("/L/", $this->gosaMailDeliveryMode)) {
+ $smarty->assign("only_local", "checked");
+ } else {
+ $smarty->assign("only_local", "");
+ }
+
+ $types = array(
+ "V"=>"use_vacation",
+ "S"=>"use_spam_filter",
+ "R"=>"use_mailsize_limit",
+ "I"=>"drop_own_mails",
+ "C"=>"own_script");
+
+ /* Fill checkboxes */
+ foreach($types as $option => $varname){
+ if (preg_match("/".$option."/", $this->gosaMailDeliveryMode)) {
+ $smarty->assign($varname, "checked");
+ } else {
+ $smarty->assign($varname, "");
+ }
+ }
+
+ /* Display mail account tab */
+ if($this->gosaVacationStart ==0){
+ $date= getdate(time());
+ }else{
+ $date= getdate($this->gosaVacationStart);
+ }
+ $days= array();
+ for($d= 1; $d<32; $d++){
+ $days[$d]= $d;
+ }
+ $years= array();
+ for($y= $date['year']-10; $y<$date['year']+10; $y++){
+ $years[]= $y;
+ }
+ $months= array(_("January"), _("February"), _("March"), _("April"),
+ _("May"), _("June"), _("July"), _("August"), _("September"),
+ _("October"), _("November"), _("December"));
+ $smarty->assign("start_day", $date["mday"]);
+ $smarty->assign("days", $days);
+ $smarty->assign("months", $months);
+ $smarty->assign("start_month", $date["mon"]-1);
+ $smarty->assign("years", $years);
+ $smarty->assign("start_year", $date["year"]);
+
+ if($this->gosaVacationStop ==0){
+ $date= getdate(time());
+ $date["mday"]++;
+ }else{
+ $date= getdate($this->gosaVacationStop);
+ }
+ $smarty->assign("end_day", $date["mday"]);
+ $smarty->assign("end_month", $date["mon"]-1);
+ $smarty->assign("end_year", $date["year"]);
+
+
+
+ /* Have vacation templates? */
+ $smarty->assign("template", "");
+ if (count($this->vacation)){
+ $smarty->assign("show_templates", "true");
+ $smarty->assign("vacationtemplates", $this->vacation);
+ if (isset($_POST['vacation_template'])){
+ $smarty->assign("template", $_POST['vacation_template']);
+ }
+ } else {
+ $smarty->assign("show_templates", "false");
+ }
+
+ /* Fill spam selector */
+ $spamlevel= array();
+ for ($i= 0; $i<21; $i++){
+ $spamlevel[]= $i;
+ }
+ $smarty->assign("spamlevel", $spamlevel);
+ $smarty->assign("spambox", $this->mailboxList);
+
+ foreach($this->attributes as $attr){
+ $u_attr = "use_".$attr;
+ $smarty->assign($u_attr,in_array($attr,$this->multi_boxes));
+ }
+
+ foreach(array("only_local","gosaMailForwardingAddress","use_mailsize_limit","drop_own_mails","use_vacation","use_spam_filter") as $attr){
+ $u_attr = "use_".$attr;
+ $smarty->assign($u_attr,in_array($attr,$this->multi_boxes));
+ }
+
+ $smarty->assign("multiple_support",$this->multiple_support_active);
+ $display.= $smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__)));
+ return ($display);
+ }
+
+
+ /* remove object from parent */
+ function remove_from_parent()
+ {
+ /* Cancel if there's nothing to do here */
+ if (!$this->initially_was_account){
+ return;
+ }
+
+ /* include global link_info */
+ $ldap= $this->config->get_ldap_link();
+
+ /* Remove and write to LDAP */
+ plugin::remove_from_parent();
+
+ /* Zero arrays */
+ $this->attrs['gosaMailAlternateAddress']= array();
+ $this->attrs['gosaMailForwardingAddress']= array();
+
+ /* Adapt attributes if needed */
+ $method= new $this->method($this->config);
+ $method->fixAttributesOnRemove($this);
+
+ @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,$this->attributes, "Save");
+ $ldap->cd($this->dn);
+ $this->cleanup();
+
+ $ldap->modify ($this->attrs);
+
+ /* Add "view" to logging class */
+ new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+
+ show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/mail account with dn '%s' failed."),$this->dn));
+
+ /* Connect to IMAP server for account deletion */
+ if ($this->gosaMailServer != ""){
+ $method= new $this->method($this->config);
+ $id= $method->uattrib;
+ if ($method->connect($this->gosaMailServer)){
+
+ /* Remove account from IMAP server */
+ $method->deleteMailbox($this->folder_prefix.$this->$id);
+ $method->disconnect();
+ }
+ }
+
+ /* Update shared folder membership, ACL may need to be updated */
+ $this->updateSharedFolder();
+
+ /* Optionally execute a command after we're done */
+ $this->handle_post_events("remove",array("uid" => $this->uid));
+ }
+
+
+ /* check if we have some delegations configured, those delegations must be removed first */
+ function accountDelegationsConfigured()
+ {
+ /* We are in administrational edit mode.
+ Check tab configurations directly */
+ if(isset($this->attrs)){
+ $checkArray = array("kolabInvitationPolicy","unrestrictedMailSize", "calFBURL","kolabDelegate","kolabFreeBusyFuture");
+ foreach($checkArray as $index){
+ if(isset($this->attrs[$index])){
+ return(true);
+ }
+ }
+ }
+ return(false);
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ if (isset($_POST['mailTab'])){
+
+ /* Save ldap attributes */
+ plugin::save_object();
+
+
+ if(isset($_POST['own_script'])){
+
+ if(!preg_match("/C/",$this->gosaMailDeliveryMode)){
+ $str= preg_replace("/[\[\]]/","",$this->gosaMailDeliveryMode);
+ $this->gosaMailDeliveryMode = "[".$str."C]";
+ }
+
+ }else{
+
+ /* Assemble mail delivery mode
+ The mode field in ldap consists of values between braces, this must
+ be called when 'mail' is set, because checkboxes may not be set when
+ we're in some other dialog.
+
+ Example for gosaMailDeliveryMode [LR ]
+ L: Local delivery
+ R: Reject when exceeding mailsize limit
+ S: Use spam filter
+ V: Use vacation message
+ C: Use custm sieve script
+ I: Only insider delivery */
+
+ $tmp= preg_replace("/[^a-z]/i","",$this->gosaMailDeliveryMode);
+
+
+ /* Handle delivery flags */
+ if($this->acl_is_writeable("gosaMailDeliveryModeL")){
+ if(!preg_match("/L/",$tmp) && !isset($_POST['only_local'])){
+ $tmp.="L";
+ }elseif(preg_match("/L/",$tmp) && isset($_POST['only_local'])){
+ $tmp = preg_replace("/L/","",$tmp);
+ }
+ }
+
+ $opts = array(
+ "R" => "use_mailsize_limit",
+ "S" => "use_spam_filter",
+ "V" => "use_vacation",
+ "C" => "own_script",
+ "I" => "drop_own_mails");
+
+ foreach($opts as $flag => $post){
+ if($this->acl_is_writeable("gosaMailDeliveryMode".$flag)){
+ if(!preg_match("/".$flag."/",$tmp) && isset($_POST[$post])){
+ $tmp.= $flag;
+ }elseif(preg_match("/".$flag."/",$tmp) && !isset($_POST[$post])){
+ $tmp = preg_replace("/".$flag."/","",$tmp);
+ }
+ }
+ }
+
+ $tmp= "[$tmp]";
+ if ($this->gosaMailDeliveryMode != $tmp){
+ $this->is_modified= TRUE;
+ }
+ $this->gosaMailDeliveryMode= $tmp;
+
+
+ if($this->acl_is_writeable("gosaVacationMessage") && preg_match("/V/",$this->gosaMailDeliveryMode)){
+ if(isset($_POST['gosaVacationStart'])){
+ $this->gosaVacationStart = $_POST['gosaVacationStart'];
+ }
+ if(isset($_POST['gosaVacationStop'])){
+ $this->gosaVacationStop = $_POST['gosaVacationStop'];
+ }
+ }
+ }
+ }
+ }
+
+
+ /* Save data to LDAP, depending on is_account we save or delete */
+ function save()
+ {
+ $ldap= $this->config->get_ldap_link();
+
+ /* Call parents save to prepare $this->attrs */
+ plugin::save();
+
+ /* Save arrays */
+ $this->attrs['gosaMailAlternateAddress']= $this->gosaMailAlternateAddress;
+ $this->attrs['gosaMailForwardingAddress']= $this->gosaMailForwardingAddress;
+
+ /* Adapt attributes if needed */
+ $method= new $this->method($this->config);
+ $id= $method->uattrib;
+
+ $method->fixAttributesOnStore($this);
+
+ /* Remove Mailquota if = "" or "0" */
+ if((isset($this->attrs['gosaMailQuota']))&&(!$this->attrs['gosaMailQuota'])) {
+ $this->attrs['gosaMailQuota']=0;
+ }
+
+ if(empty($this->attrs['gosaSpamMailbox'])){
+ unset($this->attrs['gosaSpamMailbox']);
+ }
+
+ $this->attrs['mail'] = strtolower($this->attrs['mail']);
+
+ /* Remove attributes - if not needed */
+ if (!preg_match('/V/', $this->gosaMailDeliveryMode)){
+ unset($this->attrs['gosaVacationStart']);
+ unset($this->attrs['gosaVacationStop']);
+ }
+
+
+ /* Remove attributes - if not needed */
+ if (!preg_match('/V/', $this->gosaMailDeliveryMode)){
+ unset($this->attrs['gosaVacationStart']);
+ unset($this->attrs['gosaVacationStop']);
+ }
+
+ /* Save data to LDAP */
+ $ldap->cd($this->dn);
+ $this->cleanup();
+ $ldap->modify ($this->attrs);
+
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/mail account with dn '%s' failed."),$this->dn));
+
+ /* Log last action */
+ if($this->initially_was_account){
+ new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }else{
+ new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }
+
+ /* Only do IMAP actions if we are not a template */
+ if (!$this->is_template){
+
+ if ($method->connect($this->gosaMailServer)){
+ $method->updateMailbox($this->folder_prefix.$this->$id);
+
+ $method->setQuota($this->folder_prefix.$this->$id, $this->gosaMailQuota);
+ $method->disconnect();
+
+ /* Ensure that this is an existing account */
+ if(1==1 || $this->initially_was_account){
+
+ /* Write sieve information only if not in C mode */
+ if (!is_integer(strpos($this->gosaMailDeliveryMode, "C"))){
+ $method->configureFilter($this->$id,
+ $this->gosaMailDeliveryMode,
+ $this->mail,
+ $this->gosaMailAlternateAddress,
+ $this->gosaMailMaxSize,
+ $this->gosaSpamMailbox,
+ $this->gosaSpamSortLevel,
+ $this->gosaVacationMessage);
+ $this->is_modified = TRUE;
+ }else{
+ $this->sieve_management->save();
+ }
+ }
+ }
+ }
+
+ /* Optionally execute a command after we're done */
+ if ($this->initially_was_account == $this->is_account){
+ if ($this->is_modified){
+ $this->handle_post_events("modify", array("uid" => $this->uid));
+ }
+ } else {
+ $this->handle_post_events("add", array("uid" => $this->uid));
+ }
+
+ $this->updateSharedFolder();
+ }
+
+
+ /* Check formular input */
+ function check()
+ {
+ if(!$this->is_account) return(array());
+
+ $ldap= $this->config->get_ldap_link();
+
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ if(empty($this->gosaMailServer)){
+ $message[]= _("There is no valid mailserver specified, please add one in the system setup.");
+ }
+
+ /* must: mail */
+ if ($this->mail == ""){
+ $message[]= _("The required field 'Primary address' is not set.");
+ }
+ if ($this->is_template){
+ if (!tests::is_email($this->mail, TRUE)){
+ $message[]= _("Please enter a valid email address in 'Primary address' field.");
+ }
+ } else {
+ if (!tests::is_email($this->mail)){
+ $message[]= _("Please enter a valid email address in 'Primary address' field.");
+ }
+ }
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=".$this->mail.")(gosaMailAlternateAddress=".$this->mail."))(!(uid=".$this->uid."))(!(cn=".$this->uid.")))", array("uid"));
+ if ($ldap->count() != 0){
+ $message[]= _("The primary address you've entered is already in use.");
+ }
+
+ /* Check quota */
+ if ($this->gosaMailQuota != '' && $this->acl_is_writeable("gosaMailQuota")){
+ if (!is_numeric($this->gosaMailQuota)) {
+ $message[]= _("Value in 'Quota size' is not valid.");
+ } else {
+ $this->gosaMailQuota= (int) $this->gosaMailQuota;
+ }
+ }
+
+ /* Check rejectsize for integer */
+ if ($this->gosaMailMaxSize != '' && $this->acl_is_writeable("gosaMailMaxSize")){
+ if (!is_numeric($this->gosaMailMaxSize)){
+ $message[]= _("Please specify a vaild mail size for mails to be rejected.");
+ } else {
+ $this->gosaMailMaxSize= (int) $this->gosaMailMaxSize;
+ }
+ }
+
+ /* Need gosaMailMaxSize if use_mailsize_limit is checked */
+ if (is_integer(strpos($this->gosaMailDeliveryMode, "R")) &&
+ $this->gosaMailMaxSize == ""){
+
+ $message[]= _("You need to set the maximum mail size in order to reject anything.");
+ }
+
+ if((preg_match("/S/", $this->gosaMailDeliveryMode))&&(empty($this->gosaSpamMailbox))) {
+ $message[]= _("You specified Spam settings, but there is no Folder specified.");
+ }
+
+ if (preg_match('/V/', $this->gosaMailDeliveryMode) && $this->gosaVacationStart > $this->gosaVacationStop){
+ $message[]= _("Time interval to show vacation message is not valid.");
+ }
+
+ return ($message);
+ }
+
+
+ /* Adapt from template, using 'dn' */
+ function adapt_from_template($dn)
+ {
+ plugin::adapt_from_template($dn);
+
+ foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
+ $this->$val= array();
+ if (isset($this->attrs["$val"]["count"])){
+ for ($i= 0; $i<$this->attrs["$val"]["count"]; $i++){
+ $value= $this->attrs["$val"][$i];
+ foreach (array("sn", "givenName", "uid") as $repl){
+ if (preg_match("/%$repl/i", $value)){
+ $value= preg_replace ("/%$repl/i", $this->parent->$repl, $value);
+ }
+ }
+ array_push($this->$val, strtolower(rewrite($value)));
+ }
+ }
+ }
+ $this->mail= strtolower(rewrite($this->mail));
+ }
+
+
+ /* Add entry to forwarder list */
+ function addForwarder($address)
+ {
+ if($this->acl_is_writeable("gosaMailForwardingAddress")){
+ $this->gosaMailForwardingAddress[]= $address;
+ $this->gosaMailForwardingAddress= array_unique ($this->gosaMailForwardingAddress);
+ sort ($this->gosaMailForwardingAddress);
+ reset ($this->gosaMailForwardingAddress);
+ $this->is_modified= TRUE;
+ }else{
+ msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses."), ERROR_DIALOG);
+ }
+ }
+
+
+ /* Remove list of addresses from forwarder list */
+ function delForwarder($addresses)
+ {
+ if($this->acl_is_writeable("gosaMailForwardingAddress")){
+ $this->gosaMailForwardingAddress= array_remove_entries ($addresses, $this->gosaMailForwardingAddress);
+ $this->is_modified= TRUE;
+ }else{
+ msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses."), ERROR_DIALOG);
+ }
+ }
+
+
+ /* Add given mail address to the list of alternate adresses ,
+ check if this mal address is used, skip adding in this case */
+ function addAlternate($address)
+ {
+ if($this->acl_is_writeable("gosaMailAlternateAddress")){
+ $ldap= $this->config->get_ldap_link();
+ $address= strtolower($address);
+
+ /* Is this address already assigned in LDAP? */
+ $ldap->cd ($this->config->current['BASE']);
+ $ldap->search ("(&(objectClass=gosaMailAccount)(|(mail=$address)"."(gosaMailAlternateAddress=$address)))", array("uid"));
+ $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=$address)"."(gosaMailAlternateAddress=$address)))", array("uid"));
+
+ if ($ldap->count() > 0){
+ $attrs= $ldap->fetch ();
+ return ($attrs["uid"][0]);
+ }
+
+ /* Add to list of alternates */
+ if (!in_array($address, $this->gosaMailAlternateAddress)){
+ $this->gosaMailAlternateAddress[]= $address;
+ $this->is_modified= TRUE;
+ }
+
+ sort ($this->gosaMailAlternateAddress);
+ reset ($this->gosaMailAlternateAddress);
+ return ("");
+ }else{
+ msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses."), ERROR_DIALOG);
+ }
+ }
+
+
+ function delAlternate($addresses)
+ {
+ if($this->acl_is_writeable("gosaMailAlternateAddress")){
+ $this->gosaMailAlternateAddress= array_remove_entries ($addresses,$this->gosaMailAlternateAddress);
+ $this->is_modified= TRUE;
+ }else{
+ msg_dialog::display(_("Permission error"), _("You have no permission to modify these addresses."), ERROR_DIALOG);
+ }
+ }
+
+ function make_name($attrs)
+ {
+ $name= "";
+ if (isset($attrs['sn'][0])){
+ $name= $attrs['sn'][0];
+ }
+ if (isset($attrs['givenName'][0])){
+ if ($name != ""){
+ $name.= ", ".$attrs['givenName'][0];
+ } else {
+ $name.= $attrs['givenName'][0];
+ }
+ }
+ if ($name != ""){
+ $name.= " ";
+ }
+
+ return ($name);
+ }
+
+
+ /* Create the mail part for the copy & paste dialog */
+ function getCopyDialog()
+ {
+ if(!$this->is_account) return("");
+ $smarty = get_smarty();
+ $smarty->assign("mail",$this->mail);
+ $smarty->assign("gosaMailAlternateAddress",$this->gosaMailAlternateAddress);
+ $smarty->assign("gosaMailForwardingAddress",$this->gosaMailForwardingAddress);
+ $str = $smarty->fetch(get_template_path("copypaste.tpl",TRUE, dirname(__FILE__)));
+
+ $ret = array();
+ $ret['status'] = "";
+ $ret['string'] = $str;
+ return($ret);
+ }
+
+ function saveCopyDialog()
+ {
+ if(!$this->is_account) return;
+
+ /* Execute to save mailAlternateAddress && gosaMailForwardingAddress */
+ $this->execute();
+
+ if(isset($_POST['mail'])){
+ $this->mail = $_POST['mail'];
+ }
+
+ }
+
+ function allow_remove()
+ {
+ if (isset($this->config->current['MAILMETHOD'])){
+ $method= $this->config->current['MAILMETHOD'];
+ if(preg_match("/olab/i",$method)){
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->cat($this->dn);
+ if($ldap->count()){
+ $attrs = $ldap->fetch();
+ if(isset($attrs['kolabDeleteFlag'])){
+ return(_("Waiting for kolab to remove mail properties."));
+ }elseif(in_array("gosaMailAccount",$attrs['objectClass'])){
+ return(_("Please remove the mail account first, to allow kolab to call its remove methods."));
+ }
+ }
+ }
+ }
+ }
+
+
+ function PrepareForCopyPaste($source)
+ {
+ plugin::PrepareForCopyPaste($source);
+
+ /* Reset alternate mail addresses */
+ $this->gosaMailAlternateAddress = array();
+ }
+
+
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Mail"),
+ "plDescription" => _("Mail settings"),
+ "plSelfModify" => TRUE,
+ "plDepends" => array("user"), // This plugin depends on
+ "plPriority" => 4, // Position in tabs
+ "plSection" => array("personal" => _("My account")),
+ "plCategory" => array("users"),
+ "plOptions" => array(),
+
+ "plProvidedAcls" => array(
+ "mail" => _("Mail address"),
+ "gosaMailServer" => _("Mail server"),
+ "gosaMailQuota" => _("Quota size"),
+
+ "gosaMailDeliveryModeV" => _("Add vacation information"), // This is flag of gosaMailDeliveryMode
+ "gosaVacationMessage" => _("Vacation message"),
+
+ "gosaMailDeliveryModeS" => _("Use spam filter"), // This is flag of gosaMailDeliveryMode
+ "gosaSpamSortLevel" => _("Spam level"),
+ "gosaSpamMailbox" => _("Spam mail box"),
+
+ "sieveManagement" => _("Sieve management"),
+
+ "gosaMailDeliveryModeR" => _("Reject due to mailsize"), // This is flag of gosaMailDeliveryMode
+ "gosaMailMaxSize" => _("Mail max size"),
+
+ "gosaMailForwardingAddress" => _("Forwarding address"),
+ "gosaMailDeliveryModeL" => _("Local delivery"), // This is flag of gosaMailDeliveryMode
+ "gosaMailDeliveryModeI" => _("No delivery to own mailbox "), // This is flag of gosaMailDeliveryMode
+ "gosaMailAlternateAddress" => _("Mail alternative addresses"),
+
+ "gosaMailForwardingAddress" => _("Forwarding address"),
+ "gosaMailDeliveryModeC" => _("Use custom sieve script")) // This is flag of gosaMailDeliveryMode
+ ));
+ }
+
+
+ /*! \brief Prepare importet vacation string. \
+ Replace placeholder like %givenName a.s.o.
+ @param string Vacation string
+ @return string Completed vacation string
+ */
+ private function prepare_vacation_template($contents)
+ {
+ /* Replace attributes */
+ $attrs = array();
+ $obj = NULL;
+ if(isset($this->parent->by_object['user'])){
+ $attrs = $this->parent->by_object['user']->attributes;
+ $obj = $this->parent->by_object['user'];
+ }else{
+ $obj = new user($this->config,$this->dn);
+ $attrs = $obj->attributes;
+ }
+
+ if($obj){
+ foreach ($attrs as $val){
+ if(preg_match("/dateOfBirth/",$val)){
+ if($obj->use_dob){
+ $contents= preg_replace("/%$val/",date("Y-d-m",$obj->dateOfBirth),$contents);
+ }
+ }else {
+ $contents= preg_replace("/%$val/",
+ $obj->$val, $contents);
+ }
+
+ /* Replace vacation start and end time */
+ if(preg_match("/%start/",$contents)){
+ $contents = preg_replace("/%start/",date("d.m.Y",$this->gosaVacationStart),$contents);
+ }
+ if(preg_match("/%end/",$contents)){
+ $contents = preg_replace("/%end/",date("d.m.Y",$this->gosaVacationStop),$contents);
+ }
+ }
+ }
+ return($contents);
+ }
+
+
+
+ /* Upated shared folder ACLs
+ */
+ function updateSharedFolder()
+ {
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(&(objectClass=posixGroup)(objectClass=gosaMailAccount)(memberUid=".$this->uid."))",array('dn','cn'));
+ if(class_exists("grouptabs")){
+ while($attrs = $ldap->fetch()){
+ $tmp = new grouptabs($this->config, $this->config->data['TABS']['GROUPTABS'], $attrs['dn']);
+ if(isset($tmp->by_object['mailgroup'])){
+ $tmp->by_object['mailgroup']->members= $tmp->by_object['group']->memberUid;
+ if(!$this->is_account){
+ $tmp->by_object['mailgroup']->removeUserAcl($this->uid);
+ $tmp->by_object['mailgroup']->removeUserAcl($this->mail);
+ }
+ $tmp->by_object['mailgroup']->save();
+ }
+ }
+ }
+ }
+
+ /* Initialize plugin with given atribute arrays
+ */
+ function init_multiple_support($attrs,$all)
+ {
+ plugin::init_multiple_support($attrs,$all);
+
+ if(isset($this->multi_attrs['gosaMailQuota'])){
+ $this->gosaMailQuota = $this->multi_attrs['gosaMailQuota'];
+ }
+ }
+
+ function get_multi_init_values()
+ {
+ $attrs = plugin::get_multi_init_values();
+ $attrs['gosaMailQuota'] = $this->gosaMailQuota;
+ return($attrs);
+ }
+
+ function multiple_execute()
+ {
+ return($this->execute());
+ }
+
+ function multiple_save_object()
+ {
+ plugin::multiple_save_object();
+
+ $this->save_object();
+ foreach(array("only_local","gosaMailForwardingAddress","use_mailsize_limit","drop_own_mails","use_vacation","use_spam_filter") as $attr){
+ if(isset($_POST["use_".$attr])){
+ $this->multi_boxes[] = $attr;
+ }
+ }
+ }
+
+ function get_multi_edit_values()
+ {
+ $ret = plugin::get_multi_edit_values();
+
+ if(in_array("gosaMailQuota",$this->multi_boxes)){
+ $ret['gosaMailQuota'] = $this->gosaMailQuota;
+ }
+
+ $flag_add = $flag_remove = array();
+ $tmp= preg_replace("/[^a-z]/i","",$this->gosaMailDeliveryMode);
+ $opts = array(
+ "R" => "use_mailsize_limit",
+ "S" => "use_spam_filter",
+ "L" => "only_local",
+ "V" => "use_vacation",
+ "C" => "own_script",
+ "I" => "drop_own_mails");
+
+ foreach($opts as $flag => $post){
+ if(in_array($post, $this->multi_boxes)){
+ if(preg_match("/".$flag."/",$tmp)){
+ $flag_add[] = $flag;
+ }else{
+ $flag_remove[] = $flag;
+ }
+ }
+ }
+
+ $ret['flag_add'] = $flag_add;
+ $ret['flag_remove'] = $flag_remove;
+ return($ret);
+ }
+
+
+ function multiple_check()
+ {
+ $message = plugin::multiple_check();
+
+ if(empty($this->gosaMailServer) && in_array("gosaMailServer",$this->multi_boxes)){
+ $message[]= _("There is no valid mailserver specified, please add one in the system setup.");
+ }
+
+ /* Check quota */
+ if ($this->gosaMailQuota != '' && in_array("gosaMailQuota",$this->multi_boxes)){
+ if (!is_numeric($this->gosaMailQuota)) {
+ $message[]= _("Value in 'Quota size' is not valid.");
+ } else {
+ $this->gosaMailQuota= (int) $this->gosaMailQuota;
+ }
+ }
+
+ /* Check rejectsize for integer */
+ if ($this->gosaMailMaxSize != '' && in_array("gosaMailMaxSize",$this->multi_boxes)){
+ if (!is_numeric($this->gosaMailMaxSize)){
+ $message[]= _("Please specify a vaild mail size for mails to be rejected.");
+ } else {
+ $this->gosaMailMaxSize= (int) $this->gosaMailMaxSize;
+ }
+ }
+
+ if(empty($this->gosaSpamMailbox) && in_array("gosaSpamMailbox",$this->multi_boxes)){
+ $message[]= _("You specified Spam settings, but there is no Folder specified.");
+ }
+
+ if ( in_array("use_vacation",$this->multi_boxes) &&
+ preg_match('/V/', $this->gosaMailDeliveryMode) && $this->gosaVacationStart > $this->gosaVacationStop){
+ $message[]= _("Time interval to show vacation message is not valid.");
+ }
+ return($message);
+ }
+
+
+ function set_multi_edit_values($values)
+ {
+ plugin::set_multi_edit_values($values);
+ $tmp= preg_replace("/[^a-z]/i","",$this->gosaMailDeliveryMode);
+ if(isset($values['flag_add'])){
+ foreach($values['flag_add'] as $flag){
+ if(!preg_match("/".$flag."/",$tmp)){
+ $tmp .= $flag;
+ }
+ }
+ }
+ if(isset($values['flag_remove'])){
+ foreach($values['flag_remove'] as $flag){
+ if(preg_match("/".$flag."/",$tmp)){
+ $tmp = preg_replace("/".$flag."/","",$tmp);
+ }
+ }
+ }
+ $this->gosaMailDeliveryMode = "[".$tmp."]";
+
+ /* Set vacation message and replace placeholder like %givenName
+ */
+ if(isset($values['gosaVacationMessage'])){
+ $this->gosaVacationMessage = $this->prepare_vacation_template($values['gosaVacationMessage']);
+ }
+ }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/mail/personal/mail/copypaste.tpl b/gosa-plugins/mail/personal/mail/copypaste.tpl
--- /dev/null
@@ -0,0 +1,70 @@
+<h2>{t}Mail settings{/t}</h2>
+<table style='width:100%;' cellspacing=0>
+ <tr>
+ <td style='width:50%;vertical-align:top; border-right:1px solid #AAA'>
+ <table style="width:100%;">
+ <tr>
+ <td><label for="mail">{t}Primary address{/t}</label>{$must}</td>
+ <td><input id="mail" name="mail" size=35 maxlength=65 value="{$mail}"></td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <p style="margin-bottom:0px;">
+ <b><label for="forwarder_list">{t}Forward messages to{/t}</label></b>
+ </p>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td style="vertical-align:bottom;border-left:1px solid #A0A0A0">
+ <table style="width:100%;">
+ <tr>
+ <td style="vertical-align:top;">
+ <h2>
+ <img class="center" alt="" align="middle" src="images/alternatemail.png" />
+ <label for="alternates_list">{t}Alternative addresses{/t}</label>
+ </h2>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table style='width:100%;'>
+ <tr>
+ <td colspan="2">
+ <select id="gosaMailForwardingAddress" style="width:100%; height:100px;" name="forwarder_list[]" size=15 multiple >
+ {html_options values=$gosaMailForwardingAddress output=$gosaMailForwardingAddress}
+ <option disabled> </option>
+ </select>
+ <br>
+ <input name="forward_address" size=20 align="middle" maxlength=65 value="">
+ <input type="submit" value="{t}Add{/t}" name="add_forwarder" >
+ <input type="submit" value="{t}Add local{/t}" name="add_local_forwarder" >
+ <input type="submit" value="{t}Delete{/t}" name="delete_forwarder" >
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td style="vertical-align:bottom;border-left:1px solid #A0A0A0">
+ <table style='width:100%;'>
+ <tr>
+ <td colspan="2" >
+ <select id="alternates_list" style="width:100%;height:100px;" name="alternates_list[]" size="15"
+ multiple title="{t}List of alternative mail addresses{/t}">
+ {html_options values=$gosaMailAlternateAddress output=$gosaMailAlternateAddress}
+ <option disabled> </option>
+ </select>
+ <br/>
+ <input name="alternate_address" size="30" align="middle" maxlength="65" value="">
+ <input type=submit value="{t}Add{/t}" name="add_alternate">
+ <input type=submit value="{t}Delete{/t}" name="delete_alternate">
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+<br>
+<br>
diff --git a/gosa-plugins/mail/personal/mail/generic.tpl b/gosa-plugins/mail/personal/mail/generic.tpl
--- /dev/null
@@ -0,0 +1,339 @@
+<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding="0" border="0">
+ <tr>
+ <td style="width:50%; vertical-align:top;">
+
+ <h2><img class="center" alt="" align="middle" src="images/rightarrow.png" /> {t}Generic{/t}</h2>
+ <table summary="">
+ <tr>
+ <td><label for="mail">{t}Primary address{/t}</label>{$must}</td>
+ <td>
+{if $multiple_support}
+ <input id="mail" name="dummy1" size=35 maxlength=65 value="{t}Multiple edit{/t}" disabled>
+{else}
+{render acl=$mailACL}
+ <input id="mail" name="mail" size=35 maxlength=65 value="{$mail}">
+{/render}
+{/if}
+ </td>
+ </tr>
+ <tr>
+ <td><label for="gosaMailServer">{t}Server{/t}</label></td>
+ <td>
+{render acl=$gosaMailServerACL checkbox=$multiple_support checked=$use_gosaMailServer}
+ <select size="1" id="gosaMailServer" name="gosaMailServer" title="{t}Specify the mail server where the user will be hosted on{/t}">
+ {html_options values=$mailServers output=$mailServers selected=$gosaMailServer}
+ <option disabled> </option>
+ </select>
+{/render}
+ </td>
+ </tr>
+{if !$multiple_support}
+ <tr>
+ <td>
+ <br>
+ {t}Quota usage{/t}
+ </td>
+ <td>
+ <br>
+ {if $quotadefined eq "true"}
+ {$quotausage}
+ {else}
+ {t}not defined{/t}
+ {/if}
+ </td>
+ </tr>
+{/if}
+ <tr>
+ <td><label for="gosaMailQuota">{t}Quota size{/t}</label></td>
+ <td>
+{render acl=$gosaMailQuotaACL checkbox=$multiple_support checked=$use_gosaMailQuota}
+ <input id="gosaMailQuota" name="gosaMailQuota" size="6" align="middle" maxlength="60"
+ value="{$gosaMailQuota}"> MB
+{/render}
+ </td>
+ </tr>
+ </table>
+ </td>
+
+{if !$multiple_support}
+
+ <td style="border-left:1px solid #A0A0A0;vertical-align:top;">
+
+ </td>
+ <td>
+ <h2><img class="center" alt="" align="middle" src="images/alternatemail.png" /><label for="alternates_list"> {t}Alternative addresses{/t}</label></h2>
+{render acl=$gosaMailAlternateAddressACL}
+ <select id="alternates_list" style="width:100%;height:100px;" name="alternates_list[]" size="15" multiple
+ title="{t}List of alternative mail addresses{/t}">
+ {html_options values=$gosaMailAlternateAddress output=$gosaMailAlternateAddress}
+ <option disabled> </option>
+{/render}
+ </select>
+ <br />
+{render acl=$gosaMailAlternateAddressACL}
+ <input name="alternate_address" size="30" align="middle" maxlength="65" value="">
+{/render}
+{render acl=$gosaMailAlternateAddressACL}
+ <input type=submit value="{t}Add{/t}" name="add_alternate">
+{/render}
+{render acl=$gosaMailAlternateAddressACL}
+ <input type=submit value="{t}Delete{/t}" name="delete_alternate">
+{/render}
+ </td>
+
+{/if}
+
+ </tr>
+</table>
+
+{if $multiple_support}
+
+<p class="seperator"> </p>
+<h2><img class="center" alt="" align="middle" src="images/envelope.png" /> {t}Mail options{/t}</h2>
+
+{else}
+
+<!-- SIEVE -->
+<p class="seperator"> </p>
+<table summary="" style="vertical-align:top; text-align:left;" cellpadding=4 border=0>
+ <tr>
+ <td>
+{render acl=$gosaMailDeliveryModeCACL}
+ <input class="center" type=checkbox name="own_script" value="1" {$own_script}
+ onClick="
+ changeState('sieveManagement');
+ changeState('drop_own_mails');
+ changeState('use_vacation');
+ changeState('use_spam_filter');
+ changeState('use_mailsize_limit');
+ changeState('import_vacation');
+ changeState('vacation_template');
+// changeState('forward_address');
+// changeState('add_forwarder');
+// changeState('add_local_forwarder');
+// changeState('delete_forwarder');
+ changeState('only_local');
+ changeState('gosaVacationMessage');
+ changeState('gosaSpamSortLevel');
+ changeState('gosaSpamMailbox');
+ changeState('gosaMailMaxSize');
+ changeStates();
+
+ "
+
+> {t}Use custom sieve script{/t} <b>({t}disables all Mail options!{/t})</b>
+{/render}
+ </td>
+ </tr>
+ <tr>
+ <td>
+{render acl=$sieveManagementACL}
+ <input {if $own_script == ""} disabled {/if} id='sieveManagement' type='submit' name='sieveManagement' value='{t}Sieve Management{/t}'>
+{/render}
+ </td>
+ </tr>
+</table>
+
+<p class="seperator"> </p>
+{/if}
+
+<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4 border=0>
+ <tr style="padding-bottom:0px;">
+ <td style="width:50%">
+{render acl=$gosaMailDeliveryModeIACL checkbox=$multiple_support checked=$use_drop_own_mails}
+ <input {if $own_script != ""} disabled {/if} class="center" id='drop_own_mails' type=checkbox name="drop_own_mails" value="1" {$drop_own_mails} title="{t}Select if you want to forward mails without getting own copies of them{/t}"> {t}No delivery to own mailbox{/t}
+{/render}
+
+<br>
+{render acl=$gosaMailDeliveryModeVACL checkbox=$multiple_support checked=$use_use_vacation}
+ <input type=checkbox name="use_vacation" value="1" {$use_vacation} id="use_vacation" {if $own_script != ""} disabled {/if}
+ title="{t}Select to automatically response with the vacation message defined below{/t}" class="center"
+onclick="changeState('day'); changeState('month'); changeState('year'); changeState('sday'); changeState('smonth'); changeState('syear');
+"> {t}Activate vacation message{/t}
+{/render}
+
+ <br>
+
+ <table>
+ <tr>
+ <td>
+ {t}from{/t}
+ </td>
+ <td>
+{render acl=$gosaVacationMessageACL}
+ <select {if $own_script != ""} disabled {/if} name=day id="day" onChange="createResult(this.form,this.form.gosaVacationStart);" {$rangeEnabled}>
+ {html_options values=$days output=$days selected=$start_day}
+ </select>
+{/render}
+{render acl=$gosaVacationMessageACL}
+ <select {if $own_script != ""} disabled {/if} name=month id="month" onChange="populate(this.form,this.form.gosaVacationStart);" {$rangeEnabled}>
+ {html_options options=$months selected=$start_month}
+ </select>
+{/render}
+{render acl=$gosaVacationMessageACL}
+ <select {if $own_script != ""} disabled {/if} name=year id="year" onChange="populate(this.form,this.form.gosaVacationStart);" {$rangeEnabled}>
+ {html_options values=$years output=$years selected=$start_year}
+ </select>
+{/render}
+ <input type="hidden" name="gosaVacationStart" value="{$gosaVacationStart}">
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {t}till{/t}
+ </td>
+ <td>
+{render acl=$gosaVacationMessageACL}
+ <select {if $own_script != ""} disabled {/if} name=sday id="sday" onChange="createResult2(this.form,this.form.gosaVacationStop);" {$rangeEnabled}>
+ {html_options values=$days output=$days selected=$end_day}
+ </select>
+{/render}
+{render acl=$gosaVacationMessageACL}
+ <select {if $own_script != ""} disabled {/if} name=smonth id="smonth" onChange="populate2(this.form,this.form.gosaVacationStop);" {$rangeEnabled}>
+ {html_options options=$months selected=$end_month}
+ </select>
+{/render}
+{render acl=$gosaVacationMessageACL}
+ <select {if $own_script != ""} disabled {/if} name=syear id="syear" onChange="populate2(this.form,this.form.gosaVacationStop);" {$rangeEnabled}>
+ {html_options values=$years output=$years selected=$end_year}
+ </select>
+{/render}
+ <input type="hidden" name="gosaVacationStop" value="{$gosaVacationStop}">
+ </td>
+ </tr>
+ </table>
+
+
+ <td rowspan=2 style="border-left:1px solid #A0A0A0">
+
+ </td>
+ <td style="vertical-align:top;">
+{render acl=$gosaMailDeliveryModeSACL checkbox=$multiple_support checked=$use_use_spam_filter}
+ <input {if $own_script != ""} disabled {/if} id='use_spam_filter' type=checkbox name="use_spam_filter" value="1" {$use_spam_filter} title="{t}Select if you want to filter this mails through spamassassin{/t}" class="center">
+{/render}
+ <label for="gosaSpamSortLevel">{t}Move mails tagged with spam level greater than{/t}</label>
+
+{render acl=$gosaSpamSortLevelACL checkbox=$multiple_support checked=$use_gosaSpamSortLevel}
+ <select {if $own_script != ""} disabled {/if} id="gosaSpamSortLevel" size="1" name="gosaSpamSortLevel" title="{t}Choose spam level - smaller values are more sensitive{/t}">
+ {html_options values=$spamlevel output=$spamlevel selected=$gosaSpamSortLevel}
+ </select>
+{/render}
+ <label for="gosaSpamMailbox">{t}to folder{/t}</label>
+{render acl=$gosaSpamMailboxACL checkbox=$multiple_support checked=$use_gosaSpamMailbox}
+ <select {if $own_script != ""} disabled {/if} size="1" id="gosaSpamMailbox" name="gosaSpamMailbox">
+ {html_options values=$spambox output=$spambox selected=$gosaSpamMailbox}
+ <option disabled> </option>
+ </select>
+{/render}
+ <br>
+{render acl=$gosaMailDeliveryModeRACL checkbox=$multiple_support checked=$use_use_mailsize_limit}
+ <input {if $own_script != ""} disabled {/if} id='use_mailsize_limit' type=checkbox name="use_mailsize_limit" value="1" {$use_mailsize_limit} class="center">
+{/render}
+ <label for="gosaMailMaxSize">{t}Reject mails bigger than{/t}</label>
+{render acl=$gosaMailMaxSizeACL checkbox=$multiple_support checked=$use_gosaMailMaxSize}
+ <input {if $own_script != ""} disabled {/if} id="gosaMailMaxSize" name="gosaMailMaxSize" size="6" align="middle" maxlength="30" value="{$gosaMailMaxSize}" class="center"> {t}MB{/t}
+{/render}
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top; width:45%">
+ <p style="margin-bottom:0px;">
+ <b><label for="gosaVacationMessage">{t}Vacation message{/t}</label></b>
+ </p>
+{render acl=$gosaVacationMessageACL checkbox=$multiple_support checked=$use_gosaVacationMessage}
+ <textarea {if $own_script != ""} disabled {/if} id="gosaVacationMessage" style="width:99%; height:100px;" name="gosaVacationMessage" rows="4" cols="512">{$gosaVacationMessage}</textarea>
+{/render}
+ <br>
+
+ {if $show_templates eq "true"}
+{render acl=$gosaVacationMessageACL}
+ <select id='vacation_template' name="vacation_template" {if $own_script != ""} disabled {/if}>
+ {html_options options=$vacationtemplates selected=$template}
+ <option disabled> </option>
+ </select>
+{/render}
+{render acl=$gosaVacationMessageACL}
+ <input {if $own_script != ""} disabled {/if} id='import_vacation' type="submit" value="{t}Import{/t}" name="import_vacation">
+{/render}
+ {/if}
+ </td>
+ <td>
+ <p style="margin-bottom:0px;">
+ <b><label for="forwarder_list">{t}Forward messages to{/t}</label></b>
+ </p>
+
+{if $multiple_support}
+<input type="checkbox" name="use_gosaMailForwardingAddress" onclick="changeState('gosaMailForwardingAddress');"
+ class="center" {if $use_gosaMailForwardingAddress} checked {/if}>
+{/if}
+
+{render acl=$gosaMailForwardingAddressACL}
+ <select {if $use_gosaMailForwardingAddress} checked {/if}
+ id="gosaMailForwardingAddress" style="width:100%; height:100px;" name="forwarder_list[]" size=15 multiple>
+ {html_options values=$gosaMailForwardingAddress output=$gosaMailForwardingAddress selected=$template}
+ <option disabled> </option>
+ </select>
+{/render}
+ <br>
+{render acl=$gosaMailForwardingAddressACL}
+ <input id='forward_address' name="forward_address" size=20 align="middle" maxlength=65 value="">
+{/render}
+{render acl=$gosaMailForwardingAddressACL}
+ <input id='add_forwarder' type="submit" value="{t}Add{/t}" name="add_forwarder" >
+{/render}
+{render acl=$gosaMailForwardingAddressACL}
+ <input id='add_local_forwarder' type="submit" value="{t}Add local{/t}" name="add_local_forwarder" >
+{/render}
+{render acl=$gosaMailForwardingAddressACL}
+ <input id='delete_forwarder' type="submit" value="{t}Delete{/t}" name="delete_forwarder">
+{/render}
+ </td>
+ </tr>
+</table>
+<p class="seperator"> </p>
+
+<h2><img class="center" alt="" align="middle" src="images/false.png" /> {t}Advanced mail options{/t}</h2>
+
+<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding="4" border="0">
+ <tr>
+ <td>
+{render acl=$gosaMailDeliveryModeLACL checkbox=$multiple_support checked=$use_only_local}
+ <input {if $own_script != ""} disabled {/if} id='only_local' type=checkbox name="only_local" value="1" {$only_local} title="{t}Select if user can only send and receive inside his own domain{/t}" class="center">
+{/render}
+ {t}User is only allowed to send and receive local mails{/t}
+ </td>
+ </tr>
+</table>
+
+<input type="hidden" name="mailTab" value="mailTab">
+
+<!-- Place cursor -->
+<script language="JavaScript" type="text/javascript">
+
+ {literal}
+ function changeStates()
+ {
+
+ if(document.getElementById('use_vacation').checked){
+ changeState('day');
+ changeState('month');
+ changeState('year');
+ changeState('sday');
+ changeState('smonth');
+ changeState('syear');
+ }else{
+ changeSubselectState('use_vacation','day');
+ changeSubselectState('use_vacation','month');
+ changeSubselectState('use_vacation','year');
+ changeSubselectState('use_vacation','sday');
+ changeSubselectState('use_vacation','smonth');
+ changeSubselectState('use_vacation','syear');
+ }
+ }
+
+ {/literal}
+
+<!-- // First input field on page
+ focus_field('mail');
+ -->
+</script>
diff --git a/gosa-plugins/mail/personal/mail/mail_locals.tpl b/gosa-plugins/mail/personal/mail/mail_locals.tpl
--- /dev/null
@@ -0,0 +1,81 @@
+<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
+ <tr>
+ <td style="vertical-align:top;width:600px">
+ <div class="contentboxh" style="height:20px;">
+ <p class="contentboxh" style="font-size:12px">
+ <b>
+ <LABEL for="local_list">{t}Select addresses to add{/t}</LABEL>
+ {$hint}
+ </b>
+ <br>
+ </p>
+ </div>
+ <div class="contentboxb">
+ <p class="contentboxb" style="border-top:1px solid #B0B0B0;background-color:#F8F8F8">
+ <select id="local_list" style="width:600px; margin-top:4px; height:450px;" name="local_list[]" size="15" multiple>
+ {html_options options=$mailusers}
+ </select>
+ </p>
+ </div>
+ </td>
+ <td style="vertical-align:top;">
+ <div class="contentboxh" style="height:20px;">
+ <p class="contentboxh" style="font-size:12px">
+ <img src="{$launchimage}" align="right" alt="[F]">
+ <b>{t}Filters{/t}</b>
+ </p>
+ </div>
+ <div class="contentboxb" style="background-color:#F8F8F8">
+ <table summary="" style="width:100%;border-top:1px solid #B0B0B0; background-color:#F8F8F8">
+ {$alphabet}
+ </table>
+ <table summary="" width="100%" style="border-top:1px solid #B0B0B0;background-color:#F8F8F8">
+ <tr>
+ <td>
+ <LABEL for="depselect">{t}Select department{/t}</LABEL>
+ <img alt="" src="{$tree_image}" align=middle>
+ <select id="depselect" name="depselect" size=1 onChange="mainform.submit()"
+ title="{t}Choose the department the search will be based on{/t}">
+ {html_options options=$deplist selected=$depselect}
+ </select>
+ </td>
+ </tr>
+ </table>
+
+ <table summary="" width="100%" style="border-top:1px solid #B0B0B0;background-color:#F8F8F8">
+ <tr>
+ <td style="width:18px">
+ <img alt="" src="{$search_image}" align="middle">
+ </td>
+ <td>
+ <input type='text' name='regex' maxlength='20' style="width:99%" value='{$regex}'
+ title='{t}Regular expression for matching addresses{/t}' onChange="mainform.submit()">
+ </td>
+ </tr>
+ </table>
+
+ <table summary="" width="100%" style="border-top:1px solid #B0B0B0;background-color:#F8F8F8">
+ <tr>
+ <td style="width:18px;">
+ <img src="{$usearch_image}" align=middle alt="{t}Display addresses of user{/t}">
+ </td>
+ <td>
+ <input type='text' name='muser' maxlength='20' style="width:99%" value='{$muser}'
+ title='{t}User name of which addresses are shown{/t}' onChange="mainform.submit()">
+ </td>
+ </tr>
+ </table>
+ {$apply}
+ </div>
+ </td>
+ </tr>
+</table>
+
+<p class="plugbottom">
+ <input type=submit name="add_locals_finish" value="{t}Add{/t}">
+
+ <input type=submit name="add_locals_cancel" value="{t}Cancel{/t}">
+</p>
+<!--
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+-->
diff --git a/gosa-plugins/mail/personal/mail/main.inc b/gosa-plugins/mail/personal/mail/main.inc
--- /dev/null
@@ -0,0 +1,131 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2003 Cajus Pollmeier
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+$lock_msg ="";
+$display ="";
+if (!$remove_lock){
+ /* Reset requested? */
+ if (isset($_POST['edit_cancel']) ||
+ (isset($_GET['reset']) && $_GET['reset'] == 1)){
+ del_lock ($ui->dn);
+ session::un_set ('edit');
+ session::un_set ('mailAccount');
+ }
+
+ /* Create mail object on demand */
+ if (!session::is_set('mailAccount') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
+ $mailAccount= new mailAccount ($config, $ui->dn);
+ $mailAccount->enable_CSN_check();
+ $mailAccount->set_acl_base($ui->dn);
+ $mailAccount->set_acl_category("users");
+ session::set('mailAccount',$mailAccount);
+ }
+ $mailAccount = session::get('mailAccount');
+
+ /* save changes back to object */
+ if (session::is_set('edit')){
+ $mailAccount->save_object ();
+ }
+
+ /* Enter edit mode? */
+ if (isset($_POST['edit']) && preg_match("/w/",$ui->get_permissions($ui->dn,"users/mailAccount"))){
+
+ /* Check locking */
+ if (($username= get_lock($ui->dn)) != ""){
+ session::set('back_plugin',$plug);
+ session::set('LOCK_VARS_TO_USE',array("/^edit$/","/^plug$/"));
+ $lock_msg = gen_locked_message ($username, $ui->dn);
+
+ }else{
+
+ /* Lock the current entry */
+ add_lock ($ui->dn, $ui->dn);
+ session::set('dn',$ui->dn);
+ session::set('edit',TRUE);
+ }
+ }
+
+ /* save changes to LDAP and disable edit mode */
+ if (isset($_POST['edit_finish'])){
+
+ /* Perform checks */
+ $message= $mailAccount->check ();
+
+ /* No errors, save object */
+ if (count ($message) == 0){
+ $mailAccount->save ();
+ del_lock ($ui->dn);
+ session::un_set ('edit');
+
+ /* Remove object */
+ session::un_set ('mailAccount');
+ } else {
+ /* Errors found, show message */
+ show_errors ($message);
+ }
+ }
+
+ /* Execute formular */
+ if($lock_msg){
+ $display.= $lock_msg;
+ }else{
+ $display.= $mailAccount->execute ();
+ }
+
+ /* Store changes in session */
+ if (session::is_set('edit')){
+ session::set('mailAccount',$mailAccount);
+ }
+
+ $info= "";
+ /* Show page footer depending on the mode */
+ if (!$mailAccount->forward_dialog && $mailAccount->is_account && empty($lock_msg)){
+ $display.= "<p class=\"plugbottom\">";
+
+ /* Are we in edit mode? */
+ if (session::is_set('edit')){
+ $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
+ $display.= " ";
+ $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+ $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
+ "\"> ".$ui->dn." ";
+ } else {
+ $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
+ "\"> ".$ui->dn." ";
+
+ $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png').
+ "\"> "._("Click the 'Edit' button below to change informations in this dialog");
+
+ if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/mailAccount"))){
+ $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
+ }
+
+ $display.= "<input type=\"hidden\" name=\"ignore\">\n";
+ }
+ $display.= "</p>\n";
+ }
+
+ /* Page header*/
+ $display= print_header(get_template_path('images/email.png'), _("User mail settings"), $info).$display;
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/mail/personal/mail/sieve-discard.txt b/gosa-plugins/mail/personal/mail/sieve-discard.txt
--- /dev/null
@@ -0,0 +1,3 @@
+# Do not deliver to own mailbox
+discard;
+
diff --git a/gosa-plugins/mail/personal/mail/sieve-header.txt b/gosa-plugins/mail/personal/mail/sieve-header.txt
--- /dev/null
@@ -0,0 +1,3 @@
+###GOSA
+require ["fileinto", "reject", "vacation"];
+
diff --git a/gosa-plugins/mail/personal/mail/sieve-mailsize.txt b/gosa-plugins/mail/personal/mail/sieve-mailsize.txt
--- /dev/null
@@ -0,0 +1,17 @@
+# Reject mails with bigger size
+if size :over {$maxsize}M{
+ reject text:
+Dear sender,
+
+the mail you sent to our mailsystem has been rejected due
+to a user configured maximum mail size ($maxsize MB).
+
+Either ask the user to remove the sizelimit, or send smaller pieces.
+
+Thank you,
+ the mailserver
+.
+ ;
+ discard;
+}
+
diff --git a/gosa-plugins/mail/personal/mail/sieve-spam.txt b/gosa-plugins/mail/personal/mail/sieve-spam.txt
--- /dev/null
@@ -0,0 +1,5 @@
+# Sort mails with higher spam level
+if header :contains "X-Spam-Level" "$spamlevel" {
+ fileinto "$spambox";
+}
+
diff --git a/gosa-plugins/mail/personal/mail/sieve-vacation.txt b/gosa-plugins/mail/personal/mail/sieve-vacation.txt
--- /dev/null
@@ -0,0 +1,4 @@
+# Vacation message
+vacation :addresses [$addrlist]
+"$vacmsg" ;
+