summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 14fbcb6)
raw | patch | inline | side by side (parent: 14fbcb6)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 8 Dec 2008 14:05:34 +0000 (14:05 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 8 Dec 2008 14:05:34 +0000 (14:05 +0000) |
- It is completely untested
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13182 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13182 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-golab.inc b/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-golab.inc
index eba099944c74f5beb05a63972f0fd1bdbc057a03..10f96cfef639e5a6474defbc0b4ad3545f90d351 100644 (file)
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-class mailMethodGolab extends mailMethodCyrus
+class mailMethodGolab extends mailMethodKolab
{
- var $mbox= "-";
- var $config;
- var $gosaMailServer= "";
- var $uattrib= "mail";
- var $folder_prefix = "";
- var $user_prefix = "user/";
-
-
- var $attribute_map= array("gosaMailAlternateAddress" => "alias",
- "gosaMailQuota" => "cyrus-userquota",
- "gosaMailServer" => "kolabHomeServer");
-
- function mailMethodGolab(&$config)
- {
- /* Check if the mail account identification attribute
- is overridden in the configuration file
- */
- if ($config->get_cfg_value("mailAttribute") != ""){
- $new_uattrib= strtolower($config->get_cfg_value("mailAttribute"));
- if(in_array($new_uattrib,array("mail","uid"))){
- $this->uattrib = $new_uattrib;
- }else{
- trigger_error(sprintf("Unsupported 'mailAttribute' in gosa configuration specified, use 'mail' or 'uid', instead of '%s'.", $new_uattrib));
- }
- }
-
- $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)
+ public function fixAttributesOnStore()
{
- /* 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);
+ mailMethod::fixAttributesOnStore();
+ $this->build_account_id();
+ $this->parent->attrs['kolabDeleteFlag'] = array();
+ if($this->type == "group"){
+ $this->parent->attrs['gosaSharedFolderTarget'] = "kolab+".$this->parent->mail;
}
- return (TRUE);
}
-}
+}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
diff --git a/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-kolab.inc b/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-kolab.inc
index 101361a5e128c6da3d50eda11c7279b57e452870..0823fd0e68389c09d6c28399df2de16fe92f61db 100644 (file)
<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2004 Cajus Pollmeier
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
class mailMethodKolab extends mailMethodCyrus
{
- var $mbox= "-";
- var $config;
- var $gosaMailServer= "";
- var $uattrib= "mail";
- var $folder_prefix = "shared.";
- var $user_prefix = "user/";
+ /* Allow modification of account_ids for existing mail accounts */
+ protected $modifyableMail = FALSE;
- var $attribute_map= array("gosaMailAlternateAddress" => "alias",
- "gosaMailQuota" => "cyrus-userquota",
- "gosaMailServer" => "kolabHomeServer");
+ /* Enforces same value for 'mail' as used for 'cn' */
+ protected $mailEqualsCN = TRUE;
- function mailMethodKolab(&$config)
- {
- /* Check if the mail account identification attribute
- is overridden in the configuration file
- */
- if ($config->get_cfg_value("mailAttribute") != ""){
- $new_uattrib= strtolower($config->get_cfg_value("mailAttribute"));
- if(in_array($new_uattrib,array("mail","uid"))){
- $this->uattrib = $new_uattrib;
- }else{
- trigger_error(sprintf("Unsupported 'mailAttribute' in gosa configuration specified, use 'mail' or 'uid', instead of '%s'.", $new_uattrib));
- }
- }
+ /* Enabled mail domain selection. If enabled getMailDomains must the domain parts */
+ protected $enableDomainSelection= FALSE;
+ protected $enableQuota = TRUE;
+ protected $enableSieveManager = TRUE;
+ protected $enableVacationRange = TRUE;
+ protected $enableFolderTypes = TRUE;
- $this->config= $config->data['SERVERS']['IMAP'];
- }
+ protected $attributes = array(
+ "alias" => "gosaMailAlternateAddress",
+ "cyrus-userquota" => "gosaMailQuota",
+ "kolabHomeServer" => "gosaMailServer");
- function updateMailbox($folder)
- {
- }
+ protected $userObjectClasses = array("kolabInetOrgPerson");
+ protected $shareObjectClasses = array("kolabSharedFolder");
- function setQuota($folder, $gosaMailQuota)
+ public function fixAttributesOnStore()
{
- return (TRUE);
+ mailMethod::fixAttributesOnStore();
+ $this->build_account_id();
+ $this->parent->attrs['kolabDeleteFlag'] = array();
+ if($this->type == "group"){
+ $this->parent->attrs['gosaSharedFolderTarget'] = "kolab+shared.".$this->parent->mail;
+ }
}
- /* Get quota and divide it by 1024, because in gosa we display in MB
- but we get Kb */
- function getQuota($folder)
+ public function fixAttributesOnRemove()
{
- $result= array('quotaUsage' => '', 'gosaMailQuota' => '');
-
- /* Only use lower case folder names, if folder name is like "@domain.com" */
- if(preg_match("/@/",$folder)){
- $folder = strtolower($folder);
+ mailMethod::fixAttributesOnRemove();
+ foreach($this->attributes as $source => $dest){
+ $this->attrs[$dest] = array();
+ $this->attrs[$source] = array();
}
-
- 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);
+ if($this->type == "user"){
+ $ocs = $this->userObjectClasses;
+ }else{
+ $ocs = $this->shareObjectClasses;
+ }
+ $this->parent->attrs['objectClass'] = array_merge( $this->parent->attrs['objectClass'],$ocs);
+ $this->parent->attrs['objectClass'] = array_unique($this->parent->attrs['objectClass']);
+ $this->parent->attrs['gosaSharedFolderTarget'] =array();
+ $this->parent->attrs['kolabDeleteFlag'] = $this->parent->gosaMailServer;
+ if($this->folderTypesEnabled()){
+ $this->parent->attrs['kolabFolderType'] =array();
}
-
- error_reporting(E_ALL | E_STRICT);
-
- return ($result);
}
- function fixAttributesOnLoad(&$mailObject)
+ /* \brief Some method require special folder types, "kolab" for example.
+ !! Those values are dummy values, the base class doesn't use folder types;
+ @return Array Return folder types.
+ */
+ public function getAvailableFolderTypes()
{
- /* 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 = $this->folder_prefix.$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;
- }
- }
+ $ret = array();
+ $ret['CAT'][''] = _("Unspecified");
+ $ret['CAT']['mail']= _("Mails");
+ $ret['CAT']['task']= _("Tasks");
+ $ret['CAT']['journal']= _("Journals");
+ $ret['CAT']['calendar']= _("Calendar");
+ $ret['CAT']['contact']= _("Contacts");
+ $ret['CAT']['note']= _("Notes");
+
+ $ret['SUB_CAT'][''][''] = _("Unspecified");
+ $ret['SUB_CAT']['mail'][''] = _("Unspecified");
+ $ret['SUB_CAT']['mail']['inbox'] = _("Inbox");
+ $ret['SUB_CAT']['mail']['drafts'] = _("Drafts");
+ $ret['SUB_CAT']['mail']['sentitems'] = _("Sent items");
+ $ret['SUB_CAT']['mail']['junkemail'] = _("Junk mail");
+
+ $ret['SUB_CAT']['task']['defailt'] = _("Default");
+ $ret['SUB_CAT']['journal']['defailt'] = _("Default");
+ $ret['SUB_CAT']['calendar']['defailt'] = _("Default");
+ $ret['SUB_CAT']['contact']['defailt'] = _("Default");
+ $ret['SUB_CAT']['note']['defailt'] = _("Default");
+
+ return($ret);
}
- function fixAttributesOnStore(&$mailObject)
+ /* \brief Returns the selected folder type.
+ !! Those values are dummy values, the base class doesn't use folder types;
+ @return Array The folde type.
+ */
+ public function getFolderType($default)
{
- 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;
- }
+ if($this->enableFolderTypes && $this->parent->attrs['kolabFolderType'][0]){
+ list($cat,$sub) = split("\.",$this->parent->attrs['kolabFolderType'][0]);
+ return(array("CAT" => $cat, "SUB_CAT" => $sub));
+ }else{
+ return($default);
}
- $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";
- }
- }
- }
- /* 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 = $this->folder_prefix.$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
+ /* \brief Returns the selected folder type.
+ !! Those values are dummy values, the base class doesn't use folder types;
+ @return Array The folde type.
+ */
+ public function setFolderType($type)
+ {
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd ($this->parent->dn);
+ $ldap->modify(array("kolabFolderType" => $type['CAT'].".".$type['SUB_CAT']));
+ echo "Move me to KOLAB";
+ }
- /* Save shared folder target */
- $mailObject->attrs['gosaSharedFolderTarget']= "kolab+shared.".$mailObject->cn."@".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();
+ public function setQuota($number)
+ {
+ mailMethod::setQuota($number);
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>Skipped, part of kolabd!</b>",
+ "<b>Set account quota</b> on server '".$this->MailServer);
+ return(TRUE);
}
- function fixAttributesOnRemove(&$mailObject)
+ public function setFolderACLs($permissions)
{
- /* 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 = $this->folder_prefix.$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
-
- }
+ mailMethod::setFolderACLs($permissions);
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>Skipped, part of kolabd!</b>",
+ "<b>Setting folder ACLs!</b>","");
+ return(TRUE);
}
+ public function updateMailbox()
+ {
+ mailMethod::updateMailbox();
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>Skipped, part of kolabd!</b>",
+ "<b>Add/Update account</b> on server :".$this->MailServer);
+ return(TRUE);
+ }
- function deleteMailbox($folder)
+ public function deleteMailbox()
{
- /* 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);
+ mailMethod::deleteMailbox();
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "Skipped, part of kolabd!",
+ "<b>Setting Quota</b>");
+ return(TRUE);
}
}
+
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
diff --git a/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-kolab22.inc b/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-kolab22.inc
--- /dev/null
@@ -0,0 +1,155 @@
+<?php
+
+
+class mailMethodKolab22 extends mailMethodCyrus
+{
+
+ /* Allow modification of account_ids for existing mail accounts */
+ protected $modifyableMail = FALSE;
+
+ /* Enforces same value for 'mail' as used for 'cn' */
+ protected $mailEqualsCN = TRUE;
+
+ /* Enabled mail domain selection. If enabled getMailDomains must the domain parts */
+ protected $enableDomainSelection= TRUE;
+ protected $enableQuota = TRUE;
+ protected $enableSieveManager = TRUE;
+ protected $enableVacationRange = TRUE;
+ protected $enableFolderTypes = TRUE;
+
+ protected $attributes = array(
+ "alias" => "gosaMailAlternateAddress",
+ "cyrus-userquota" => "gosaMailQuota",
+ "kolabHomeServer" => "gosaMailServer");
+
+ protected $userObjectClasses = array("kolabInetOrgPerson");
+ protected $shareObjectClasses = array("kolabSharedFolder");
+
+ public function fixAttributesOnStore()
+ {
+ mailMethod::fixAttributesOnStore();
+ $this->build_account_id();
+ $this->parent->attrs['kolabDeleteFlag'] = array();
+ if($this->type == "group"){
+ $this->parent->attrs['gosaSharedFolderTarget'] = "kolab+shared.".$this->parent->mail;
+ }
+ }
+
+ public function fixAttributesOnRemove()
+ {
+ mailMethod::fixAttributesOnRemove();
+ foreach($this->attributes as $source => $dest){
+ $this->attrs[$dest] = array();
+ $this->attrs[$source] = array();
+ }
+ if($this->type == "user"){
+ $ocs = $this->userObjectClasses;
+ }else{
+ $ocs = $this->shareObjectClasses;
+ }
+ $this->parent->attrs['objectClass'] = array_merge( $this->parent->attrs['objectClass'],$ocs);
+ $this->parent->attrs['objectClass'] = array_unique($this->parent->attrs['objectClass']);
+ $this->parent->attrs['gosaSharedFolderTarget'] =array();
+ $this->parent->attrs['kolabDeleteFlag'] = $this->parent->gosaMailServer;
+ if($this->folderTypesEnabled()){
+ $this->parent->attrs['kolabFolderType'] =array();
+ }
+ }
+
+
+ /* \brief Some method require special folder types, "kolab" for example.
+ !! Those values are dummy values, the base class doesn't use folder types;
+ @return Array Return folder types.
+ */
+ public function getAvailableFolderTypes()
+ {
+ $ret = array();
+ $ret['CAT'][''] = _("Unspecified");
+ $ret['CAT']['mail']= _("Mails");
+ $ret['CAT']['task']= _("Tasks");
+ $ret['CAT']['journal']= _("Journals");
+ $ret['CAT']['calendar']= _("Calendar");
+ $ret['CAT']['contact']= _("Contacts");
+ $ret['CAT']['note']= _("Notes");
+
+ $ret['SUB_CAT'][''][''] = _("Unspecified");
+ $ret['SUB_CAT']['mail'][''] = _("Unspecified");
+ $ret['SUB_CAT']['mail']['inbox'] = _("Inbox");
+ $ret['SUB_CAT']['mail']['drafts'] = _("Drafts");
+ $ret['SUB_CAT']['mail']['sentitems'] = _("Sent items");
+ $ret['SUB_CAT']['mail']['junkemail'] = _("Junk mail");
+
+ $ret['SUB_CAT']['task']['defailt'] = _("Default");
+ $ret['SUB_CAT']['journal']['defailt'] = _("Default");
+ $ret['SUB_CAT']['calendar']['defailt'] = _("Default");
+ $ret['SUB_CAT']['contact']['defailt'] = _("Default");
+ $ret['SUB_CAT']['note']['defailt'] = _("Default");
+
+ return($ret);
+ }
+
+
+ /* \brief Returns the selected folder type.
+ !! Those values are dummy values, the base class doesn't use folder types;
+ @return Array The folde type.
+ */
+ public function getFolderType($default)
+ {
+ if($this->enableFolderTypes && $this->parent->attrs['kolabFolderType'][0]){
+ list($cat,$sub) = split("\.",$this->parent->attrs['kolabFolderType'][0]);
+ return(array("CAT" => $cat, "SUB_CAT" => $sub));
+ }else{
+ return($default);
+ }
+ }
+
+
+ /* \brief Returns the selected folder type.
+ !! Those values are dummy values, the base class doesn't use folder types;
+ @return Array The folde type.
+ */
+ public function setFolderType($type)
+ {
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd ($this->parent->dn);
+ $ldap->modify(array("kolabFolderType" => $type['CAT'].".".$type['SUB_CAT']));
+ echo "Move me to KOLAB";
+ }
+
+
+ public function setQuota($number)
+ {
+ mailMethod::setQuota($number);
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>Skipped, part of kolabd!</b>",
+ "<b>Set account quota</b> on server '".$this->MailServer);
+ return(TRUE);
+ }
+
+ public function setFolderACLs($permissions)
+ {
+ mailMethod::setFolderACLs($permissions);
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>Skipped, part of kolabd!</b>",
+ "<b>Setting folder ACLs!</b>","");
+ return(TRUE);
+ }
+
+ public function updateMailbox()
+ {
+ mailMethod::updateMailbox();
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>Skipped, part of kolabd!</b>",
+ "<b>Add/Update account</b> on server :".$this->MailServer);
+ return(TRUE);
+ }
+
+ public function deleteMailbox()
+ {
+ mailMethod::deleteMailbox();
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "Skipped, part of kolabd!",
+ "<b>Setting Quota</b>");
+ return(TRUE);
+ }
+}
+
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/mail/admin/groups/mail/class_groupMail.inc b/gosa-plugins/mail/admin/groups/mail/class_groupMail.inc
index 995703a5d4b698edfdf28ee79f494f18b60571e9..9a63d4e3a8c24ced399a218491e82e036950a32c 100644 (file)
class mailgroup extends plugin
{
- var $uid = ""; // User id
- var $cn = ""; // cn
- var $orig_cn = ""; // cn
+ /* Multiple edit */
+ var $gosaMailForwardingAddress_Some = array(); // Used in multiple edit
- var $method = "mailMethod"; // Used Mail method
- var $mmethod = ""; // Contains the gosa.conf MAILMETHOD
+ /* Default values */
var $mail = ""; // Default mail address
-
var $gosaMailAlternateAddress = array(); // Set default Alternate Mail Adresses to empty array
var $gosaMailForwardingAddress = array(); // Forwarding also empty
-
- var $gosaMailForwardingAddress_Some = array(); // Used in multiple edit
-
var $gosaMailServer = ""; // Selected mailserver
var $gosaMailQuota = ""; // Defined Quota
var $quotaUsage = 0; // Currently used quota
-
var $gosaVacationMessage = ""; // Vocation message
-
- var $imapacl = array('anyone' => 'p', // Set acls for everyone
- '%members%' => 'lrswp', // %members% are all group-members
- '' => 'p'); // Every user added gets this right
-
- var $kolabFolderTypeSubType = "";
- var $kolabFolderTypeType = "";
-
var $gosaSpamSortLevel = "";
var $gosaSpamMailbox = "";
var $gosaSharedFolderTarget ;
-
- var $forward_dialog = FALSE;
-
- var $members = array(); // Group members
-
- var $mailusers = array();
- var $perms = array();
var $gosaMailDeliveryMode = "[L ]"; //
var $gosaMailMaxSize = ""; //
-
- var $remove_folder_from_imap = true;
-
- /* Helper */
- var $indexed_acl= array();
- var $indexed_user= array();
+ var $FolderType = array("CAT" => '', "SUB_CAT" => '');
- var $view_logged = FALSE;
+ /* Internal */
+ var $AclTypes = array();
+ var $members = array(); // Group members
+ var $mailusers = array(); // Group member with mail account
+ var $folder_acls = array();
+ var $MailMethod = NULL;
+ var $forward_dialog = FALSE;
+ var $remove_folder_from_imap = true;
+ var $view_logged = FALSE;
+ var $mailDomainPart = "";
/* attribute list for save action */
var $attributes= array( "mail", "gosaMailServer", "gosaMailQuota", "gosaMailMaxSize",
"acl","gosaSharedFolderTarget", "gosaVacationMessage");
var $objectclasses= array("gosaMailAccount");
- var $CopyPasteVars = array("quotaUsage","imapacl");
-
var $multiple_support = TRUE;
-
-
- var $folder_prefix = "";
- var $user_prefix = "";
-
- var $account_name = "";
-
- function mailgroup (&$config, $dn= NULL, $ui= NULL)
+ function __construct (&$config, $dn= NULL, $ui= NULL)
{
- /* Initialise all available attributes ... if possible
- */
plugin::plugin($config, $dn);
- if (isset($this->attrs['cn'][0])){
- $this->uid = $this->cn = $this->attrs['cn'][0];
- }
- $this->orig_cn = $this->cn;
- /* Set mailMethod to the one defined in gosa.conf
+ /* Intialize the used mailMethod
*/
- if ($this->config->get_cfg_value("mailmethod")){
- $this->mmethod= $this->config->get_cfg_value("mailmethod");
- }
-
- /* Check if selected mail method exists
+ $tmp = new MailMethod_base($config,$this,"group");
+ $this->mailMethod = $tmp->get_method();
+ $this->mailDomainParts = $this->mailMethod->getMailDomains();
+ $this->AvailableFolderTypes = $this->mailMethod->getAvailableFolderTypes();
+ $this->AclTypes = $this->mailMethod->getAclTypes();
+ $this->MailBoxes = array();
+
+ /* Remember account status
*/
- $cls = get_correct_class_name("mailMethod$this->mmethod");
- if ($cls && class_exists($cls)){
- $this->method= $cls;
- } else {
- msg_dialog::display(_("Configuration error"), sprintf(_("Cannot locate mail method '%s'!"), $this->mmethod), ERROR_DIALOG);
- }
+ $this->initially_was_account = $this->is_account;
- /* Load Mailserver
+ /* Load folder_acls with defaults.
+ anyone -- The default acl, will be written to ldap.
+ member -- The ACL used for the members.
*/
- if(isset($this->attrs['gosaMailServer'][0])){
- $this->gosaMailServer = $this->attrs['gosaMailServer'][0];
- }
+ $this->folder_acls['__anyone__'] = "p";
+ $this->folder_acls['__member__'] = "lrswp";
- /* Get folder type */
- if(preg_match("/olab/i",$this->config->get_cfg_value("mailmethod"))){
- if(isset($this->attrs['kolabFolderType'])){
- $tmp = split("\.",$this->attrs['kolabFolderType'][0]);
- $this->kolabFolderTypeType = $tmp[0];
- $this->kolabFolderTypeSubType = $tmp[1];
+ /* Load acls
+ The most used acl will be used as member acl, this
+ shortens the listed acls.
+ This may be merged/overwritten by the mail methods.
+ */
+ $ldap = $this->config->get_ldap_link();
+ if(isset($this->attrs['acl'])){
+ for($i = 0; $i < $this->attrs['acl']['count'] ; $i++){
+ $str = trim($this->attrs['acl'][$i]);
+ $name = trim(preg_replace("/^([^\s]*).*$/","\\1",$str));
+ $acl = trim(preg_replace("/^[^\s]*+\s/","",$str));
+ if($name == "anyone") $name = "__anyone__";
+ $this->folder_acls[$name] = $acl;
}
}
- /* Create new instance of our defined mailclass
+ /* Initialize configured values
*/
- $method= new $this->method($this->config);
+ if($this->is_account){
+ if($this->mailMethod->connect() && $this->mailMethod->account_exists()){
+
+ /* Read quota */
+ $this->gosaMailQuota = $this->mailMethod->getQuota($this->gosaMailQuota);
+ if($this->mailMethod->is_error()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot read quota settings! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }
- $this->folder_prefix = $method->folder_prefix;
- $this->user_prefix = $method->user_prefix;
+ /* Read mailboxes */
+ $this->MailBoxes = $this->mailMethod->getMailboxList($this->MailBoxes);
+ if($this->mailMethod->is_error()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot get list of mailboxes! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }
- /* Build account name
- */
- $uattrib = $method->uattrib;
+ /* Receive folder types */
+ $this->FolderType = $this->mailMethod->getFolderType($this->FolderType);
+ if($this->mailMethod->is_error()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Could not receive folder types! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }
- /* Map uid to cn, because we are in a group currently */
- if($uattrib == "uid") $uattrib ="cn";
-
- if (isset($this->attrs[$uattrib][0])){
-
- $this->account_name= $this->attrs[$uattrib][0];
- if(preg_match("/@/",$this->account_name)){
- $cn = "";
- if(isset($this->attrs['cn'][0])){
- $cn = $this->attrs['cn'][0];
+ /* Receive permissions */
+ $this->folder_acls = $this->mailMethod->getFolderACLs($this->folder_acls);
+ if($this->mailMethod->is_error()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Could not receive folder permissions! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
}
- $this->account_name = preg_replace("/^[^@]*/",$cn,$this->account_name);
- }
- }
- /* If this isn't a new mailgroup, read all required data from ldap
- */
- if (($dn != "new")&&($dn !== NULL)){
+ }elseif(!$this->mailMethod->is_connected()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot connect mail method! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }elseif(!$this->mailMethod->account_exists()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Mailbox doesn't exists on mail server: %s."),
+ $this->gosaMailServer), ERROR_DIALOG);
+ }
- /* Load attributes which represent multiple entries
+ /* If the doamin part is selectable, we have to split the mail address
*/
+ if(!(!$this->mailMethod->isModifyableMail() && $this->is_account)){
+ if($this->mailMethod->domainSelectionEnabled() || $this->mailMethod->mailEqualsCN()){
+ $this->mailDomainPart = preg_replace("/^[^@]*+@/","",$this->mail);
+ $this->mail = preg_replace("/@.*$/","\\1",$this->mail);
+ if(!in_array($this->mailDomainPart,$this->mailDomainParts)){
+ $this->mailDomainParts[] = $this->mailDomainPart;
+ }
+ }
+ }
+
+ /* Load attributes containing arrays */
foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
- $this->$val = array();
+ $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])){
-
- if ($method->connect($this->attrs["gosaMailServer"][0])){
-
- /* If we do NOT use kolab or equal methods,
- read imap the acls from the mail method class.
- They will be merged later with the ldap specified acls.
- */
- if(!preg_match("/olab/i",$this->mmethod) && !empty($this->mmethod)){
- $this->imapacl= $method->getSharedFolderPermissions($this->folder_prefix.$this->account_name);
-
- /* Need to filter what a member acl could be... */
- $vote= array();
- $peak= 0;
- $leader= "";
- foreach ($this->imapacl as $user => $acl){
-
- if ($user != "anyone" ){
- if (!isset($vote[$acl])){
- $vote[$acl]= 1;
- } else {
- $vote[$acl]++;
- }
- if ($vote[$acl] > $peak){
- $leader= $acl;
- $peek= $vote[$acl];
- }
- }
- }
- /* Highest count wins as %members%, remove all members
- with the same acl */
- if(!empty($leader)){
- $this->imapacl['%members%']= $leader;
- }
- foreach ($this->imapacl as $user => $acl){
- if ($this->acl == $leader && in_array($user, $this->attrs['memberUid'])){
- unset($this->imapacl[$user]);
- }
- }
- }
-
- /* Adapt attributes if needed */
- $method->fixAttributesOnLoad($this);
-
- /* get Quota */
- $quota= $method->getQuota($this->folder_prefix.$this->account_name);
-
- /* Update quota values */
- if(is_array($quota)){
- if ($quota['gosaMailQuota'] == 2147483647){
- $this->quotaUsage= "";
- $this->gosaMailQuota= "";
- } else {
- $this->quotaUsage= $quota['quotaUsage'];
- $this->gosaMailQuota= $quota['gosaMailQuota'];
- }
- }else{
- $this->quotaUsage = "";
- $this->gosaMailQuota = "";
- }
- $method->disconnect();
- } // ENDE $method->connect($this->attrs["gosaMailServer"][0])){
- } // ENDE gosaMailServer
- } // ENDE dn != "new"
+ /* Disconnect mailMethod. Connect on demand later.
+ */
+ $this->mailMethod->disconnect();
+ /* Summarize most used ACLs as member acl
+ */
+ if(count($this->folder_acls) > 2){
+ $acl_usage = array();
+ $most_acl = "";
+ $most_cnt = 0;
+ $member = $this->get_member();
+ foreach($this->folder_acls as $user => $acl){
+ if(!isset($acl_usage[$acl])) $acl_usage[$acl]=0;
+ $acl_usage[$acl] ++;
+ if($acl_usage[$acl] > $most_cnt){
+ $most_cnt = $acl_usage[$acl];
+ $most_acl = $acl;
+ }
+ }
+ $this->folder_acls['__member__'] = $most_acl;
+ foreach($this->folder_acls as $name => $acl){
+ if(preg_match("/^__/",$name)) continue;
+ if($acl == $most_acl && in_array($name,$member['mail'])){
+ unset($this->folder_acls[$name]);
+ }
+ }
+ }
/* Get global filter config */
if (!session::is_set("gmailfilter")){
"regex" => "*");
session::set("gmailfilter", $gmailfilter);
}
+ }
- /* Load permissions */
- $tmp = array();
+
+ /*! \brief Returns all group members once with 'dn' and once with 'mail'.
+ This function is used to summarize ACLs by member acls.
+ @return Array Containing all members, with mail and dn
+ */
+ function get_member()
+ {
+ $member = array('all' => array(), 'mail' => array());
$ldap = $this->config->get_ldap_link();
-
- /* Read acls from ldap and merge them with
- * acls read from mail method.
- */
- if (isset($this->attrs['acl'])){
-
- for ($i= 0; $i<$this->attrs['acl']['count']; $i++){
- list($user, $permission)= split(' ', $this->attrs['acl'][$i]);
-
- /* Add to list */
- $this->imapacl[$user]= $permission;
-
- /* Get all user permissions sorted by acl, to detect the most used acl
- This acl is then used for %members%
- */
- if ($user != "anyone" && $user != "%members%"){
- $tmp[$permission][] = $user;
- }
-
- /* There is an entry in $this->imapacl like this this ...
- $this->attrs['imapacl']['anyone'] = "p";
- $this->attrs['imapacl']['%members%'] = "lprs";
- $this->attrs['imapacl'][''] = ""; <------ This is used to diplay an empty
- Field for special acls in our template.
- If there is at least one special acl in out imapacl,
- we don't need this entry anymore, because it is already displayed.
- */
- if ($user != "anyone" && $user != "%members%"){
- unset($this->imapacl['']);
+ $ldap->cd($this->config->current['BASE']);
+ if(isset($this->parent->by_object['group'])){
+ foreach($this->parent->by_object['group']->memberUid as $uid){
+ $dn = $this->parent->by_object['group']->dnMapping[$uid];
+ $member['all'][$uid] = $uid;
+ if($ldap->object_match_filter($dn,"(&(objectClass=gosaMailAccount)(".$this->mailMethod->getUAttrib()."=*))")){
+ $ldap->cat($dn);
+ $attrs = $ldap->fetch();
+ $member['mail'][$uid] = $attrs[$this->mailMethod->getUAttrib()][0];
}
}
- }
-
- /**
- * Detect group members which use the same acl
- * as used for %members% and remove them.
- **/
-
- /* In this section we detect which acl is the most used.
- This will be used as %members% acl.
- */
- $tmp2 = array();
- foreach($tmp as $acl => $user){
- $tmp2[count($tmp[$acl])]=$acl;
- }
- /* Most used at last
- */
- ksort($tmp2);
-
- /* Assign last (most used acl) to %members% acl
- */
- $str = array_pop($tmp2);
- if(!empty($str)) {
- $this->imapacl['%members%']=$str;
- }
- if(!isset($this->imapacl['%members%'])){
- $this->imapacl['%members%'] = "lrspw";
- }
-
-
- /* Open ldap connection
- */
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
-
- /* Remove those users, that use %members% acl && are member of this group. */
- foreach($this->imapacl as $mail => $permission){
- $ldap->search("(&(objectClass=person)(|(mail=".$mail.")(uid=".$mail.")))",array("uid"));
- $atr = $ldap->fetch();
- if((isset($this->attrs['memberUid'])) && (is_array($this->attrs['memberUid']))){
- if((isset($atr['uid'][0]))&&(in_array($atr['uid'][0],$this->attrs['memberUid']))&&($permission == $this->imapacl['%members%'])){
- unset($this->imapacl[$mail]);
+ }else{
+ if(!isset($this->attrs['memberUid'])) return($member);
+ $uattrib = $this->mailMethod->getUAttrib();
+ $users = get_list("(&(objectClass=person)(objectClass=gosaAccount)(uid=*))",
+ "users",$this->config->current['BASE'],
+ array("uid","objectClass",$uattrib),GL_SUBSEARCH | GL_NO_ACL_CHECK);
+ foreach($users as $user){
+ $member['all'][$user['uid'][0]] = $user['dn'];
+ if(isset($user[$uattrib])
+ && in_array("gosaMailAccount",$user['objectClass'])
+ && (in_array($user['uid'][0], $this->attrs['memberUid']))){
+ $member['mail'][$user['uid'][0]] = $user[$uattrib][0];
}
}
}
-
- /**
- * ENDE: Detect group member with same acl and replace them with %members%
- **/
- $this->indexed_user = array("%members%","anyone");
-
- /* Append an empty entry, for special acl handling */
- if(count($this->imapacl)==2){
- $this->imapacl[''] ="lrsw";
- $this->indexed_user[] = '';
- }
-
- /* Load Mailserver
- */
- if(isset($this->attrs['gosaMailServer'][0])){
- $this->gosaMailServer = $this->attrs['gosaMailServer'][0];
- }
- /* Fill translations */
- $this->perms["lrsw"]= _("read");
- $this->perms["lrswp"]= _("post");
- $this->perms["p"]= _("external post");
- $this->perms["lrswip"]= _("append");
- $this->perms["lrswipcd"]= _("write");
- $this->perms["lrswipcda"]= _("admin");
- $this->perms[""]= _("none");
+ return($member);
}
-
function execute()
{
/* Call parent execute */
- //plugin::execute();
- $display = "";
+ plugin::execute();
/* Log view */
if($this->is_account && !$this->view_logged){
new log("view","groups/".get_class($this),$this->dn);
}
- /* Load templating engine */
- $smarty= get_smarty();
-
- /* Assign acls */
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation) {
- $smarty->assign($name."ACL",$this->getacl($name));
- }
-
- if (session::get('js')==FALSE){
- $smarty->assign("javascript", "false");
- } else {
- $smarty->assign("javascript", "true");
- }
+ $this->get_member();
+
+ /****************
+ Account status
+ ****************/
- /* Handle actions should not be done, when
- * editing multiple entries at once. e.g. account state
- */
if(!$this->multiple_support_active){
- /* Do we need to flip is_account state? */
if(isset($_POST['modify_state'])){
- if($this->is_account && $this->acl_is_removeable()){
+ if($this->is_account && $this->acl_is_removeable() && $this->mailMethod->accountRemoveAble()){
$this->is_account= FALSE;
- }elseif(!$this->is_account && $this->acl_is_createable()){
+ }elseif(!$this->is_account && $this->acl_is_createable() && $this->mailMethod->accountCreateable()){
$this->is_account= TRUE;
}
}
- $display = "";
-
- /* Do we represent a valid account? */
- if (!$this->is_account && $this->parent === NULL){
-
- $display.= "<img alt=\"\" src=\"images/small-error.png\" align=middle> <b>".msgPool::noValidExtension(_("mail"))."</b>";
- return ($display);
- }
-
- /* Show tab dialog headers */
- $display= "";
- if ($this->parent !== NULL){
- if ($this->is_account){
- $display.= $this->show_disable_header(_("Remove mail account"),
- msgPool::featuresEnabled(_("mail")));
- } else {
- $display.= $this->show_enable_header(_("Create mail account"),
- msgPool::featuresDisabled(_("mail")));
+ if ($this->is_account){
+ $reason = "";
+ if(!$this->mailMethod->accountRemoveable($reason)){
+ $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Mail")),$reason ,TRUE,TRUE);
+ }else{
+ $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Mail")),msgPool::
+ featuresEnabled(_("Mail")));
+ }
+ } else {
+ $reason = "";
+ if(!$this->mailMethod->accountCreateable($reason)){
+ $display= $this->show_disable_header(msgPool::addFeaturesButton(_("Mail")),$reason ,TRUE,TRUE);
+ }else{
+ $display= $this->show_disable_header(msgPool::addFeaturesButton(_("Mail")),msgPool::
+ featuresDisabled(_("Mail")));
/* Show checkbox that allows us to remove imap entry too*/
if($this->initially_was_account){
title='"._("Remove shared folder from mail server database when entry gets removed in LDAP")."'>";
$display .= _("Remove the shared folder and all its contents after saving this account");
}
- return ($display);
}
+ return ($display);
}
}
- /* Add ACL? */
- if($this->acl_is_writeable("acl")){
- foreach ($this->indexed_user as $nr => $user){
- if (isset($_POST["add_$nr"])){
- $this->imapacl[""]= "l";
- }
- if (isset($_POST["del_$nr"])){
- unset ($this->imapacl[$user]);
- }
- }
- }
- /* Trigger forward add dialog? */
- if($this->acl_is_writeable("gosaMailForwardingAddress")){
- if (isset($_POST['add_local_forwarder'])){
- $this->forward_dialog= TRUE;
- $this->dialog= TRUE;
- }
+ /****************
+ Forward addresses
+ ****************/
+ if (isset($_POST['add_local_forwarder'])){
+ $this->forward_dialog= TRUE;
+ $this->dialog= TRUE;
}
-
- /* Cancel forward add dialog? */
- if($this->acl_is_writeable("gosaMailForwardingAddress")){
- if (isset($_POST['add_locals_cancel'])){
- $this->forward_dialog= FALSE;
- $this->dialog= FALSE;
- }
+ if (isset($_POST['add_locals_cancel'])){
+ $this->forward_dialog= FALSE;
+ $this->dialog= FALSE;
}
-
- /* Finished adding of locals? */
- if ((isset($_POST['add_locals_finish'])) && ($this->acl_is_writeable("gosaMailForwardingAddress"))) {
- if (count ($_POST['local_list']) && $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);
+ if (isset($_POST['add_locals_finish'])){
+ if (isset($_POST['local_list'])){
+ if($this->acl_is_writeable("gosaMailForwardingAddress")){
+ 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;
+ } else {
+ msg_dialog::display(_("Error"), _("Please select an entry!"), ERROR_DIALOG);
}
- $this->forward_dialog= FALSE;
- $this->dialog= FALSE;
}
- /* Add forward email addresses */
- if ((isset($_POST['add_forwarder'])) && ($this->acl_is_writeable("gosaMailForwardingAddress"))){
+ if (isset($_POST['add_forwarder'])){
if ($_POST['forward_address'] != ""){
-
- /* Valid email address specified? */
$address= $_POST['forward_address'];
+ $valid= FALSE;
if (!tests::is_email($address)){
- msg_dialog::display(_("Error"), msgPool::invalid(_("forward address")), ERROR_DIALOG);
+ if (!tests::is_email($address, TRUE)){
+ if ($this->is_template){
+ $valid= TRUE;
+ } else {
+ msg_dialog::display(_("Error"), msgPool::invalid(_("Mail address"),
+ "","","your-address@your-domain.com"),ERROR_DIALOG);
+ }
+ }
} elseif ($address == $this->mail
|| in_array($address, $this->gosaMailAlternateAddress)) {
-
- msg_dialog::display(_("Error"), _("Cannot forward to users own mail address!"), ERROR_DIALOG);
-
+ msg_dialog::display(_("Error"),_("Cannot add primary address to the list of forwarders!") , ERROR_DIALOG);
} else {
-
- /* Add it */
- if ($this->acl_is_writeable("gosaMailForwardingAddress")){
+ $valid= TRUE;
+ }
+ if ($valid){
+ if($this->acl_is_writeable("gosaMailForwardingAddress")){
$this->addForwarder ($address);
+ $this->is_modified= TRUE;
}
-
}
}
}
-
- /* Delete forward email addresses */
- if (isset($_POST['delete_forwarder']) && ($this->acl_is_writeable("gosaMailForwardingAddress"))){
- if (count($_POST['forwarder_list'])&& $this->acl_is_writeable("gosaMailForwardingAddress")){
-
- $this->delForwarder ($_POST['forwarder_list']);
- }
+ if (isset($_POST['delete_forwarder'])){
+ $this->delForwarder ($_POST['forwarder_list']);
}
+ if ($this->forward_dialog){
+ return($this->display_forward_dialog());
+ }
- /* Add alternate email addresses */
- if (isset($_POST['add_alternate'])){
- if ($_POST['alternate_address'] != "" && $this->acl_is_writeable("gosaMailAlternateAddress")){
-
- if (!tests::is_email($_POST['alternate_address'])){
- msg_dialog::display(_("Error"),msgPool::invalid(_("Alternate address")), ERROR_DIALOG);
+
+ /****************
+ Alternate addresses
+ ****************/
- } elseif (($user= $this->addAlternate ($_POST['alternate_address'])) != ""){
- $ui= get_userinfo();
- if ($user != $ui->username){
- msg_dialog::display(_("Error"),msgPool::duplicated(_("Mail address")), ERROR_DIALOG);
+ 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"),msgPool::invalid(_("Mail address"),
+ "","","your-domain@your-domain.com"), ERROR_DIALOG);
+ } else {
+ $valid= TRUE;
}
+ } else {
+ msg_dialog::display(_("Error"),msgPool::invalid(_("Mail address"),
+ "","","your-domain@your-domain.com"), ERROR_DIALOG);
}
- }
- }
-
- /* Delete alternate email addresses */
- if($this->acl_is_writeable("gosaMailAlternateAddress")){
- if (isset($_POST['delete_alternate']) && isset ($_POST['alternates_list'])){
- if (count($_POST['alternates_list']) && $this->acl_is_writeable("gosaMailAlternateAddress")){
- $this->delAlternate ($_POST['alternates_list']);
- }
- }
- }
-
- /* Show forward add dialog */
- if ($this->forward_dialog){
- $ldap= $this->config->get_ldap_link();
-
- /* Save data */
- $gmailfilter= session::get("gmailfilter");
- foreach( array("depselect", "muser", "regex") as $type){
- if (isset($_POST[$type])){
- $gmailfilter[$type]= $_POST[$type];
- }
- }
- if (isset($_GET['search'])){
- $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
- if ($s == "**"){
- $s= "*";
- }
- $gmailfilter['regex']= $s;
- }
- session::set("gmailfilter", $gmailfilter);
-
- /* Get actual list */
- $mailusers= array ();
- if ($gmailfilter['regex'] != '*' && $gmailfilter['regex'] != ""){
- $regex= $gmailfilter['regex'];
- $filter= "(|(mail=$regex)(gosaMailAlternateAddress=$regex))";
} else {
- $filter= "";
+ $valid= TRUE;
}
- if ($gmailfilter['muser'] != ""){
- $user= $gmailfilter['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", $gmailfilter['depselect'],
- array("sn", "mail", "givenName"), GL_SUBSEARCH | GL_SIZELIMIT);
- $ldap->cd($gmailfilter['depselect']);
- $ldap->search ("(&(objectClass=gosaMailAccount)$filter)", array("sn", "mail", "givenName"));
- error_reporting (0);
- while ($attrs= $ldap->fetch()){
- if(preg_match('/%/', $attrs['mail'][0])){
- continue;
+ if ($valid && ($user= $this->addAlternate ($_POST['alternate_address'])) != ""){
+ $ui= get_userinfo();
+ if ($user != $ui->username){
+ msg_dialog::display(_("Error"), msgPool::duplicated(_("Mail address"))." ".
+ sprintf(_("Address is already in use by user '%s'."), $user), ERROR_DIALOG);
}
- $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/lists/search.png'));
- $smarty->assign("usearch_image", get_template_path('images/lists/search-user.png'));
- $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
- $smarty->assign("infoimage", get_template_path('images/info.png'));
- $smarty->assign("launchimage", get_template_path('images/lists/action.png'));
- $smarty->assign("mailusers", $mailusers);
- $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", $gmailfilter[$type]);
}
- $smarty->assign("hint", print_sizelimit_warning());
- $display.= $smarty->fetch (get_template_path('mail_locals.tpl', TRUE, dirname(__FILE__)));
- return ($display);
}
-
- /* Assemble normal permissions */
- if (isset($this->imapacl['anyone'])){
- $smarty->assign("default_permissions", $this->imapacl['anyone']);
- }
- $smarty->assign("member_permissions", "lrsp");
- if (isset($this->imapacl['%members%'])){
- $smarty->assign("member_permissions", $this->imapacl['%members%']);
+ if (isset($_POST['delete_alternate']) && isset($_POST['alternates_list'])){
+ $this->delAlternate ($_POST['alternates_list']);
}
- /* Assemble extra attributes */
- $perm= $this->getacl( "acl");
- $tmp= "";
- $nr= 0;
- $count= count($this->imapacl);
- $this->indexed_user= array();
- $this->indexed_acl= array();
- foreach($this->imapacl as $user => $acl){
- /* Add additional acl settings */
- if ($user != "anyone" && $user != "%members%"){
+ /****************
+ SMARTY- Assign smarty variables
+ ****************/
- $Dis = "";
- if(!preg_match("/w/",$perm)){
- $Dis = " disabled ";
- }
+ /* Load templating engine */
+ $smarty= get_smarty();
+ $smarty->assign("initially_was_account", $this->initially_was_account);
+ $smarty->assign("isModifyableMail", $this->mailMethod->isModifyableMail());
+ $smarty->assign("mailEqualsCN", $this->mailMethod->mailEqualsCN());
+ $smarty->assign("folder_acls" , $this->postable_acls());
+ $smarty->assign("AclTypes" , $this->AclTypes);
- /* Reset given Acls to ensure that nobody can read username and acls if not allwoed */
- if(!preg_match("/r/",$perm)){
- $user = "";
- $nr = "none";
- $key = "none";
- }
-
- $tmp.= "<tr>
- <td>
- <input name=\"user_$nr\" size=20 maxlength=60 value=\"$user\" ".$Dis.">
- </td>
- <td>
- <select size=\"1\" name=\"perm_$nr\" ".$Dis.">";
-
- /* Add acl options for this additional acl setting */
- if(preg_match("/r/",$perm)){
- foreach ($this->perms as $key => $value){
- if ($acl == $key){
- $tmp.= "<option value=\"$key\" selected>$value</option>";
- } else {
- $tmp.= "<option value=\"$key\">$value</option>";
- }
- }
- }
- $tmp.= "</select> ";
-
-
-
- if ($nr == $count - 1){
- if($this->acl_is_writeable("acl")){
- $tmp.= "<input type=submit value=\""._("Add")."\" ".
- "name=\"add_$nr\" >";
- }
- }
- if ($count > 3){
- if($this->acl_is_writeable("acl")){
- $tmp.= "<input type=submit value=\""._("Remove")."\" ".
- "name=\"del_$nr\" ></td></tr>";
- }
- }
- }
- $this->indexed_user[$nr]= $user;
- $this->indexed_acl[$nr++]= $acl;
- }
- $smarty->assign("plusattributes", $tmp);
-
- /* Show main page */
- $mailserver= array();
- $ui = get_userinfo();
- foreach ($this->config->data['SERVERS']['IMAP'] as $key => $val){
- if(!preg_match("/r/",$ui->get_category_permissions($val['server_dn'],"server"))) continue;
- $mailserver[]= $key;
+ $smarty->assign("quotaEnabled", $this->mailMethod->quotaEnabled());
+ $smarty->assign("gosaMailQuota",$this->gosaMailQuota);
+ if($this->mailMethod->is_connected()){
+ $smarty->assign("quotaUsage", $this->mailMethod->getQuotaUsage());
+ }else{
+ $smarty->assign("quotaUsage", _("Unknown"));
}
- /* Append currently selected server if we are not allowed to view it.
- */
- if(isset($this->config->data['SERVERS']['IMAP'][$this->gosaMailServer]) &&
- !in_array($this->gosaMailServer,$mailserver)){
- $mailserver[] = $this->gosaMailServer;
- }
+ $smarty->assign("MailDomains", $this->mailDomainParts);
+ $smarty->assign("MailDomain" , $this->mailDomainPart);
+ $smarty->assign("MailServers", $this->mailMethod->getMailServers());
+ $smarty->assign("allowSieveManagement", $this->mailMethod->allowSieveManagement());
- $smarty->assign("mailServers", $mailserver);
- foreach(array("gosaMailServer", "gosaMailQuota", "perms", "mail",
- "gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
- $smarty->assign("$val", $this->$val);
- }
+ $smarty->assign("domainSelectionEnabled", $this->mailMethod->domainSelectionEnabled());
+ $smarty->assign("folderTypesEnabled",$this->mailMethod->folderTypesEnabled());
+ $smarty->assign("AvailableFolderTypes", $this->AvailableFolderTypes);
+ $smarty->assign("FolderType", $this->FolderType);
+
if (is_numeric($this->gosaMailQuota) && $this->gosaMailQuota != 0){
if($this->acl_is_readable("gosaMailQuota")){
$smarty->assign("quotausage", progressbar(round(($this->quotaUsage * 100)/ $this->gosaMailQuota),100,15,true));
$smarty->assign("quotadefined", "false");
}
- if(preg_match("/olab/i",$this->config->get_cfg_value("mailmethod"))){
+ /* Assign acls */
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation) {
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+ foreach($this->attributes as $name){
+ $smarty->assign($name,$this->$name);
+ }
+
- $smarty->assign("kolab", TRUE);
- $smarty->assign("JS",session::get('js'));
- $smarty->assign("kolabFolderTypeTypes", array ( '' => _('Unspecified'), 'mail' => _('Mails'),
- 'task' => _('Tasks') , 'journal' => _('Journals'),
- 'calendar' => _('Calendar'), 'contact' => _('Contacts'),
- 'note' => _('Notes')));
- if($this->kolabFolderTypeType == "mail"){
- $smarty->assign("kolabFolderTypeSubTypes", array(
- '' => _('Unspecified'), 'inbox' => _("Inbox") ,
- 'drafts' => _("Drafts"), 'sentitems' => _("Sent items"),
- 'junkemail' => _("Junk mail")));
- }else{
- $smarty->assign("kolabFolderTypeSubTypes", array( 'default' => _("Default")));
- }
- $smarty->assign("kolabFolderTypeType", $this->kolabFolderTypeType);
- $smarty->assign("kolabFolderTypeSubType", $this->kolabFolderTypeSubType);
+
+ $smarty->assign("mailServers", $this->mailMethod->getMailServers());
+ if (preg_match("/I/", $this->gosaMailDeliveryMode)) {
+ $smarty->assign("only_local", "checked");
}else{
- $smarty->assign("kolab", FALSE);
+ $smarty->assign("only_local", "");
}
- /* Multiple support handling */
+
+ /******
+ Multi edit support
+ ******/
foreach($this->attributes as $attr){
if(in_array($attr,$this->multi_boxes)){
$smarty->assign("use_".$attr,TRUE);
$smarty->assign("Forward_all",$this->gosaMailForwardingAddress);
$smarty->assign("Forward_some",$this->gosaMailForwardingAddress_Some);
-
- if (preg_match("/I/", $this->gosaMailDeliveryMode)) {
- $smarty->assign("only_local", "checked");
- }else{
- $smarty->assign("only_local", "");
- }
-
$smarty->assign("multiple_support",$this->multiple_support_active);
+
$display.= $smarty->fetch (get_template_path('mail.tpl', TRUE, dirname(__FILE__)));
return ($display);
}
if(!$this->initially_was_account){
return;
}
-
- /* Added these ObjectClass and Attributes, because they were not
- removed correctly, only in case of kolab ...
- */
- if(preg_match("/olab/i",$this->config->get_cfg_value("mailmethod"))){
- $this->attributes[]="acl";
- $this->objectclasses[] = "kolabSharedFolder";
+
+ /* If domain part was selectable, contruct mail address */
+ if($this->mailMethod->domainSelectionEnabled() || $this->mailMethod->mailEqualsCN()){
+ $this->mail = $this->mail."@".$this->mailDomainPart;
}
- /* include global link_info */
- $ldap= $this->config->get_ldap_link();
- /* Remove and write to LDAP */
+ /* Remove GOsa attributes */
plugin::remove_from_parent();
/* Zero arrays */
- $this->attrs['gosaMailAlternateAddress']= array();
+ $this->attrs['gosaMailAlternateAddress'] = array();
$this->attrs['gosaMailForwardingAddress']= array();
$this->attrs['gosaSharedFolderTarget']= array();
- /* Connect to IMAP server for account deletion */
- if ($this->initially_was_account){
-
- $method= new $this->method($this->config);
- $method->fixAttributesOnRemove($this);
- if ($method->connect($this->gosaMailServer) && $this->remove_folder_from_imap){
+ $this->cleanup();
- /* Remove account from IMAP server */
- $method->deleteMailbox($this->folder_prefix.$this->account_name);
- $method->disconnect();
- }
- }
- /* Keep uid */
- unset ($this->attrs['uid']);
+ $this->mailMethod->fixAttributesOnRemove();
+ $ldap = $this->config->get_ldap_link();
$ldap->cd($this->dn);
$ldap->modify ($this->attrs);
if (!$ldap->success()){
msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
}
-
new log("remove","groups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+
+ /* Let the mailMethod remove this mailbox, e.g. from imap and
+ update shared folder membership, ACL may need to be updated.
+ */
+ if (!$this->is_template && $this->remove_folder_from_imap){
+
+ if(!$this->mailMethod->connect()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot connect mail method! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }else{
+ if(!$this->mailMethod->deleteMailbox()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot remove mailbox! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }
+ if(!$this->mailMethod->updateSharedFolder()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot update shared folder permissions! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }
+ }
+ }
+ $this->mailMethod->disconnect();
+
+
/* Optionally execute a command after we're done */
$this->handle_post_events("remove");
}
/* Save data to object */
function save_object()
{
-
- /* Add special kolab attributes */
- if(preg_match("/olab/i",$this->config->get_cfg_value("mailmethod"))){
- if(isset($_POST['kolabFolderTypeType']) && $this->acl_is_writeable("kolabFolderType")){
- $this->kolabFolderTypeType = get_post("kolabFolderTypeType");
- $this->kolabFolderTypeSubType = get_post("kolabFolderTypeSubType");
- }
- }
-
- /* Check if user wants to remove the shared folder from imap too */
+ /* Check if user wants to remove the shared folder from imap too
+ */
if($this->initially_was_account && !$this->is_account){
if(isset($_POST['remove_folder_from_imap'])){
$this->remove_folder_from_imap = true;
$this->remove_folder_from_imap = false;
}
}
+ if (isset($_POST['mailedit'])){
+
+ $mail = $this->mail;
+ plugin::save_object();
+
+ if(!$this->mailMethod->isModifyableMail() && $this->initially_was_account){
+ $this->mail = $mail;
+ }else{
+
+ if($this->mailMethod->mailEqualsCN()){
+ $this->mail = &$this->parent->by_object['group']->cn;
+ if(isset($_POST['MailDomain'])){
+ $this->mailDomainPart = get_post('MailDomain');
+ }
+ }
+
+ /* Get posted mail domain part, if necessary
+ */
+ if($this->mailMethod->domainSelectionEnabled() && isset($_POST['MailDomain'])){
+ if(in_array(get_post('MailDomain'), $this->mailDomainParts)){
+ $this->mailDomainPart = get_post('MailDomain');
+ }
+ }
+ }
+
+ /* Get folder type
+ */
+ if($this->mailMethod->folderTypesEnabled()){
+ if(isset($_POST['FolderTypeCAT'])){
+ $this->FolderType['CAT'] = get_post('FolderTypeCAT');
+ }
+ if(isset($_POST['FolderTypeSUB_CAT'])){
+ $this->FolderType['SUB_CAT'] = get_post('FolderTypeSUB_CAT');
+ }
+ }
+
+ /* Handle posted ACL changes.
+ Add/del member acls.
+ */
+ if(isset($_POST['mail_acls_posted'])){
+ $new_acls = array();
+ foreach(array("__anyone__","__member__") as $attr){
+ $pname = base64_encode($attr);
+ if(get_post('acl_value_'.$pname)){
+ $new_acls[$attr] = get_post('acl_value_'.$pname);
+ }else{
+ $new_acls[$attr] = $this->folder_acls[$attr];
+ }
+ }
+
+ foreach($this->folder_acls as $user => $acl){
+ $pname = base64_encode($user);
+ if($user == "__member__" || $user == "__anyone__") continue;
+ if(isset($_POST['remove_acl_user_'.$pname])){
+ }elseif(isset($_POST['acl_user_'.$pname])){
+ if($user != get_post('acl_user_'.$pname)){
+ $new_acls[get_post('acl_user_'.$pname)] = get_post('acl_value_'.$pname);
+ }else{
+ $new_acls[$user] = get_post('acl_value_'.$pname);
+ }
+ }else{
+ $new_acls[$user] = $acl;
+ }
+ }
+ if(isset($_POST['add_acl_user'])){
+ $new_acls[_('new')] = $this->folder_acls['__anyone__'];
+ }
+ $this->folder_acls = $new_acls;
+ }
+
+ /* Handle GOsa mail delivery flags.
+ */
/* Assemble mail delivery mode
The mode field in ldap consists of values between braces, this must
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 custom sieve script
-I: Only insider delivery */
- if (isset($_POST['mailedit'])){
-
- plugin::save_object();
-
+ L - Local delivery
+ R - Reject when exceeding mailsize limit
+ S - Use spam filter
+ V - Use vacation message
+ C - Use custom 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['drop_own_mails'])){
$tmp.="L";
$this->is_modified= TRUE;
}
$this->gosaMailDeliveryMode= $tmp;
-
- /* Collect data and re-assign it to the imapacl array */
- if ($this->acl_is_writeable("acl")){
- $this->imapacl= array();
- $this->imapacl['%members%']= $_POST['member_permissions'];
- $this->imapacl['anyone']= $_POST['default_permissions'];
- foreach ($this->indexed_user as $nr => $user){
- if (!isset($_POST["user_$nr"])){
- continue;
- }
- if ($_POST["user_$nr"] != $user ||
- $_POST["perm_$nr"] != $this->indexed_acl[$nr]){
- $this->is_modified= TRUE;
- }
- $this->imapacl[$_POST["user_$nr"]]= $_POST["perm_$nr"];
- }
- }
}
-
}
function save()
{
$ldap= $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
-
- /* Call parents save to prepare $this->attrs */
- plugin::save();
-
- /* Update sharefolder account name */
- if(isset($this->parent->by_object['group']->cn)) {
- $this->account_name = $this->parent->by_object['group']->cn;
- }
-
- /* Save arrays */
- $this->attrs['gosaMailAlternateAddress'] = $this->gosaMailAlternateAddress;
- $this->attrs['gosaMailForwardingAddress'] = $this->gosaMailForwardingAddress;
- $this->attrs['gosaSharedFolderTarget'] = "share+".$this->account_name;
- $this->attrs['acl']= array();
-
- /* Prepare Mail server attribute */
- if(preg_match("/olab/i",$this->mmethod)){
- if (empty($this->gosaMailServer)||is_array($this->gosaMailServer)){
- if(isset($this->attrs['gosaMailServer'][0])){
- $this->gosaMailServer = $this->attrs['gosaMailServer'][0];
- }
- }
- }
-
- /* Exchange '%member%' pseudo entry */
- $memberacl= $this->imapacl['%members%'];
- foreach ($this->members as $user){
- if (!isset($this->imapacl[$user])){
- $this->imapacl[$user]= $memberacl;
- }
- }
- /* Prepare kolab attributes to be written */
- if(preg_match("/olab/i",$this->mmethod)){
- if(!empty($this->kolabFolderTypeType)){
- $this->attrs['kolabFolderType'] = $this->kolabFolderTypeType.".".$this->kolabFolderTypeSubType;
- }else{
- $this->attrs['kolabFolderType'] = array();
- }
+ /* If domain part was selectable, contruct mail address */
+ if($this->mailMethod->domainSelectionEnabled() || $this->mailMethod->mailEqualsCN()){
+ $this->mail = $this->mail."@".$this->mailDomainPart;
}
- /* Get naming attribute for mail accounts */
- $tmp = new $this->method($this->config);
- $uattrib = $tmp->uattrib;
-
- /* Create ACL array
- What is done here.
-
- 1. Do not write acl entries for empty entries.
- 2. Check if given user is a valid GOsa user.
- - If he is one, check if he has a valid mail extension
- -If this is true, add the user to the ACL entry.
- -If this is NOT true, skip ACL entries for this user.
- - He is not a GOsa Account, so write the ACL. (Manually entered ACL)
- 3. In case of "olab" mail method, remove the entry from the $this->imapacl array
- because the kolab deamon will set the acls for us.
-
+ /* Enforce lowercase mail address and trim whitespaces
*/
- $acls_set_for = array();
- foreach ($this->imapacl as $user => $acl){
-
- /* Skip empty entries */
- if (empty($user) || $user == ""){
- unset($this->imapacl[$user]);
- }
-
- /* Skip placeholder */
- if (empty($user) || $user == "" || preg_match("/%members%/",$user)){
- continue;
- }
+ $this->mail = trim(strtolower($this->mail));
- /* Check if your is a real GOsa user
- * If user is a real GOsa user but do not have an email address - SKIP adding acls
- * If user is a real GOsa user with an email address - add acls
- */
- $ldap->search("(&(objectClass=person)(|(uid=".$user.")(mail=".$user.")))",array("mail","uid"));
- if($ldap->count()){
-
- /* Has the user a valid mail account? */
- $attrs = $ldap->fetch();
- if(isset($attrs['mail'][0])){
-
- $name = $attrs[$uattrib][0];
-
- /* Do not overwrite manually set ACLs with group member acls
- */
- if(!in_array($name,$acls_set_for)){
- $this->attrs['acl'][]= $name." ".$acl;
- }
- $acls_set_for[] = $name;
+ /* Create acls
+ */
+ $this->acl = array("anyone ".$this->folder_acls['__anyone__']);
+ $member = $this->get_member();
+ $new_folder_acls = array("anyone" => $this->folder_acls['__anyone__']);
+ foreach($member['mail'] as $uid => $mail){
+ $this->acl[] = $mail." ".$this->folder_acls['__member__'];
+ $new_folder_acls[$mail]=$this->folder_acls['__member__'];
+ }
+ foreach($this->folder_acls as $user => $acls){
+ if(preg_match("/^__/",$user)) continue;
+ $this->acl[] = $user." ".$acls;
+ $new_folder_acls[$user]=$acls;
+ }
+ $this->folder_acls = $new_folder_acls;
+ $this->acl = array_unique($this->acl);
+ /* Call parents save to prepare $this->attrs */
+ plugin::save();
- /* Do not write imap acl directly i nkolab mode, let the kolab deamon do this. */
- unset($this->imapacl[$user]);
- if(!preg_match("/olab/i",$this->mmethod)){
- $this->imapacl[$name] = $acl;
- }
-
- }else{
-
- /* User is a valid GOsa account, but he has no mail extension. Skip ACLs */
- unset($this->imapacl[$user]);
- }
- }else{
-
- /* Seems to be a manually a added acl
- * Write this acl.
- */
-
- /* Do not overwrite manually set ACLs with group member acls
- */
- if(!in_array($user,$acls_set_for)){
- $this->attrs['acl'][]= $user." ".$acl;
- $acls_set_for[] = $user;
- }
-
- /* In case of kolab methods, let the deamon add the imap acls */
- if(preg_match("/olab/i",$this->mmethod)){
- unset($this->imapacl[$user]);
- }
- }
- }
-
- /* Handle mail method actions, set acls, quota ...*/
- if ((!$this->is_template)&&(!empty($this->gosaMailServer))){
- $method= new $this->method($this->config);
- $method->fixAttributesOnStore($this);
- if (($method->connect($this->gosaMailServer))){
- $method->updateMailbox($this->folder_prefix.$this->account_name);
- $method->setQuota($this->folder_prefix.$this->account_name, $this->gosaMailQuota);
+ /* Save arrays */
+ $this->attrs['gosaMailAlternateAddress'] = $this->gosaMailAlternateAddress;
+ $this->attrs['gosaMailForwardingAddress']= $this->gosaMailForwardingAddress;
- /* Only write imap acls directly if we are not
- * using a kolab like mail method.
- */
- if(!preg_match("/olab/i",$this->mmethod)){
- $method->setSharedFolderPermissions($this->folder_prefix.$this->account_name, $this->imapacl);
- }
- $method->disconnect();
- }
- }
+ /* Map method attributes */
+ $this->mailMethod->fixAttributesOnStore();
/* Save data to LDAP */
$ldap->cd($this->dn);
new log("create","groups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
}
+ /* Do imap/sieve actions,
+ */
+ $this->mailMethod->connect();
+ if(!$this->mailMethod->is_connected()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot connect mail method! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }else{
+ if(!$this->mailMethod->updateMailbox()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot update mailbox! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }
+ if(!$this->mailMethod->setQuota($this->gosaMailQuota)){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot write quota settings! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }
+ /* Save Folder Types, if available
+ */
+ if($this->mailMethod->folderTypesEnabled()){
+ $this->mailMethod->setFolderType($this->FolderType);
+ }
+ if(!$this->mailMethod->setFolderACLs($this->folder_acls)){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot update shared folder permissions! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }
+ }
+ $this->mailMethod->disconnect();
/* Optionally execute a command after we're done */
if ($this->initially_was_account == $this->is_account){
/* 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(!$this->is_account) return array();
-
- //$message[] = $str;
-
- /* must: mail */
- if ($this->mail == ""){
- $message[]= msgPool::required(_("Mail address"));
- }
- if (!tests::is_email($this->mail)){
- $message[]= msgPool::invalid(_("Mail address"),"","",_("your-name@your-domain.com"));
+ if(empty($this->gosaMailServer)){
+ $message[]= msgPool::noserver(_("Mail"));
}
- $ldap->cd($this->config->current['BASE']);
- $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=".$this->mail.")(gosaMailAlternateAddress=".
- $this->mail."))(!(uid=".$this->orig_cn."))(!(cn=".$this->orig_cn.")))");
- if ($ldap->count() != 0){
- $message[]= msgPool::duplicated(_("Mail address"));
+
+ /* Mail address checks */
+ if(!(!$this->mailMethod->isModifyableMail() && $this->initially_was_account)){
+ $mail = $this->mail;
+ if($this->mailMethod->domainSelectionEnabled() || $this->mailMethod->mailEqualsCN()){
+ $mail.= "@".$this->mailDomainPart;
+ }
+ if (empty($mail)){
+ $message[]= msgPool::required(_("Primary address"));
+ }elseif (!tests::is_email($mail)){
+ $message[]= msgPool::invalid(_("Mail address"),"","","your-address@your-domain.com");
+ }
}
-
+
/* Check quota */
if ($this->gosaMailQuota != '' && $this->acl_is_writeable("gosaMailQuota")){
if (!is_numeric($this->gosaMailQuota)) {
$message[]= _("You need to set the maximum mail size in order to reject anything.");
}
- if(ord($this->imapacl['anyone'][0])==194){
- $message[] = _("Please choose valid permission settings. Default permission can't be emtpy.");
- }
-
if(empty($this->gosaMailServer)){
$message[] = msgPool::required(_("Mail server"));
}
}
}
- /* Add entry to forwarder list */
- function addForwarder($address)
- {
- $this->gosaMailForwardingAddress[]= $address;
- $this->gosaMailForwardingAddress= array_unique($this->gosaMailForwardingAddress);
-
- /* Update multiple edit values too */
- if($this->multiple_support_active){
- $this->gosaMailForwardingAddress_Some=
- array_remove_entries (array($address),$this->gosaMailForwardingAddress_Some);
- }
-
- sort ($this->gosaMailForwardingAddress);
- reset ($this->gosaMailForwardingAddress);
- $this->is_modified= TRUE;
- }
-
- /* Remove list of addresses from forwarder list */
- function delForwarder($addresses)
- {
- $this->gosaMailForwardingAddress= array_remove_entries ($addresses,
- $this->gosaMailForwardingAddress);
-
- /* Update multiple edit values too */
- if($this->multiple_support_active){
- $this->gosaMailForwardingAddress_Some = array_remove_entries ($addresses,
- $this->gosaMailForwardingAddress_Some);
- }
- $this->is_modified= TRUE;
- }
-
-
-
- function addAlternate($address)
- {
- $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)))");
-
- 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;
- }
-
- sort ($this->gosaMailAlternateAddress);
- reset ($this->gosaMailAlternateAddress);
- $this->is_modified= TRUE;
-
- return ("");
- }
-
-
- function delAlternate($addresses)
- {
- $this->gosaMailAlternateAddress= array_remove_entries ($addresses,
- $this->gosaMailAlternateAddress);
- $this->is_modified= TRUE;
- }
function make_name($attrs)
plugin::set_multi_edit_values($attrs);
$this->gosaMailForwardingAddress = $forward;
}
+
+
+ /*! \brief Displays a dialog that allows mail address selection.
+ */
+ function display_forward_dialog()
+ {
+ restore_error_handler();
+
+ $smarty = get_smarty();
+ $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"));
+ while ($attrs= $ldap->fetch()){
+ if(preg_match('/%/', $attrs['mail'][0])){
+ continue;
+ }
+ $name= $this->make_name($attrs);
+ $mailusers[$attrs['mail'][0]]= $name."<".
+ $attrs['mail'][0].">";
+ }
+ natcasesort ($mailusers);
+ reset ($mailusers);
+
+ /* Show dialog */
+ $smarty->assign("search_image", get_template_path('images/lists/search.png'));
+ $smarty->assign("usearch_image", get_template_path('images/lists/search-user.png'));
+ $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
+ $smarty->assign("infoimage", get_template_path('images/info.png'));
+ $smarty->assign("launchimage", get_template_path('images/lists/action.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);
+ }
+
+
+ /*! \brief Add given mail address to the list of forwarders.
+ */
+ function addForwarder($address)
+ {
+ if(empty($address)) continue;
+ $this->gosaMailForwardingAddress[]= $address;
+ $this->gosaMailForwardingAddress= array_unique($this->gosaMailForwardingAddress);
+
+ /* Update multiple edit values too */
+ if($this->multiple_support_active){
+ $this->gosaMailForwardingAddress_Some=
+ array_remove_entries (array($address),$this->gosaMailForwardingAddress_Some);
+ }
+
+ sort ($this->gosaMailForwardingAddress);
+ reset ($this->gosaMailForwardingAddress);
+ $this->is_modified= TRUE;
+ }
+
+
+ /*! \brief Removes the given mail address from the forwarders
+ */
+ function delForwarder($addresses)
+ {
+ if(empty($address)) continue;
+ $this->gosaMailForwardingAddress= array_remove_entries ($addresses,
+ $this->gosaMailForwardingAddress);
+
+ /* Update multiple edit values too */
+ if($this->multiple_support_active){
+ $this->gosaMailForwardingAddress_Some = array_remove_entries ($addresses,
+ $this->gosaMailForwardingAddress_Some);
+ }
+ $this->is_modified= TRUE;
+ }
+
+
+ /*! \brief 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(empty($address)) continue;
+ $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)))");
+
+ 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;
+ }
+
+ sort ($this->gosaMailAlternateAddress);
+ reset ($this->gosaMailAlternateAddress);
+ $this->is_modified= TRUE;
+
+ return ("");
+ }
+
+
+ /*! \brief Removes the given mail address from the alternate addresses
+ */
+ function delAlternate($addresses)
+ {
+ if(empty($address)) continue;
+ $this->gosaMailAlternateAddress= array_remove_entries ($addresses,
+ $this->gosaMailAlternateAddress);
+ $this->is_modified= TRUE;
+ }
+
+
+ function postable_acls()
+ {
+ $ret = array();
+ foreach($this->folder_acls as $name => $acl){
+ $ret[$name] = array("name" => $name,"acl" => $acl,"post_name" => base64_encode($name));
+ }
+ return($ret);
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
diff --git a/gosa-plugins/mail/admin/groups/mail/mail.tpl b/gosa-plugins/mail/admin/groups/mail/mail.tpl
index 2345794d41ce08747f2f98c27b71d9a63bb2b53a..30eb89f1614621df528ded670be6424bf18ec289 100644 (file)
-<input type="hidden" name="mailedit" value="1">
-<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=0 border=0>
-
- <!-- Headline container -->
+<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding="0" border="0">
<tr>
- <td style="width:50%; border-right:1px solid #A0A0A0; vertical-align:top">
- <h2><img class="center" alt="" align="middle" src="images/rightarrow.png"> {t}Generic{/t}</h2>
+ <td style="width:50%; vertical-align:top;">
+ <h2><img class="center" alt="" align="middle" src="images/rightarrow.png" /> {t}Generic{/t}</h2>
<table summary="">
<tr>
- <td><LABEL for="mail">{t}Primary address{/t}</LABEL>{$must}</td>
+ <td><label for="mail">{t}Primary address{/t}</label>{$must}</td>
<td>
-{if $multiple_support}
- <input id="dummy1" name="dummy1" size="25" maxlength="65"
- value="{t}Multiple edit{/t}" disabled>
-{else}
- {render acl=$mailACL}
- <input id="mail" name="mail" size="25" maxlength="65" value="{$mail}" title="{t}Primary mail address for this shared folder{/t}">
- {/render}
-{/if}
+ {if !$isModifyableMail && $initially_was_account}
+ <input disabled size=30 value="{$mail}">
+ {else}
+ {if $domainSelectionEnabled}
+ {render acl=$mailACL}
+ <input id="mail" name="mail" size=20 maxlength=65 value="{$mail}"
+ {if $mailEqualsCN} disabled {/if}
+ >
+ {/render}
+ @<select name='MailDomain'>
+ {html_options values=$MailDomains output=$MailDomains selected=$MailDomain}
+ </select>
+ {else}
+ {if $mailEqualsCN}
+ <input type='text' disabled name='dummy' value='{$mail}'>
+ @<input type='text' value="{$MailDomain}" name="MailDomain">
+ {else}
+ {render acl=$mailACL}
+ <input id="mail" name="mail" size=35 maxlength=65 value="{$mail}">
+ {/render}
+ {/if}
+ {/if}
+ {/if}
</td>
</tr>
<tr>
- <td><LABEL for="gosaMailServer">{t}Server{/t}</LABEL></td>
+ <td><label for="gosaMailServer">{t}Server{/t}</label></td>
<td>
-{render acl=$gosaMailServerACL checkbox=$multiple_support checked=$use_gosaMailServer}
- <select size="1" name="gosaMailServer" title="{t}Select mail server to place user on{/t}">
- {html_options values=$mailServers output=$mailServers selected=$gosaMailServer}
- <option disabled> </option>
+{render acl=$gosaMailServerACL}
+ <select size="1" id="gosaMailServer" name="gosaMailServer"
+ title="{t}Specify the mail server where the user will be hosted on{/t}">
+ {html_options values=$MailServers output=$MailServers selected=$gosaMailServer}
+ <option disabled> </option>
</select>
{/render}
</td>
</tr>
<tr>
- <td>
- <br>
- <LABEL for="gosaMailQuota"> {t}Quota usage{/t}</LABEL>
- </td>
- <td>
- <br>
-{if $quotadefined eq "true"}
- {$quotausage}
-{else}
- {t}not defined{/t}
-{/if}
+ <td>
</td>
</tr>
+{if $quotaEnabled}
<tr>
- <td>{t}Quota size{/t}</td>
+ <td>{t}Quota usage{/t}</td>
+ <td>{$quotaUsage}</td>
+ </tr>
+ <tr>
+ <td><label for="gosaMailQuota">{t}Quota size{/t}</label></td>
<td>
-{render acl=$gosaMailQuotaACL checkbox=$multiple_support checked=$use_gosaMailQuota}
- <input id="gosaMailQuota" name="gosaMailQuota" size="6" align=middle maxlength="30" value="{$gosaMailQuota}">
-{/render}
- {t}MB{/t}
- </td>
-</tr>
- {if $kolab}
+{render acl=$gosaMailQuotaACL}
+ <input id="gosaMailQuota" name="gosaMailQuota" size="6" align="middle" maxlength="60"
+ value="{$gosaMailQuota}"> MB
+ {/render}
+ </td>
+ </tr>
+{/if}
+
+{if $folderTypesEnabled && !$multiple_support}
<tr>
<td>
{t}Folder type{/t}
</td>
<td>
-
- {if $multiple_support}
- <input type='checkbox' name='use_kolabFolderType' id='use_kolabFolderType' class="center"
- {if $use_kolabFolderType} checked {/if}
- onClick="changeState('kolabFolderTypeType');changeState('kolabFolderTypeSubType');"
- >
- <select id="kolabFolderTypeType" name="kolabFolderTypeType" onChange="document.mainform.submit();"
- {if !$use_kolabFolderType} disabled {/if}>
- {html_options options=$kolabFolderTypeTypes selected=$kolabFolderTypeType}
+ <select id="FolderTypeCAT" name="FolderTypeCAT" onChange="document.mainform.submit();">
+ {foreach from=$AvailableFolderTypes.CAT item=item key=key}
+ <option {if $key == $FolderType.CAT} selected {/if} value="{$key}">{$item}</option>
+ {/foreach}
</select>
- <select id="kolabFolderTypeSubType" name="kolabFolderTypeSubType" onChange="document.mainform.submit();"
- {if !$use_kolabFolderType} disabled {/if}>
- {html_options options=$kolabFolderTypeSubTypes selected=$kolabFolderTypeSubType}
+ <select id="FolderTypeSUB_CAT" name="FolderTypeSUB_CAT" onChange="document.mainform.submit();">
+ {foreach from=$AvailableFolderTypes.SUB_CAT item=item key=key}
+ {if $key == $FolderType.CAT}
+ {foreach from=$item item=item2 key=key2}
+ <option {if $key2 == $FolderType.SUB_CAT} selected {/if}
+ value='{$key2}'>{$item2}</option>
+ {/foreach}
+ {/if}
+ {/foreach}
</select>
- {else}
- <select id="kolabFolderTypeType" name="kolabFolderTypeType" onChange="document.mainform.submit();">
- {html_options options=$kolabFolderTypeTypes selected=$kolabFolderTypeType}
- </select>
- <select id="kolabFolderTypeSubType" name="kolabFolderTypeSubType" onChange="document.mainform.submit();">
- {html_options options=$kolabFolderTypeSubTypes selected=$kolabFolderTypeSubType}
- </select>
- {/if}
- {if !$JS}
- <input type='image' src='images/lists/reload.png' class='center' alt='{t}Reload{/t}'>
- {/if}
+ <input type='image' src='images/lists/reload.png' class='center' alt='{t}Reload{/t}'>
</td>
</tr>
{/if}
</table>
-
</td>
-{if $multiple_support}
-
-{else}
-
+<!-- Alternate addresses -->
+{if !$multiple_support}
<td style="vertical-align:top;padding-left:2px;">
-
-
-
- <h2><img class="center" alt="" align="middle" src="plugins/mail/images/alternatemail.png"> {t}Alternative addresses{/t}</h2>
+ <h2><img class="center" alt="" align="middle" src="plugins/mail/images/alternatemail.png">
+ {t}Alternative addresses{/t}
+ </h2>
{render acl=$gosaMailAlternateAddressACL}
- <select style="width:100%;" name="alternates_list[]" size=10 multiple title="{t}List of alternative mail addresses{/t}">
+ <select style="width:100%;" name="alternates_list[]" size=10 multiple
+ title="{t}List of alternative mail addresses{/t}">
{html_options values=$gosaMailAlternateAddress output=$gosaMailAlternateAddress}
<option disabled> </option>
</select>
{/render}
-
<br>
-
{render acl=$gosaMailAlternateAddressACL}
<input name="alternate_address" size="30" align=middle maxlength="60" value="">
{/render}
{render acl=$gosaMailAlternateAddressACL}
<input type=submit value="{msgPool type=delButton}" name="delete_alternate">
{/render}
-
</td>
{/if}
</tr>
-
</table>
+
<p class="seperator"> </p>
+{if !$multiple_support}
<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4 border=0>
<tr>
<td style="vertical-align:top;width:50%; border-right:1px solid #A0A0A0">
- <h2><img class="center" alt="" align="middle" src="plugins/mail/images/shared_folder.png"> {t}IMAP shared folders{/t}</h2>
-{if $multiple_support}
-
- <input class="center" type='checkbox' name="use_acl" value="1" {if $use_acl} checked {/if}
- onClick="toggle('acl_div');">{t}Set shared folder permissions{/t}
- {if $use_acl}
- <div style="visibility:visible;" id="acl_div">
- {else}
- <div style="visibility:hidden;" id="acl_div">
- {/if}
-{/if}
+ <h2><img class="center" alt="" align="middle" src="plugins/mail/images/shared_folder.png">
+ {t}IMAP shared folders{/t}
+ </h2>
+ <input type='hidden' name='mail_acls_posted' value='1'>
<table summary="" cellpadding=0 border=0>
- <tr>
- <td><LABEL for="default_permissions">{t}Default permission{/t}</LABEL></td>
- <td>
-{render acl=$aclACL}
- <select size="1" id="default_permissions" name="default_permissions">
- {html_options options=$perms selected=$default_permissions}
- <option disabled> </option>
- </select>
-{/render}
- </td>
- </tr>
- <tr>
- <td><LABEL for="member_permissions">{t}Member permission{/t}</LABEL></td>
- <td>
+ {foreach from=$folder_acls item=item key=user}
+ <tr>
+ {if $user == "__anyone__"}
+ <td><LABEL for="default_permissions">{t}Default permission{/t}</LABEL></td>
+ {elseif $user == "__member__"}
+ <td><LABEL for="member_permissions">{t}Member permission{/t}</LABEL></td>
+ {else}
+ <td>
+ <input type='input' name='acl_user_{$item.post_name}' value='{$user}'>
+ </td>
+ {/if}
+ <td>
{render acl=$aclACL}
- <select id="member_permissions" size="1" name="member_permissions">
- {html_options options=$perms selected=$member_permissions}
- </select>
+ <select size="1" name="acl_value_{$item.post_name}">
+ {html_options options=$AclTypes selected=$item.acl}
+ <option disabled> </option>
+ </select>
+ {if !($user == "__anyone__" || $user == "__member__")}
+ <input type='submit' value='{msgPool type=delButton}' name='remove_acl_user_{$item.post_name}'>
+ {/if}
{/render}
- </td>
- </tr>
- {$plusattributes}
+ </td>
+ </tr>
+ {/foreach}
+ <tr>
+ <td colspan="1"></td>
+ <td><input type='submit' value='{msgPool type=addButton}' name='add_acl_user'>
+ </tr>
</table>
-{if $multiple_support}
- </div>
-{/if}
+{/if}
<p class="seperator"> </p>
</td>
</tr>
</table>
+<input type="hidden" name='mailedit' value='1'>
<!-- Place cursor -->
<script language="JavaScript" type="text/javascript">
diff --git a/gosa-plugins/mail/personal/mail/class_mail-methods-cyrus.inc b/gosa-plugins/mail/personal/mail/class_mail-methods-cyrus.inc
index c050ed4e7019e0697f24743c0ccbffe3175781b9..147a5d1f49cf1aba372d6de11ee6106f470d8b8b 100644 (file)
<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2004 Cajus Pollmeier
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-class mailMethodCyrus extends mailMethod
-{
- var $mbox= "-";
- var $config;
- var $gosaMailServer= "";
- var $uattrib= "uid";
-
- var $folder_prefix = "share.";
- var $user_prefix = "user.";
-
- function mailMethodCyrus(&$config)
- {
- /* Check if the mail account identification attribute
- is overridden in the configuration file
- */
- if($config->get_cfg_value("mailAttribute") != ""){
- $new_uattrib= strtolower($config->get_cfg_value("mailAttribute"));
- if(in_array($new_uattrib,array("mail","uid"))){
- $this->uattrib = $new_uattrib;
- }else{
- trigger_error(sprintf("Unsupported 'mailAttribute' in gosa configuration specified, use 'mail' or 'uid', instead of '%s'.", $new_uattrib));
- }
- }
-
- /* Create the account prefix user. user/
- Preset folder prefix. Will change it later to respect
- altnamespace. */
- if ($config->get_cfg_value("cyrusUseSlashes") == "true"){
- $this->user_prefix= "user/";
- }
- $this->config= $config->data['SERVERS']['IMAP'];
- }
- function connect($gosaMailServer)
+class mailMethodCyrus extends mailMethod{
+
+ protected $ServerList = array();
+ protected $imap_handle = NULL;
+ protected $quota_loaded = FALSE;
+
+ /* Allow modification of account_ids for existing mail accounts */
+ protected $modifyableMail = FALSE;
+
+ /* Enforces same value for 'mail' as used for 'cn' */
+ protected $mailEqualsCN = FALSE;
+
+ protected $enableDomainSelection= FALSE;
+ protected $enableQuota = TRUE;
+ protected $enableSieveManager = TRUE;
+ protected $enableVacationRange = TRUE;
+ protected $enableFolderTypes = FALSE;
+
+ protected function init()
{
- $cfg=array();
+ mailMethod::init();
+ $this->ServerList = $this->config->data['SERVERS']['IMAP'];
+ }
- /* 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);
+
+ public function connect()
+ {
+ mailMethod::connect();
+
+ if (!isset($this->ServerList[$this->MailServer])){
+ $this->error = _("Mail server for this account is invalid!");
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,
+ "<b>The selected mail server '".$this->MailServer."' is invalid.</b>","");
+ return(FALSE);
} else {
- $cfg= $this->config[$gosaMailServer];
+ $cfg= $this->ServerList[$this->MailServer];
}
+
/* For some reason, hiding errors with @ does not wor here... */
if(!isset($cfg['connect'])) $cfg['connect']="";
if(!isset($cfg['admin'])) $cfg['admin']="";
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);
+ $this->imap_handle = @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);
+ if ($this->imap_handle === FALSE){
+ $this->error = imap_last_error();
return (FALSE);
+ $this->connected = FALSE;
}
+ $this->connected = TRUE;
+
return (TRUE);
}
- function disconnect()
+
+ public function account_exists()
+ {
+ if(!$this->is_connected() || !$this->imap_handle){
+ trigger_error("Method not connected, catch error.");
+ return(array());
+ }
+
+ /* Get server config */
+ $cfg= $this->ServerList[$this->MailServer];
+ $list = @imap_listmailbox($this->imap_handle, $cfg["connect"], $this->account_id);
+ $res = is_array($list) && count($list);
+ if($res){
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"","<b>Account exists in imap server.</b>");
+ }else{
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"","<b>Account seems NOT to exists in imap server.</b>");
+ }
+ return($res);
+ }
+
+ public function disconnect()
+ {
+ mailMethod::disconnect();
+ if($this->is_connected()){
+ @imap_close ($this->imap_handle);
+ }
+ }
+
+
+ public function is_connected()
{
- imap_close ($this->mbox);
+ $ret = mailMethod::is_connected();
+ return($ret && $this->imap_handle);
}
- function getQuota($folder)
+ protected function loadQuota()
{
- $result= array('quotaUsage' => '', 'gosaMailQuota' => '');
+ if(!$this->quotaEnabled()) return(TRUE);
+ if(!$this->is_connected() || !$this->imap_handle){
+ trigger_error("Method not connected, catch error.");
+ return(FALSE);
+ }
/* Load quota settings */
- error_reporting (0);
- $quota_value = @imap_get_quota($this->mbox, $folder);
- if(is_array($quota_value)) {
+ $result = array("quotaUsage"=>"","gosaMailQuota"=>"");
+ $quota_value = @imap_get_quota($this->imap_handle, $this->account_id);
+
+ if(is_array($quota_value) && count($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'] );
+ $result['gosaMailQuota']= "";
}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'] );
+ $result['gosaMailQuota']= "";
}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);
- }
+ $this->quotaValue = $result['gosaMailQuota'];
+ $this->quotaUsage = $result['quotaUsage'];
+ /* Write debug output */
+ if(is_array($quota_value)){
+ if($this->quotaValue == ""){
+ $quota = "(".$this->quotaUsage." / unlimited)";
+ }else{
+ $quota = "(".$this->quotaUsage." / ".$this->quotaValue.")";
+ }
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, $quota ,
+ "<b>Successfully received account quota</b>");
+ }else{
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, imap_last_error() ,
+ "<b>Failed to receive account quota</b>");
+ }
+ }
- /* return all folders of the users mailbox*/
- function getMailboxList($folder, $uid)
+ public function getQuota($quota)
{
- global $config;
- $result = array();
+ mailMethod::getQuota($quota);
+ if(!$this->quota_loaded){
+ $this->quota_loaded = TRUE;
+ $this->loadQuota();
+ }
+ return($this->quotaValue);
+ }
- /* Get domain an mail address if uid is an mail address */
- $domain = "";
- if(preg_match("/@/",$folder)){
- $domain = "@".preg_replace("/^.*@/","",$folder);
- $folder = preg_replace("/@.*$/","",$folder);
+ public function getQuotaUsage()
+ {
+ mailMethod::getQuotaUsage();
+ if(!$this->quota_loaded){
+ $this->quota_loaded = TRUE;
+ $this->loadQuota();
}
+ return($this->quotaUsage);
+ }
- /* Get list of mailboxes for combo box */
- $cfg= $this->config[$this->gosaMailServer];
+ public function setQuota($number)
+ {
+ mailMethod::setQuota($number);
- /* 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);
+ if(!$this->quotaEnabled()) return(TRUE);
+ if(!$this->is_connected() || !$this->imap_handle){
+ trigger_error("Method not connected, catch error.");
+ return(FALSE);
+ }
- /* Create list of returned folder names */
- if (is_array($list)){
- foreach ($list as $val){
+ $this->build_account_id();
- /* Cut domain name */
- $val = preg_replace("/@.*$/","",$val);
- $result[]=preg_replace ("/^.*".preg_quote($folder, '/')."/","INBOX", mb_convert_encoding($val, "UTF-8", "UTF7-IMAP"));
- }
+ /* Workaround for the php imap extension */
+ if (($this->quotaValue == "") || ($this->quotaValue== "2147483647")){
+ $this->quotaValue= "2147483647";
+ }elseif($this->quotaValue > 0){
+ $this->quotaValue = $this->quotaValue *1024;
}
-
- /* Append "INBOX" to the folder array if result is empty and request comes from user dialog */
- if(empty($result) && !empty($uid)){
- $result[] = "INBOX";
+ $debug_number = $this->quotaValue." KB";
+ if($this->quotaValue == "2147483647"){
+ $debug_number .= "<i>Unlimited</i>";
}
- return ($result);
+ if (!imap_set_quota($this->imap_handle, $this->account_id, $this->quotaValue)){
+ msg_dialog::display(_("IMAP error"), sprintf(_("Cannot modify IMAP mailbox quota: %s"),
+ '<br><br><i>'.imap_last_error().'</i>'), ERROR_DIALOG);
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>".$this->account_id.": (".$debug_number.")</b>" ,
+ "<b>Set account quota</b> on server '".$this->MailServer."' <b>".imap_last_error()."</b>");
+ return (FALSE);
+ }
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>".$this->account_id.": (".$debug_number.")</b>" ,
+ "<b>Set account quota</b> on server :".$this->MailServer);
+ return (TRUE);
}
- function updateMailbox($folder)
+ public function updateMailbox()
{
- /* Check if mailbox exists */
- $cfg= $this->config[$this->gosaMailServer];
- $list = imap_listmailbox($this->mbox, $cfg["connect"], $folder);
- if ($list === FALSE){
- if (!imap_createmailbox($this->mbox, $cfg["connect"]. $folder)){
- msg_dialog::display(_("IMAP error"), sprintf(_("Cannot create IMAP mailbox: %s"), '<br><br><i>'.imap_last_error().'</i>'), ERROR_DIALOG);
- return;
+ mailMethod::updateMailbox();
+
+ if(!$this->is_connected() || !$this->imap_handle){
+ trigger_error("Method not connected, catch error.");
+ return(FALSE);
+ }
+
+ $this->build_account_id ();
+ if($this->is_connected()){
+ $cfg= $this->ServerList[$this->MailServer];
+ $list = imap_listmailbox($this->imap_handle, $cfg["connect"], $this->account_id);
+ if ($list === FALSE){
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>".$this->account_id."</b>" ,
+ "<b>Add/Update account</b> on server :".$this->MailServer);
+ if (!imap_createmailbox($this->imap_handle, $cfg["connect"]. $this->account_id)){
+ $this->error = imap_last_error();
+ return(FALSE);
+ }
}
}
+ return(TRUE);
}
- function setQuota($folder, $gosaMailQuota)
+ public function deleteMailbox()
{
- /* Workaround for the php imap extension */
- if (($gosaMailQuota == "") || ($gosaMailQuota== "2147483647")){
- $gosaMailQuota= "2147483647";
- }elseif($gosaMailQuota > 0){
- $gosaMailQuota = $gosaMailQuota *1024;
- }
-
-
- /* Write mail quota */
- if (!imap_set_quota($this->mbox, $folder, $gosaMailQuota)){
- msg_dialog::display(_("IMAP error"), sprintf(_("Cannot modify IMAP mailbox quota: %s"), '<br><br><i>'.imap_last_error().'</i>'), ERROR_DIALOG);
+ mailMethod::deleteMailbox();
+
+ if(!$this->is_connected() || !$this->imap_handle){
+ trigger_error("Method not connected, catch error.");
+ return(FALSE);
+ }
+
+ $this->build_account_id ();
+
+ $cfg= $this->ServerList[$this->MailServer];
+ @imap_setacl ($this->imap_handle, $this->account_id, $cfg["admin"], "lrswipcda");
+ if (!imap_deletemailbox($this->imap_handle, $cfg["connect"].$this->account_id)){
+ $this->error = imap_last_error();
return (FALSE);
}
return (TRUE);
}
-
- function setSharedFolderPermissions($folder, $permissions)
+
+ public function getMailboxList()
{
- /* Get list of subfolders */
- $folders= $this->getMailboxList($folder, "");
- $folders[]= $folder;
-
- foreach ($folders as $subfolder){
+ mailMethod::getMailboxList();
+
+ if(!$this->is_connected() || !$this->imap_handle){
+ trigger_error("Method not connected, catch error.");
+ return(array());
+ }
- /* Set shared folder acl's */
- if (function_exists('imap_getacl')){
+ $result = array();
- /* 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, "");
- }
+ /* Get server config */
+ $cfg= $this->ServerList[$this->MailServer];
+
+ /* Create search string
+ And prepare replacements
+ */
+ if(preg_match("/\@/",$this->account_id)){
+ $search = preg_replace("/\@/","*@",$this->account_id);
+ $with_domain = TRUE;
+ }else{
+ $search = $this->account_id."*";
+ $with_domain = FALSE;
+ }
+ $folder = $this->account_id;
+ if(preg_match("/\@/",$folder)){
+ $folder = preg_replace("/\@.*$/","",$folder);
+ }
+
+ /* Contact imap server */
+ $list = @imap_listmailbox($this->imap_handle, $cfg["connect"], $search);
+
+ /* Create list of returned folder names */
+ if (is_array($list)){
+ foreach ($list as $val){
+ $str = trim(preg_replace("/^\{[^\}]*+\}/","",$val));
+ if($with_domain){
+ $str = trim(preg_replace("/\@.*$/","",$str));
}
- } else {
- msg_dialog::display(_("Internal error"), _("Cannot remove IMAP ACL: imap_getacl not implemented!"), ERROR_DIALOG);
+ $str = preg_replace ("/^.*".preg_quote($folder, '/')."/","INBOX",
+ mb_convert_encoding($str, "UTF-8", "UTF7-IMAP"));
+ $result[] = $str;
}
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,trim(implode($result,", "),", "),
+ "<b>Received mailbox folders.</b>");
+ $this->error = imap_last_error();
+ }else{
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,imap_last_error(),
+ "<b>Cannot receive mailbox folders.</b>");
+ $this->error = imap_last_error();
+ return(array());
+ }
- /* Set permissions for this folder */
- foreach ($permissions as $user => $acl){
- imap_setacl ($this->mbox, $subfolder, $user, $acl);
- }
+ /* Append "INBOX" to the folder array if result is empty and request comes from user dialog */
+ if(!count($result)){
+ $result[] = "INBOX";
}
+ return($result);
}
- function getSharedFolderPermissions($folder)
+ /*! \brief Returns configured acls
+ */
+ public function getFolderACLs($folder_acls)
{
- $result= array();
+ $this->reset_error();
/* imap_getacl available? */
if (!function_exists('imap_getacl')){
- msg_dialog::display(_("Internal error"), _("Cannot retrieve IMAP ACL: imap_getacl not implemented!"), ERROR_DIALOG);
+ $this->error = _("The module imap_getacl is not implemented!");
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"The imap_getacl module is missing!",
+ "<b>Cannot set folder acls.</b>");
+ return($folder_acls);
}
- /* 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;
- }
-
+ /* Get ACLs and merge them with the already given acls (ldap)
+ */
+ $this->build_account_id();
+ $acls = imap_getacl ($this->imap_handle, $this->account_id);
+ foreach($acls as $user => $acl){
+ if($user == "anyone") $user = "__anyone__"; // Map to internal placeholder
+ $folder_acls[$user] = $acl;
}
- return ($result);
+ return($folder_acls);
}
- function deleteMailbox($folder)
+
+ /*! \brief Write ACLs back to imap or what ever
+ */
+ public function setFolderACLs($permissions)
{
- $cfg= $this->config[$this->gosaMailServer];
- imap_setacl ($this->mbox, $folder, $cfg["admin"], "lrswipcda");
- if (!imap_deletemailbox($this->mbox, $cfg["connect"].$folder)){
- msg_dialog::display(_("IMAP error"), sprintf(_('Cannot remove IMAP mailbox: %s'), '<br><br><i>'.imap_last_error().'</i>'), ERROR_DIALOG);
- return (FALSE);
+ $this->reset_error();
+
+ /* imap_getacl available? */
+ if (!function_exists('imap_getacl')){
+ $this->error = _("The module imap_getacl is not implemented!");
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"The imap_getacl module is missing!",
+ "<b>Cannot set folder acls.</b>");
+ return(FALSE);
}
- return (TRUE);
- }
+ /* Get list of subfolders */
+ $folders= $this->getMailboxList();
+ foreach ($folders as $subfolder){
+ $folder_id = $this->create_folder_id($subfolder);
+ echo $folder_id."<br>";
+
+ /* Remove all acl's for this folder */
+ $users= @imap_getacl ($this->imap_handle, $folder_id);
+
+ if(is_array($users)){
+ foreach ($users as $userid => $perms){
+ $userid = strtolower($userid);
+ imap_setacl ($this->imap_handle, $folder_id, $userid, "");
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,$folder_id." -> ".$userid,
+ "<b>Removing folder permissions.</b>");
+ }
+ }
+ }
- function configureFilter($user, $gosaMailDeliveryMode,
- $mail, $gosaMailAlternateAddress,
- $gosaMailMaxSize,
- $gosaSpamMailbox, $gosaSpamSortLevel,
- $gosaVacationMessage)
- {
- $cfg= $this->config[$this->gosaMailServer];
+ /* Set permissions for this folder */
+ foreach($folders as $subfolder){
+ $folder_id = $this->create_folder_id($subfolder);
- /* 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 .= "*";
+ foreach ($permissions as $user => $acl){
+ imap_setacl ($this->imap_handle, $folder_id, $user, $acl);
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,$folder_id." -> ".$user.": ".$acl,
+ "<b>Setting new folder permissions.</b>");
+ }
}
+ return(TRUE);
+ }
- /* Log into the mail server */
- $sieve= new sieve($cfg["sieve_server"], $cfg["sieve_port"], $user,
- $cfg["password"], $cfg["admin"],$cfg["sieve_option"]);
+ public function saveSieveSettings()
+ {
+ mailMethod::saveSieveSettings();
+
+ /* Map attribute from parent class
+ */
+ $mail = $this->parent->mail;
+ $gosaMailDeliveryMode = $this->parent->gosaMailDeliveryMode;
+ $gosaMailAlternateAddress = $this->parent->gosaMailAlternateAddress;
+ $gosaMailMaxSize = $this->parent->gosaMailMaxSize;
+ $gosaSpamMailbox = $this->parent->gosaSpamMailbox;
+ $gosaSpamSortLevel = $this->parent->gosaSpamSortLevel;
+ $gosaVacationMessage = $this->parent->gosaVacationMessage;
+
+ /* Try to login into sieve
+ */
+ $cfg = $this->ServerList[$this->MailServer];
+ $sieve= new sieve($cfg["sieve_server"], $cfg["sieve_port"], $this->getUAttribValue(),
+ $cfg["password"], $cfg["admin"],$cfg["sieve_option"]);
if (!$sieve->sieve_login()){
- msg_dialog::display(_("SIEVE error"), sprintf(_("Cannot log into SIEVE server: %s"), '<br><br><i>'.to_string($sieve->error_raw).'</i>'), ERROR_DIALOG);
- return;
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,$sieve->error_raw ,"<b>SIEVE: login failed.</b>");
+ $this->error = $sieve->error_raw;
+ return(FALSE);
+ }else{
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "Options: ".$cfg["sieve_option"] ,
+ "SIEVE: <b>login successfull.</b>");
}
- /* Load current script from server and remove everything between the comments
- "###GOSA" */
+ /* 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= str_pad("",(int) $gosaSpamSortLevel,"*");
+
+ /* Get current sieve script named 'gosa'.
+ Check if it valid ("###GOSA" must be the first string).
+ If it is valid just replace it, if it is NOT valid
+ create a backup of the old
+ */
$script= "";
if($sieve->sieve_listscripts()){
if (in_array("gosa", $sieve->response)){
-
- /* get old GOsa script */
if(!$sieve->sieve_getscript("gosa")){
- msg_dialog::display(_("SIEVE error"), sprintf(_("Cannot retrieve SIEVE script: %s"), '<br><br><i>'.to_string($sieve->error_raw).'</i>'), ERROR_DIALOG);
- return;
+ $this->error = sprintf(_("Cannot retrieve SIEVE script: %s"),to_string($sieve->error_raw));
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,$sieve->error_raw ,
+ "SIEVE: <b>Connot read 'gosa' sieve script.</b>");
+ $this->error = $sieve->error_raw;
+ return(FALSE);
+ }else{
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,$sieve->error_raw ,
+ "SIEVE: <b>Sieve script named 'gosa' found.</b>");
}
+ $is_valid_script = FALSE;
foreach ($sieve->response as $line){
- if (preg_match ("/^###GOSA/", $line)){
- break;
+ if(empty($line)) continue;
+ if (preg_match ("/^###GOSA/", $line) && strlen($script) == 0){
+ $is_valid_script = TRUE;
}
$line= rtrim($line);
- if (!preg_match ('/^\s*$/', $line)){
- $script .= $line."\n";
- }
+ $script .= $line;
}
+ if($is_valid_script || strlen($script) == 0 || empty($script)){
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"" ,
+ "SIEVE: Sieve script 'gosa' was a valid GOsa script and will be replaced.");
+ }else{
+ $new_name = "non_gosa_".date("Ymd_H-i-s");
+ $sieve->sieve_sendscript($new_name, $script);
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,$this->sieve->error_raw ,
+ "SIEVE: Non GOsa sieve script. <b>Creating backup of the current sieve script '".$new_name."'.</b>");
+ }
}
}
+
+ /*****
+ Build up new sieve script here.
+ *****/
+
/* Only create a new one, if it is not empty */
+ $script= "";
if (is_integer(strpos($gosaMailDeliveryMode, "R")) ||
is_integer(strpos($gosaMailDeliveryMode, "C")) ||
!is_integer(strpos($gosaMailDeliveryMode, "L")) ||
eval ("\$script.=\"$text\";");
}
- /* Just be aware of null scripts... */
- if (!isset ($script)){
- $script= "";
- }
+ /****
+ Sieve script build complete
+ ****/
/* Upload script and make it the default one */
if (!$sieve->sieve_sendscript("gosa", $script)){
- msg_dialog::display(_("SIEVE error"), sprintf(_("Cannot store SIEVE script: %s"), '<br><br><i>'.to_string($sieve->error_raw).'</i>'), ERROR_DIALOG);
- return;
+ $this->error = sprintf(_("Cannot store SIEVE script: %s"), to_string($sieve->error_raw));
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "Error was: ".to_string($sieve->error_raw) ,
+ "SIEVE: <b>Writing new Sieve script failed!</b>");
+ return(FALSE);
+ }else{
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"<b>Successfully written!</b>" ,
+ "SIEVE: <b>NEW sieve script 'gosa' contains '".strlen($script)."' characters.</b>");
}
+
if(!$sieve->sieve_setactivescript("gosa")){
- msg_dialog::display(_("SIEVE error"), sprintf(_("Cannot activate SIEVE script: %s"), '<br><br><i>'.to_string($sieve->error_raw).'</i>'), ERROR_DIALOG);
- return;
+ $this->error = sprintf(_("Cannot activate SIEVE script: %s"), to_string($sieve->error_raw));
+ return(FALSE);
}
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"","SIEVE: <b>Logout</b>");
$sieve->sieve_logout();
}
-
}
// 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
index 498fb3ecb9b7a0a28428f383c74529696107c5fc..70908a385a9b2ca3d62479da709e80d2e9853045 100644 (file)
class mailMethodSendmailCyrus extends mailMethodCyrus
{
- function mailMethodSendmailCyrus(&$config)
- {
- /* Check if the mail account identification attribute
- is overridden in the configuration file
- */
- if($config->get_cfg_value("mailAttribute") != ""){
- $new_uattrib= strtolower($config->get_cfg_value("mailAttribute"));
- if(in_array($new_uattrib,array("mail","uid"))){
- $this->uattrib = $new_uattrib;
- }else{
- trigger_error(sprintf("Unsupported 'mailAttribute' in gosa configuration specified, use 'mail' or 'uid', instead of '%s'.", $new_uattrib));
- }
- }
-
- $this->config= $config->data['SERVERS']['IMAP'];
- }
-
- function fixAttributesOnLoad(&$mailObject)
+ public function fixAttributesOnLoad()
{
/* Remove possible local alias from forwarders */
- $newForwarder= array();
- foreach ($mailObject->gosaMailForwardingAddress as $addr){
- if (!preg_match('/^\\\\/', $addr)){
- $newForwarder[]= $addr;
+ mailMethodCyrus::fixAttributesOnLoad();
+ if(isset($this->parent->attrs['gosaMailForwardingAddress'])){
+ $newForwarder= array();
+ for($i = 0; $i < $this->parent->attrs['gosaMailForwardingAddress']['count']; $i++){
+ $addr = $this->parent->attrs['gosaMailForwardingAddress'][$i];
+ if (!preg_match('/^\\\\/', $addr)){
+ $newForwarder[]= $addr;
+ }
}
+ $newForwarder['count'] = count($newForwarder);
+ $this->parent->attrs['gosaMailForwardingAddress'] = $newForwarder;
}
- $mailObject->gosaMailForwardingAddress= $newForwarder;
}
- function fixAttributesOnStore(&$mailObject)
+ public function fixAttributesOnStore()
{
+ mailMethodCyrus::fixAttributesOnStore();
+
/* Add local user if checked */
+ $uattrib = $this->getUAttrib();
if (preg_match("/L/", $mailObject->gosaMailDeliveryMode)) {
- $mailObject->gosaMailForwardingAddress[]= "\\".$mailObject->uid;
+ if(!isset($this->parent->attrs['gosaMailForwardingAddress'])){
+ $this->parent->attrs['gosaMailForwardingAddress'] = array();
+ }
+ $this->parent->attrs['gosaMailForwardingAddress'][]= "\\".$this->parent->$uattrib;
}
}
diff --git a/gosa-plugins/mail/personal/mail/class_mail-methods.inc b/gosa-plugins/mail/personal/mail/class_mail-methods.inc
index 570a38aca2cfb181e60ffc05b9c174085783ce92..60764445e1094fce25051b0e75f3d5b0dcebcc9a 100644 (file)
<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2004 Cajus Pollmeier
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+class mailMethod{
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
+ /* Allow modification of account_ids for existing mail accounts */
+ protected $modifyableMail = TRUE;
+ /* Enforces same value for 'mail' as used for 'cn' */
+ protected $mailEqualsCN = FALSE;
+
+ /* the attribute used to create accounts */
+ protected $uattrib = "mail"; // Naming attribute for accounts, e.g. imap.
+
+ /* The account prefixes, keep the '.' here! See FAQ cyrusUseSlashes */
+ protected $user_prefix = "user.";
+ protected $share_prefix = "share.";
+
+ /* Create accounts in cyrus style with '/' instead of '.' */
+ protected $cyrusUseSlashes= FALSE;
+
+ /* The atribute mapping for this class Source --> Destination */
+ protected $attributes = array();
+ protected $userObjectClasses = array();
+ protected $shareObjectClasses = array();
+
+ /* Enabled mail domain selection. If enabled getMailDomains must the domain parts */
+ protected $enableDomainSelection= FALSE;
+ protected $enableQuota = TRUE;
+ protected $enableSieveManager = FALSE;
+ protected $enableVacationRange = TRUE;
+ protected $enableFolderTypes = FALSE;
+
+ /* Default values */
+ protected $quotaValue = 0;
+ protected $quotaUsage = 0;
+
+ /* Method internal */
+ protected $type = "user";
+ protected $account_id = "";
+ protected $initial_account_id = "";
+ protected $connected = FALSE;
+ protected $error = "";
+ protected $parent = NULL;
+ protected $MailServer = "";
+
+
+ /*! \brief Constructs the mail class
+ @param Object Config The GOsa configuration object
+ @param Object Plugin The initator
+ @param String Open "user" or "group" account.
+ */
+ function __construct(&$config, &$parent, $type = "user")
+ {
+ $this->parent = $parent;
+ $this->config = $config;
+
+ /* Create a refernce to the mail selected server
+ */
+ if(isset($this->parent->gosaMailServer)){
+ $this->MailServer = &$this->parent->gosaMailServer;
+ }else{
+ trigger_error("mailMethod with invalid parent object initialized.");
+ }
+
+ if(!in_array($this->type,array("user","group"))){
+ trigger_error("Unknown mail class type used '".$type."'.");
+ }else{
+ $this->type = $type;
+ }
+ }
-class mailMethod
-{
- var $uattrib= "uid";
- var $folder_prefix = "";
- var $user_prefix = "";
- function mailMethod(&$config)
+ /*! \brief Intialize attributes and config settings.
+ */
+ protected function init()
{
+ /* Get config value for cyrusUseSlashes
+ */
+ if ($this->config->get_cfg_value("cyrusUseSlashes") == "true"){
+ $this->cyrusUseSlashes = TRUE;
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "cyrusUseSlashes: <b>Enabled</b>","");
+ }else{
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "cyrusUseSlashes: <b>Disabled</b>","");
+ }
+
/* Check if the mail account identification attribute
is overridden in the configuration file
*/
- if($config->get_cfg_value("mailAttribute") != ""){
- $new_uattrib= strtolower($config->get_cfg_value("mailAttribute"));
+ if($this->config->get_cfg_value("mailAttribute","mail") != ""){
+ $new_uattrib= strtolower($this->config->get_cfg_value("mailAttribute"));
if(in_array($new_uattrib,array("mail","uid"))){
$this->uattrib = $new_uattrib;
}else{
- trigger_error(sprintf("Unsupported 'mailAttribute' in gosa configuration specified, use 'mail' or 'uid', instead of '%s'.", $new_uattrib));
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>".$new_uattrib."</b>",
+ "Unsupported 'mailAttribute' in gosa configuration specified");
+ msg_dialog::display(_("Configuration error"),
+ sprintf(_("The configured mail attribute '%s' is unsupported!"), $new_uattrib), ERROR_DIALOG);
+ }
+ }
+ $this->build_account_id();
+ $this->initial_account_id = $this->account_id;
+ }
+
+
+ public function fixAttributesOnLoad()
+ {
+ foreach($this->attributes as $source => $dest){
+ if(isset($this->parent->attrs[$source])){
+ $this->parent->attrs[$dest] = $this->parent->attrs[$source];
+ }
+ if(isset($this->parent->$source)){
+ $this->parent->$dest = $this->parent->$source;
+ }
+ }
+ }
+
+
+ public function mailEqualsCN()
+ {
+ return($this->mailEqualsCN);
+ }
+
+
+ public function fixAttributesOnRemove()
+ {
+ /* Remove objectClasses
+ */
+ if($this->type == "user"){
+ $this->parent->attrs['objectClass'] =
+ array_remove_entries_ics($this->userObjectClasses, $this->parent->attrs['objectClass']);
+ }else{
+ $this->parent->attrs['objectClass'] =
+ array_remove_entries_ics($this->shareObjectClasses, $this->parent->attrs['objectClass']);
+ }
+ foreach($this->attributes as $source => $dest){
+ $this->attrs[$dest] = array();
+ $this->attrs[$source] = array();
+ }
+ }
+
+ public function fixAttributesOnStore()
+ {
+ foreach($this->attributes as $source => $dest){
+ if(isset($this->parent->attrs[$dest])){
+ $this->parent->attrs[$source] = $this->parent->attrs[$dest ];
+ }
+ if(isset($this->parent->$dest)){
+ $this->parent->$source = $this->parent->$dest;
+ }
+ }
+
+ if($this->type == "user"){
+ $ocs = $this->userObjectClasses;
+ }else{
+ $ocs = $this->shareObjectClasses;
+ }
+ foreach($ocs as $oc){
+ if(!in_array($oc, $this->parent->attrs['objectClass'])){
+ $this->parent->attrs['objectClass'][] = $oc;
+ }
+ }
+ }
+
+
+ /*! \brief Connect services like imap.
+ Not necessary for the base class.
+ @return Boolean True if this method is connected else false.
+ */
+ public function connect()
+ {
+ $this->reset_error();
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"<b>Connect method</b>: ".get_class($this),"");
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"<b>Current server</b>: ".$this->MailServer,"");
+
+ $this->connected = TRUE;
+ return(TRUE);
+ }
+
+
+ /*! \brief Returns the connection status of this method.
+ @return Boolean True if this method is connected else false.
+ */
+ public function is_connected()
+ {
+ return($this->connected);
+ }
+
+
+ /*! \brief Disconnect this method. Close services like imap connection.
+ Not necessary for the base class.
+ */
+ public function disconnect()
+ {
+ $this->reset_error();
+ if($this->is_connected()){
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"<b>Disconnect method</b>: ".get_class($this),"");
+ $this->connected =FALSE;
+ }
+ }
+
+
+ /*! \brief Returns true the current object represents a valid account
+ (Some methods may check imap accounts here.)
+ @return Boolean TRUE if this is a valid account else FALSE
+ */
+ public function account_exists()
+ {
+ $this->reset_error();
+ return(TRUE);
+ }
+
+
+ /*! \brief Returns the last error occurred
+ @return String The last error message.
+ */
+ public function get_error(){
+ return($this->error);
+ }
+
+
+ public function isModifyableMail()
+ {
+ return($this->modifyableMail);
+ }
+
+
+ /*! \brief Returns TRUE if the action caused an error.
+ @return Boolean TRUE on error else FALSE
+ */
+ public function is_error(){
+ return($this->error != "");
+ }
+
+
+ /*! \brief Resets the error message.
+ */
+ public function reset_error(){
+ $this->error = "";
+ }
+
+
+ /*! \brief Create a new account id, like 'user/name@domain.com'.
+ */
+ protected function build_account_id()
+ {
+ /* Build account identicator */
+ if($this->type == "user"){
+ $str = $this->user_prefix;
+ }else{
+ $str = $this->share_prefix;
+ }
+ $uattrib = $this->uattrib;
+ if($this->cyrusUseSlashes){
+ $str = preg_replace("/\./","/",$str);
+ }
+ $str = trim(strtolower($str . $this->parent->$uattrib));
+ if($this->account_id != $str){
+ $this->account_id = $str;
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "accountID generated: <b>".$str."</b>","");
+ }
+ }
+
+
+ /*! \brief Creates a valid folder id for a given folder name.
+ e.g. $folder_id = "INBOX/test" && $this->account_id = "share/mailbox@domain.de"
+ will result in "share/mailbox/test@domain.de"
+ This function is mainly used to read and write folder permissions.
+ @return String A valid folder id
+ */
+ public function create_folder_id($folder, $type = "")
+ {
+
+ if(!empty($folder)){
+ $folder = trim(preg_replace("/^INBOX[\.\/]*/i","",$folder));
+ }
+ if(!empty($folder)){
+ $folder = "/".$folder;
+ }
+
+ /* Build account identicator */
+ if($type == ""){
+ $type = $this->type;
+ }
+ if($type == "user"){
+ $str = $this->user_prefix;
+ }else{
+ $str = $this->share_prefix;
+ }
+
+ $uattrib = $this->uattrib;
+ if($this->cyrusUseSlashes){
+ $str = preg_replace("/\./","/",$str);
+ }
+ if(preg_match("/\@/",$this->parent->$uattrib)){
+ list($mail,$domain) = split("\@",$this->parent->$uattrib);
+ $str = trim(strtolower($str . $mail . $folder . "@" . $domain));
+ }else{
+ $str = trim(strtolower($str . $this->parent->$uattrib));
+ }
+ return($str) ;
+ }
+
+
+ /*! \brief Returns the configured mail method for the given parent object,
+ initialized and read for use.
+ @return mailMethod The configured mailMethod.
+ */
+ public function get_method()
+ {
+ $methods = mailMethod::get_methods();
+ if ($this->config->get_cfg_value("mailmethod") != ""){
+ $method= $this->config->get_cfg_value("mailmethod");
+ $cls = get_correct_class_name("mailMethod$method");
+ if(isset($methods[$cls])){
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "Selected mailMethod: <b>".$cls."</b>","");
+ $tmp = new $cls($this->config,$this->parent,$this->type);
+ $tmp->init();
+ return($tmp);
+ }else{
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "Invalid mailMethod defined <b>".$cls.
+ "</b> falling back to <b>".get_class($this)."</b>","");
+
+ /* Print out configuration errors directly, we can't catch them everywhere.
+ */
+ msg_dialog::display(_("Configuration error"),
+ sprintf(_("Mail method '%s' is unknown!"), $method), ERROR_DIALOG);
+ }
+ }
+
+ /* If no valued mailMethod could be detected, return the base class.
+ */
+ $this->init();
+ return($this);
+ }
+
+
+ /*! \brief Saves sieve settings
+ */
+ public function saveSieveSettings()
+ {
+ $this->reset_error();
+ return(TRUE);
+ }
+
+
+ /*! \brief Creates or Updates the mailAccount represented by this class.
+ */
+ public function updateMailbox()
+ {
+ $this->reset_error();
+ return(TRUE);
+ }
+
+
+ /*! \brief Update shared folder dependencies
+ */
+ public function updateSharedFolder()
+ {
+ $this->reset_error();
+ return(TRUE);
+ }
+
+
+ /*! \brief Removes the mailbox represented by this class,
+ and update shared folder ACLs .
+ */
+ public function deleteMailbox()
+ {
+ $this->reset_error();
+
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>".$this->account_id."</b>" ,
+ "<b>Remove account</b> from server :".$this->MailServer);
+
+ return(TRUE);
+
+ /* No imap actions here, just updated shared folder membership
+ */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(&(objectClass=posixGroup)(objectClass=gosaMailAccount)(memberUid=".$account."))",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($account);
+ $tmp->by_object['mailgroup']->removeUserAcl($this->mail);
+ }
+ $tmp->by_object['mailgroup']->save();
+ }
+ }
+ }
+ return(TRUE);
+ }
+
+
+ /*! \brief Returns the used mail attribute (mail,uid)
+ @param String One out of 'mail','uid'
+ */
+ public function getUAttrib()
+ {
+ return($this->uattrib);
+ }
+
+
+ /*! \brief Returns the used mail attribute (mail,uid)
+ @param String One out of 'mail','uid'
+ */
+ public function getUAttribValue()
+ {
+ $uattrib = $this->getUAttrib();
+ return($this->parent->$uattrib);
+ }
+
+
+ /*! \brief Returns whether the quota settings are enabled or not
+ @return Boolean TRUE if enabled else FALSE
+ */
+ public function quotaEnabled()
+ {
+ return($this->enableQuota);
+ }
+
+
+ /*! \brief Returns the used quota
+ @return Integer Quota used.
+ */
+ public function getQuotaUsage()
+ {
+ return(-1);
+ }
+
+
+ /*! \brief Returns the quota restrictions.
+ @return Integer Quota restrictions.
+ */
+ public function getQuota($quotaValue)
+ {
+ return($quotaValue);
+ }
+
+
+ /*! \brief Sets the mail quota
+ */
+ public function setQuota($number)
+ {
+ if(!is_numeric($number)){
+ $number = (int) $number;
+ if(!$number){
+ $number = 0;
}
}
+ $this->quotaValue = $number;
+ return(TRUE);
}
- function connect($gosaMailServer)
+
+ /*! \brief Returns true whether the domain is selectable or not
+ */
+ public function domainSelectionEnabled()
{
- return (TRUE);
+ return($this->enableDomainSelection);
+ }
+
+
+ /*! \brief Returns a list of configured mail domains
+ @return Array A list of mail domains
+ */
+ public function getMailDomains()
+ {
+ return(array("gonicus.de","test.intranet.de"));
+ }
+
+
+ /*! \brief Returns the used Spamlevels for this mailmethod
+ */
+ public function getSpamLevels()
+ {
+ $spamlevel= array();
+ for ($i= 0; $i<21; $i++){
+ $spamlevel[]= $i;
+ }
+ return($spamlevel);
}
- function disconnect()
+
+ /*! \brief Returns the list of configured mailbox folders
+ @return Array The mailbox folders.
+ */
+ public function getMailboxList()
{
+ return(array("INBOX"));
}
- function getQuota($folder)
+
+ /*! \brief Returns whether the vacation range is selectable or not
+ @return Boolean TRUE, FALSE
+ */
+ public function vacationRangeEnabled()
{
- return (array('quotaUsage' => 0, 'gosaMailQuota' => 0));
+ return($this->enableVacationRange);
}
- function getMailboxList($folder, $uid)
+
+ /*! \brief Returns true if the sieveManagement is allowed
+ @return Boolean TRUE, FALSE
+ */
+ public function allowSieveManagement()
{
- return (array("INBOX"));
+ return($this->enableSieveManager);
+ }
+
+
+ /*! \brief Checks dependencies to other GOsa plugins.
+ */
+ public function accountCreateable(&$reason = ""){
+ return(TRUE);
}
- function setQuota($folder, $gosaMailQuota)
+
+ /*! \brief Checks whether this account is removeable or not.
+ There may be some dependencies left, eg. kolab.
+ */
+ public function accountRemoveable(&$reason = ""){
+ return(TRUE);
+
+ /* 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);
+
+ */
+ }
+
+
+ /*! \brief Returns all mail servers configured in GOsa
+ that are useable with this mailMethod.
+ @return Array All useable mail servers.
+ */
+ public function getMailServers()
{
- return (TRUE);
+ $mailserver = array();
+ $ui = get_userinfo();
+ foreach ($this->config->data['SERVERS']['IMAP'] as $key => $val){
+ if( $this->MailServer == $key ||
+ preg_match("/r/",$ui->get_permissions($val['server_dn'],"server/goImapServer",""))){
+ $mailserver[]= $key;
+ }
+ }
+ return($mailserver);
}
- function updateMailbox($folder)
+
+ /*! \brief Returns the available mailMethods
+ @return Array A list of all avaialable mailMethods_
+ */
+ static protected function get_methods()
{
+ global $class_mapping;
+ $available = array();
+ foreach($class_mapping as $class => $path){
+ if($class == "mailMethod") continue;
+ if(preg_match("/^mailMethod/",$class)){
+ $available[$class] = $class;
+ }
+ }
+ return($available);
}
- function deleteMailbox($folder)
+
+ /* \brief Some method require special folder types, "kolab" for example.
+ !! Those values are dummy values, the base class doesn't use folder types;
+ @return Array Return folder types.
+ */
+ public function getAvailableFolderTypes()
{
- return (TRUE);
+ $ret = array();
+ $ret['CAT']['mail'] = _("Mail");
+ $ret['CAT']['peter']= _("User");
+ $ret['SUB_CAT']['mail']['a'] = "a";
+ $ret['SUB_CAT']['mail']['b'] = "b";
+ $ret['SUB_CAT']['peter']['tt'] = "tt";
+ $ret['SUB_CAT']['peter']['dd'] = "dd";
+ $ret['SUB_CAT']['peter']['did'] = "did";
+ return($ret);
}
- function setSharedFolderPermissions($folder, $permissions)
+
+ /* \brief Returns the selected folder type.
+ !! Those values are dummy values, the base class doesn't use folder types;
+ @return Array The folde type.
+ */
+ public function getFolderType($default)
{
+ if($this->enableFolderTypes && $this->parent->attrs['kolabFolderType'][0]){
+ list($cat,$sub) = split("\.",$this->parent->attrs['kolabFolderType'][0]);
+ return(array("CAT" => $cat, "SUB_CAT" => $sub));
+ }else{
+ return($default);
+ }
}
- function configureFilter($user, $gosaMailDeliveryMode,
- $mail, $gosaMailAlternateAddress,
- $gosaMailMaxSize,
- $gosaSpamMailbox, $gosaSpamSortLevel,
- $gosaVacationMessage)
+
+ /* \brief Returns the selected folder type.
+ !! Those values are dummy values, the base class doesn't use folder types;
+ @return Array The folde type.
+ */
+ public function setFolderType($type)
{
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd ($this->parent->dn);
+ $ldap->modify(array("kolabFolderType" => $type['CAT'].".".$type['SUB_CAT']));
+ echo "Move me to KOLAB";
}
- function fixAttributesOnLoad(&$mailObject)
+
+ /*! \brief Returns configured acls
+ */
+ public function getFolderACLs($folder_acls)
{
+ return($folder_acls);
}
- function fixAttributesOnStore(&$mailObject)
+
+ /*! \brief Write ACLs back to imap or what ever
+ */
+ public function setFolderACLs($array)
{
+ return(TRUE);
}
- function fixAttributesOnRemove(&$mailObject)
+
+ /*! \brief Returns a list of all possible acls.
+ @return Array ACLs.
+ */
+ public function getAclTypes()
{
+ $acls["lrsw"] = _("read");
+ $acls["lrswp"] = _("post");
+ $acls["p"] = _("external post");
+ $acls["lrswip"] = _("append");
+ $acls["lrswipcd"] = _("write");
+ $acls["lrswipcda"]= _("admin");
+ $acls[" "]= _("none");
+ return($acls);
}
+ public function folderTypesEnabled()
+ {
+ return($this->enableFolderTypes);
+ }
+
}
+
// 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
index 42251b8724ccf4456668f20a2a73642fe2f4a156..7931e167cc0c33684dae0ffb87d964d588238c22 100644 (file)
<?php
-/*! \brief mail plugin
- \author Cajus Pollmeier <pollmeier@gonicus.de>
- \version 2.00
- \date 24.07.2003
+/*!
+ \brief mail plugin
+ \author Fabian Hicker <Fabian.Hickert@GONICUS.de>
+ \version 2.6.2
+ \date 03.12.2007
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.
+ relevant for gosaMailAccounts from/to the LDAP.
+ It does syntax checking and displays the formulars required.
+ Special handling like sieve or imap actions will be implemented
+ by the mailMethods.
+
+
+Functions :
+
+ - mailAccount (&$config, $dn= NULL)
+ - execute()
+ - save_object()
+ - get_vacation_templates()
+ - addForwarder($address)
+ - delForwarder($addresses)
+ - addAlternate($address)
+ - delAlternate($addresses)
+ - prepare_vacation_template($contents)
+ - display_forward_dialog()
+ - remove_from_parent()
+ - save()
+ - check()
+ - adapt_from_template($dn, $skip= array())
+ - getCopyDialog()
+ - saveCopyDialog()
+ - PrepareForCopyPaste($source)
+ - get_multi_edit_values()
+ - multiple_check()
+ - set_multi_edit_values($values)
+ - init_multiple_support($attrs,$all)
+ - get_multi_init_values()
+ - multiple_execute()
+ - multiple_save_object()
+ - make_name($attrs)
+ - plInfo()
+
+
*/
class mailAccount extends plugin
{
/* Definitions */
- var $plHeadline = "Mail";
- var $plDescription = "This does something";
- var $method = "mailMethod";
+ var $plHeadline = "Mail";
+ var $plDescription = "This does something";
+ var $view_logged = FALSE;
+ var $is_account = FALSE;
+ var $initially_was_account = FALSE;
+ /* GOsa mail attributes */
+ var $mail = "";
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 $gosaSpamSortLevel = "";
var $gosaSpamMailbox = "";
- var $quotaUsage = 0;
- var $forward_dialog = FALSE;
- var $user_prefix = "";
- 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");
+ /* The methods defaults */
+ var $mailMethod = NULL;
+ var $MailDomain = "";
+ var $sieveManagementUsed = FALSE;
+ var $multiple_support = FALSE;
+ var $vacationTemplates = array();
+ var $sieve_management = NULL;
+ var $forward_dialog = FALSE;
+ var $initial_uid = "";
+ var $mailDomainPart = "";
+ var $mailDomainParts = array();
+ var $MailBoxes = array("INBOX");
+
+ /* Used LDAP attributes && classes */
+ 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)
+ /*! \brief Initialize the mailAccount
+ */
+ function __construct (&$config, $dn= NULL)
{
- global $class_mapping;
+ plugin::plugin($config,$dn);
- $this->gosaVacationStart = time();
- $this->gosaVacationStop = time();
+ /* Intialize the used mailMethod
+ */
+ $tmp = new mailMethod($config,$this);
+ $this->mailMethod = $tmp->get_method();
+ $this->mailMethod->fixAttributesOnLoad();
+ $this->mailDomainParts = $this->mailMethod->getMailDomains();
+ $this->SpamLevels = $this->mailMethod->getSpamLevels();
- /* Load bases attributes */
- plugin::plugin($config, $dn);
+ /* Remember account status
+ */
+ $this->initially_was_account = $this->is_account;
- /* 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];
+ /* Initialize vacation settings
+ */
+ if(empty($this->gosaVacationStart)){
+ $this->gosaVacationStart = time();
+ $this->gosaVacationStop = time();
}
- /* Save initial account state */
- $this->initially_was_account= $this->is_account;
+ /* Read vacation templates
+ */
+ $this->vacationTemplates = $this->get_vacation_templates();
- /* Set mailMethod to the one defined in gosa.conf */
- if ($this->config->get_cfg_value("mailmethod") != ""){
- $method= $this->config->get_cfg_value("mailmethod");
+ /* Initialize configured values
+ */
+ if($this->is_account){
- $cls = get_correct_class_name("mailMethod$method");
- if ($cls && class_exists($cls)){
- $this->method= $cls;
- } else {
- msg_dialog::display(_("Configuration error"), sprintf(_("Mail method '%s' is unknown!"), $method), ERROR_DIALOG);
- }
- }
+ if($this->mailMethod->connect() && $this->mailMethod->account_exists()){
- /* get user and folder prefix */
- $method = new $this->method($this->config);
- $this->user_prefix = $method->user_prefix;
- $this->folder_prefix = $method->folder_prefix;
+ /* Read quota */
+ $this->gosaMailQuota = $this->mailMethod->getQuota($this->gosaMailQuota);
+ if($this->mailMethod->is_error()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot read quota settings! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }
+
+ /* Read mailboxes */
+ $this->MailBoxes = $this->mailMethod->getMailboxList($this->MailBoxes);
+ if($this->mailMethod->is_error()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot get list of mailboxes! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }
+
+ }elseif(!$this->mailMethod->is_connected()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot connect mail method! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }elseif(!$this->mailMethod->account_exists()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Mailbox doesn't exists on mail server: %s."),
+ $this->gosaMailServer), ERROR_DIALOG);
+ }
-
- /* This is not a new account, parse additional attributes */
- if (($dn !== NULL) && ($dn != "new") && $this->is_account){
+ /* If the doamin part is selectable, we have to split the mail address
+ */
+ if($this->mailMethod->domainSelectionEnabled()){
+ $this->mailDomainPart = preg_replace("/^[^@]*+@/","",$this->mail);
+ $this->mail = preg_replace("/@.*$/","\\1",$this->mail);
+ if(!in_array($this->mailDomainPart,$this->mailDomainParts)){
+ $this->mailDomainParts[] = $this->mailDomainPart;
+ }
+ }
/* Load attributes containing arrays */
foreach (array("gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
}
}
}
-
-
- /* Only do IMAP actions if gosaMailServer attribute is set */
- if (isset ($this->attrs["gosaMailServer"][0])){
-
- $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->user_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->user_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 ($this->config->get_cfg_value("vacationTemplateDirectory") != ""){
- $dir= $this->config->get_cfg_value("vacationTemplateDirectory");
- 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);
- }
+ /* Intialize sieveManagement if necessary */
+ if($this->mailMethod->allowSieveManagement()){
+ $this->mailboxList = &$this->MailBoxes;
+ $this->sieve_management = new sieveManagement($this->config,$this->dn,$this,$this->mailMethod->getUAttrib());
}
- /* 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 */
+ /* Get global filter config used in add local forward
+ */
if (!session::is_set("mailfilter")){
$ui= get_userinfo();
$base= get_base_from_people($ui->dn);
"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;
+ /* Disconnect mailMethod. Connect on demand later.
+ */
+ $this->mailMethod->disconnect();
}
function execute()
{
/* Call parent execute */
- plugin::execute();
+ $display = plugin::execute();
/* Log view */
if($this->is_account && !$this->view_logged){
new log("view","users/".get_class($this),$this->dn);
}
- /* Initialise vars */
-
- /* Load templating engine */
- $smarty= get_smarty();
- $display= "";
-
- /* Get available mailserver */
- $mailserver= array();
- $ui = get_userinfo();
- foreach ($this->config->data['SERVERS']['IMAP'] as $key => $val){
- if( $this->gosaMailServer == $key ||
- preg_match("/r/",$ui->get_permissions($val['server_dn'],"server/goImapServer",""))){
- $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());
- }
+ /****************
+ Account status
+ ****************/
- /* Handle account state */
- /* Do we need to flip is_account state? */
if(isset($_POST['modify_state'])){
- if($this->is_account && $this->acl_is_removeable()){
+ if($this->is_account && $this->acl_is_removeable() && $this->mailMethod->accountRemoveAble()){
$this->is_account= FALSE;
- }elseif(!$this->is_account && $this->acl_is_createable()){
+ }elseif(!$this->is_account && $this->acl_is_createable() && $this->mailMethod->accountCreateable()){
$this->is_account= TRUE;
}
}
-
- /* Do we represent a valid account? */
if(!$this->multiple_support_active){
if (!$this->is_account && $this->parent === NULL){
$display= "<img alt=\"\" src=\"images/small-error.png\" align=\"middle\"> <b>".
msgPool::noValidExtension(_("Mail"))."</b>";
-
$display.= back_to_main();
return ($display);
}
-
- /* Show tab dialog headers */
if ($this->parent !== NULL){
- if ($this->is_account){
- if($this->accountDelegationsConfigured()){
- $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Mail")),
- _("Mail settings cannot be removed while there are delegations configured!"),TRUE,TRUE);
+ if ($this->is_account){
+ $reason = "";
+ if(!$this->mailMethod->accountRemoveable($reason)){
+ $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Mail")),$reason ,TRUE,TRUE);
}else{
- $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Mail")),
- msgPool::featuresEnabled(_("Mail")));
+ $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Mail")),msgPool::featuresEnabled(_("Mail")));
}
} else {
- $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Mail")),
- msgPool::featuresDisabled(_("Mail")));
+ $reason = "";
+ if(!$this->mailMethod->accountCreateable($reason)){
+ $display= $this->show_disable_header(msgPool::addFeaturesButton(_("Mail")),$reason ,TRUE,TRUE);
+ }else{
+ $display= $this->show_disable_header(msgPool::addFeaturesButton(_("Mail")),msgPool::featuresDisabled(_("Mail")));
+ }
return ($display);
}
}
}
- /* Forwarder subdialog */
+ /****************
+ Sieve Management Dialog
+ ****************/
+ if($this->mailMethod->allowSieveManagement()){
+ if(isset($_POST['sieveManagement'])
+ && preg_match("/C/",$this->gosaMailDeliveryMode)
+ && $this->acl_is_writeable("sieveManagement")
+ && $this->mailMethod->allowSieveManagement()) {
+ $this->dialog = $this->sieve_management;
+ }
+ if(isset($_POST['sieve_cancel'])){
+ $this->dialog = FALSE;
+ }
+ 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());
+ }
+ }
- /* Trigger forward add dialog? */
+ /****************
+ Forward addresses
+ ****************/
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'])){
-
if (isset($_POST['local_list'])){
-
- /* 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;
}
msg_dialog::display(_("Error"), _("Please select an entry!"), ERROR_DIALOG);
}
}
-
- /* 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 ($this->is_template){
$valid= TRUE;
} else {
- msg_dialog::display(_("Error"),
- msgPool::invalid(_("Mail address"),"","","your-domain@your-domain.com"),
- ERROR_DIALOG);
+ msg_dialog::display(_("Error"), msgPool::invalid(_("Mail address"),
+ "","","your-address@your-domain.com"),ERROR_DIALOG);
}
}
} elseif ($address == $this->mail
} 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']);
}
+ if ($this->forward_dialog){
+ return($this->display_forward_dialog());
+ }
- /* Add alternate email addresses */
- if (isset($_POST['add_alternate'])){
+ /****************
+ Alternate 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"),
- msgPool::invalid(_("Mail address"),"","","your-domain@your-domain.com"),
- ERROR_DIALOG);
-
+ msg_dialog::display(_("Error"),msgPool::invalid(_("Mail address"),"","","your-domain@your-domain.com"),ERROR_DIALOG);
} else {
$valid= TRUE;
}
} else {
- msg_dialog::display(_("Error"),
- msgPool::invalid(_("Mail address"),"","","your-domain@your-domain.com"),
- ERROR_DIALOG);
+ msg_dialog::display(_("Error"),msgPool::invalid(_("Mail address"),"","","your-domain@your-domain.com"),ERROR_DIALOG);
}
-
} else {
$valid= TRUE;
}
-
if ($valid && ($user= $this->addAlternate ($_POST['alternate_address'])) != ""){
$ui= get_userinfo();
if ($user != $ui->username){
msg_dialog::display(_("Error"), msgPool::duplicated(_("Mail address"))." ".
- sprintf(_("Address is already in use by user '%s'."), $user), ERROR_DIALOG);
+ sprintf(_("Address is already in use 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/lists/search.png'));
- $smarty->assign("usearch_image", get_template_path('images/lists/search-user.png'));
- $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
- $smarty->assign("infoimage", get_template_path('images/info.png'));
- $smarty->assign("launchimage", get_template_path('images/lists/action.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);
+ /****************
+ SMARTY- Assign smarty variables
+ ****************/
+ $smarty = get_smarty();
$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);
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
}
-
- 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");
+ $smarty->assign("quotaEnabled", $this->mailMethod->quotaEnabled());
+ if($this->mailMethod->is_connected()){
+ $smarty->assign("quotaUsage", $this->mailMethod->getQuotaUsage());
+ }else{
+ $smarty->assign("quotaUsage", _("Unknown"));
}
+ $smarty->assign("gosaMailQuota",$this->gosaMailQuota);
+ $smarty->assign("domainSelectionEnabled", $this->mailMethod->domainSelectionEnabled());
+ $smarty->assign("MailDomains", $this->mailDomainParts);
+ $smarty->assign("MailDomain" , $this->mailDomainPart);
+ $smarty->assign("MailServers", $this->mailMethod->getMailServers());
+ $smarty->assign("allowSieveManagement", $this->mailMethod->allowSieveManagement());
+ $smarty->assign("own_script", $this->sieveManagementUsed);
- /* 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)));
+ /* _Multiple users vars_ */
+ foreach($this->attributes as $attr){
+ $u_attr = "use_".$attr;
+ $smarty->assign($u_attr,in_array($attr,$this->multi_boxes));
}
-
- /* 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");
+ 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));
}
- 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");
+ /****************
+ SMARTY- Assign flags
+ ****************/
- /* Fill checkboxes */
+ $types = array(
+ "V"=>"use_vacation",
+ "S"=>"use_spam_filter",
+ "R"=>"use_mailsize_limit",
+ "I"=>"drop_own_mails",
+ "C"=>"own_script");
foreach($types as $option => $varname){
if (preg_match("/".$option."/", $this->gosaMailDeliveryMode)) {
$smarty->assign($varname, "checked");
$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= msgPool::months();
- $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);
+ if (!preg_match("/L/", $this->gosaMailDeliveryMode)) {
+ $smarty->assign("only_local", "checked");
+ } else {
+ $smarty->assign("only_local", "");
}
- $smarty->assign("end_day", $date["mday"]);
- $smarty->assign("end_month", $date["mon"]-1);
- $smarty->assign("end_year", $date["year"]);
-
- /* Have vacation templates? */
+ /****************
+ Smarty- Vacation settings
+ ****************/
+ $smarty->assign("rangeEnabled", FALSE);
$smarty->assign("template", "");
- if (count($this->vacation)){
+ if (count($this->vacationTemplates)){
$smarty->assign("show_templates", "true");
- $smarty->assign("vacationtemplates", $this->vacation);
+ $smarty->assign("vacationtemplates", $this->vacationTemplates);
if (isset($_POST['vacation_template'])){
$smarty->assign("template", $_POST['vacation_template']);
}
$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());
-
- if (!$ldap->success()){
- msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
- }
-
- /* Connect to IMAP server for account deletion */
- if ($this->gosaMailServer != ""){
- $method= new $this->method($this->config);
- $id= $method->uattrib;
- if ($method->connect($this->gosaMailServer)){
+ /* Vacation range assigments
+ */
+ if($this->mailMethod->vacationRangeEnabled()){
+ $smarty->assign("rangeEnabled", TRUE);
+ 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"]);
- /* Remove account from IMAP server */
- $method->deleteMailbox($this->user_prefix.$this->$id);
- $method->disconnect();
+ if($this->gosaVacationStart == 0){
+ $date= getdate(time());
+ }else{
+ $date= getdate($this->gosaVacationStart);
+ }
+ $smarty->assign("start_day", $date["mday"]);
+ $smarty->assign("start_month", $date["mon"]-1);
+ $smarty->assign("start_year", $date["year"]);
+ $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= msgPool::months();
+ $smarty->assign("months", $months);
+ $smarty->assign("years", $years);
+ $smarty->assign("days", $days);
+
}
- /* Update shared folder membership, ACL may need to be updated */
- $this->updateSharedFolder();
+ /* fill filter settings
+ */
+ $smarty->assign("spamlevel", $this->SpamLevels);
+ $smarty->assign("spambox" , $this->MailBoxes);
- /* Optionally execute a command after we're done */
- $this->handle_post_events("remove",array("uid" => $this->uid));
+ $smarty->assign("multiple_support",$this->multiple_support_active);
+ return($display.$smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
}
-
- /* 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()
/* Save ldap attributes */
plugin::save_object();
+ /* Get posted mail domain part, if necessary
+ */
+ if($this->mailMethod->domainSelectionEnabled() && isset($_POST['MailDomain'])){
+ if(in_array(get_post('MailDomain'), $this->mailDomainParts)){
+ $this->mailDomainPart = get_post('MailDomain');
+ }
+ }
+
+ /* Import vacation message?
+ */
+ if (isset($_POST["import_vacation"]) && isset($this->vacationTemplates[$_POST["vacation_template"]])){
+ 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);
+ }
+ /* Handle flags
+ */
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
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 */
+ 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);
$tmp = preg_replace("/L/","",$tmp);
}
}
-
- $opts = array(
+ $opts = array(
"R" => "use_mailsize_limit",
"S" => "use_spam_filter",
"V" => "use_vacation",
$this->is_modified= TRUE;
}
$this->gosaMailDeliveryMode= $tmp;
+ if($this->mailMethod->vacationRangeEnabled()){
+ 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'];
+ }
+ }
+ }
+ }
+ }
+ }
- if($this->acl_is_writeable("gosaVacationMessage") && preg_match("/V/",$this->gosaMailDeliveryMode)){
- if(isset($_POST['gosaVacationStart'])){
- $this->gosaVacationStart = $_POST['gosaVacationStart'];
+ /*! \brief Parse vacation templates and build up an array
+ containing 'filename' => 'description'.
+ Used to fill vacation dropdown box.
+ @return Array All useable vacation templates.
+ */
+ function get_vacation_templates()
+ {
+ $vct = array();
+ if ($this->config->get_cfg_value("vacationTemplateDirectory") != ""){
+ $dir= $this->config->get_cfg_value("vacationTemplateDirectory");
+ if (is_dir($dir) && is_readable($dir)){
+ $dh = opendir($dir);
+ while($file = readdir($dh)){
+ $description= "";
+ if (is_file($dir."/".$file)){
+ $fh = fopen($dir."/".$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);
+ }else{
+ $description= trim(preg_replace('/^DESC:\s*/', '', $line));
+ }
+ fclose ($fh);
}
- if(isset($_POST['gosaVacationStop'])){
- $this->gosaVacationStop = $_POST['gosaVacationStop'];
+ if ($description != ""){
+ $vct["$dir/$file"]= $description;
}
}
+ closedir($dh);
}
}
+ return($vct);
}
- /* Save data to LDAP, depending on is_account we save or delete */
- function save()
+ /*! \brief Adds the given mail address to the list of mail forwarders
+ */
+ function addForwarder($address)
{
- $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);
+ if(empty($address)) return;
+ 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);
+ }
+ }
+
+
+ /*! \brief Removes the given mail address from the list of mail forwarders
+ */
+ 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);
+ }
+ }
+
+
+ /*! \brief 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(empty($address)) return;
+ if($this->acl_is_writeable("gosaMailAlternateAddress")){
+ $ldap= $this->config->get_ldap_link();
+ $address= strtolower($address);
- /* Remove Mailquota if = "" or "0" */
- if((isset($this->attrs['gosaMailQuota']))&&(!$this->attrs['gosaMailQuota'])) {
- $this->attrs['gosaMailQuota']=0;
+ /* Is this address already assigned in LDAP? */
+ $ldap->cd ($this->config->current['BASE']);
+ $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=$address)".
+ "(alias=$address)(gosaMailAlternateAddress=$address)))", array("uid"));
+ if ($ldap->count() > 0){
+ $attrs= $ldap->fetch ();
+ return ($attrs["uid"][0]);
+ }
+ 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);
}
+ }
- if(empty($this->attrs['gosaSpamMailbox'])){
- unset($this->attrs['gosaSpamMailbox']);
+
+ /*! \brief Removes the given mail address from the alternate addresses list
+ */
+ 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);
}
+ }
- $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']);
+ /*! \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);
+ }
+ }
+ }
+ $contents = ltrim(preg_replace("/^DESC:.*$/m","",$contents),"\n ");
+ return($contents);
+ }
+
+
+ /*! \brief Displays a dialog that allows mail address selection.
+ */
+ function display_forward_dialog()
+ {
+ restore_error_handler();
+
+ $smarty = get_smarty();
+ $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"));
+ while ($attrs= $ldap->fetch()){
+ if(preg_match('/%/', $attrs['mail'][0])){
+ continue;
+ }
+ $name= $this->make_name($attrs);
+ $mailusers[$attrs['mail'][0]]= $name."<".
+ $attrs['mail'][0].">";
+ }
+ natcasesort ($mailusers);
+ reset ($mailusers);
+
+ /* Show dialog */
+ $smarty->assign("search_image", get_template_path('images/lists/search.png'));
+ $smarty->assign("usearch_image", get_template_path('images/lists/search-user.png'));
+ $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
+ $smarty->assign("infoimage", get_template_path('images/info.png'));
+ $smarty->assign("launchimage", get_template_path('images/lists/action.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);
+ }
+
+
+ /*! \brief Removes the mailAccount extension from ldap
+ */
+ function remove_from_parent()
+ {
+ /* Cancel if there's nothing to do here */
+ if (!$this->initially_was_account){
+ return;
+ }
+
+ /* If domain part was selectable, contruct mail address */
+ if($this->mailMethod->domainSelectionEnabled()){
+ $this->mail = $this->mail."@".$this->mailDomainPart;
+ }
+
+ /* Remove GOsa attributes */
+ plugin::remove_from_parent();
+
+ /* Zero arrays */
+ $this->attrs['gosaMailAlternateAddress'] = array();
+ $this->attrs['gosaMailForwardingAddress']= array();
+
+
+ $this->mailMethod->fixAttributesOnRemove();
+ $this->cleanup();
+
+ @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,$this->attributes, "Save");
+ $ldap= $this->config->get_ldap_link();
+ $ldap->cd($this->dn);
+ $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());
+ if (!$ldap->success()){
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
+ }
+
+ /* Let the mailMethod remove this mailbox, e.g. from imap and
+ update shared folder membership, ACL may need to be updated.
+ */
+ if (!$this->is_template){
+
+ if(!$this->mailMethod->connect()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot connect mail method! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }else{
+ if(!$this->mailMethod->deleteMailbox()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot remove mailbox! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }
+ if(!$this->mailMethod->updateSharedFolder()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot update shared folder permissions! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }
+ }
+ }
+ $this->mailMethod->disconnect();
+
+ /* Optionally execute a command after we're done */
+ $this->handle_post_events("remove",array("uid" => $this->uid));
+ }
+
+
+ /*! \brief Save the mailAccount settings to the ldap database.
+ */
+ function save()
+ {
+ $ldap= $this->config->get_ldap_link();
+
+ /* If domain part was selectable, contruct mail address */
+ if($this->mailMethod->domainSelectionEnabled()){
+ $this->mail = $this->mail."@".$this->mailDomainPart;
}
+
+ /* Enforce lowercase mail address and trim whitespaces
+ */
+ $this->mail = trim(strtolower($this->mail));
+
+ /* Call parents save to prepare $this->attrs */
+ plugin::save();
+ /* Save arrays */
+ $this->attrs['gosaMailAlternateAddress'] = $this->gosaMailAlternateAddress;
+ $this->attrs['gosaMailForwardingAddress']= $this->gosaMailForwardingAddress;
- /* Remove attributes - if not needed */
- if (!preg_match('/V/', $this->gosaMailDeliveryMode)){
+ if(!$this->mailMethod->vacationRangeEnabled()){
+ $this->attrs['gosaVacationStart'] = $this->attrs['gosaVacationStop'] = array();
+ }elseif (!preg_match('/V/', $this->gosaMailDeliveryMode)){
unset($this->attrs['gosaVacationStart']);
unset($this->attrs['gosaVacationStop']);
}
+ /* Map method attributes */
+ $this->mailMethod->fixAttributesOnStore();
+
/* Save data to LDAP */
$ldap->cd($this->dn);
$this->cleanup();
- $ldap->modify ($this->attrs);
+ $ldap->modify ($this->attrs);
if (!$ldap->success()){
msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
}
- /* Log last action */
+ /* 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{
/* Only do IMAP actions if we are not a template */
if (!$this->is_template){
+ $this->mailMethod->connect();
+ if(!$this->mailMethod->is_connected()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot connect mail method! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }else{
+ if(!$this->mailMethod->updateMailbox()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot update mailbox! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }
+ if(!$this->mailMethod->setQuota($this->gosaMailQuota)){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot write quota settings! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
+ }
- if ($method->connect($this->gosaMailServer)){
- $method->updateMailbox($this->user_prefix.$this->$id);
-
- $method->setQuota($this->user_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();
+ if (!is_integer(strpos($this->gosaMailDeliveryMode, "C"))){
+ if(!$this->mailMethod->saveSieveSettings()){
+ msg_dialog::display(_("Mail error"), $this->mailMethod->get_error(), ERROR_DIALOG);
}
+ }else{
+
+ echo "Check sieve management here";
+
+ @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,
+ "User uses an own sieve script, skipping sieve update.".$str."</b>","");
+ }
+
+ if(!$this->mailMethod->updateSharedFolder()){
+ msg_dialog::display(_("Mail error"), sprintf(_("Cannot update shared folder permissions! Error was: %s."),
+ $this->mailMethod->get_error()), ERROR_DIALOG);
}
}
}
+ $this->mailMethod->disconnect();
/* Optionally execute a command after we're done */
if ($this->initially_was_account == $this->is_account){
} else {
$this->handle_post_events("add", array("uid" => $this->uid));
}
-
- $this->updateSharedFolder();
}
- /* Check formular input */
+ /*! \brief Check given values
+ */
function check()
{
- if(!$this->is_account) return(array());
+ if(!$this->is_account){
+ return(array());
+ }
$ldap= $this->config->get_ldap_link();
$message[]= msgPool::noserver(_("Mail"));
}
- /* must: mail */
- if ($this->mail == ""){
+ /* Mail address checks */
+ $mail = $this->mail;
+ if($this->mailMethod->domainSelectionEnabled()){
+ $mail.= "@".$this->mailDomainPart;
+ }
+
+ if (empty($mail)){
$message[]= msgPool::required(_("Primary address"));
}
if ($this->is_template){
- if (!tests::is_email($this->mail, TRUE)){
+ if (!tests::is_email($mail, TRUE)){
$message[]= msgPool::invalid(_("Mail address"),"","","%givenName.%sn@your-domain.com");
}
} else {
- if (!tests::is_email($this->mail)){
- $message[]= msgPool::invalid(_("Mail address"),"","","your-domain@your-domain.com");
+ if (!tests::is_email($mail)){
+ $message[]= msgPool::invalid(_("Mail address"),"","","your-address@your-domain.com");
}
}
+ /* Check if this mail address is already in use */
$ldap->cd($this->config->current['BASE']);
$filter = "(&(!(objectClass=gosaUserTemplate))(!(uid=".$this->uid."))".
"(objectClass=gosaMailAccount)".
- "(|(mail=".$this->mail.")(alias=".$this->mail.")(gosaMailAlternateAddress=".$this->mail.")))";
-
+ "(|(mail=".$mail.")(alias=".$mail.")(gosaMailAlternateAddress=".$mail.")))";
$ldap->search($filter,array("uid"));
if ($ldap->count() != 0){
$message[]= msgPool::duplicated(_("Mail address"));
$message[]= msgPool::required(_("Spam folder"));
}
- if (preg_match('/V/', $this->gosaMailDeliveryMode) && $this->gosaVacationStart >= $this->gosaVacationStop){
+ if ($this->mailMethod->vacationRangeEnabled()
+ && preg_match('/V/', $this->gosaMailDeliveryMode)
+ && $this->gosaVacationStart > $this->gosaVacationStop){
$message[]= msgPool::invalid(_("Vacation interval"));
}
-
- return ($message);
+ return($message);
}
- /* Adapt from template, using 'dn' */
+ /*! \brief Adapt from template, using 'dn'
+ */
function adapt_from_template($dn, $skip= array())
{
plugin::adapt_from_template($dn, $skip);
}
- /* Add entry to forwarder list */
- function addForwarder($address)
+ /*! \brief Creates the mail part for the copy & paste dialog
+ */
+ function getCopyDialog()
{
- 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);
- }
- }
+ 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);
+ }
- /* Remove list of addresses from forwarder list */
- function delForwarder($addresses)
+
+ /*! \brief save_object for copy&paste vars
+ */
+ function saveCopyDialog()
{
- 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);
+ if(!$this->is_account) return;
+
+ /* Execute to save mailAlternateAddress && gosaMailForwardingAddress */
+ $this->execute();
+ if(isset($_POST['mail'])){
+ $this->mail = $_POST['mail'];
}
}
-
- /* 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)
+
+ /*! \brief Prepare this account to be copied
+ */
+ function PrepareForCopyPaste($source)
{
- 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=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=$address)".
- "(alias=$address)(gosaMailAlternateAddress=$address)))", array("uid"));
+ plugin::PrepareForCopyPaste($source);
- if ($ldap->count() > 0){
- $attrs= $ldap->fetch ();
- return ($attrs["uid"][0]);
- }
+ /* Reset alternate mail addresses */
+ $this->gosaMailAlternateAddress = array();
+ }
- /* 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 ($this->config->get_cfg_value("mailmethod") != ""){
- $method= $this->config->get_cfg_value("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 settings 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
+ /*! \brief Prepare this class the be useable when editing multiple users at once
*/
- 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(
"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)){
}
}
}
-
$ret['flag_add'] = $flag_add;
$ret['flag_remove'] = $flag_remove;
return($ret);
}
+ /*! \brief Check given input for multiple user edit
+ */
function multiple_check()
{
$message = plugin::multiple_check();
}
if ( in_array("use_vacation",$this->multi_boxes) &&
- preg_match('/V/', $this->gosaMailDeliveryMode) && $this->gosaVacationStart > $this->gosaVacationStop){
+ preg_match('/V/', $this->gosaMailDeliveryMode) && $this->gosaVacationStart > $this->gosaVacationStop){
$message[]= msgPool::invalid(_("Vacation interval"));
}
return($message);
}
-
+
+ /*! \brief ...
+ */
function set_multi_edit_values($values)
{
plugin::set_multi_edit_values($values);
}
$this->gosaMailDeliveryMode = "[".$tmp."]";
- /* Set vacation message and replace placeholder like %givenName
+ /* Set vacation message and replace placeholder like %givenName
*/
if(isset($values['gosaVacationMessage'])){
$this->gosaVacationMessage = $this->prepare_vacation_template($values['gosaVacationMessage']);
}
}
+
+
+ /*! \brief Initialize plugin to be used as multiple edit class.
+ */
+ function init_multiple_support($attrs,$all)
+ {
+ plugin::init_multiple_support($attrs,$all);
+ if(isset($this->multi_attrs['gosaMailQuota'])){
+ $this->gosaMailQuota = $this->multi_attrs['gosaMailQuota'];
+ }
+ }
+
+
+ /*! \brief
+ */
+ function get_multi_init_values()
+ {
+ $attrs = plugin::get_multi_init_values();
+ $attrs['gosaMailQuota'] = $this->gosaMailQuota;
+ return($attrs);
+ }
+
+
+ /*! \brief Display multiple edit dialog
+ */
+ function multiple_execute()
+ {
+ return($this->execute());
+ }
+
+
+ /*! \brief Save posts from multiple edit dialog
+ */
+ 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;
+ }
+ }
+ }
+
+
+ /*! \brief Creates the user names for the add_local_forward 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);
+ }
+
+
+ /*! \brief ACL settings
+ */
+ 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
+ ));
+ }
+
+
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
diff --git a/gosa-plugins/mail/personal/mail/generic.tpl b/gosa-plugins/mail/personal/mail/generic.tpl
index 1dcde3f9d1b19f443f2e5dcfdb021f8e115a71ac..af073b5905e4afb892c7f1f72dfefefd47014abf 100644 (file)
<tr>
<td><label for="mail">{t}Primary address{/t}</label>{$must}</td>
<td>
-{if $multiple_support}
- <input id="mail" name="dummy1" size=35 maxlength=65 value="{t}Multiple edit{/t}" disabled>
-{else}
-{render acl=$mailACL}
- <input id="mail" name="mail" size=35 maxlength=65 value="{$mail}">
-{/render}
-{/if}
+ {if $domainSelectionEnabled}
+ {render acl=$mailACL}
+ <input id="mail" name="mail" size=20 maxlength=65 value="{$mail}">
+ {/render}
+ @<select name='MailDomain'>
+ {html_options values=$MailDomains output=$MailDomains selected=$MailDomain}
+ </select>
+ {else}
+ {render acl=$mailACL}
+ <input id="mail" name="mail" size=35 maxlength=65 value="{$mail}">
+ {/render}
+ {/if}
</td>
</tr>
<tr>
<td><label for="gosaMailServer">{t}Server{/t}</label></td>
<td>
-{render acl=$gosaMailServerACL checkbox=$multiple_support checked=$use_gosaMailServer}
+{render acl=$gosaMailServerACL}
<select size="1" id="gosaMailServer" name="gosaMailServer" title="{t}Specify the mail server where the user will be hosted on{/t}">
- {html_options values=$mailServers output=$mailServers selected=$gosaMailServer}
- <option disabled> </option>
+ {html_options values=$MailServers output=$MailServers selected=$gosaMailServer}
+ <option disabled> </option>
</select>
{/render}
</td>
</tr>
-{if !$multiple_support}
- <tr>
- <td>
- <br>
- {t}Quota usage{/t}
- </td>
- <td>
- <br>
- {if $quotadefined eq "true"}
- {$quotausage}
- {else}
- {t}not defined{/t}
- {/if}
+
+ <tr>
+ <td>
</td>
</tr>
-{/if}
- <tr>
- <td><label for="gosaMailQuota">{t}Quota size{/t}</label></td>
- <td>
-{render acl=$gosaMailQuotaACL checkbox=$multiple_support checked=$use_gosaMailQuota}
- <input id="gosaMailQuota" name="gosaMailQuota" size="6" align="middle" maxlength="60"
+{if $quotaEnabled}
+ <tr>
+ <td>{t}Quota usage{/t}</td>
+ <td>{$quotaUsage}</td>
+ </tr>
+ <tr>
+ <td><label for="gosaMailQuota">{t}Quota size{/t}</label></td>
+ <td>
+{render acl=$gosaMailQuotaACL}
+ <input id="gosaMailQuota" name="gosaMailQuota" size="6" align="middle" maxlength="60"
value="{$gosaMailQuota}"> MB
-{/render}
- </td>
- </tr>
- </table>
+ {/render}
+ </td>
+ </tr>
+{/if}
+ </table>
</td>
-
-{if !$multiple_support}
-
<td style="border-left:1px solid #A0A0A0;vertical-align:top;">
-
+
</td>
- <td>
- <h2><img class="center" alt="" align="middle" src="plugins/mail/images/alternatemail.png" /><label for="alternates_list"> {t}Alternative addresses{/t}</label></h2>
+ <td>
+ <h2><img class="center" alt="" align="middle" src="plugins/mail/images/alternatemail.png" /><label for="alternates_list"> {t}Alternative addresses{/t}</ label></h2>
{render acl=$gosaMailAlternateAddressACL}
- <select id="alternates_list" style="width:100%;height:100px;" name="alternates_list[]" size="15" multiple
- title="{t}List of alternative mail addresses{/t}">
- {html_options values=$gosaMailAlternateAddress output=$gosaMailAlternateAddress}
- <option disabled> </option>
+ <select id="alternates_list" style="width:100%;height:100px;" name="alternates_list[]" size="15" multiple
+ title="{t}List of alternative mail addresses{/t}">
+ {html_options values=$gosaMailAlternateAddress output=$gosaMailAlternateAddress}
+ <option disabled> </option>
{/render}
</select>
<br />
<input type=submit value="{msgPool type=delButton}" name="delete_alternate">
{/render}
</td>
-
-{/if}
-
</tr>
-</table>
-
-{if $multiple_support}
-
-<p class="seperator"> </p>
-<h2><img class="center" alt="" align="middle" src="plugins/mail/images/envelope.png" /> {t}Mail options{/t}</h2>
-
-{else}
-
-<!-- SIEVE -->
-<p class="seperator"> </p>
-<table summary="" style="vertical-align:top; text-align:left;" cellpadding=4 border=0>
<tr>
- <td>
+ <td colspan="3">
+ <p class="seperator"> </p>
+ <table summary="" style="vertical-align:top; text-align:left;" cellpadding=4 border=0>
+ <tr>
+ <td>
{render acl=$gosaMailDeliveryModeCACL}
- <input class="center" type=checkbox name="own_script" value="1" {$own_script}
- onClick="
- changeState('sieveManagement');
- changeState('drop_own_mails');
- changeState('use_vacation');
- changeState('use_spam_filter');
- changeState('use_mailsize_limit');
- changeState('import_vacation');
- changeState('vacation_template');
-// changeState('forward_address');
-// changeState('add_forwarder');
-// changeState('add_local_forwarder');
-// changeState('delete_forwarder');
- changeState('only_local');
- changeState('gosaVacationMessage');
- changeState('gosaSpamSortLevel');
- changeState('gosaSpamMailbox');
- changeState('gosaMailMaxSize');
- changeStates();
-
- "
-
-> {t}Use custom sieve script{/t} <b>({t}disables all Mail options!{/t})</b>
+ <input class="center" type=checkbox name="own_script" value="1" {$own_script}
+ onClick="
+ changeState('sieveManagement');
+ changeState('drop_own_mails');
+ changeState('use_vacation');
+ changeState('use_spam_filter');
+ changeState('use_mailsize_limit');
+ changeState('import_vacation');
+ changeState('vacation_template');
+ changeState('only_local');
+ changeState('gosaVacationMessage');
+ changeState('gosaSpamSortLevel');
+ changeState('gosaSpamMailbox');
+ changeState('gosaMailMaxSize');
+ changeStates();"> {t}Use custom sieve script{/t} <b>({t}disables all Mail options!{/t})</b>
{/render}
+ </td>
+ </tr>
+{if $allowSieveManagement}
+ <tr>
+ <td>
+{render acl=$sieveManagementACL}
+ <input {if $own_script == ""} disabled {/if} id='sieveManagement' type='submit' name='sieveManagement' value='{t}Sieve Management{/t}'>
+{/render}
+ </td>
+ </tr>
+{/if}
+ </table>
</td>
</tr>
<tr>
- <td>
-{render acl=$sieveManagementACL}
- <input {if $own_script == ""} disabled {/if} id='sieveManagement' type='submit' name='sieveManagement' value='{t}Sieve Management{/t}'>
-{/render}
+ <td colspan="3">
+ <p class="seperator"> </p>
</td>
</tr>
</table>
-<p class="seperator"> </p>
-{/if}
-
<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4 border=0>
<tr style="padding-bottom:0px;">
<td style="width:50%">
{render acl=$gosaMailDeliveryModeIACL checkbox=$multiple_support checked=$use_drop_own_mails}
- <input {if $own_script != ""} disabled {/if} class="center" id='drop_own_mails' type=checkbox name="drop_own_mails" value="1" {$drop_own_mails} title="{t}Select if you want to forward mails without getting own copies of them{/t}"> {t}No delivery to own mailbox{/t}
+ <input {if $own_script != ""} disabled {/if} class="center" id='drop_own_mails'
+ type=checkbox name="drop_own_mails" value="1" {$drop_own_mails}
+ title="{t}Select if you want to forward mails without getting own copies of them{/t}"> {t}No delivery to own mailbox{/t}
{/render}
+ <br>
-<br>
{render acl=$gosaMailDeliveryModeVACL checkbox=$multiple_support checked=$use_use_vacation}
- <input type=checkbox name="use_vacation" value="1" {$use_vacation} id="use_vacation" {if $own_script != ""} disabled {/if}
- title="{t}Select to automatically response with the vacation message defined below{/t}" class="center"
-onclick="changeState('day'); changeState('month'); changeState('year'); changeState('sday'); changeState('smonth'); changeState('syear');
-"> {t}Activate vacation message{/t}
+ <input type=checkbox name="use_vacation" value="1" {$use_vacation}
+ id="use_vacation" {if $own_script != ""} disabled {/if}
+ title="{t}Select to automatically response with the vacation message defined below{/t}" class="center"
+ onclick="changeState('day'); changeState('month'); changeState('year');
+ changeState('sday'); changeState('smonth'); changeState('syear');"> {t}Activate vacation message{/t}
{/render}
<br>
- <table>
- <tr>
- <td>
- {t}from{/t}
- </td>
- <td>
+{if $rangeEnabled}
+ <table>
+ <tr>
+ <td>{t}from{/t}</td>
+ <td>
{render acl=$gosaVacationMessageACL}
- <select {if $own_script != ""} disabled {/if} name=day id="day" onChange="createResult(this.form,this.form.gosaVacationStart);" {$rangeEnabled}>
- {html_options values=$days output=$days selected=$start_day}
- </select>
+ <select {if $own_script != "" || $use_vacation == ""} disabled {/if} name=day id="day"
+ onChange="createResult(this.form,this.form.gosaVacationStart);">
+ {html_options values=$days output=$days selected=$start_day}
+ </select>
{/render}
{render acl=$gosaVacationMessageACL}
- <select {if $own_script != ""} disabled {/if} name=month id="month" onChange="populate(this.form,this.form.gosaVacationStart);" {$rangeEnabled}>
- {html_options options=$months selected=$start_month}
- </select>
+ <select {if $own_script != "" || $use_vacation == ""} disabled {/if} name=month id="month"
+ onChange="populate(this.form,this.form.gosaVacationStart);">
+ {html_options options=$months selected=$start_month}
+ </select>
{/render}
{render acl=$gosaVacationMessageACL}
- <select {if $own_script != ""} disabled {/if} name=year id="year" onChange="populate(this.form,this.form.gosaVacationStart);" {$rangeEnabled}>
- {html_options values=$years output=$years selected=$start_year}
- </select>
+ <select {if $own_script != "" || $use_vacation == ""} disabled {/if} name=year id="year"
+ onChange="populate(this.form,this.form.gosaVacationStart);">
+ {html_options values=$years output=$years selected=$start_year}
+ </select>
{/render}
- <input type="hidden" name="gosaVacationStart" value="{$gosaVacationStart}">
- </td>
- </tr>
- <tr>
- <td>
- {t}till{/t}
- </td>
- <td>
+ <input type="hidden" name="gosaVacationStart" value="{$gosaVacationStart}">
+ </td>
+ </tr>
+ <tr>
+ <td>{t}till{/t}</td>
+ <td>
{render acl=$gosaVacationMessageACL}
- <select {if $own_script != ""} disabled {/if} name=sday id="sday" onChange="createResult2(this.form,this.form.gosaVacationStop);" {$rangeEnabled}>
+ <select {if $own_script != "" || $use_vacation == ""} disabled {/if} name=sday id="sday"
+ onChange="createResult2(this.form,this.form.gosaVacationStop);">
{html_options values=$days output=$days selected=$end_day}
- </select>
+ </select>
{/render}
{render acl=$gosaVacationMessageACL}
- <select {if $own_script != ""} disabled {/if} name=smonth id="smonth" onChange="populate2(this.form,this.form.gosaVacationStop);" {$rangeEnabled}>
+ <select {if $own_script != "" || $use_vacation == ""} disabled {/if} name=smonth id="smonth"
+ onChange="populate2(this.form,this.form.gosaVacationStop);">
{html_options options=$months selected=$end_month}
- </select>
+ </select>
{/render}
{render acl=$gosaVacationMessageACL}
- <select {if $own_script != ""} disabled {/if} name=syear id="syear" onChange="populate2(this.form,this.form.gosaVacationStop);" {$rangeEnabled}>
+ <select {if $own_script != "" || $use_vacation == ""} disabled {/if} name=syear id="syear"
+ onChange="populate2(this.form,this.form.gosaVacationStop);">
{html_options values=$years output=$years selected=$end_year}
- </select>
+ </select>
{/render}
- <input type="hidden" name="gosaVacationStop" value="{$gosaVacationStop}">
- </td>
- </tr>
- </table>
-
-
- <td rowspan=2 style="border-left:1px solid #A0A0A0">
-
- </td>
- <td style="vertical-align:top;">
+ <input type="hidden" name="gosaVacationStop" value="{$gosaVacationStop}">
+ </td>
+ </tr>
+ </table>
+{/if}
+ <td rowspan=2 style="border-left:1px solid #A0A0A0"> </td>
+ <td style="vertical-align:top;">
{render acl=$gosaMailDeliveryModeSACL checkbox=$multiple_support checked=$use_use_spam_filter}
- <input {if $own_script != ""} disabled {/if} id='use_spam_filter' type=checkbox name="use_spam_filter" value="1" {$use_spam_filter} title="{t}Select if you want to filter this mails through spamassassin{/t}" class="center">
+ <input {if $own_script != ""} disabled {/if} id='use_spam_filter' type=checkbox name="use_spam_filter"
+ value="1" {$use_spam_filter} title="{t}Select if you want to filter this mails through spamassassin{/t}" class="center">
{/render}
- <label for="gosaSpamSortLevel">{t}Move mails tagged with spam level greater than{/t}</label>
-
+ <label for="gosaSpamSortLevel">{t}Move mails tagged with spam level greater than{/t}</label>
{render acl=$gosaSpamSortLevelACL checkbox=$multiple_support checked=$use_gosaSpamSortLevel}
- <select {if $own_script != ""} disabled {/if} id="gosaSpamSortLevel" size="1" name="gosaSpamSortLevel" title="{t}Choose spam level - smaller values are more sensitive{/t}">
- {html_options values=$spamlevel output=$spamlevel selected=$gosaSpamSortLevel}
- </select>
+ <select {if $own_script != ""} disabled {/if} id="gosaSpamSortLevel" size="1" name="gosaSpamSortLevel"
+ title="{t}Choose spam level - smaller values are more sensitive{/t}">
+ {html_options values=$spamlevel output=$spamlevel selected=$gosaSpamSortLevel}
+ </select>
{/render}
- <label for="gosaSpamMailbox">{t}to folder{/t}</label>
+ <label for="gosaSpamMailbox">{t}to folder{/t}</label>
{render acl=$gosaSpamMailboxACL checkbox=$multiple_support checked=$use_gosaSpamMailbox}
- <select {if $own_script != ""} disabled {/if} size="1" id="gosaSpamMailbox" name="gosaSpamMailbox">
- {html_options values=$spambox output=$spambox selected=$gosaSpamMailbox}
- <option disabled> </option>
- </select>
+ <select {if $own_script != ""} disabled {/if} size="1" id="gosaSpamMailbox" name="gosaSpamMailbox">
+ {html_options values=$spambox output=$spambox selected=$gosaSpamMailbox}
+ <option disabled> </option>
+ </select>
{/render}
- <br>
+ <br>
{render acl=$gosaMailDeliveryModeRACL checkbox=$multiple_support checked=$use_use_mailsize_limit}
- <input {if $own_script != ""} disabled {/if} id='use_mailsize_limit' type=checkbox name="use_mailsize_limit" value="1" {$use_mailsize_limit} class="center">
+ <input {if $own_script != ""} disabled {/if} id='use_mailsize_limit' type=checkbox
+ name="use_mailsize_limit" value="1" {$use_mailsize_limit} class="center">
{/render}
- <label for="gosaMailMaxSize">{t}Reject mails bigger than{/t}</label>
+ <label for="gosaMailMaxSize">{t}Reject mails bigger than{/t}</label>
{render acl=$gosaMailMaxSizeACL checkbox=$multiple_support checked=$use_gosaMailMaxSize}
- <input {if $own_script != ""} disabled {/if} id="gosaMailMaxSize" name="gosaMailMaxSize" size="6" align="middle" maxlength="30" value="{$gosaMailMaxSize}" class="center"> {t}MB{/t}
+ <input {if $own_script != ""} disabled {/if} id="gosaMailMaxSize" name="gosaMailMaxSize"
+ size="6" align="middle" maxlength="30" value="{$gosaMailMaxSize}" class="center"> {t}MB{/t}
{/render}
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top; width:45%">
- <p style="margin-bottom:0px;">
- <b><label for="gosaVacationMessage">{t}Vacation message{/t}</label></b>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top; width:45%">
+ <p style="margin-bottom:0px;">
+ <b><label for="gosaVacationMessage">{t}Vacation message{/t}</label></b>
</p>
{render acl=$gosaVacationMessageACL checkbox=$multiple_support checked=$use_gosaVacationMessage}
- <textarea {if $own_script != ""} disabled {/if} id="gosaVacationMessage" style="width:99%; height:100px;" name="gosaVacationMessage" rows="4" cols="512">{$gosaVacationMessage}</textarea>
+ <textarea {if $own_script != ""} disabled {/if} id="gosaVacationMessage" style="width:99%; height:100px;"
+ name="gosaVacationMessage" rows="4" cols="512">{$gosaVacationMessage}</textarea>
{/render}
- <br>
+ <br>
- {if $show_templates eq "true"}
-{render acl=$gosaVacationMessageACL}
- <select id='vacation_template' name="vacation_template" {if $own_script != ""} disabled {/if}>
- {html_options options=$vacationtemplates selected=$template}
- <option disabled> </option>
- </select>
-{/render}
-{render acl=$gosaVacationMessageACL}
- <input {if $own_script != ""} disabled {/if} id='import_vacation' type="submit" value="{t}Import{/t}" name="import_vacation">
-{/render}
- {/if}
- </td>
+{if $show_templates eq "true"}
+ {render acl=$gosaVacationMessageACL}
+ <select id='vacation_template' name="vacation_template" {if $own_script != ""} disabled {/if}>
+ {html_options options=$vacationtemplates selected=$template}
+ <option disabled> </option>
+ </select>
+ {/render}
+ {render acl=$gosaVacationMessageACL}
+ <input {if $own_script != ""} disabled {/if} id='import_vacation' type="submit" value="{t}Import{/t}" name="import_vacation">
+ {/render}
+{/if}
+ </td>
<td>
<p style="margin-bottom:0px;">
<b><label for="forwarder_list">{t}Forward messages to{/t}</label></b>
</p>
{if $multiple_support}
-<input type="checkbox" name="use_gosaMailForwardingAddress" onclick="changeState('gosaMailForwardingAddress');"
- class="center" {if $use_gosaMailForwardingAddress} checked {/if}>
+ <input type="checkbox" name="use_gosaMailForwardingAddress" onclick="changeState('gosaMailForwardingAddress');"
+ class="center" {if $use_gosaMailForwardingAddress} checked {/if}>
{/if}
{render acl=$gosaMailForwardingAddressACL}
<select {if $use_gosaMailForwardingAddress} checked {/if}
- id="gosaMailForwardingAddress" style="width:100%; height:100px;" name="forwarder_list[]" size=15 multiple>
- {html_options values=$gosaMailForwardingAddress output=$gosaMailForwardingAddress selected=$template}
- <option disabled> </option>
+ id="gosaMailForwardingAddress" style="width:100%; height:100px;" name="forwarder_list[]" size=15 multiple>
+ {html_options values=$gosaMailForwardingAddress output=$gosaMailForwardingAddress selected=$template}
+ <option disabled> </option>
</select>
{/render}
- <br>
+ <br>
{render acl=$gosaMailForwardingAddressACL}
- <input id='forward_address' name="forward_address" size=20 align="middle" maxlength=65 value="">
+ <input id='forward_address' name="forward_address" size=20 align="middle" maxlength=65 value="">
{/render}
{render acl=$gosaMailForwardingAddressACL}
- <input id='add_forwarder' type="submit" value="{msgPool type=addButton}" name="add_forwarder" >
+ <input id='add_forwarder' type="submit" value="{msgPool type=addButton}" name="add_forwarder" >
{/render}
{render acl=$gosaMailForwardingAddressACL}
- <input id='add_local_forwarder' type="submit" value="{t}Add local{/t}" name="add_local_forwarder" >
+ <input id='add_local_forwarder' type="submit" value="{t}Add local{/t}" name="add_local_forwarder" >
{/render}
{render acl=$gosaMailForwardingAddressACL}
- <input id='delete_forwarder' type="submit" value="{msgPool type=delButton}" name="delete_forwarder">
+ <input id='add_local_forwarder' type="submit" value="{t}Add local{/t}" name="add_local_forwarder" >
{/render}
- </td>
- </tr>
-</table>
+{render acl=$gosaMailForwardingAddressACL}
+ <input id='delete_forwarder' type="submit" value="{msgPool type=delButton}" name="delete_forwarder">
+{/render}
+ </td>
+ </tr>
+ </table>
<p class="seperator"> </p>
<h2><img class="center" alt="" align="middle" src="images/false.png" /> {t}Advanced mail options{/t}</h2>
-
<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding="4" border="0">
<tr>
<td>
{render acl=$gosaMailDeliveryModeLACL checkbox=$multiple_support checked=$use_only_local}
- <input {if $own_script != ""} disabled {/if} id='only_local' type=checkbox name="only_local" value="1" {$only_local} title="{t}Select if user can only send and receive inside his own domain{/t}" class="center">
+ <input {if $own_script != ""} disabled {/if} id='only_local' type=checkbox name="only_local"
+ value="1" {$only_local} title="{t}Select if user can only send and receive inside his own domain{/t}" class="center">
{/render}
{t}User is only allowed to send and receive local mails{/t}
</td>
@@ -330,7 +325,6 @@ onclick="changeState('day'); changeState('month'); changeState('year'); changeSt
changeSubselectState('use_vacation','syear');
}
}
-
{/literal}
<!-- // First input field on page