From: cajus Date: Thu, 17 Jan 2008 08:55:01 +0000 (+0000) Subject: Moved kolab stuff X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f505a192726df94d10aaf250c5bbcbca74eae77a;p=gosa.git Moved kolab stuff git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8436 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/admin/systems/services/kolab/class_servKolab.inc b/gosa-core/plugins/admin/systems/services/kolab/class_servKolab.inc deleted file mode 100644 index 08b75ea86..000000000 --- a/gosa-core/plugins/admin/systems/services/kolab/class_servKolab.inc +++ /dev/null @@ -1,415 +0,0 @@ -"Eins ist toll", "zwei"=>"Zwei ist noch besser"); - - var $postfix_mydomain = ""; - var $cyrus_admins = ""; - var $postfix_mydestination = ""; - var $postfix_mynetworks = "127.0.0.1/8"; - var $postfix_enable_virus_scan = "TRUE"; - var $postfix_relayhost = ""; - var $postfix_mxrelayenabled = true; - var $postfix_allow_unauthenticated = "FALSE"; - var $cyrus_quotawarn = "80"; - var $kolabFreeBusyFuture = "1"; - var $k = "kolab"; - var $cyrus_imap = "TRUE"; - var $cyrus_pop3 = "FALSE"; - var $cyrus_imaps = "TRUE"; - var $cyrus_pop3s = "TRUE"; - var $cyrus_sieve = "TRUE"; - var $apache_allow_unauthenticated_fb = "TRUE"; - var $proftpd_ftp = "FALSE"; - var $apache_http = "TRUE"; - var $kolabHost = array(); - var $orig_cn = ""; - var $view_logged = FALSE; - - var $attributes = array("postfix_mydomain", "postfix_mydestination", "proftpd_ftp", "k", - "postfix_mynetworks", "postfix_enable_virus_scan", "postfix_relayhost", "apache_http", - "postfix_allow_unauthenticated", "cyrus_admins", "cyrus_imap","kolabFreeBusyFuture", - "cyrus_pop3", "cyrus_imaps", "cyrus_pop3s", "cyrus_sieve", "apache_allow_unauthenticated_fb", - "cyrus_quotawarn"); - var $objectclasses = array("top", "kolab"); - - /* Serverservice vars */ - var $conflicts = array("goImapServer","goMailServer"); - var $DisplayName = "Kolab mail service"; - var $StatusFlag = ""; - - function servkolab(&$config, $dn = NULL, $parent= NULL) - { - /* Setting the hostname and tell this Plugin that we are the kolab extension*/ - $this->hostname = preg_replace('/^cn=([^,]+),.*$/', '\1', $dn); - $this->dn = "k=kolab,".$config->current['BASE']; - - /* Load variables, if given*/ - plugin::plugin($config, $this->dn); - - /* Copy needed attributes */ - foreach($this->attributes as $val) { - $name = preg_replace('/_/', '-', $val); - if (isset($this->attrs["$name"][0])) { - $this->$val = $this->attrs["$name"][0]; - } - } - - /* Toggle relayhost */ - $this->postfix_mxrelayenabled = preg_match('/^\[/', $this->postfix_relayhost); - $this->postfix_relayhost = preg_replace("/[\[\]]/","",$this->postfix_relayhost); - - /* Is this Server a member of the Kolab extension or not ?*/ - if(isset($this->attrs['kolabHost'])) { - $this->kolabHost= $this->attrs['kolabHost']; - unset($this->kolabHost['count']); - } - $this->is_account = false; - $this->initially_was_account = false; - foreach($this->kolabHost as $host){ - if($this->hostname == $host){ - $this->is_account = true; - $this->initially_was_account = true; - } - } - } - - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } - - /*************** - Variable initialisation - ***************/ - - $smarty = get_smarty(); - $display = ""; - $ldap = $this->config->get_ldap_link(); - - - /* Assemble free/busy string */ - $edit = sprintf('', - $this->kolabFreeBusyFuture); - $fbfuture = sprintf(_("Include data from %s days in the past when creating free/busy lists"), $edit); - - /* Assemble quota string */ - $edit = sprintf('', - $this->cyrus_quotawarn); - $quotastr = sprintf(_("Warn users when using more than %s%% of their mail quota"), $edit); - - /*************** - Assign informations to smarty - ***************/ - - /* Set relayhost and if we have MX lookup enabled*/ - if($this->postfix_mxrelayenabled) { - $smarty->assign("RelayMxSupportCheck"," checked "); - } else { - $smarty->assign("RelayMxSupportCheck",""); - } - - /* Set acls */ - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); - } - - /* Initialize all attributes, that were submitted */ - foreach($this->attributes as $val) - { - /* Tell smarty which variables we are useing */ - $smarty->assign($val, $this->$val); - if (($this->$val != "FALSE") && !empty($this->$val)){ - $smarty->assign($val."Check", "checked"); - } else { - $smarty->assign($val."Check", ""); - } - } - - $smarty->assign("fbfuture", $fbfuture); - $smarty->assign("quotastr", $quotastr); - - /* Load Template */ - $display.=$smarty->fetch(get_template_path('servkolab.tpl', TRUE)); - return ($display); - } - - function remove_from_parent() - { - - /* Remove status flag, it is not a memeber of - this->attributes, so ensure that it is deleted too */ - if(!empty($this->StatusFlag)){ - $this->attrs[$this->StatusFlag] = array(); - } - - - /* Only walk through following code, if this host - was a member of the kolab hosts, else skip this */ - if(!$this->initially_was_account){ - return; - } - - /* !!! Don't use "cn" in this function - hostname -> the initial name of the host - cn -> is the new name of the host, in case that it was renamed. - */ - - $ldap = $this->config->get_ldap_link(); - $this->dn = "k=kolab,".$this->config->current['BASE']; - - /* We can't simply remove the whole entry, it is possible that there are - some other hosts assigned to this object. - So, first of all check if we are the last host entry within the host - : Remove k=kolab entry - if we aren't alone, only remove host name from hosts entry and save */ - /* Are we alone? Remove complete entry... */ - - /* Check if we are definitly in kolabHosts */ - if(!in_array_ics($this->hostname,$this->kolabHost)) { - return; - } - - /* Integration check, not translated because they can't pop up at all, only for debug */ - if(count($this->kolabHost) == 0){ - print_red("Server - Kolab tab : This is not possible, we can't remove an account which doesn't exists."); - return; - } - if(!isset($this->hostname) || (empty($this->hostname))){ - print_red("The required attribute hostname seams to empty."); - } - - /* Our hostname is in kolabHosts and there is a only one entry - = we are the last host entry, delete k=kolab entry */ - if (count($this->kolabHost) == 1){ - - /* Remove complete entry */ - $ldap->rmdir ($this->dn); - show_ldap_error($ldap->get_error(), sprintf(_("Removing host entry from system server/kolab with dn '%s' failed."),$this->dn)); - } else { - - /* Only modify kolabHost */ - $hosts= array(); - foreach ($this->kolabHost as $host){ - if($host != $this->hostname){ - $hosts[]= $host; - } - } - $attrs= array('kolabHost' => $hosts); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Removing host entry from system server/kolab with dn '%s' failed."),$this->dn)); - } - - new log("remove","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - /* Optionally execute a command after we're done */ - $this->handle_post_events("remove"); - } - - - function save_object() - { - if (isset($_POST['kolabtab'])){ - plugin::save_object(); - - - foreach($this->attributes as $attr){ - if(($this->acl_is_writeable(preg_replace("/_/","",$attr))) && (isset($_POST[$attr]))){ - $this->$attr = $_POST[$attr]; - } - } - - /* Save checkboxes */ - foreach (array( "postfix_enable_virus_scan", "postfix_allow_unauthenticated", - "cyrus_imap", "cyrus_pop3", "cyrus_imaps", - "cyrus_pop3s", "cyrus_sieve", "apache_allow_unauthenticated_fb", - "proftpd_ftp", "apache_http") as $cb){ - - if($this->acl_is_writeable(preg_replace("/_/","",$cb))){ - if (isset($_POST[$cb])){ - $this->$cb= "TRUE"; - } else { - $this->$cb= "FALSE"; - } - } - } - - /* Toggell relay check */ - if($this->acl_is_writeable("postfixmxrelayenabled")){ - $this->postfix_mxrelayenabled= isset($_POST['RelayMxSupport']); - } - } - - } - - - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if(($this->kolabFreeBusyFuture=="")) { - $message[] = _("Future days in Free/Busy settings must be set."); - }elseif(!tests::is_uid($this->kolabFreeBusyFuture) || $this->kolabFreeBusyFuture < 0){ - $message[] = _("Future days in Free/Busy settings must be a positive value."); - } - - if(!is_int((int)($this->cyrus_quotawarn))) { - $message[] = _("The given Quota settings value must be a number."); - }elseif(!(($this->cyrus_quotawarn<=100)&&($this->cyrus_quotawarn>=0))){ - $message[] = _("Please choose a value between 1 and 100 for Quota settings."); - }elseif(strcasecmp($this->cyrus_quotawarn,(int)$this->cyrus_quotawarn)){ - $message[] = _("Future days must be a value."); - } - - if(empty($this->postfix_mynetworks)) { - $message[] = _("No SMTP privileged networks set."); - } - - /*if(empty($this->postfix_relayhost)) { - $message[] = _("No SMTP smarthost/relayhost set."); - } - */ - - return ($message); - } - - - /* Save to LDAP */ - function save() - { - /* Set ldap connection */ - $ldap = $this->config->get_ldap_link(); - - /* Open current dn*/ - $this->dn = "k=kolab,".$this->config->current['BASE']; - - /* Adapt relayhost */ - $this->postfix_relayhost= preg_replace('/[\[\]]/', '', $this->postfix_relayhost); - if ($this->postfix_mxrelayenabled && $this->postfix_relayhost != ""){ - $this->postfix_relayhost= "[".$this->postfix_relayhost."]"; - } - - /* Check if this server was renamed, in this case we have to remove old cn first*/ - if($this->hostname != $this->cn){ - $tmp = array(); - if(in_array_ics($this->hostname,$this->kolabHost)){ - foreach($this->kolabHost as $host){ - if($host != $this->hostname){ - $tmp[] = $host; - } - } - $this->kolabHost = $tmp; - } - } - - /* Add ourselves to the list of kolabHost's if needed */ - if (!in_array_ics($this->cn,$this->kolabHost)){ - $this->kolabHost[]= $this->cn; - } - - /* Call parents save to prepare $this->attrs */ - plugin::save(); - - /* Save or modify? */ - $ldap->cat($this->dn, array('dn')); - if (!$ldap->fetch()){ - $mode= "add"; - } else { - $mode= "modify"; - } - - /* Do attribute conversion */ - foreach ($this->attrs as $key => $value){ - if (preg_match('/_/', $key)){ - $old_key= $key; - $key= preg_replace('/_/', '-', $key); - $this->attrs[$key]= $value; - unset($this->attrs[$old_key]); - } - } - /* Add kolab hosts */ - $this->attrs['kolabHost']= $this->kolabHost; - - /* Perform LDAP action */ - $ldap->cd($this->dn); - $this->cleanup();; - $ldap->$mode($this->attrs); - - if($mode == "add"){ - new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving system server/kolab with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - if ($this->initially_was_account == $this->is_account) { - if ($this->is_modified) { - $this->handle_post_events("modify"); - } - } else { - $this->handle_post_events("add"); - } - } - - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("Kolab mail service"); - $fields['AllowEdit'] = true; - return($fields); - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Kolab"), - "plDescription" => _("Kolab mail service")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 85, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - "postfixmydomain" => _("Postfix mydomain") , - "postfixmydestination" => _("My destination") , - "cyrusadmins" => _("Cyrus admins") , - "proftpdftp" => _("FTP FreeBusy service") , - "postfixmynetworks" => _("SMTP privileged networks") , - "postfixenablevirusscan" => _("Enable virus scan") , - "postfixrelayhost" => _("Relayhost") , - "postfixmxrelayenabled" => _("Enable MX lookup for relayhost"), - "apachehttp" => _("HTTP FreeBusy service") , - "apacheallowunauthenticatedfb" => _("Allow unauthenticated free busy"), - "postfixallowunauthenticated" => _("Accept Internet Mail") , - "cyrusimap" => _("IMAP service") , - "kolabFreeBusyFuture" => _("kolabFreeBusyFuture") , - "cyruspop3" => _("POP3 service") , - "cyrusimaps" => _("IMAP/SSL service") , - "cyruspop3s" => _("POP3/SSL service") , - "cyrussieve" => _("Sieve service") , - "cyrusquotawarn" => _("Quota settings")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-core/plugins/admin/systems/services/kolab/servkolab.tpl b/gosa-core/plugins/admin/systems/services/kolab/servkolab.tpl deleted file mode 100644 index ec83b7801..000000000 --- a/gosa-core/plugins/admin/systems/services/kolab/servkolab.tpl +++ /dev/null @@ -1,249 +0,0 @@ - - - - - -
- - - - - - - - - - - - - - - - -
{t}Generic{/t}
{t}Postfix mydomain{/t} - -{render acl=$postfixmydomainACL} - -{/render} -
{t}Postfix mydestination{/t} - -{render acl=$postfixmydestinationACL} - -{/render} -
{t}Cyrus admins{/t} - -{render acl=$cyrusadminsACL} - -{/render} -
-

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{t}Services{/t}
-{render acl=$cyruspop3ACL} - -{/render} - - -
-{render acl=$cyruspop3sACL} - -{/render} - - -
-{render acl=$cyrusimapACL} - -{/render} - - -
-{render acl=$cyrusimapsACL} - -{/render} - - -
-{render acl=$cyrussieveACL} - -{/render} - - -
-{render acl=$proftpdftpACL} - -{/render} - - -
-{render acl=$apachehttpACL} - -{/render} - - -
-{render acl=$postfixenablevirusscanACL} - -{/render} - - -
- -

 

-
- - - - - - - - -
- {t}Quota settings{/t} -
-{render acl=$cyrusquotawarnACL} - {$quotastr} -{/render} -
- -
- - - - - - - - - - - -
- {t}Free/Busy settings{/t} -
-{render acl=$apacheallowunauthenticatedfbACL} - {t}Allow unauthenticated downloading of Free/Busy information{/t} -{/render} -
-{render acl=$kolabFreeBusyFutureACL} - {$fbfuture} -{/render} -
- -

 

-
- - - - - - - -
- {t}SMTP privileged networks{/t} -
-
-{render acl=$postfixmynetworksACL} - -{/render} -
- ( {t}Enter multiple values, seperated with{/t} , ) -
- - -

 

-
- - - - - - - - - - - - -
- {t}SMTP smarthost/relayhost{/t} -
-{render acl=$postfixrelayhostACL} - -{/render} - -
-   -{render acl=$postfixrelayhostACL} - -{/render} -
- - -

 

-
- - - - - - - - - -
- {t}Accept Internet Mail{/t} -
-{render acl=$postfixallowunauthenticatedACL} - -{/render} - -
- - -
- - - -

 

-
- -   - -
- diff --git a/gosa-plugins/kolab/admin/systems/services/kolab/class_servKolab.inc b/gosa-plugins/kolab/admin/systems/services/kolab/class_servKolab.inc new file mode 100644 index 000000000..08b75ea86 --- /dev/null +++ b/gosa-plugins/kolab/admin/systems/services/kolab/class_servKolab.inc @@ -0,0 +1,415 @@ +"Eins ist toll", "zwei"=>"Zwei ist noch besser"); + + var $postfix_mydomain = ""; + var $cyrus_admins = ""; + var $postfix_mydestination = ""; + var $postfix_mynetworks = "127.0.0.1/8"; + var $postfix_enable_virus_scan = "TRUE"; + var $postfix_relayhost = ""; + var $postfix_mxrelayenabled = true; + var $postfix_allow_unauthenticated = "FALSE"; + var $cyrus_quotawarn = "80"; + var $kolabFreeBusyFuture = "1"; + var $k = "kolab"; + var $cyrus_imap = "TRUE"; + var $cyrus_pop3 = "FALSE"; + var $cyrus_imaps = "TRUE"; + var $cyrus_pop3s = "TRUE"; + var $cyrus_sieve = "TRUE"; + var $apache_allow_unauthenticated_fb = "TRUE"; + var $proftpd_ftp = "FALSE"; + var $apache_http = "TRUE"; + var $kolabHost = array(); + var $orig_cn = ""; + var $view_logged = FALSE; + + var $attributes = array("postfix_mydomain", "postfix_mydestination", "proftpd_ftp", "k", + "postfix_mynetworks", "postfix_enable_virus_scan", "postfix_relayhost", "apache_http", + "postfix_allow_unauthenticated", "cyrus_admins", "cyrus_imap","kolabFreeBusyFuture", + "cyrus_pop3", "cyrus_imaps", "cyrus_pop3s", "cyrus_sieve", "apache_allow_unauthenticated_fb", + "cyrus_quotawarn"); + var $objectclasses = array("top", "kolab"); + + /* Serverservice vars */ + var $conflicts = array("goImapServer","goMailServer"); + var $DisplayName = "Kolab mail service"; + var $StatusFlag = ""; + + function servkolab(&$config, $dn = NULL, $parent= NULL) + { + /* Setting the hostname and tell this Plugin that we are the kolab extension*/ + $this->hostname = preg_replace('/^cn=([^,]+),.*$/', '\1', $dn); + $this->dn = "k=kolab,".$config->current['BASE']; + + /* Load variables, if given*/ + plugin::plugin($config, $this->dn); + + /* Copy needed attributes */ + foreach($this->attributes as $val) { + $name = preg_replace('/_/', '-', $val); + if (isset($this->attrs["$name"][0])) { + $this->$val = $this->attrs["$name"][0]; + } + } + + /* Toggle relayhost */ + $this->postfix_mxrelayenabled = preg_match('/^\[/', $this->postfix_relayhost); + $this->postfix_relayhost = preg_replace("/[\[\]]/","",$this->postfix_relayhost); + + /* Is this Server a member of the Kolab extension or not ?*/ + if(isset($this->attrs['kolabHost'])) { + $this->kolabHost= $this->attrs['kolabHost']; + unset($this->kolabHost['count']); + } + $this->is_account = false; + $this->initially_was_account = false; + foreach($this->kolabHost as $host){ + if($this->hostname == $host){ + $this->is_account = true; + $this->initially_was_account = true; + } + } + } + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + /*************** + Variable initialisation + ***************/ + + $smarty = get_smarty(); + $display = ""; + $ldap = $this->config->get_ldap_link(); + + + /* Assemble free/busy string */ + $edit = sprintf('', + $this->kolabFreeBusyFuture); + $fbfuture = sprintf(_("Include data from %s days in the past when creating free/busy lists"), $edit); + + /* Assemble quota string */ + $edit = sprintf('', + $this->cyrus_quotawarn); + $quotastr = sprintf(_("Warn users when using more than %s%% of their mail quota"), $edit); + + /*************** + Assign informations to smarty + ***************/ + + /* Set relayhost and if we have MX lookup enabled*/ + if($this->postfix_mxrelayenabled) { + $smarty->assign("RelayMxSupportCheck"," checked "); + } else { + $smarty->assign("RelayMxSupportCheck",""); + } + + /* Set acls */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + /* Initialize all attributes, that were submitted */ + foreach($this->attributes as $val) + { + /* Tell smarty which variables we are useing */ + $smarty->assign($val, $this->$val); + if (($this->$val != "FALSE") && !empty($this->$val)){ + $smarty->assign($val."Check", "checked"); + } else { + $smarty->assign($val."Check", ""); + } + } + + $smarty->assign("fbfuture", $fbfuture); + $smarty->assign("quotastr", $quotastr); + + /* Load Template */ + $display.=$smarty->fetch(get_template_path('servkolab.tpl', TRUE)); + return ($display); + } + + function remove_from_parent() + { + + /* Remove status flag, it is not a memeber of + this->attributes, so ensure that it is deleted too */ + if(!empty($this->StatusFlag)){ + $this->attrs[$this->StatusFlag] = array(); + } + + + /* Only walk through following code, if this host + was a member of the kolab hosts, else skip this */ + if(!$this->initially_was_account){ + return; + } + + /* !!! Don't use "cn" in this function + hostname -> the initial name of the host + cn -> is the new name of the host, in case that it was renamed. + */ + + $ldap = $this->config->get_ldap_link(); + $this->dn = "k=kolab,".$this->config->current['BASE']; + + /* We can't simply remove the whole entry, it is possible that there are + some other hosts assigned to this object. + So, first of all check if we are the last host entry within the host + : Remove k=kolab entry + if we aren't alone, only remove host name from hosts entry and save */ + /* Are we alone? Remove complete entry... */ + + /* Check if we are definitly in kolabHosts */ + if(!in_array_ics($this->hostname,$this->kolabHost)) { + return; + } + + /* Integration check, not translated because they can't pop up at all, only for debug */ + if(count($this->kolabHost) == 0){ + print_red("Server - Kolab tab : This is not possible, we can't remove an account which doesn't exists."); + return; + } + if(!isset($this->hostname) || (empty($this->hostname))){ + print_red("The required attribute hostname seams to empty."); + } + + /* Our hostname is in kolabHosts and there is a only one entry + = we are the last host entry, delete k=kolab entry */ + if (count($this->kolabHost) == 1){ + + /* Remove complete entry */ + $ldap->rmdir ($this->dn); + show_ldap_error($ldap->get_error(), sprintf(_("Removing host entry from system server/kolab with dn '%s' failed."),$this->dn)); + } else { + + /* Only modify kolabHost */ + $hosts= array(); + foreach ($this->kolabHost as $host){ + if($host != $this->hostname){ + $hosts[]= $host; + } + } + $attrs= array('kolabHost' => $hosts); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($attrs); + show_ldap_error($ldap->get_error(), sprintf(_("Removing host entry from system server/kolab with dn '%s' failed."),$this->dn)); + } + + new log("remove","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + /* Optionally execute a command after we're done */ + $this->handle_post_events("remove"); + } + + + function save_object() + { + if (isset($_POST['kolabtab'])){ + plugin::save_object(); + + + foreach($this->attributes as $attr){ + if(($this->acl_is_writeable(preg_replace("/_/","",$attr))) && (isset($_POST[$attr]))){ + $this->$attr = $_POST[$attr]; + } + } + + /* Save checkboxes */ + foreach (array( "postfix_enable_virus_scan", "postfix_allow_unauthenticated", + "cyrus_imap", "cyrus_pop3", "cyrus_imaps", + "cyrus_pop3s", "cyrus_sieve", "apache_allow_unauthenticated_fb", + "proftpd_ftp", "apache_http") as $cb){ + + if($this->acl_is_writeable(preg_replace("/_/","",$cb))){ + if (isset($_POST[$cb])){ + $this->$cb= "TRUE"; + } else { + $this->$cb= "FALSE"; + } + } + } + + /* Toggell relay check */ + if($this->acl_is_writeable("postfixmxrelayenabled")){ + $this->postfix_mxrelayenabled= isset($_POST['RelayMxSupport']); + } + } + + } + + + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if(($this->kolabFreeBusyFuture=="")) { + $message[] = _("Future days in Free/Busy settings must be set."); + }elseif(!tests::is_uid($this->kolabFreeBusyFuture) || $this->kolabFreeBusyFuture < 0){ + $message[] = _("Future days in Free/Busy settings must be a positive value."); + } + + if(!is_int((int)($this->cyrus_quotawarn))) { + $message[] = _("The given Quota settings value must be a number."); + }elseif(!(($this->cyrus_quotawarn<=100)&&($this->cyrus_quotawarn>=0))){ + $message[] = _("Please choose a value between 1 and 100 for Quota settings."); + }elseif(strcasecmp($this->cyrus_quotawarn,(int)$this->cyrus_quotawarn)){ + $message[] = _("Future days must be a value."); + } + + if(empty($this->postfix_mynetworks)) { + $message[] = _("No SMTP privileged networks set."); + } + + /*if(empty($this->postfix_relayhost)) { + $message[] = _("No SMTP smarthost/relayhost set."); + } + */ + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + /* Set ldap connection */ + $ldap = $this->config->get_ldap_link(); + + /* Open current dn*/ + $this->dn = "k=kolab,".$this->config->current['BASE']; + + /* Adapt relayhost */ + $this->postfix_relayhost= preg_replace('/[\[\]]/', '', $this->postfix_relayhost); + if ($this->postfix_mxrelayenabled && $this->postfix_relayhost != ""){ + $this->postfix_relayhost= "[".$this->postfix_relayhost."]"; + } + + /* Check if this server was renamed, in this case we have to remove old cn first*/ + if($this->hostname != $this->cn){ + $tmp = array(); + if(in_array_ics($this->hostname,$this->kolabHost)){ + foreach($this->kolabHost as $host){ + if($host != $this->hostname){ + $tmp[] = $host; + } + } + $this->kolabHost = $tmp; + } + } + + /* Add ourselves to the list of kolabHost's if needed */ + if (!in_array_ics($this->cn,$this->kolabHost)){ + $this->kolabHost[]= $this->cn; + } + + /* Call parents save to prepare $this->attrs */ + plugin::save(); + + /* Save or modify? */ + $ldap->cat($this->dn, array('dn')); + if (!$ldap->fetch()){ + $mode= "add"; + } else { + $mode= "modify"; + } + + /* Do attribute conversion */ + foreach ($this->attrs as $key => $value){ + if (preg_match('/_/', $key)){ + $old_key= $key; + $key= preg_replace('/_/', '-', $key); + $this->attrs[$key]= $value; + unset($this->attrs[$old_key]); + } + } + /* Add kolab hosts */ + $this->attrs['kolabHost']= $this->kolabHost; + + /* Perform LDAP action */ + $ldap->cd($this->dn); + $this->cleanup();; + $ldap->$mode($this->attrs); + + if($mode == "add"){ + new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving system server/kolab with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + if ($this->initially_was_account == $this->is_account) { + if ($this->is_modified) { + $this->handle_post_events("modify"); + } + } else { + $this->handle_post_events("add"); + } + } + + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("Kolab mail service"); + $fields['AllowEdit'] = true; + return($fields); + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Kolab"), + "plDescription" => _("Kolab mail service")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 85, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + "postfixmydomain" => _("Postfix mydomain") , + "postfixmydestination" => _("My destination") , + "cyrusadmins" => _("Cyrus admins") , + "proftpdftp" => _("FTP FreeBusy service") , + "postfixmynetworks" => _("SMTP privileged networks") , + "postfixenablevirusscan" => _("Enable virus scan") , + "postfixrelayhost" => _("Relayhost") , + "postfixmxrelayenabled" => _("Enable MX lookup for relayhost"), + "apachehttp" => _("HTTP FreeBusy service") , + "apacheallowunauthenticatedfb" => _("Allow unauthenticated free busy"), + "postfixallowunauthenticated" => _("Accept Internet Mail") , + "cyrusimap" => _("IMAP service") , + "kolabFreeBusyFuture" => _("kolabFreeBusyFuture") , + "cyruspop3" => _("POP3 service") , + "cyrusimaps" => _("IMAP/SSL service") , + "cyruspop3s" => _("POP3/SSL service") , + "cyrussieve" => _("Sieve service") , + "cyrusquotawarn" => _("Quota settings")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/kolab/admin/systems/services/kolab/servkolab.tpl b/gosa-plugins/kolab/admin/systems/services/kolab/servkolab.tpl new file mode 100644 index 000000000..ec83b7801 --- /dev/null +++ b/gosa-plugins/kolab/admin/systems/services/kolab/servkolab.tpl @@ -0,0 +1,249 @@ + + + + + +
+ + + + + + + + + + + + + + + + +
{t}Generic{/t}
{t}Postfix mydomain{/t} + +{render acl=$postfixmydomainACL} + +{/render} +
{t}Postfix mydestination{/t} + +{render acl=$postfixmydestinationACL} + +{/render} +
{t}Cyrus admins{/t} + +{render acl=$cyrusadminsACL} + +{/render} +
+

 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{t}Services{/t}
+{render acl=$cyruspop3ACL} + +{/render} + + +
+{render acl=$cyruspop3sACL} + +{/render} + + +
+{render acl=$cyrusimapACL} + +{/render} + + +
+{render acl=$cyrusimapsACL} + +{/render} + + +
+{render acl=$cyrussieveACL} + +{/render} + + +
+{render acl=$proftpdftpACL} + +{/render} + + +
+{render acl=$apachehttpACL} + +{/render} + + +
+{render acl=$postfixenablevirusscanACL} + +{/render} + + +
+ +

 

+
+ + + + + + + + +
+ {t}Quota settings{/t} +
+{render acl=$cyrusquotawarnACL} + {$quotastr} +{/render} +
+ +
+ + + + + + + + + + + +
+ {t}Free/Busy settings{/t} +
+{render acl=$apacheallowunauthenticatedfbACL} + {t}Allow unauthenticated downloading of Free/Busy information{/t} +{/render} +
+{render acl=$kolabFreeBusyFutureACL} + {$fbfuture} +{/render} +
+ +

 

+
+ + + + + + + +
+ {t}SMTP privileged networks{/t} +
+
+{render acl=$postfixmynetworksACL} + +{/render} +
+ ( {t}Enter multiple values, seperated with{/t} , ) +
+ + +

 

+
+ + + + + + + + + + + + +
+ {t}SMTP smarthost/relayhost{/t} +
+{render acl=$postfixrelayhostACL} + +{/render} + +
+   +{render acl=$postfixrelayhostACL} + +{/render} +
+ + +

 

+
+ + + + + + + + + +
+ {t}Accept Internet Mail{/t} +
+{render acl=$postfixallowunauthenticatedACL} + +{/render} + +
+ + +
+ + + +

 

+
+ +   + +
+ diff --git a/gosa-plugins/kolab/personal/connectivity/class_kolabAccount.inc b/gosa-plugins/kolab/personal/connectivity/class_kolabAccount.inc deleted file mode 100644 index a9149d4dc..000000000 --- a/gosa-plugins/kolab/personal/connectivity/class_kolabAccount.inc +++ /dev/null @@ -1,602 +0,0 @@ -attrs['uid'][0])){ - $this->uid = $this->attrs['uid'][0]; - } - - /* Pull arrays */ - foreach(array("kolabDelegate", "kolabInvitationPolicy") as $attr){ - if (isset($this->attrs["$attr"]["count"])){ - $tmp = array(); - for ($i= 0; $i<$this->attrs["$attr"]["count"]; $i++){ - $tmp[]=$this->attrs["$attr"][$i]; - } - $this->$attr = $tmp; - } - } - - /* If this one is empty, preset with ACT_MANUAL for anonymous users */ - if (count ($this->kolabInvitationPolicy) == 0){ - $this->kolabInvitationPolicy= array("ACT_MANUAL"); - } - - /* Check is account state */ - $this->is_account = false; - if(count($this->kolabDelegate)){ - $this->is_account = true; - } - foreach(array("calFBURL","unrestrictedMailSize") as $attr){ - if(!empty($this->$attr)){ - $this->is_account = true; - } - } - - /* Transfer account states for this union */ - if (isset($this->parent->by_object['mailAccount']) && $this->parent->by_object['mailAccount']->is_account){ - $this->mail_Account = true; - }elseif( isset($this->attrs) && isset($this->attrs['kolabHomeServer'])){ - $this->mail_Account= true; - }else{ - $this->is_account = false; - $this->mail_Account = false; - } - } - - - /*! \brief Create thml output - */ - function execute() - { - /* Call parent execute */ - plugin::execute(); - - /* Log view */ - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","users/".get_class($this),$this->dn); - } - - /* Show tab dialog headers */ - $display= ""; - - /* Show main page */ - $smarty= get_smarty(); - - /* Load attributes */ - foreach($this->attributes as $val){ - $smarty->assign("$val", $this->$val); - } - - $tmp = $this->plInfo(); - foreach($tmp['plProvidedAcls'] as $acl => $description){ - $smarty->assign($acl."ACL",$this->getacl($acl,$this->ReadOnly)); - $smarty->assign($acl."_W", $this->acl_is_writeable($acl,$this->ReadOnly)); - } - $smarty->assign("is_account" , $this->is_account); - - if($this->ReadOnly){ - $smarty->assign("is_removeable",false); - $smarty->assign("is_createable",false); - }else{ - $smarty->assign("is_removeable",$this->acl_is_removeable()); - $smarty->assign("is_createable",$this->acl_is_createable()); - } - - /* Check for invitation action */ - $nr= 0; - - foreach($_POST as $name => $value){ - if(preg_match("/add_inv_/",$name)){ - $this->kolabInvitationPolicy[]= ": ACT_MANUAL"; - } - } - foreach($_POST as $name => $value){ - if(preg_match("/del_inv_/",$name)){ - - $id = preg_replace("/del_inv_/","",$name); - $id = preg_replace("/_(x|y)$/","",$id); - - $new= array(); - foreach ($this->kolabInvitationPolicy as $entry){ - if (!preg_match("/^".$this->imapping[$id].":/", $entry)){ - $new[]= $entry; - } - } - $this->kolabInvitationPolicy= $new; - } - } - - /* Unify addresses */ - $new= array(); - foreach($this->kolabInvitationPolicy as $value){ - $address= preg_replace('/^([^:]+:).*$/', '\1', $value); - $new[$address]= $value; - } - $this->kolabInvitationPolicy= array(); - foreach($new as $value){ - $this->kolabInvitationPolicy[]= $value; - } - - /* Add delegation */ - if (isset($_POST['add_delegation'])){ - if ($_POST['delegate_address'] != ""){ - - /* Valid email address specified? */ - $address= $_POST['delegate_address']; - $valid= FALSE; - if (!tests::is_email($address)){ - if (!tests::is_email($address, TRUE)){ - msg_dialog::display(_("Error"), _("Cannot add invalid mail address!"), ERROR_DIALOG); - } - } else { - - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->config->current['BASE']); - $ldap->search('(mail='.$address.')',array("mail")); - if ($ldap->count() == 0){ - msg_dialog::display(_("Error"), _("Primary mail address already in use by another user!"), ERROR_DIALOG); - } else { - $valid= TRUE; - } - } - - if ($valid){ - /* Add it */ - if ($this->acl_is_writeable("kolabDelegate")){ - $this->addDelegate ($address); - $this->is_modified= TRUE; - } - - } - } - } - - /* Delete forward email addresses */ - if ((isset($_POST['delete_delegation'])) && (isset($_POST['delegate_list']))){ - if (count($_POST['delegate_list']) && $this->acl_is_writeable("kolabDelegate")){ - $this->delDelegate ($_POST['delegate_list']); - } - } - - /* Assemble policies */ - $policies= array( 'ACT_ALWAYS_ACCEPT' => _("Always accept"), - 'ACT_ALWAYS_REJECT' => _("Always reject"), - 'ACT_REJECT_IF_CONFLICTS' => _("Reject if conflicts"), - 'ACT_MANUAL_IF_CONFLICTS' => _("Manual if conflicts"), - 'ACT_MANUAL' => _("Manual")); - $smarty->assign('policies', $policies); - - /* Adjust checkbox */ - if ($this->unrestrictedMailSize){ - $smarty->assign('unrestrictedMailSizeState', "checked"); - } else { - $smarty->assign('unrestrictedMailSizeState', ""); - } - - /* Transfer delegation list */ - if (!count($this->kolabDelegate)){ - /* Smarty will produce and tidy don't like that, so tell smarty to create no option (array();)*/ - $smarty->assign("kolabDelegate", array()); - } else { - $smarty->assign("kolabDelegate", $this->kolabDelegate); - } - - $smarty->assign("mail_account",$this->mail_Account); - - /* Create InvitationPolicy table */ - $invitation= ""; - $this->imapping= array(); - $nr= 0; - $changeState = ""; - foreach ($this->kolabInvitationPolicy as $entry){ - - if($this->acl_is_writeable("kolabInvitationPolicy")){ - $changeState .= "changeState('address".$nr."'); \n changeState('policy".$nr."'); \n - changeState('add".$nr."'); \n changeState('remove".$nr."'); \n"; - } - - if(!$this->acl_is_writeable("kolabInvitationPolicy") && !$this->multiple_support_active){ - $dis = " disabled "; - }else{ - if($this->is_account || $this->multiple_support_active){ - $dis = " "; - }else{ - $dis = " disabled "; - } - } - $invitation.= ""; - - if(!$this->acl_is_readable("kolabInvitationPolicy")) { - } - - /* The default entry does not have colons... */ - if (!preg_match('/:/', $entry)){ - $invitation.= _("Anonymous"); - $name= ""; - $mode= $entry; - } else { - $name= preg_replace('/:.*$/', '', $entry); - $mode= preg_replace('/^[^:]*: */', '', $entry); - - if(!$this->acl_is_readable("kolabInvitationPolicy")){ - $name=''; - } - $invitation.= ""; - } - $invitation.= ""; - - /* Add mode switch */ - $invitation.= ""; - } - if ($nr != 0) { - $button.= ""; - } - - $invitation.= "  - $button - \n"; - $this->imapping[$nr]= $name; - $nr++; - } - $smarty->assign("invitation", $invitation); - $smarty->assign("changeState", $changeState); - $smarty->assign("kolabState",$this->is_account); - - - $smarty->assign("multiple_support",$this->multiple_support_active); - foreach($this->attributes as $attr){ - $smarty->assign("use_".$attr,in_array($attr,$this->multi_boxes)); - } - foreach(array("kolabState") as $attr){ - $smarty->assign("use_".$attr,in_array($attr,$this->multi_boxes)); - } - - if($this->multiple_support_active){ - } - - - $display.= $smarty->fetch (get_template_path('kolab.tpl', TRUE, dirname(__FILE__))); - return ($display); - } - - function remove_from_parent() - { - if(!$this->initially_was_account){ - return; - } - - /* Optionally execute a command after we're done */ - plugin::remove_from_parent(); - - if(!in_array("kolabInetOrgPerson",$this->attrs['objectClass'])){ - $this->attrs['objectClass'][] = "kolabInetOrgPerson"; - } - - $ldap = $this->config->get_ldap_linK(); - $ldap->cd($this->config->current['BASE']); - $ldap->cd ($this->dn); - $ldap->modify($this->attrs); - - /* Log last action */ - new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - - $this->handle_post_events('remove',array("uid" => $this->uid)); - show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/kolab account with dn '%s' failed."),$this->dn)); - } - - - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - /* FBFuture is in days... */ - if ($this->kolabFreeBusyFuture != "" && !preg_match('/^[0-9]+$/', $this->kolabFreeBusyFuture)){ - $message[]= _("The value specified as Free Busy future needs to be an integer."); - } - - /* Check for URL scheme... */ - if(!empty($this->calFBURL) && !preg_match("/http+(s)*:\/\//",$this->calFBURL)){ - $message[]= _("The value specified as Free Busy Information URL is invalid."); - } - - /* Check invitation policy for existing mail addresses */ - foreach($this->kolabInvitationPolicy as $policy){ - - /* Ignore anonymous string */ - if (!preg_match('/:/', $policy)){ - continue; - } - - $address= preg_replace('/^([^:]+).*$/', '\1', $policy); - if (!tests::is_email($address)){ - if (!tests::is_email($address, TRUE)){ - $message[]= sprintf(_("The invitation policy entry for address '%s' is not valid."), $address); - } - } else { - - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->config->current['BASE']); - $ldap->search('(mail='.$address.')',array("mail")); - if ($ldap->count() == 0){ - $message[]= sprintf(_("There's no mail user with address '%s' for your invitation policy!"), $address); - } else { - $valid= TRUE; - } - } - } - - return ($message); - } - - /* Save data to object */ - function save_object() - { - /* Do we need to flip is_account state? */ - if (isset($_POST['connectivityTab'])){ - - if(isset($_POST["kolabState"])){ - if($this->acl_is_createable()){ - $this->is_account = true; - } - }else{ - if($this->acl_is_removeable()){ - $this->is_account = false; - } - } - if ($this->acl_is_writeable("unrestrictedMailSize")){ - if (isset($_POST['unrestrictedMailSize']) && $_POST['unrestrictedMailSize'] == 1){ - $this->unrestrictedMailSize= 1; - } else { - $this->unrestrictedMailSize= 0; - } - } - } - - plugin::save_object(); - - /* Save changes done in invitation policies */ - if($this->acl_is_writeable("kolabInvitationPolicy")){ - - $nr= 0; - $this->kolabInvitationPolicy= array(); - while (isset($_POST["policy$nr"])){ - - /* Anonymous? */ - if (!isset($_POST["address$nr"])){ - $this->kolabInvitationPolicy[]= $_POST["policy$nr"]; - } else { - $this->kolabInvitationPolicy[]= $_POST["address$nr"].": ".$_POST["policy$nr"]; - } - - $nr++; - } - - /* If this one is empty, preset with ACT_MANUAL for anonymous users */ - if (count ($this->kolabInvitationPolicy) == 0){ - $this->kolabInvitationPolicy= array("ACT_MANUAL"); - } - } - } - - - /* Save to LDAP */ - function save() - { - /* Check mailmethod before doing something useful */ - plugin::save(); - - /* Transfer arrays */ - $this->attrs['kolabDelegate']= $this->kolabDelegate; - $this->attrs['kolabInvitationPolicy']= $this->kolabInvitationPolicy; - - /* unrestrictedMailSize is boolean */ - if($this->attrs['unrestrictedMailSize']){ - $this->attrs['unrestrictedMailSize'] = "TRUE"; - }else{ - $this->attrs['unrestrictedMailSize'] = "FALSE"; - } - - /* Write back to ldap */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - /* Log last action */ - if($this->initially_was_account){ - new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - - show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/kolab account with dn '%s' failed."),$this->dn)); - - /* Optionally execute a command after we're done */ - if ($this->initially_was_account == $this->is_account){ - if ($this->is_modified){ - $this->handle_post_events("modify",array("uid" => $this->uid)); - } - } else { - $this->handle_post_events("add",array("uid" => $this->uid)); - } - } - - - /* Add entry to delegation list */ - function addDelegate($address) - { - $this->kolabDelegate[]= $address; - $this->kolabDelegate= array_unique ($this->kolabDelegate); - - sort ($this->kolabDelegate); - reset ($this->kolabDelegate); - $this->is_modified= TRUE; - } - - function delDelegate($addresses) - { - $this->kolabDelegate= array_remove_entries ($addresses, $this->kolabDelegate); - $this->is_modified= TRUE; - } - - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Kolab"), - "plDescription" => _("Kolab account settings")." : "._("Connectivity addon")."", - "plSelfModify" => TRUE, - "plDepends" => array("user"), - "plPriority" => 20, // Position in tabs - "plSection" => array("personal" => _("My account")), - "plCategory" => array("users"), - "plOptions" => array(), - - "plProvidedAcls" => array( - "kolabFreeBusyFuture" => _("Free busy future"), - "unrestrictedMailSize" => _("Mail size restriction"), - "calFBURL" => _("Free busy information"), - "kolabDelegate" => _("Delegations"), - "kolabInvitationPolicy" => _("Invitation policy")) - )); - } - - - /*! \brief Enable multiple edit support. \ - Also sets $this->mail_account to TRUE, which simulates \ - a valid mail extension. - */ - public function enable_multiple_support() - { - plugin::enable_multiple_support(); - $this->mail_Account = TRUE; - } - - - /*! \brief Save html POSTs in multiple edit. - */ - public function multiple_save_object() - { - if (isset($_POST['connectivityTab'])){ - plugin::multiple_save_object(); - if(isset($_POST['use_kolabState'])){ - $this->multi_boxes[] = "kolabState"; - } - $this->save_object(); - } - } - - - /*! \brief Returns all modified values. \ - All selected an modified values will be returned \ - in an array. - @return array Returns an array containing all attribute modifications - */ - public function get_multi_edit_values() - { - $ret = plugin::get_multi_edit_values(); - if(in_array("kolabState",$this->multi_boxes)){ - $ret['is_account'] = $this->is_account; - } - - print_a($ret); - - return($ret); - } - - /*! \brief Sets modified attributes in mutliple edit. \ - All collected values from "get_multi_edit_values()" \ - will be applied to this plugin. - @param array An array containing modified attributes returned by get_multi_edit_values(); - */ - public function set_multi_edit_values($values) - { - plugin::set_multi_edit_values($values); - if(isset($values['is_account'])){ - $this->is_account = $values['is_account']; - } - } - - - /*! \brief Initialize multiple edit ui for this plugin. \ - This function sets plugin defaults in multiple edit. - @param array Attributes used in all object - @param array All used attributes. - */ - public function init_multiple_support($attrs,$all) - { - plugin::init_multiple_support($attrs,$all); - if(isset($attrs['objectClass']) && in_array("kolabInetOrgPerson",$attrs['objectClass'])){ - $this->is_account = TRUE; - } - - /* Pull arrays */ - foreach(array("kolabDelegate", "kolabInvitationPolicy") as $attr){ - if (isset($this->multi_attrs["$attr"]["count"])){ - $tmp = array(); - for ($i= 0; $i<$this->multi_attrs["$attr"]["count"]; $i++){ - $tmp[]=$this->multi_attrs["$attr"][$i]; - } - $this->$attr = $tmp; - } - } - - /* If this one is empty, preset with ACT_MANUAL for anonymous users */ - if (count ($this->kolabInvitationPolicy) == 0){ - $this->kolabInvitationPolicy= array("ACT_MANUAL"); - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-plugins/kolab/personal/connectivity/kolab.tpl b/gosa-plugins/kolab/personal/connectivity/kolab.tpl deleted file mode 100644 index c05bfb177..000000000 --- a/gosa-plugins/kolab/personal/connectivity/kolab.tpl +++ /dev/null @@ -1,134 +0,0 @@ - -{if !$mail_account} -

{t}Kolab account{/t}

- {t}The kolab account is currently disabled. It's features can be adjusted if you add a mail account.{/t} -{else} - -

-{if $multiple_support} - - - - -{else} - -{/if} - -{t}Kolab account{/t}

- - - - - - -
- -{if $multiple_support} - -
- -
- -   - - -{else} -
- {render acl=$kolabDelegateACL} - - {/render} -
- {render acl=$kolabDelegateACL} - - {/render} - {render acl=$kolabDelegateACL} -   - {/render} - {render acl=$kolabDelegateACL} - - {/render} -{/if} - -

{t}Mail size{/t}

-{render acl=$unrestrictedMailSizeACL checkbox=$multiple_support checked=$use_unrestrictedMailSize} -   - {t}No mail size restriction for this account{/t} -{/render} -
-   - - -

{t}Free Busy information{/t}

- - - - - - - - - -
-{render acl=$calFBURLACL checkbox=$multiple_support checked=$use_calFBURL} - -{/render} -
-{render acl=$kolabFreeBusyFutureACL checkbox=$multiple_support checked=$use_kolabFreeBusyFuture} - - {t}days{/t} -{/render} -
- - -

{t}Invitation policy{/t}

-{if $multiple_support} - -{/if} -{render acl=$kolabInvitationPolicyACL} - - {$invitation} -
-{/render} - - -
- -{/if} diff --git a/gosa-plugins/kolab/personal/connectivity/kolab/class_kolabAccount.inc b/gosa-plugins/kolab/personal/connectivity/kolab/class_kolabAccount.inc new file mode 100644 index 000000000..a9149d4dc --- /dev/null +++ b/gosa-plugins/kolab/personal/connectivity/kolab/class_kolabAccount.inc @@ -0,0 +1,602 @@ +attrs['uid'][0])){ + $this->uid = $this->attrs['uid'][0]; + } + + /* Pull arrays */ + foreach(array("kolabDelegate", "kolabInvitationPolicy") as $attr){ + if (isset($this->attrs["$attr"]["count"])){ + $tmp = array(); + for ($i= 0; $i<$this->attrs["$attr"]["count"]; $i++){ + $tmp[]=$this->attrs["$attr"][$i]; + } + $this->$attr = $tmp; + } + } + + /* If this one is empty, preset with ACT_MANUAL for anonymous users */ + if (count ($this->kolabInvitationPolicy) == 0){ + $this->kolabInvitationPolicy= array("ACT_MANUAL"); + } + + /* Check is account state */ + $this->is_account = false; + if(count($this->kolabDelegate)){ + $this->is_account = true; + } + foreach(array("calFBURL","unrestrictedMailSize") as $attr){ + if(!empty($this->$attr)){ + $this->is_account = true; + } + } + + /* Transfer account states for this union */ + if (isset($this->parent->by_object['mailAccount']) && $this->parent->by_object['mailAccount']->is_account){ + $this->mail_Account = true; + }elseif( isset($this->attrs) && isset($this->attrs['kolabHomeServer'])){ + $this->mail_Account= true; + }else{ + $this->is_account = false; + $this->mail_Account = false; + } + } + + + /*! \brief Create thml output + */ + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Log view */ + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","users/".get_class($this),$this->dn); + } + + /* Show tab dialog headers */ + $display= ""; + + /* Show main page */ + $smarty= get_smarty(); + + /* Load attributes */ + foreach($this->attributes as $val){ + $smarty->assign("$val", $this->$val); + } + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $acl => $description){ + $smarty->assign($acl."ACL",$this->getacl($acl,$this->ReadOnly)); + $smarty->assign($acl."_W", $this->acl_is_writeable($acl,$this->ReadOnly)); + } + $smarty->assign("is_account" , $this->is_account); + + if($this->ReadOnly){ + $smarty->assign("is_removeable",false); + $smarty->assign("is_createable",false); + }else{ + $smarty->assign("is_removeable",$this->acl_is_removeable()); + $smarty->assign("is_createable",$this->acl_is_createable()); + } + + /* Check for invitation action */ + $nr= 0; + + foreach($_POST as $name => $value){ + if(preg_match("/add_inv_/",$name)){ + $this->kolabInvitationPolicy[]= ": ACT_MANUAL"; + } + } + foreach($_POST as $name => $value){ + if(preg_match("/del_inv_/",$name)){ + + $id = preg_replace("/del_inv_/","",$name); + $id = preg_replace("/_(x|y)$/","",$id); + + $new= array(); + foreach ($this->kolabInvitationPolicy as $entry){ + if (!preg_match("/^".$this->imapping[$id].":/", $entry)){ + $new[]= $entry; + } + } + $this->kolabInvitationPolicy= $new; + } + } + + /* Unify addresses */ + $new= array(); + foreach($this->kolabInvitationPolicy as $value){ + $address= preg_replace('/^([^:]+:).*$/', '\1', $value); + $new[$address]= $value; + } + $this->kolabInvitationPolicy= array(); + foreach($new as $value){ + $this->kolabInvitationPolicy[]= $value; + } + + /* Add delegation */ + if (isset($_POST['add_delegation'])){ + if ($_POST['delegate_address'] != ""){ + + /* Valid email address specified? */ + $address= $_POST['delegate_address']; + $valid= FALSE; + if (!tests::is_email($address)){ + if (!tests::is_email($address, TRUE)){ + msg_dialog::display(_("Error"), _("Cannot add invalid mail address!"), ERROR_DIALOG); + } + } else { + + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->config->current['BASE']); + $ldap->search('(mail='.$address.')',array("mail")); + if ($ldap->count() == 0){ + msg_dialog::display(_("Error"), _("Primary mail address already in use by another user!"), ERROR_DIALOG); + } else { + $valid= TRUE; + } + } + + if ($valid){ + /* Add it */ + if ($this->acl_is_writeable("kolabDelegate")){ + $this->addDelegate ($address); + $this->is_modified= TRUE; + } + + } + } + } + + /* Delete forward email addresses */ + if ((isset($_POST['delete_delegation'])) && (isset($_POST['delegate_list']))){ + if (count($_POST['delegate_list']) && $this->acl_is_writeable("kolabDelegate")){ + $this->delDelegate ($_POST['delegate_list']); + } + } + + /* Assemble policies */ + $policies= array( 'ACT_ALWAYS_ACCEPT' => _("Always accept"), + 'ACT_ALWAYS_REJECT' => _("Always reject"), + 'ACT_REJECT_IF_CONFLICTS' => _("Reject if conflicts"), + 'ACT_MANUAL_IF_CONFLICTS' => _("Manual if conflicts"), + 'ACT_MANUAL' => _("Manual")); + $smarty->assign('policies', $policies); + + /* Adjust checkbox */ + if ($this->unrestrictedMailSize){ + $smarty->assign('unrestrictedMailSizeState', "checked"); + } else { + $smarty->assign('unrestrictedMailSizeState', ""); + } + + /* Transfer delegation list */ + if (!count($this->kolabDelegate)){ + /* Smarty will produce and tidy don't like that, so tell smarty to create no option (array();)*/ + $smarty->assign("kolabDelegate", array()); + } else { + $smarty->assign("kolabDelegate", $this->kolabDelegate); + } + + $smarty->assign("mail_account",$this->mail_Account); + + /* Create InvitationPolicy table */ + $invitation= ""; + $this->imapping= array(); + $nr= 0; + $changeState = ""; + foreach ($this->kolabInvitationPolicy as $entry){ + + if($this->acl_is_writeable("kolabInvitationPolicy")){ + $changeState .= "changeState('address".$nr."'); \n changeState('policy".$nr."'); \n + changeState('add".$nr."'); \n changeState('remove".$nr."'); \n"; + } + + if(!$this->acl_is_writeable("kolabInvitationPolicy") && !$this->multiple_support_active){ + $dis = " disabled "; + }else{ + if($this->is_account || $this->multiple_support_active){ + $dis = " "; + }else{ + $dis = " disabled "; + } + } + $invitation.= ""; + + if(!$this->acl_is_readable("kolabInvitationPolicy")) { + } + + /* The default entry does not have colons... */ + if (!preg_match('/:/', $entry)){ + $invitation.= _("Anonymous"); + $name= ""; + $mode= $entry; + } else { + $name= preg_replace('/:.*$/', '', $entry); + $mode= preg_replace('/^[^:]*: */', '', $entry); + + if(!$this->acl_is_readable("kolabInvitationPolicy")){ + $name=''; + } + $invitation.= ""; + } + $invitation.= ""; + + /* Add mode switch */ + $invitation.= ""; + } + if ($nr != 0) { + $button.= ""; + } + + $invitation.= "  + $button + \n"; + $this->imapping[$nr]= $name; + $nr++; + } + $smarty->assign("invitation", $invitation); + $smarty->assign("changeState", $changeState); + $smarty->assign("kolabState",$this->is_account); + + + $smarty->assign("multiple_support",$this->multiple_support_active); + foreach($this->attributes as $attr){ + $smarty->assign("use_".$attr,in_array($attr,$this->multi_boxes)); + } + foreach(array("kolabState") as $attr){ + $smarty->assign("use_".$attr,in_array($attr,$this->multi_boxes)); + } + + if($this->multiple_support_active){ + } + + + $display.= $smarty->fetch (get_template_path('kolab.tpl', TRUE, dirname(__FILE__))); + return ($display); + } + + function remove_from_parent() + { + if(!$this->initially_was_account){ + return; + } + + /* Optionally execute a command after we're done */ + plugin::remove_from_parent(); + + if(!in_array("kolabInetOrgPerson",$this->attrs['objectClass'])){ + $this->attrs['objectClass'][] = "kolabInetOrgPerson"; + } + + $ldap = $this->config->get_ldap_linK(); + $ldap->cd($this->config->current['BASE']); + $ldap->cd ($this->dn); + $ldap->modify($this->attrs); + + /* Log last action */ + new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + + $this->handle_post_events('remove',array("uid" => $this->uid)); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/kolab account with dn '%s' failed."),$this->dn)); + } + + + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + /* FBFuture is in days... */ + if ($this->kolabFreeBusyFuture != "" && !preg_match('/^[0-9]+$/', $this->kolabFreeBusyFuture)){ + $message[]= _("The value specified as Free Busy future needs to be an integer."); + } + + /* Check for URL scheme... */ + if(!empty($this->calFBURL) && !preg_match("/http+(s)*:\/\//",$this->calFBURL)){ + $message[]= _("The value specified as Free Busy Information URL is invalid."); + } + + /* Check invitation policy for existing mail addresses */ + foreach($this->kolabInvitationPolicy as $policy){ + + /* Ignore anonymous string */ + if (!preg_match('/:/', $policy)){ + continue; + } + + $address= preg_replace('/^([^:]+).*$/', '\1', $policy); + if (!tests::is_email($address)){ + if (!tests::is_email($address, TRUE)){ + $message[]= sprintf(_("The invitation policy entry for address '%s' is not valid."), $address); + } + } else { + + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->config->current['BASE']); + $ldap->search('(mail='.$address.')',array("mail")); + if ($ldap->count() == 0){ + $message[]= sprintf(_("There's no mail user with address '%s' for your invitation policy!"), $address); + } else { + $valid= TRUE; + } + } + } + + return ($message); + } + + /* Save data to object */ + function save_object() + { + /* Do we need to flip is_account state? */ + if (isset($_POST['connectivityTab'])){ + + if(isset($_POST["kolabState"])){ + if($this->acl_is_createable()){ + $this->is_account = true; + } + }else{ + if($this->acl_is_removeable()){ + $this->is_account = false; + } + } + if ($this->acl_is_writeable("unrestrictedMailSize")){ + if (isset($_POST['unrestrictedMailSize']) && $_POST['unrestrictedMailSize'] == 1){ + $this->unrestrictedMailSize= 1; + } else { + $this->unrestrictedMailSize= 0; + } + } + } + + plugin::save_object(); + + /* Save changes done in invitation policies */ + if($this->acl_is_writeable("kolabInvitationPolicy")){ + + $nr= 0; + $this->kolabInvitationPolicy= array(); + while (isset($_POST["policy$nr"])){ + + /* Anonymous? */ + if (!isset($_POST["address$nr"])){ + $this->kolabInvitationPolicy[]= $_POST["policy$nr"]; + } else { + $this->kolabInvitationPolicy[]= $_POST["address$nr"].": ".$_POST["policy$nr"]; + } + + $nr++; + } + + /* If this one is empty, preset with ACT_MANUAL for anonymous users */ + if (count ($this->kolabInvitationPolicy) == 0){ + $this->kolabInvitationPolicy= array("ACT_MANUAL"); + } + } + } + + + /* Save to LDAP */ + function save() + { + /* Check mailmethod before doing something useful */ + plugin::save(); + + /* Transfer arrays */ + $this->attrs['kolabDelegate']= $this->kolabDelegate; + $this->attrs['kolabInvitationPolicy']= $this->kolabInvitationPolicy; + + /* unrestrictedMailSize is boolean */ + if($this->attrs['unrestrictedMailSize']){ + $this->attrs['unrestrictedMailSize'] = "TRUE"; + }else{ + $this->attrs['unrestrictedMailSize'] = "FALSE"; + } + + /* Write back to ldap */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $this->cleanup(); + $ldap->modify ($this->attrs); + + /* Log last action */ + if($this->initially_was_account){ + new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + + show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/kolab account with dn '%s' failed."),$this->dn)); + + /* Optionally execute a command after we're done */ + if ($this->initially_was_account == $this->is_account){ + if ($this->is_modified){ + $this->handle_post_events("modify",array("uid" => $this->uid)); + } + } else { + $this->handle_post_events("add",array("uid" => $this->uid)); + } + } + + + /* Add entry to delegation list */ + function addDelegate($address) + { + $this->kolabDelegate[]= $address; + $this->kolabDelegate= array_unique ($this->kolabDelegate); + + sort ($this->kolabDelegate); + reset ($this->kolabDelegate); + $this->is_modified= TRUE; + } + + function delDelegate($addresses) + { + $this->kolabDelegate= array_remove_entries ($addresses, $this->kolabDelegate); + $this->is_modified= TRUE; + } + + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Kolab"), + "plDescription" => _("Kolab account settings")." : "._("Connectivity addon")."", + "plSelfModify" => TRUE, + "plDepends" => array("user"), + "plPriority" => 20, // Position in tabs + "plSection" => array("personal" => _("My account")), + "plCategory" => array("users"), + "plOptions" => array(), + + "plProvidedAcls" => array( + "kolabFreeBusyFuture" => _("Free busy future"), + "unrestrictedMailSize" => _("Mail size restriction"), + "calFBURL" => _("Free busy information"), + "kolabDelegate" => _("Delegations"), + "kolabInvitationPolicy" => _("Invitation policy")) + )); + } + + + /*! \brief Enable multiple edit support. \ + Also sets $this->mail_account to TRUE, which simulates \ + a valid mail extension. + */ + public function enable_multiple_support() + { + plugin::enable_multiple_support(); + $this->mail_Account = TRUE; + } + + + /*! \brief Save html POSTs in multiple edit. + */ + public function multiple_save_object() + { + if (isset($_POST['connectivityTab'])){ + plugin::multiple_save_object(); + if(isset($_POST['use_kolabState'])){ + $this->multi_boxes[] = "kolabState"; + } + $this->save_object(); + } + } + + + /*! \brief Returns all modified values. \ + All selected an modified values will be returned \ + in an array. + @return array Returns an array containing all attribute modifications + */ + public function get_multi_edit_values() + { + $ret = plugin::get_multi_edit_values(); + if(in_array("kolabState",$this->multi_boxes)){ + $ret['is_account'] = $this->is_account; + } + + print_a($ret); + + return($ret); + } + + /*! \brief Sets modified attributes in mutliple edit. \ + All collected values from "get_multi_edit_values()" \ + will be applied to this plugin. + @param array An array containing modified attributes returned by get_multi_edit_values(); + */ + public function set_multi_edit_values($values) + { + plugin::set_multi_edit_values($values); + if(isset($values['is_account'])){ + $this->is_account = $values['is_account']; + } + } + + + /*! \brief Initialize multiple edit ui for this plugin. \ + This function sets plugin defaults in multiple edit. + @param array Attributes used in all object + @param array All used attributes. + */ + public function init_multiple_support($attrs,$all) + { + plugin::init_multiple_support($attrs,$all); + if(isset($attrs['objectClass']) && in_array("kolabInetOrgPerson",$attrs['objectClass'])){ + $this->is_account = TRUE; + } + + /* Pull arrays */ + foreach(array("kolabDelegate", "kolabInvitationPolicy") as $attr){ + if (isset($this->multi_attrs["$attr"]["count"])){ + $tmp = array(); + for ($i= 0; $i<$this->multi_attrs["$attr"]["count"]; $i++){ + $tmp[]=$this->multi_attrs["$attr"][$i]; + } + $this->$attr = $tmp; + } + } + + /* If this one is empty, preset with ACT_MANUAL for anonymous users */ + if (count ($this->kolabInvitationPolicy) == 0){ + $this->kolabInvitationPolicy= array("ACT_MANUAL"); + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/kolab/personal/connectivity/kolab/kolab.tpl b/gosa-plugins/kolab/personal/connectivity/kolab/kolab.tpl new file mode 100644 index 000000000..c05bfb177 --- /dev/null +++ b/gosa-plugins/kolab/personal/connectivity/kolab/kolab.tpl @@ -0,0 +1,134 @@ + +{if !$mail_account} +

{t}Kolab account{/t}

+ {t}The kolab account is currently disabled. It's features can be adjusted if you add a mail account.{/t} +{else} + +

+{if $multiple_support} + + + + +{else} + +{/if} + +{t}Kolab account{/t}

+ + + + + + +
+ +{if $multiple_support} + +
+ +
+ +   + + +{else} +
+ {render acl=$kolabDelegateACL} + + {/render} +
+ {render acl=$kolabDelegateACL} + + {/render} + {render acl=$kolabDelegateACL} +   + {/render} + {render acl=$kolabDelegateACL} + + {/render} +{/if} + +

{t}Mail size{/t}

+{render acl=$unrestrictedMailSizeACL checkbox=$multiple_support checked=$use_unrestrictedMailSize} +   + {t}No mail size restriction for this account{/t} +{/render} +
+   + + +

{t}Free Busy information{/t}

+ + + + + + + + + +
+{render acl=$calFBURLACL checkbox=$multiple_support checked=$use_calFBURL} + +{/render} +
+{render acl=$kolabFreeBusyFutureACL checkbox=$multiple_support checked=$use_kolabFreeBusyFuture} + + {t}days{/t} +{/render} +
+ + +

{t}Invitation policy{/t}

+{if $multiple_support} + +{/if} +{render acl=$kolabInvitationPolicyACL} + + {$invitation} +
+{/render} + + +
+ +{/if} diff --git a/gosa-plugins/kolab/personal/mail/class_mail-methods-golab.inc b/gosa-plugins/kolab/personal/mail/class_mail-methods-golab.inc deleted file mode 100644 index dc75674c2..000000000 --- a/gosa-plugins/kolab/personal/mail/class_mail-methods-golab.inc +++ /dev/null @@ -1,261 +0,0 @@ - "alias", - "gosaMailQuota" => "cyrus-userquota", - "gosaMailServer" => "kolabHomeServer"); - - function mailMethodGolab(&$config) - { - $this->config= $config->data['SERVERS']['IMAP']; - } - - function updateMailbox($folder) - { - } - - function setQuota($folder, $gosaMailQuota) - { - return (TRUE); - } - - /* Get quota and divide it by 1024, because in gosa we display in MB - but we get Kb */ - function getQuota($folder) - { - $result= array('quotaUsage' => '', 'gosaMailQuota' => ''); - - /* Only use lower case folder names, if folder name is like "@domain.com" */ - if(preg_match("/@/",$folder)){ - $folder = strtolower($folder); - } - - error_reporting(0); - - /* Load quota settings */ - $quota_value = @imap_get_quota($this->mbox, $folder); - if(is_array($quota_value)) { - if (isset($quota_value["STORAGE"]) && is_array($quota_value["STORAGE"])){ - /* use for PHP >= 4.3 */ - $result['quotaUsage']= (int) ($quota_value["STORAGE"]['usage'] / 1024); - $result['gosaMailQuota']= (int) ($quota_value["STORAGE"]['limit'] / 1024); - } else { - /* backward icompatible */ - $result['quotaUsage']= (int) ($quota_value['usage'] / 1024); - $result['gosaMailQuota']= (int) ($quota_value['limit'] / 1024); - } - }elseif(!$quota_value){ - return(false); - } - - error_reporting(E_ALL | E_STRICT); - - return ($result); - } - - - function fixAttributesOnLoad(&$mailObject) - { - /* Kolab shared folder names are like ' shared.uid@server.de ' - So overwrite uid to match these folder names. Else we can't read quota settings etc. - #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/ - if(get_class($mailObject) == "mailgroup"){ - $mailObject->uid = $mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail); - } - - /* Convert attributes and objectClasses */ - foreach ($this->attribute_map as $dest => $source){ - /* Hickert 11.11.05 : Alternate email addresses were saved, but not displayed again. - if (isset($mailObject->attrs[$source])){ - $mailObject->attrs[$dest]= $mailObject->attrs[$source]; - unset ($mailObject->attrs[$source]); - */ - - if (isset($mailObject->attrs[$source])){ - unset($mailObject->attrs[$source]['count']); - $mailObject->attrs[$dest]= $mailObject->attrs[$source]; - $mailObject->$dest= $mailObject->attrs[$source]; - - unset ($mailObject->$dest['count']); - unset ($mailObject->attrs[$source]); - } - } - - /* Adjust server name if needed */ - foreach ($mailObject->config->data['SERVERS']['IMAP'] as $srv => $dummy){ - if (preg_match("%".$mailObject->attrs['gosaMailServer'][0]."$%", $srv)){ - $mailObject->attrs['gosaMailServer']= array(0 => $srv, "count" => 1); - break; - } - } - } - - - function fixAttributesOnStore(&$mailObject) - { - global $config; - - /* If quota is empty, remove quota restrictions by setting quota to 0 */ - if(isset($mailObject->gosaMailQuota) && (empty($mailObject->gosaMailQuota))){ - $mailObject->attrs['gosaMailQuota'] = 0; - } - - /* Convert attributes and objectClasses */ - foreach ($this->attribute_map as $source => $dest){ - if (isset($mailObject->attrs[$source])){ - $mailObject->attrs[$dest]= $mailObject->attrs[$source]; - unset ($mailObject->attrs[$source]); - } - } - $objectclasses= array(); - foreach ($mailObject->attrs['objectClass'] as $oc){ - if ($oc != 'kolabInetOrgPerson' && $oc != 'kolabSharedFolder'){ - $objectclasses[]= $oc; - } - } - $mailObject->attrs['objectClass']= $objectclasses; - if (in_array("posixGroup", $mailObject->attrs['objectClass'])){ - - /* Add kolabSharedFoleder Class */ - $mailObject->attrs['objectClass'][]= 'kolabSharedFolder'; - - /* Work on acl attribute */ - $new_acl= array(); - foreach ($mailObject->attrs['acl'] as $uacl){ - - /* Get user=(mail) & acls */ - list($user, $acl) = split(" ", $uacl); - - /* Add al users which have seperated acls - %members% are all users in this group, - which have the standard group acl - */ - if ($user != "%members%"){ - $new_acl[$user]= $uacl; - } else { - - /* All groupmembers will be added */ - $ldap = $config->get_ldap_link(); - $ldap->cd($config->current['BASE']); - foreach ($mailObject->members as $member){ - - /* Get user mail address .... */ - $ldap->search("(&(objectClass=person)(|(uid=".$member.")(mail=".$member.")))",array("mail")); - $res = $ldap->fetch(); - - /* Default mail address is set to uid - - So if there is no mail address defined the uid is added - */ - $mail = $member; - - /* Use mail address if it is available */ - if(isset($res['mail'][0])){ - $mail = $res['mail'][0]; - } - - /* only append this mail/permission string to acl, - if there arn't already some (special) configs for this user */ - $found =false; - foreach($mailObject->imapacl as $mailA => $acl){ - if(strtolower(trim($mailA))==strtolower(trim($mail))){ - $found = true; - } - } - - /* Skipp user, with no email adress too */ - if($member == $mail){ - $found = true; - } - - /* Append new user acl */ - if(!$found){ - $new_acl[$member]= "$mail $acl"; - } - - /* Old line */ - // $new_acl[$member]= "$member $acl"; - } - } - } - - /* Save shared folder target */ - $mailObject->attrs['gosaSharedFolderTarget']= "kolab+".$mailObject->mail; - - /* Kolab shared folder names are like ' shared.uid@server.de ' - So overwrite uid to match these folder names. Else we can't read quota settings etc. - #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/ - $mailObject->uid = $mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail); - - /* Assign new acls */ - $mailObject->attrs['acl']= array(); - foreach ($new_acl as $key => $value){ - $mailObject->attrs['acl'][]= $value; - } - } else { - $mailObject->attrs['objectClass'][]= 'kolabInetOrgPerson'; - } - - /* Remove imap:// tagging */ - $mailObject->attrs['kolabHomeServer']= preg_replace('%imap://%', '', $mailObject->attrs['kolabHomeServer']); - $mailObject->attrs['gosaMailServer']= $mailObject->attrs['kolabHomeServer']; - $mailObject->attrs['kolabDeleteFlag']= array(); - } - - function fixAttributesOnRemove(&$mailObject) - { - /* Add attribute for object deletion and remove GOsa specific - values from entry. */ - foreach($this->attribute_map as $kolabAttr){ - $mailObject->attrs[$kolabAttr] = array(); - } - - /* Only add kolab delete Flag in case of an user.mailAccount */ - if(!in_array("posixGroup", $mailObject->attrs['objectClass'])){ - $mailObject->attrs['kolabDeleteFlag']= preg_replace('%imap://%', '', $mailObject->gosaMailServer); - }else{ - /* Kolab shared folder names are like ' shared.uid@server.de ' - So overwrite uid to match these folder names. Else we can't read quota settings etc. - #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/ - $mailObject->uid = $mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail); - - } - } - - - function deleteMailbox($folder) - { - /* Remove shared folders and skip removing users. - KolabD is not able to remove shared folders yet, so we do it instead */ - if(!(preg_match("/^user\//",$folder))){ - return mailMethodCyrus::deleteMailbox($folder); - } - return (TRUE); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-plugins/kolab/personal/mail/class_mail-methods-kolab.inc b/gosa-plugins/kolab/personal/mail/class_mail-methods-kolab.inc deleted file mode 100644 index c0606046b..000000000 --- a/gosa-plugins/kolab/personal/mail/class_mail-methods-kolab.inc +++ /dev/null @@ -1,267 +0,0 @@ - "alias", - "gosaMailQuota" => "cyrus-userquota", - "gosaMailServer" => "kolabHomeServer"); - - function mailMethodKolab(&$config) - { - $this->config= $config->data['SERVERS']['IMAP']; - } - - function updateMailbox($folder) - { - } - - function setQuota($folder, $gosaMailQuota) - { - return (TRUE); - } - - /* Get quota and divide it by 1024, because in gosa we display in MB - but we get Kb */ - function getQuota($folder) - { - $result= array('quotaUsage' => '', 'gosaMailQuota' => ''); - - /* Only use lower case folder names, if folder name is like "@domain.com" */ - if(preg_match("/@/",$folder)){ - $folder = strtolower($folder); - } - - error_reporting(0); - - /* Load quota settings */ - $quota_value = @imap_get_quota($this->mbox, $folder); - if(is_array($quota_value)) { - if (isset($quota_value["STORAGE"]) && is_array($quota_value["STORAGE"])){ - /* use for PHP >= 4.3 */ - $result['quotaUsage']= (int) ($quota_value["STORAGE"]['usage'] / 1024); - $result['gosaMailQuota']= (int) ($quota_value["STORAGE"]['limit'] / 1024); - } else { - /* backward icompatible */ - $result['quotaUsage']= (int) ($quota_value['usage'] / 1024); - $result['gosaMailQuota']= (int) ($quota_value['limit'] / 1024); - } - }elseif(!$quota_value){ - return(false); - } - - error_reporting(E_ALL | E_STRICT); - - return ($result); - } - - - function fixAttributesOnLoad(&$mailObject) - { - /* Kolab shared folder names are like ' shared.uid@server.de ' - So overwrite uid to match these folder names. Else we can't read quota settings etc. - #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/ - if(get_class($mailObject) == "mailgroup"){ - $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail); - } - - /* Convert attributes and objectClasses */ - foreach ($this->attribute_map as $dest => $source){ - /* Hickert 11.11.05 : Alternate email addresses were saved, but not displayed again. - if (isset($mailObject->attrs[$source])){ - $mailObject->attrs[$dest]= $mailObject->attrs[$source]; - unset ($mailObject->attrs[$source]); - */ - - if (isset($mailObject->attrs[$source])){ - unset($mailObject->attrs[$source]['count']); - $mailObject->attrs[$dest]= $mailObject->attrs[$source]; - $mailObject->$dest= $mailObject->attrs[$source]; - - /* Ensure that cleanup will recognize the ampped attributes too */ - if(isset($mailObject->saved_attributes)){ - $mailObject->saved_attributes[$dest] = $mailObject->attrs[$source]; - $mailObject->saved_attributes[$source] = $mailObject->attrs[$source]; - } - - unset ($mailObject->$dest['count']); - unset ($mailObject->attrs[$source]); - } - } - - /* Adjust server name if needed */ - foreach ($mailObject->config->data['SERVERS']['IMAP'] as $srv => $dummy){ - if (preg_match("%".$mailObject->attrs['gosaMailServer'][0]."$%", $srv)){ - $mailObject->attrs['gosaMailServer']= array(0 => $srv, "count" => 1); - break; - } - } - } - - - function fixAttributesOnStore(&$mailObject) - { - global $config; - - /* If quota is empty, remove quota restrictions by setting quota to 0 */ - if(isset($mailObject->gosaMailQuota) && (empty($mailObject->gosaMailQuota))){ - $mailObject->attrs['gosaMailQuota'] = 0; - } - - /* Convert attributes and objectClasses */ - foreach ($this->attribute_map as $source => $dest){ - if (isset($mailObject->attrs[$source])){ - $mailObject->attrs[$dest]= $mailObject->attrs[$source]; - unset ($mailObject->attrs[$source]); - } - } - $objectclasses= array(); - foreach ($mailObject->attrs['objectClass'] as $oc){ - if ($oc != 'kolabInetOrgPerson' && $oc != 'kolabSharedFolder'){ - $objectclasses[]= $oc; - } - } - $mailObject->attrs['objectClass']= $objectclasses; - if (in_array("posixGroup", $mailObject->attrs['objectClass'])){ - - /* Add kolabSharedFoleder Class */ - $mailObject->attrs['objectClass'][]= 'kolabSharedFolder'; - - /* Work on acl attribute */ - $new_acl= array(); - foreach ($mailObject->attrs['acl'] as $uacl){ - - /* Get user=(mail) & acls */ - list($user, $acl) = split(" ", $uacl); - - /* Add al users which have seperated acls - %members% are all users in this group, - which have the standard group acl - */ - if ($user != "%members%"){ - $new_acl[$user]= $uacl; - } else { - - /* All groupmembers will be added */ - $ldap = $config->get_ldap_link(); - $ldap->cd($config->current['BASE']); - foreach ($mailObject->members as $member){ - - /* Get user mail address .... */ - $ldap->search("(&(objectClass=person)(|(uid=".$member.")(mail=".$member.")))",array("mail")); - $res = $ldap->fetch(); - - /* Default mail address is set to uid - - So if there is no mail address defined the uid is added - */ - $mail = $member; - - /* Use mail address if it is available */ - if(isset($res['mail'][0])){ - $mail = $res['mail'][0]; - } - - /* only append this mail/permission string to acl, - if there arn't already some (special) configs for this user */ - $found =false; - foreach($mailObject->imapacl as $mailA => $acl){ - if(strtolower(trim($mailA))==strtolower(trim($mail))){ - $found = true; - } - } - - /* Skipp user, with no email adress too */ - if($member == $mail){ - $found = true; - } - - /* Append new user acl */ - if(!$found){ - $new_acl[$member]= "$mail $acl"; - } - - /* Old line */ - // $new_acl[$member]= "$member $acl"; - } - } - } - - /* Save shared folder target */ - $mailObject->attrs['gosaSharedFolderTarget']= "kolab+shared.".$mailObject->mail; - - /* Kolab shared folder names are like ' shared.uid@server.de ' - So overwrite uid to match these folder names. Else we can't read quota settings etc. - #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/ - $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail); - - /* Assign new acls */ - $mailObject->attrs['acl']= array(); - foreach ($new_acl as $key => $value){ - $mailObject->attrs['acl'][]= $value; - } - } else { - $mailObject->attrs['objectClass'][]= 'kolabInetOrgPerson'; - } - - /* Remove imap:// tagging */ - $mailObject->attrs['kolabHomeServer']= preg_replace('%imap://%', '', $mailObject->attrs['kolabHomeServer']); - $mailObject->attrs['gosaMailServer']= $mailObject->attrs['kolabHomeServer']; - $mailObject->attrs['kolabDeleteFlag']= array(); - } - - function fixAttributesOnRemove(&$mailObject) - { - /* Add attribute for object deletion and remove GOsa specific - values from entry. */ - foreach($this->attribute_map as $kolabAttr){ - $mailObject->attrs[$kolabAttr] = array(); - } - - /* Only add kolab delete Flag in case of an user.mailAccount */ - if(!in_array("posixGroup", $mailObject->attrs['objectClass'])){ - $mailObject->attrs['kolabDeleteFlag']= preg_replace('%imap://%', '', $mailObject->gosaMailServer); - }else{ - /* Kolab shared folder names are like ' shared.uid@server.de ' - So overwrite uid to match these folder names. Else we can't read quota settings etc. - #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/ - $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail); - - } - } - - - function deleteMailbox($folder) - { - /* Remove shared folders and skip removing users. - KolabD is not able to remove shared folders yet, so we do it instead */ - if(preg_match("/^shared/",$folder)){ - return mailMethodCyrus::deleteMailbox($folder); - } - return (TRUE); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-golab.inc b/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-golab.inc new file mode 100644 index 000000000..dc75674c2 --- /dev/null +++ b/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-golab.inc @@ -0,0 +1,261 @@ + "alias", + "gosaMailQuota" => "cyrus-userquota", + "gosaMailServer" => "kolabHomeServer"); + + function mailMethodGolab(&$config) + { + $this->config= $config->data['SERVERS']['IMAP']; + } + + function updateMailbox($folder) + { + } + + function setQuota($folder, $gosaMailQuota) + { + return (TRUE); + } + + /* Get quota and divide it by 1024, because in gosa we display in MB + but we get Kb */ + function getQuota($folder) + { + $result= array('quotaUsage' => '', 'gosaMailQuota' => ''); + + /* Only use lower case folder names, if folder name is like "@domain.com" */ + if(preg_match("/@/",$folder)){ + $folder = strtolower($folder); + } + + error_reporting(0); + + /* Load quota settings */ + $quota_value = @imap_get_quota($this->mbox, $folder); + if(is_array($quota_value)) { + if (isset($quota_value["STORAGE"]) && is_array($quota_value["STORAGE"])){ + /* use for PHP >= 4.3 */ + $result['quotaUsage']= (int) ($quota_value["STORAGE"]['usage'] / 1024); + $result['gosaMailQuota']= (int) ($quota_value["STORAGE"]['limit'] / 1024); + } else { + /* backward icompatible */ + $result['quotaUsage']= (int) ($quota_value['usage'] / 1024); + $result['gosaMailQuota']= (int) ($quota_value['limit'] / 1024); + } + }elseif(!$quota_value){ + return(false); + } + + error_reporting(E_ALL | E_STRICT); + + return ($result); + } + + + function fixAttributesOnLoad(&$mailObject) + { + /* Kolab shared folder names are like ' shared.uid@server.de ' + So overwrite uid to match these folder names. Else we can't read quota settings etc. + #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/ + if(get_class($mailObject) == "mailgroup"){ + $mailObject->uid = $mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail); + } + + /* Convert attributes and objectClasses */ + foreach ($this->attribute_map as $dest => $source){ + /* Hickert 11.11.05 : Alternate email addresses were saved, but not displayed again. + if (isset($mailObject->attrs[$source])){ + $mailObject->attrs[$dest]= $mailObject->attrs[$source]; + unset ($mailObject->attrs[$source]); + */ + + if (isset($mailObject->attrs[$source])){ + unset($mailObject->attrs[$source]['count']); + $mailObject->attrs[$dest]= $mailObject->attrs[$source]; + $mailObject->$dest= $mailObject->attrs[$source]; + + unset ($mailObject->$dest['count']); + unset ($mailObject->attrs[$source]); + } + } + + /* Adjust server name if needed */ + foreach ($mailObject->config->data['SERVERS']['IMAP'] as $srv => $dummy){ + if (preg_match("%".$mailObject->attrs['gosaMailServer'][0]."$%", $srv)){ + $mailObject->attrs['gosaMailServer']= array(0 => $srv, "count" => 1); + break; + } + } + } + + + function fixAttributesOnStore(&$mailObject) + { + global $config; + + /* If quota is empty, remove quota restrictions by setting quota to 0 */ + if(isset($mailObject->gosaMailQuota) && (empty($mailObject->gosaMailQuota))){ + $mailObject->attrs['gosaMailQuota'] = 0; + } + + /* Convert attributes and objectClasses */ + foreach ($this->attribute_map as $source => $dest){ + if (isset($mailObject->attrs[$source])){ + $mailObject->attrs[$dest]= $mailObject->attrs[$source]; + unset ($mailObject->attrs[$source]); + } + } + $objectclasses= array(); + foreach ($mailObject->attrs['objectClass'] as $oc){ + if ($oc != 'kolabInetOrgPerson' && $oc != 'kolabSharedFolder'){ + $objectclasses[]= $oc; + } + } + $mailObject->attrs['objectClass']= $objectclasses; + if (in_array("posixGroup", $mailObject->attrs['objectClass'])){ + + /* Add kolabSharedFoleder Class */ + $mailObject->attrs['objectClass'][]= 'kolabSharedFolder'; + + /* Work on acl attribute */ + $new_acl= array(); + foreach ($mailObject->attrs['acl'] as $uacl){ + + /* Get user=(mail) & acls */ + list($user, $acl) = split(" ", $uacl); + + /* Add al users which have seperated acls + %members% are all users in this group, + which have the standard group acl + */ + if ($user != "%members%"){ + $new_acl[$user]= $uacl; + } else { + + /* All groupmembers will be added */ + $ldap = $config->get_ldap_link(); + $ldap->cd($config->current['BASE']); + foreach ($mailObject->members as $member){ + + /* Get user mail address .... */ + $ldap->search("(&(objectClass=person)(|(uid=".$member.")(mail=".$member.")))",array("mail")); + $res = $ldap->fetch(); + + /* Default mail address is set to uid - + So if there is no mail address defined the uid is added + */ + $mail = $member; + + /* Use mail address if it is available */ + if(isset($res['mail'][0])){ + $mail = $res['mail'][0]; + } + + /* only append this mail/permission string to acl, + if there arn't already some (special) configs for this user */ + $found =false; + foreach($mailObject->imapacl as $mailA => $acl){ + if(strtolower(trim($mailA))==strtolower(trim($mail))){ + $found = true; + } + } + + /* Skipp user, with no email adress too */ + if($member == $mail){ + $found = true; + } + + /* Append new user acl */ + if(!$found){ + $new_acl[$member]= "$mail $acl"; + } + + /* Old line */ + // $new_acl[$member]= "$member $acl"; + } + } + } + + /* Save shared folder target */ + $mailObject->attrs['gosaSharedFolderTarget']= "kolab+".$mailObject->mail; + + /* Kolab shared folder names are like ' shared.uid@server.de ' + So overwrite uid to match these folder names. Else we can't read quota settings etc. + #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/ + $mailObject->uid = $mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail); + + /* Assign new acls */ + $mailObject->attrs['acl']= array(); + foreach ($new_acl as $key => $value){ + $mailObject->attrs['acl'][]= $value; + } + } else { + $mailObject->attrs['objectClass'][]= 'kolabInetOrgPerson'; + } + + /* Remove imap:// tagging */ + $mailObject->attrs['kolabHomeServer']= preg_replace('%imap://%', '', $mailObject->attrs['kolabHomeServer']); + $mailObject->attrs['gosaMailServer']= $mailObject->attrs['kolabHomeServer']; + $mailObject->attrs['kolabDeleteFlag']= array(); + } + + function fixAttributesOnRemove(&$mailObject) + { + /* Add attribute for object deletion and remove GOsa specific + values from entry. */ + foreach($this->attribute_map as $kolabAttr){ + $mailObject->attrs[$kolabAttr] = array(); + } + + /* Only add kolab delete Flag in case of an user.mailAccount */ + if(!in_array("posixGroup", $mailObject->attrs['objectClass'])){ + $mailObject->attrs['kolabDeleteFlag']= preg_replace('%imap://%', '', $mailObject->gosaMailServer); + }else{ + /* Kolab shared folder names are like ' shared.uid@server.de ' + So overwrite uid to match these folder names. Else we can't read quota settings etc. + #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/ + $mailObject->uid = $mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail); + + } + } + + + function deleteMailbox($folder) + { + /* Remove shared folders and skip removing users. + KolabD is not able to remove shared folders yet, so we do it instead */ + if(!(preg_match("/^user\//",$folder))){ + return mailMethodCyrus::deleteMailbox($folder); + } + return (TRUE); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-kolab.inc b/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-kolab.inc new file mode 100644 index 000000000..c0606046b --- /dev/null +++ b/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-kolab.inc @@ -0,0 +1,267 @@ + "alias", + "gosaMailQuota" => "cyrus-userquota", + "gosaMailServer" => "kolabHomeServer"); + + function mailMethodKolab(&$config) + { + $this->config= $config->data['SERVERS']['IMAP']; + } + + function updateMailbox($folder) + { + } + + function setQuota($folder, $gosaMailQuota) + { + return (TRUE); + } + + /* Get quota and divide it by 1024, because in gosa we display in MB + but we get Kb */ + function getQuota($folder) + { + $result= array('quotaUsage' => '', 'gosaMailQuota' => ''); + + /* Only use lower case folder names, if folder name is like "@domain.com" */ + if(preg_match("/@/",$folder)){ + $folder = strtolower($folder); + } + + error_reporting(0); + + /* Load quota settings */ + $quota_value = @imap_get_quota($this->mbox, $folder); + if(is_array($quota_value)) { + if (isset($quota_value["STORAGE"]) && is_array($quota_value["STORAGE"])){ + /* use for PHP >= 4.3 */ + $result['quotaUsage']= (int) ($quota_value["STORAGE"]['usage'] / 1024); + $result['gosaMailQuota']= (int) ($quota_value["STORAGE"]['limit'] / 1024); + } else { + /* backward icompatible */ + $result['quotaUsage']= (int) ($quota_value['usage'] / 1024); + $result['gosaMailQuota']= (int) ($quota_value['limit'] / 1024); + } + }elseif(!$quota_value){ + return(false); + } + + error_reporting(E_ALL | E_STRICT); + + return ($result); + } + + + function fixAttributesOnLoad(&$mailObject) + { + /* Kolab shared folder names are like ' shared.uid@server.de ' + So overwrite uid to match these folder names. Else we can't read quota settings etc. + #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/ + if(get_class($mailObject) == "mailgroup"){ + $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail); + } + + /* Convert attributes and objectClasses */ + foreach ($this->attribute_map as $dest => $source){ + /* Hickert 11.11.05 : Alternate email addresses were saved, but not displayed again. + if (isset($mailObject->attrs[$source])){ + $mailObject->attrs[$dest]= $mailObject->attrs[$source]; + unset ($mailObject->attrs[$source]); + */ + + if (isset($mailObject->attrs[$source])){ + unset($mailObject->attrs[$source]['count']); + $mailObject->attrs[$dest]= $mailObject->attrs[$source]; + $mailObject->$dest= $mailObject->attrs[$source]; + + /* Ensure that cleanup will recognize the ampped attributes too */ + if(isset($mailObject->saved_attributes)){ + $mailObject->saved_attributes[$dest] = $mailObject->attrs[$source]; + $mailObject->saved_attributes[$source] = $mailObject->attrs[$source]; + } + + unset ($mailObject->$dest['count']); + unset ($mailObject->attrs[$source]); + } + } + + /* Adjust server name if needed */ + foreach ($mailObject->config->data['SERVERS']['IMAP'] as $srv => $dummy){ + if (preg_match("%".$mailObject->attrs['gosaMailServer'][0]."$%", $srv)){ + $mailObject->attrs['gosaMailServer']= array(0 => $srv, "count" => 1); + break; + } + } + } + + + function fixAttributesOnStore(&$mailObject) + { + global $config; + + /* If quota is empty, remove quota restrictions by setting quota to 0 */ + if(isset($mailObject->gosaMailQuota) && (empty($mailObject->gosaMailQuota))){ + $mailObject->attrs['gosaMailQuota'] = 0; + } + + /* Convert attributes and objectClasses */ + foreach ($this->attribute_map as $source => $dest){ + if (isset($mailObject->attrs[$source])){ + $mailObject->attrs[$dest]= $mailObject->attrs[$source]; + unset ($mailObject->attrs[$source]); + } + } + $objectclasses= array(); + foreach ($mailObject->attrs['objectClass'] as $oc){ + if ($oc != 'kolabInetOrgPerson' && $oc != 'kolabSharedFolder'){ + $objectclasses[]= $oc; + } + } + $mailObject->attrs['objectClass']= $objectclasses; + if (in_array("posixGroup", $mailObject->attrs['objectClass'])){ + + /* Add kolabSharedFoleder Class */ + $mailObject->attrs['objectClass'][]= 'kolabSharedFolder'; + + /* Work on acl attribute */ + $new_acl= array(); + foreach ($mailObject->attrs['acl'] as $uacl){ + + /* Get user=(mail) & acls */ + list($user, $acl) = split(" ", $uacl); + + /* Add al users which have seperated acls + %members% are all users in this group, + which have the standard group acl + */ + if ($user != "%members%"){ + $new_acl[$user]= $uacl; + } else { + + /* All groupmembers will be added */ + $ldap = $config->get_ldap_link(); + $ldap->cd($config->current['BASE']); + foreach ($mailObject->members as $member){ + + /* Get user mail address .... */ + $ldap->search("(&(objectClass=person)(|(uid=".$member.")(mail=".$member.")))",array("mail")); + $res = $ldap->fetch(); + + /* Default mail address is set to uid - + So if there is no mail address defined the uid is added + */ + $mail = $member; + + /* Use mail address if it is available */ + if(isset($res['mail'][0])){ + $mail = $res['mail'][0]; + } + + /* only append this mail/permission string to acl, + if there arn't already some (special) configs for this user */ + $found =false; + foreach($mailObject->imapacl as $mailA => $acl){ + if(strtolower(trim($mailA))==strtolower(trim($mail))){ + $found = true; + } + } + + /* Skipp user, with no email adress too */ + if($member == $mail){ + $found = true; + } + + /* Append new user acl */ + if(!$found){ + $new_acl[$member]= "$mail $acl"; + } + + /* Old line */ + // $new_acl[$member]= "$member $acl"; + } + } + } + + /* Save shared folder target */ + $mailObject->attrs['gosaSharedFolderTarget']= "kolab+shared.".$mailObject->mail; + + /* Kolab shared folder names are like ' shared.uid@server.de ' + So overwrite uid to match these folder names. Else we can't read quota settings etc. + #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/ + $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail); + + /* Assign new acls */ + $mailObject->attrs['acl']= array(); + foreach ($new_acl as $key => $value){ + $mailObject->attrs['acl'][]= $value; + } + } else { + $mailObject->attrs['objectClass'][]= 'kolabInetOrgPerson'; + } + + /* Remove imap:// tagging */ + $mailObject->attrs['kolabHomeServer']= preg_replace('%imap://%', '', $mailObject->attrs['kolabHomeServer']); + $mailObject->attrs['gosaMailServer']= $mailObject->attrs['kolabHomeServer']; + $mailObject->attrs['kolabDeleteFlag']= array(); + } + + function fixAttributesOnRemove(&$mailObject) + { + /* Add attribute for object deletion and remove GOsa specific + values from entry. */ + foreach($this->attribute_map as $kolabAttr){ + $mailObject->attrs[$kolabAttr] = array(); + } + + /* Only add kolab delete Flag in case of an user.mailAccount */ + if(!in_array("posixGroup", $mailObject->attrs['objectClass'])){ + $mailObject->attrs['kolabDeleteFlag']= preg_replace('%imap://%', '', $mailObject->gosaMailServer); + }else{ + /* Kolab shared folder names are like ' shared.uid@server.de ' + So overwrite uid to match these folder names. Else we can't read quota settings etc. + #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/ + $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail); + + } + } + + + function deleteMailbox($folder) + { + /* Remove shared folders and skip removing users. + KolabD is not able to remove shared folders yet, so we do it instead */ + if(preg_match("/^shared/",$folder)){ + return mailMethodCyrus::deleteMailbox($folder); + } + return (TRUE); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?>