From: cajus Date: Thu, 17 Jan 2008 08:32:38 +0000 (+0000) Subject: Moved mail plugin X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0f95409eb6ae55d4212d27c044a315ab8b21b392;p=gosa.git Moved mail plugin git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8432 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/addons/mailqueue/class_mailqueue.inc b/gosa-core/plugins/addons/mailqueue/class_mailqueue.inc deleted file mode 100644 index fd890dfa4..000000000 --- a/gosa-core/plugins/addons/mailqueue/class_mailqueue.inc +++ /dev/null @@ -1,417 +0,0 @@ -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"; - foreach(split("\n",$str) as $line){ - $line = trim($line); - if(empty($line)) { - continue; - } - $this->disp_header .= "\n"; - $tmp0 = preg_replace("/:.*$/","",$line); - $tmp1 = preg_replace("/^.*:/","",$line); - $this->disp_header .= "\n"; - $this->disp_header .= "\n"; - } - $this->disp_header .= "\n
".$tmp0."".$tmp1."
"; - } - } - } - } - } - - - /* 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",""._("up").""); - }else{ - $smarty->assign("SortType",""._("down").""); - } - } - } - - /* 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 deleted file mode 100644 index b510cb3a7..000000000 --- a/gosa-core/plugins/addons/mailqueue/class_parseMailQueue.inc +++ /dev/null @@ -1,237 +0,0 @@ -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 deleted file mode 100644 index 139bcd481..000000000 --- a/gosa-core/plugins/addons/mailqueue/contents.tpl +++ /dev/null @@ -1,130 +0,0 @@ -
 
-
-

[F]Filter

-
-
-
- - - - - -
- {t}Search{/t} -  {t}Search for{/t} - -  in - - {t}with status{/t} : - -  {t}within the last{/t}  - -   - -   - - - - -
-
-
-
- - -{if $all_ok != "true"} -{t}Search returned no results{/t}... -{else} - - - - - - - - - - - - - -{counter start=0 assign=i start=1} -{foreach from=$entries item=val key=key} - - {if ($i%2)== 0 } - - {else} - - {/if} - - - - - - - - - - {counter} -{/foreach} -
{t}ID{/t} {if $OrderBy == "MailID"} {$SortType}{/if}{t}Server{/t} {if $OrderBy == "Server"} {$SortType}{/if}{t}Size{/t} {if $OrderBy == "Size"} {$SortType}{/if}{t}Arrival{/t} {if $OrderBy == "Arrival"} {$SortType}{/if}{t}Sender{/t} {if $OrderBy == "Sender"} {$SortType}{/if}{t}Recipient{/t} {if $OrderBy == "Recipient"}{$SortType}{/if}{t}Error{/t} {if $OrderBy == "Error"} {$SortType}{/if} 
- - {if $entries[$key].Active == true} - {t}Active{/t} - {/if} - - {$entries[$key].MailID} - - {$entries[$key].Server} - {$entries[$key].Size} - {$entries[$key].Arrival} - {$entries[$key].Sender} - {$entries[$key].Recipient}{$entries[$key].Error} - - {t}delete{/t} - - {if $entries[$key].Hold == true} - - {t}unhold{/t} - - {else} - - {t}hold{/t} - - {/if} - - {t}requeue{/t} - - - {t}header{/t} - -
- - - - - -
{$range_selector}
-

 

- -{/if} - - diff --git a/gosa-core/plugins/addons/mailqueue/header.tpl b/gosa-core/plugins/addons/mailqueue/header.tpl deleted file mode 100644 index eeb8bcfbc..000000000 --- a/gosa-core/plugins/addons/mailqueue/header.tpl +++ /dev/null @@ -1,6 +0,0 @@ -{$header} - -

 

-
- -
diff --git a/gosa-core/plugins/addons/mailqueue/main.inc b/gosa-core/plugins/addons/mailqueue/main.inc deleted file mode 100644 index 2e0f274d0..000000000 --- a/gosa-core/plugins/addons/mailqueue/main.inc +++ /dev/null @@ -1,48 +0,0 @@ -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.= "\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 deleted file mode 100644 index 9180cfa54..000000000 --- a/gosa-core/plugins/admin/systems/services/mail/class_goMailServer.inc +++ /dev/null @@ -1,725 +0,0 @@ - "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.= " "; - }else{ - $img.= ""; - } - if(($key+1) < count($this->postfixTransportTable) && $this->acl_is_writeable("postfixTransportTable")){ - $img.= " "; - }else{ - $img.= ""; - } - - if($this->acl_is_writeable("postfixTransportTable")){ - $img.= " "; - } - $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.= " "; - }else{ - $img.= ""; - } - if(($key+1) < count($this->postfixSenderRestrictions) && $this->acl_is_writeable("postfixSenderRestrictions")){ - $img.= " "; - }else{ - $img.= ""; - } - - if($this->acl_is_writeable("postfixSenderRestrictions")){ - $img.= " "; - } - - $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.= " "; - }else{ - $img.= ""; - } - if(($key+1) < count($this->postfixRecipientRestrictions) && $this->acl_is_writeable("postfixRecipientRestrictions")){ - $img.= " "; - }else{ - $img.= ""; - } - - if($this->acl_is_writeable("postfixRecipientRestrictions")){ - $img.= " "; - } - $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 deleted file mode 100644 index a17d08f04..000000000 --- a/gosa-core/plugins/admin/systems/services/mail/goMailServer.tpl +++ /dev/null @@ -1,225 +0,0 @@ -

{t}Generic{/t}

- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
{t}Visible full qualified hostname{/t} - -{render acl=$postfixMyhostnameACL} - -{/render} -
{t}Max mail header size{/t} - -{render acl=$postfixMyhostnameACL} -  {t}KB{/t} -{/render} -
{t}Max mailbox size{/t} - -{render acl=$postfixMailboxSizeLimitACL} -  {t}KB{/t} -{/render}
{t}Max message size{/t} - -{render acl=$postfixMessageSizeLimitACL} -  {t}KB{/t} -{/render} -
{t}Relay host{/t} - -{render acl=$postfixRelayhostACL} - -{/render} -
-
- - - - -
- {t}Local networks{/t}
-{render acl=$postfixMyNetworksACL} - -{/render} -{render acl=$postfixMyNetworksACL} - -{/render} -{render acl=$postfixMyNetworksACL} - -{/render} -{render acl=$postfixMyNetworksACL} - -{/render} -
-
-

 

-

{t}Domains and routing{/t}

-
- - - - -
- {t}Domains to accept mail for{/t}
-{render acl=$postfixMyDestinationsACL} - -{render acl=$postfixMyDestinationsACL} - -{/render} -{render acl=$postfixMyDestinationsACL} - -{/render} -{render acl=$postfixMyDestinationsACL} - -{/render} -
-
- - - - -
- {t}Transports{/t}
-{render acl=$postfixTransportTableACL} - {$Div_postfixTransportTable} -{/render} - -{render acl=$postfixTransportTableACL} - -{/render} -{render acl=$postfixTransportTableACL} - -{/render} -{render acl=$postfixTransportTableACL} - -{/render} -{render acl=$postfixTransportTableACL} - -{/render} -
-
-

 

-

{t}Restrictions{/t}

-
- - - - -
- {t}Restrictions for sender{/t}
-{render acl=$postfixSenderRestrictionsACL} - {$Div_postfixSenderRestrictions} -{/render} -{render acl=$postfixSenderRestrictionsACL} - -{/render} -{render acl=$postfixSenderRestrictionsACL} - -{/render} -{render acl=$postfixSenderRestrictionsACL} - -{/render} -{render acl=$postfixSenderRestrictionsACL} - -{/render} -
-
- - - - -
- {t}Restrictions for recipient{/t}
-{render acl=$postfixRecipientRestrictionsACL} - {$Div_postfixRecipientRestrictions} -{/render} -{render acl=$postfixRecipientRestrictionsACL} - -{/render} -{render acl=$postfixRecipientRestrictionsACL} - -{/render} -{render acl=$postfixRecipientRestrictionsACL} - -{/render} -{render acl=$postfixRecipientRestrictionsACL} - -{/render} -
-
- -

 

-
-

Action

-{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} -
- - - -

 

-
- -   - -

- diff --git a/gosa-core/plugins/personal/mail/class_mail-methods-cyrus.inc b/gosa-core/plugins/personal/mail/class_mail-methods-cyrus.inc deleted file mode 100644 index 388a5a715..000000000 --- a/gosa-core/plugins/personal/mail/class_mail-methods-cyrus.inc +++ /dev/null @@ -1,366 +0,0 @@ -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"), '

'.imap_last_error().''), 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"), '

'.imap_last_error().''), 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'), '

'.imap_last_error().''), 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"), '

'.to_string($sieve->error_raw).''), 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"), '

'.to_string($sieve->error_raw).''), 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"), '

'.to_string($sieve->error_raw).''), ERROR_DIALOG); - return; - } - if(!$sieve->sieve_setactivescript("gosa")){ - msg_dialog::display(_("SIEVE error"), sprintf(_("Cannot activate SIEVE script: %s"), '

'.to_string($sieve->error_raw).''), 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 deleted file mode 100644 index dc75674c2..000000000 --- a/gosa-core/plugins/personal/mail/class_mail-methods-golab.inc +++ /dev/null @@ -1,261 +0,0 @@ - "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 deleted file mode 100644 index c0606046b..000000000 --- a/gosa-core/plugins/personal/mail/class_mail-methods-kolab.inc +++ /dev/null @@ -1,267 +0,0 @@ - "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 deleted file mode 100644 index 8bb8d73be..000000000 --- a/gosa-core/plugins/personal/mail/class_mail-methods-sendmail-cyrus.inc +++ /dev/null @@ -1,52 +0,0 @@ -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 deleted file mode 100644 index 1874648a9..000000000 --- a/gosa-core/plugins/personal/mail/class_mail-methods.inc +++ /dev/null @@ -1,90 +0,0 @@ - 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 deleted file mode 100644 index 5a0356566..000000000 --- a/gosa-core/plugins/personal/mail/class_mailAccount.inc +++ /dev/null @@ -1,1386 +0,0 @@ - - \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= "\"\" ". - _("This account has no mail extensions.").""; - - $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 deleted file mode 100644 index 56ec107ff..000000000 --- a/gosa-core/plugins/personal/mail/copypaste.tpl +++ /dev/null @@ -1,70 +0,0 @@ -

{t}Mail settings{/t}

- - - - - - - - - -
- - - - - - - - -
{$must}
-

- -

-
-
- - - - -
-

- - -

-
-
- - - - -
- -
- -   -   - -
-
- - - - -
- -
- - - -
-
-
-
diff --git a/gosa-core/plugins/personal/mail/generic.tpl b/gosa-core/plugins/personal/mail/generic.tpl deleted file mode 100644 index 2c2d7305a..000000000 --- a/gosa-core/plugins/personal/mail/generic.tpl +++ /dev/null @@ -1,339 +0,0 @@ - - - - -{if !$multiple_support} - - - - -{/if} - - -
- -

 {t}Generic{/t}

- - - - - - - - - -{if !$multiple_support} - - - - -{/if} - - - - -
{$must} -{if $multiple_support} - -{else} -{render acl=$mailACL} - -{/render} -{/if} -
-{render acl=$gosaMailServerACL checkbox=$multiple_support checked=$use_gosaMailServer} - -{/render} -
-
- {t}Quota usage{/t} -
-
- {if $quotadefined eq "true"} - {$quotausage} - {else} - {t}not defined{/t} - {/if} -
-{render acl=$gosaMailQuotaACL checkbox=$multiple_support checked=$use_gosaMailQuota} - MB -{/render} -
-
-   - -

-{render acl=$gosaMailAlternateAddressACL} - -
-{render acl=$gosaMailAlternateAddressACL} - -{/render} -{render acl=$gosaMailAlternateAddressACL} - -{/render} -{render acl=$gosaMailAlternateAddressACL} - -{/render} -
- -{if $multiple_support} - -

 

-

 {t}Mail options{/t}

- -{else} - - -

 

- - - - - - - -
-{render acl=$gosaMailDeliveryModeCACL} - {t}Use custom sieve script{/t} ({t}disables all Mail options!{/t}) -{/render} -
-{render acl=$sieveManagementACL} - -{/render} -
- -

 

-{/if} - - - - - - - - - - -
-{render acl=$gosaMailDeliveryModeIACL checkbox=$multiple_support checked=$use_drop_own_mails} - {t}No delivery to own mailbox{/t} -{/render} - -
-{render acl=$gosaMailDeliveryModeVACL checkbox=$multiple_support checked=$use_use_vacation} - {t}Activate vacation message{/t} -{/render} - -
- - - - - - - - - - -
- {t}from{/t} - -{render acl=$gosaVacationMessageACL} - -{/render} -{render acl=$gosaVacationMessageACL} - -{/render} -{render acl=$gosaVacationMessageACL} - -{/render} - -
- {t}till{/t} - -{render acl=$gosaVacationMessageACL} - -{/render} -{render acl=$gosaVacationMessageACL} - -{/render} -{render acl=$gosaVacationMessageACL} - -{/render} - -
- - -
-   - -{render acl=$gosaMailDeliveryModeSACL checkbox=$multiple_support checked=$use_use_spam_filter} - -{/render} - - -{render acl=$gosaSpamSortLevelACL checkbox=$multiple_support checked=$use_gosaSpamSortLevel} - -{/render} - -{render acl=$gosaSpamMailboxACL checkbox=$multiple_support checked=$use_gosaSpamMailbox} - -{/render} -
-{render acl=$gosaMailDeliveryModeRACL checkbox=$multiple_support checked=$use_use_mailsize_limit} - -{/render} - -{render acl=$gosaMailMaxSizeACL checkbox=$multiple_support checked=$use_gosaMailMaxSize} - {t}MB{/t} -{/render} -
-

- -

-{render acl=$gosaVacationMessageACL checkbox=$multiple_support checked=$use_gosaVacationMessage} - -{/render} -
- - {if $show_templates eq "true"} -{render acl=$gosaVacationMessageACL} - -{/render} -{render acl=$gosaVacationMessageACL} - -{/render} - {/if} -
-

- -

- -{if $multiple_support} - -{/if} - -{render acl=$gosaMailForwardingAddressACL} - -{/render} -
-{render acl=$gosaMailForwardingAddressACL} - -{/render} -{render acl=$gosaMailForwardingAddressACL} -   -{/render} -{render acl=$gosaMailForwardingAddressACL} -   -{/render} -{render acl=$gosaMailForwardingAddressACL} - -{/render} -
-

 

- -

 {t}Advanced mail options{/t}

- - - - - -
-{render acl=$gosaMailDeliveryModeLACL checkbox=$multiple_support checked=$use_only_local} - -{/render} - {t}User is only allowed to send and receive local mails{/t} -
- - - - - diff --git a/gosa-core/plugins/personal/mail/mail_locals.tpl b/gosa-core/plugins/personal/mail/mail_locals.tpl deleted file mode 100644 index d277ceb45..000000000 --- a/gosa-core/plugins/personal/mail/mail_locals.tpl +++ /dev/null @@ -1,81 +0,0 @@ - - - - - -
-
-

- - - {$hint} - -
-

-
-
-

- -

-
-
-
-

- [F] - {t}Filters{/t} -

-
-
- - {$alphabet} -
- - - - -
- -   - -
- - - - - - -
- - - -
- - - - - - -
- {t}Display addresses of user{/t} - - -
- {$apply} -
-
- -

- -   - -

- diff --git a/gosa-core/plugins/personal/mail/main.inc b/gosa-core/plugins/personal/mail/main.inc deleted file mode 100644 index 7a5516e26..000000000 --- a/gosa-core/plugins/personal/mail/main.inc +++ /dev/null @@ -1,131 +0,0 @@ -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.= "

"; - - /* Are we in edit mode? */ - if (session::is_set('edit')){ - $display.= "\n"; - $display.= " "; - $display.= "\n"; - $info= "\"\" ".$ui->dn." "; - } else { - $info= "\"\" ".$ui->dn." "; - - $info.= "\"\" "._("Click the 'Edit' button below to change informations in this dialog"); - - if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/mailAccount"))){ - $display.= "\n"; - } - - $display.= "\n"; - } - $display.= "

\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 deleted file mode 100644 index 8ac4db68a..000000000 --- a/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 deleted file mode 100644 index 5222282e5..000000000 --- a/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 deleted file mode 100644 index de639c26c..000000000 --- a/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 deleted file mode 100644 index 63392d011..000000000 --- a/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 deleted file mode 100644 index 3aed3a916..000000000 --- a/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 new file mode 100644 index 000000000..fd890dfa4 --- /dev/null +++ b/gosa-plugins/mail/addons/mailqueue/class_mailqueue.inc @@ -0,0 +1,417 @@ +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"; + foreach(split("\n",$str) as $line){ + $line = trim($line); + if(empty($line)) { + continue; + } + $this->disp_header .= "\n"; + $tmp0 = preg_replace("/:.*$/","",$line); + $tmp1 = preg_replace("/^.*:/","",$line); + $this->disp_header .= "\n"; + $this->disp_header .= "\n"; + } + $this->disp_header .= "\n
".$tmp0."".$tmp1."
"; + } + } + } + } + } + + + /* 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",""._("up").""); + }else{ + $smarty->assign("SortType",""._("down").""); + } + } + } + + /* 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 new file mode 100644 index 000000000..b510cb3a7 --- /dev/null +++ b/gosa-plugins/mail/addons/mailqueue/class_parseMailQueue.inc @@ -0,0 +1,237 @@ +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 new file mode 100644 index 000000000..139bcd481 --- /dev/null +++ b/gosa-plugins/mail/addons/mailqueue/contents.tpl @@ -0,0 +1,130 @@ +
 
+
+

[F]Filter

+
+
+
+ + + + + +
+ {t}Search{/t} +  {t}Search for{/t} + +  in + + {t}with status{/t} : + +  {t}within the last{/t}  + +   + +   + + + + +
+
+
+
+ + +{if $all_ok != "true"} +{t}Search returned no results{/t}... +{else} + + + + + + + + + + + + + +{counter start=0 assign=i start=1} +{foreach from=$entries item=val key=key} + + {if ($i%2)== 0 } + + {else} + + {/if} + + + + + + + + + + {counter} +{/foreach} +
{t}ID{/t} {if $OrderBy == "MailID"} {$SortType}{/if}{t}Server{/t} {if $OrderBy == "Server"} {$SortType}{/if}{t}Size{/t} {if $OrderBy == "Size"} {$SortType}{/if}{t}Arrival{/t} {if $OrderBy == "Arrival"} {$SortType}{/if}{t}Sender{/t} {if $OrderBy == "Sender"} {$SortType}{/if}{t}Recipient{/t} {if $OrderBy == "Recipient"}{$SortType}{/if}{t}Error{/t} {if $OrderBy == "Error"} {$SortType}{/if} 
+ + {if $entries[$key].Active == true} + {t}Active{/t} + {/if} + + {$entries[$key].MailID} + + {$entries[$key].Server} + {$entries[$key].Size} + {$entries[$key].Arrival} + {$entries[$key].Sender} + {$entries[$key].Recipient}{$entries[$key].Error} + + {t}delete{/t} + + {if $entries[$key].Hold == true} + + {t}unhold{/t} + + {else} + + {t}hold{/t} + + {/if} + + {t}requeue{/t} + + + {t}header{/t} + +
+ + + + + +
{$range_selector}
+

 

+ +{/if} + + diff --git a/gosa-plugins/mail/addons/mailqueue/header.tpl b/gosa-plugins/mail/addons/mailqueue/header.tpl new file mode 100644 index 000000000..eeb8bcfbc --- /dev/null +++ b/gosa-plugins/mail/addons/mailqueue/header.tpl @@ -0,0 +1,6 @@ +{$header} + +

 

+
+ +
diff --git a/gosa-plugins/mail/addons/mailqueue/main.inc b/gosa-plugins/mail/addons/mailqueue/main.inc new file mode 100644 index 000000000..2e0f274d0 --- /dev/null +++ b/gosa-plugins/mail/addons/mailqueue/main.inc @@ -0,0 +1,48 @@ +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.= "\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 new file mode 100644 index 000000000..9180cfa54 --- /dev/null +++ b/gosa-plugins/mail/admin/systems/services/mail/class_goMailServer.inc @@ -0,0 +1,725 @@ + "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.= " "; + }else{ + $img.= ""; + } + if(($key+1) < count($this->postfixTransportTable) && $this->acl_is_writeable("postfixTransportTable")){ + $img.= " "; + }else{ + $img.= ""; + } + + if($this->acl_is_writeable("postfixTransportTable")){ + $img.= " "; + } + $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.= " "; + }else{ + $img.= ""; + } + if(($key+1) < count($this->postfixSenderRestrictions) && $this->acl_is_writeable("postfixSenderRestrictions")){ + $img.= " "; + }else{ + $img.= ""; + } + + if($this->acl_is_writeable("postfixSenderRestrictions")){ + $img.= " "; + } + + $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.= " "; + }else{ + $img.= ""; + } + if(($key+1) < count($this->postfixRecipientRestrictions) && $this->acl_is_writeable("postfixRecipientRestrictions")){ + $img.= " "; + }else{ + $img.= ""; + } + + if($this->acl_is_writeable("postfixRecipientRestrictions")){ + $img.= " "; + } + $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 new file mode 100644 index 000000000..a17d08f04 --- /dev/null +++ b/gosa-plugins/mail/admin/systems/services/mail/goMailServer.tpl @@ -0,0 +1,225 @@ +

{t}Generic{/t}

+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
{t}Visible full qualified hostname{/t} + +{render acl=$postfixMyhostnameACL} + +{/render} +
{t}Max mail header size{/t} + +{render acl=$postfixMyhostnameACL} +  {t}KB{/t} +{/render} +
{t}Max mailbox size{/t} + +{render acl=$postfixMailboxSizeLimitACL} +  {t}KB{/t} +{/render}
{t}Max message size{/t} + +{render acl=$postfixMessageSizeLimitACL} +  {t}KB{/t} +{/render} +
{t}Relay host{/t} + +{render acl=$postfixRelayhostACL} + +{/render} +
+
+ + + + +
+ {t}Local networks{/t}
+{render acl=$postfixMyNetworksACL} + +{/render} +{render acl=$postfixMyNetworksACL} + +{/render} +{render acl=$postfixMyNetworksACL} + +{/render} +{render acl=$postfixMyNetworksACL} + +{/render} +
+
+

 

+

{t}Domains and routing{/t}

+
+ + + + +
+ {t}Domains to accept mail for{/t}
+{render acl=$postfixMyDestinationsACL} + +{render acl=$postfixMyDestinationsACL} + +{/render} +{render acl=$postfixMyDestinationsACL} + +{/render} +{render acl=$postfixMyDestinationsACL} + +{/render} +
+
+ + + + +
+ {t}Transports{/t}
+{render acl=$postfixTransportTableACL} + {$Div_postfixTransportTable} +{/render} + +{render acl=$postfixTransportTableACL} + +{/render} +{render acl=$postfixTransportTableACL} + +{/render} +{render acl=$postfixTransportTableACL} + +{/render} +{render acl=$postfixTransportTableACL} + +{/render} +
+
+

 

+

{t}Restrictions{/t}

+
+ + + + +
+ {t}Restrictions for sender{/t}
+{render acl=$postfixSenderRestrictionsACL} + {$Div_postfixSenderRestrictions} +{/render} +{render acl=$postfixSenderRestrictionsACL} + +{/render} +{render acl=$postfixSenderRestrictionsACL} + +{/render} +{render acl=$postfixSenderRestrictionsACL} + +{/render} +{render acl=$postfixSenderRestrictionsACL} + +{/render} +
+
+ + + + +
+ {t}Restrictions for recipient{/t}
+{render acl=$postfixRecipientRestrictionsACL} + {$Div_postfixRecipientRestrictions} +{/render} +{render acl=$postfixRecipientRestrictionsACL} + +{/render} +{render acl=$postfixRecipientRestrictionsACL} + +{/render} +{render acl=$postfixRecipientRestrictionsACL} + +{/render} +{render acl=$postfixRecipientRestrictionsACL} + +{/render} +
+
+ +

 

+
+

Action

+{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} +
+ + + +

 

+
+ +   + +

+ diff --git a/gosa-plugins/mail/personal/mail/class_mail-methods-cyrus.inc b/gosa-plugins/mail/personal/mail/class_mail-methods-cyrus.inc new file mode 100644 index 000000000..388a5a715 --- /dev/null +++ b/gosa-plugins/mail/personal/mail/class_mail-methods-cyrus.inc @@ -0,0 +1,366 @@ +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"), '

'.imap_last_error().''), 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"), '

'.imap_last_error().''), 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'), '

'.imap_last_error().''), 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"), '

'.to_string($sieve->error_raw).''), 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"), '

'.to_string($sieve->error_raw).''), 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"), '

'.to_string($sieve->error_raw).''), ERROR_DIALOG); + return; + } + if(!$sieve->sieve_setactivescript("gosa")){ + msg_dialog::display(_("SIEVE error"), sprintf(_("Cannot activate SIEVE script: %s"), '

'.to_string($sieve->error_raw).''), 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 new file mode 100644 index 000000000..dc75674c2 --- /dev/null +++ b/gosa-plugins/mail/personal/mail/class_mail-methods-golab.inc @@ -0,0 +1,261 @@ + "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 new file mode 100644 index 000000000..c0606046b --- /dev/null +++ b/gosa-plugins/mail/personal/mail/class_mail-methods-kolab.inc @@ -0,0 +1,267 @@ + "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 new file mode 100644 index 000000000..8bb8d73be --- /dev/null +++ b/gosa-plugins/mail/personal/mail/class_mail-methods-sendmail-cyrus.inc @@ -0,0 +1,52 @@ +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 new file mode 100644 index 000000000..1874648a9 --- /dev/null +++ b/gosa-plugins/mail/personal/mail/class_mail-methods.inc @@ -0,0 +1,90 @@ + 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 new file mode 100644 index 000000000..5a0356566 --- /dev/null +++ b/gosa-plugins/mail/personal/mail/class_mailAccount.inc @@ -0,0 +1,1386 @@ + + \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= "\"\" ". + _("This account has no mail extensions.").""; + + $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 new file mode 100644 index 000000000..56ec107ff --- /dev/null +++ b/gosa-plugins/mail/personal/mail/copypaste.tpl @@ -0,0 +1,70 @@ +

{t}Mail settings{/t}

+ + + + + + + + + +
+ + + + + + + + +
{$must}
+

+ +

+
+
+ + + + +
+

+ + +

+
+
+ + + + +
+ +
+ +   +   + +
+
+ + + + +
+ +
+ + + +
+
+
+
diff --git a/gosa-plugins/mail/personal/mail/generic.tpl b/gosa-plugins/mail/personal/mail/generic.tpl new file mode 100644 index 000000000..2c2d7305a --- /dev/null +++ b/gosa-plugins/mail/personal/mail/generic.tpl @@ -0,0 +1,339 @@ + + + + +{if !$multiple_support} + + + + +{/if} + + +
+ +

 {t}Generic{/t}

+ + + + + + + + + +{if !$multiple_support} + + + + +{/if} + + + + +
{$must} +{if $multiple_support} + +{else} +{render acl=$mailACL} + +{/render} +{/if} +
+{render acl=$gosaMailServerACL checkbox=$multiple_support checked=$use_gosaMailServer} + +{/render} +
+
+ {t}Quota usage{/t} +
+
+ {if $quotadefined eq "true"} + {$quotausage} + {else} + {t}not defined{/t} + {/if} +
+{render acl=$gosaMailQuotaACL checkbox=$multiple_support checked=$use_gosaMailQuota} + MB +{/render} +
+
+   + +

+{render acl=$gosaMailAlternateAddressACL} + +
+{render acl=$gosaMailAlternateAddressACL} + +{/render} +{render acl=$gosaMailAlternateAddressACL} + +{/render} +{render acl=$gosaMailAlternateAddressACL} + +{/render} +
+ +{if $multiple_support} + +

 

+

 {t}Mail options{/t}

+ +{else} + + +

 

+ + + + + + + +
+{render acl=$gosaMailDeliveryModeCACL} + {t}Use custom sieve script{/t} ({t}disables all Mail options!{/t}) +{/render} +
+{render acl=$sieveManagementACL} + +{/render} +
+ +

 

+{/if} + + + + + + + + + + +
+{render acl=$gosaMailDeliveryModeIACL checkbox=$multiple_support checked=$use_drop_own_mails} + {t}No delivery to own mailbox{/t} +{/render} + +
+{render acl=$gosaMailDeliveryModeVACL checkbox=$multiple_support checked=$use_use_vacation} + {t}Activate vacation message{/t} +{/render} + +
+ + + + + + + + + + +
+ {t}from{/t} + +{render acl=$gosaVacationMessageACL} + +{/render} +{render acl=$gosaVacationMessageACL} + +{/render} +{render acl=$gosaVacationMessageACL} + +{/render} + +
+ {t}till{/t} + +{render acl=$gosaVacationMessageACL} + +{/render} +{render acl=$gosaVacationMessageACL} + +{/render} +{render acl=$gosaVacationMessageACL} + +{/render} + +
+ + +
+   + +{render acl=$gosaMailDeliveryModeSACL checkbox=$multiple_support checked=$use_use_spam_filter} + +{/render} + + +{render acl=$gosaSpamSortLevelACL checkbox=$multiple_support checked=$use_gosaSpamSortLevel} + +{/render} + +{render acl=$gosaSpamMailboxACL checkbox=$multiple_support checked=$use_gosaSpamMailbox} + +{/render} +
+{render acl=$gosaMailDeliveryModeRACL checkbox=$multiple_support checked=$use_use_mailsize_limit} + +{/render} + +{render acl=$gosaMailMaxSizeACL checkbox=$multiple_support checked=$use_gosaMailMaxSize} + {t}MB{/t} +{/render} +
+

+ +

+{render acl=$gosaVacationMessageACL checkbox=$multiple_support checked=$use_gosaVacationMessage} + +{/render} +
+ + {if $show_templates eq "true"} +{render acl=$gosaVacationMessageACL} + +{/render} +{render acl=$gosaVacationMessageACL} + +{/render} + {/if} +
+

+ +

+ +{if $multiple_support} + +{/if} + +{render acl=$gosaMailForwardingAddressACL} + +{/render} +
+{render acl=$gosaMailForwardingAddressACL} + +{/render} +{render acl=$gosaMailForwardingAddressACL} +   +{/render} +{render acl=$gosaMailForwardingAddressACL} +   +{/render} +{render acl=$gosaMailForwardingAddressACL} + +{/render} +
+

 

+ +

 {t}Advanced mail options{/t}

+ + + + + +
+{render acl=$gosaMailDeliveryModeLACL checkbox=$multiple_support checked=$use_only_local} + +{/render} + {t}User is only allowed to send and receive local mails{/t} +
+ + + + + diff --git a/gosa-plugins/mail/personal/mail/mail_locals.tpl b/gosa-plugins/mail/personal/mail/mail_locals.tpl new file mode 100644 index 000000000..d277ceb45 --- /dev/null +++ b/gosa-plugins/mail/personal/mail/mail_locals.tpl @@ -0,0 +1,81 @@ + + + + + +
+
+

+ + + {$hint} + +
+

+
+
+

+ +

+
+
+
+

+ [F] + {t}Filters{/t} +

+
+
+ + {$alphabet} +
+ + + + +
+ +   + +
+ + + + + + +
+ + + +
+ + + + + + +
+ {t}Display addresses of user{/t} + + +
+ {$apply} +
+
+ +

+ +   + +

+ diff --git a/gosa-plugins/mail/personal/mail/main.inc b/gosa-plugins/mail/personal/mail/main.inc new file mode 100644 index 000000000..7a5516e26 --- /dev/null +++ b/gosa-plugins/mail/personal/mail/main.inc @@ -0,0 +1,131 @@ +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.= "

"; + + /* Are we in edit mode? */ + if (session::is_set('edit')){ + $display.= "\n"; + $display.= " "; + $display.= "\n"; + $info= "\"\" ".$ui->dn." "; + } else { + $info= "\"\" ".$ui->dn." "; + + $info.= "\"\" "._("Click the 'Edit' button below to change informations in this dialog"); + + if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/mailAccount"))){ + $display.= "\n"; + } + + $display.= "\n"; + } + $display.= "

\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 new file mode 100644 index 000000000..8ac4db68a --- /dev/null +++ b/gosa-plugins/mail/personal/mail/sieve-discard.txt @@ -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 new file mode 100644 index 000000000..5222282e5 --- /dev/null +++ b/gosa-plugins/mail/personal/mail/sieve-header.txt @@ -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 new file mode 100644 index 000000000..de639c26c --- /dev/null +++ b/gosa-plugins/mail/personal/mail/sieve-mailsize.txt @@ -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 new file mode 100644 index 000000000..63392d011 --- /dev/null +++ b/gosa-plugins/mail/personal/mail/sieve-spam.txt @@ -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 new file mode 100644 index 000000000..3aed3a916 --- /dev/null +++ b/gosa-plugins/mail/personal/mail/sieve-vacation.txt @@ -0,0 +1,4 @@ +# Vacation message +vacation :addresses [$addrlist] +"$vacmsg" ; +