X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fpersonal%2Fmail%2Fclass_mailAccount.inc;h=bff7beeb0397a48690f7a5d1a423d8b8a2cdf9d8;hb=888f9d7ce78494b0c3308f551bd0857e1ecfc0d0;hp=9982147537f88c2f655eadf3d0f09eabcccdf98b;hpb=e3e8bf372a9c676d46e580820d12e4cf74af4d35;p=gosa.git diff --git a/plugins/personal/mail/class_mailAccount.inc b/plugins/personal/mail/class_mailAccount.inc index 998214753..bff7beeb0 100644 --- a/plugins/personal/mail/class_mailAccount.inc +++ b/plugins/personal/mail/class_mailAccount.inc @@ -71,9 +71,16 @@ class mailAccount extends plugin plugin::plugin($config, $dn); if(isset($this->attrs['uid'])){ - $this->uid = $this->attrs['uid']; + $this->uid = $this->attrs['uid'][0]; } + if(is_array($this->gosaMailServer) && isset($this->gosaMailServer[0])){ + $this->gosaMailServer = $this->gosaMailServer[0]; + } + + /* Save initial account state */ + $this->initially_was_account= $this->is_account; + /* Set mailMethod to the one defined in gosa.conf */ if (isset($this->config->current['MAILMETHOD'])){ $method= $this->config->current['MAILMETHOD']; @@ -85,9 +92,8 @@ class mailAccount extends plugin } - /* Create the account prefix user. user/ */ - - /* Preset folder prefix. Will change it later to respect + /* Create the account prefix user. user/ + Preset folder prefix. Will change it later to respect altnamespace. */ if (isset($this->config->current['CYRUSUNIXSTYLE']) && $this->config->current['CYRUSUNIXSTYLE'] == "true"){ $this->folder_prefix= "user/"; @@ -97,8 +103,6 @@ class mailAccount extends plugin /* This is not a new account, parse additional attributes */ - - #FIXME i think is_account would be enough if (($dn != NULL) && ($dn != "new") && $this->is_account){ /* Load attributes containing arrays */ @@ -111,15 +115,6 @@ class mailAccount extends plugin } } - if(is_array($this->gosaMailServer) && isset($this->gosaMailServer[0])){ - $this->gosaMailServer = $this->gosaMailServer[0]; - } - - /* Save initial account state */ - $this->initially_was_account= $this->is_account; - - - /* If there is a server defined, connect and get some more infos */ /* Only do IMAP actions if gosaMailServer attribute is set */ if (isset ($this->attrs["gosaMailServer"][0])){ @@ -133,7 +128,7 @@ class mailAccount extends plugin /* Update quota values */ $quota= $method->getQuota($this->folder_prefix.$this->$id); - + if($quota){ if ($quota['gosaMailQuota'] == 2147483647){ $this->quotaUsage = ""; @@ -143,7 +138,9 @@ class mailAccount extends plugin $this->gosaMailQuota = $quota['gosaMailQuota']; } }else{ - print_red(sprintf(_("Can't get quota for for '%s'."),$this->folder_prefix.$this->$id)); + $this->quotaUsage = ""; + $this->gosaMailQuota = ""; + print_red(sprintf(_("Can't get quota information for '%s'."),$this->folder_prefix.$this->$id)); } /* Get mailboxes / folder like INBOX ..*/ @@ -704,11 +701,12 @@ class mailAccount extends plugin /* Adapt attributes if needed */ $method= new $this->method($this->config); $id= $method->uattrib; + $method->fixAttributesOnStore($this); - /* Remove Mailquota if = "" */ - if((isset($this->attrs['gosaMailQuota']))&&($this->attrs['gosaMailQuota']=="")) { - $this->attrs['gosaMailQuota']=array(); + /* Remove Mailquota if = "" or "0" */ + if((isset($this->attrs['gosaMailQuota']))&&(!$this->attrs['gosaMailQuota'])) { + $this->attrs['gosaMailQuota']=0; } if(empty($this->attrs['gosaSpamMailbox'])){ @@ -729,6 +727,7 @@ class mailAccount extends plugin if ($method->connect($this->gosaMailServer)){ $method->updateMailbox($this->folder_prefix.$this->$id); + $method->setQuota($this->folder_prefix.$this->$id, $this->gosaMailQuota); $method->disconnect(); @@ -757,10 +756,12 @@ class mailAccount extends plugin } + /* Check formular input */ function check() { if(!$this->is_account) return(array()); + $ldap= $this->config->get_ldap_link(); /* Call common method to give check the hook */ @@ -821,6 +822,7 @@ class mailAccount extends plugin return ($message); } + /* Adapt from template, using 'dn' */ function adapt_from_template($dn) { @@ -843,17 +845,18 @@ class mailAccount extends plugin $this->mail= strtolower(rewrite($this->mail)); } + /* Add entry to forwarder list */ function addForwarder($address) { $this->gosaMailForwardingAddress[]= $address; $this->gosaMailForwardingAddress= array_unique ($this->gosaMailForwardingAddress); - sort ($this->gosaMailForwardingAddress); reset ($this->gosaMailForwardingAddress); $this->is_modified= TRUE; } + /* Remove list of addresses from forwarder list */ function delForwarder($addresses) { @@ -862,13 +865,13 @@ class mailAccount extends plugin } - + /* Add given mail address to the list of alternate adresses , + check if this mal address is used, skip adding in this case */ function addAlternate($address) { $ldap= $this->config->get_ldap_link(); - $address= strtolower($address); - + /* Is this address already assigned in LDAP? */ $ldap->cd ($this->config->current['BASE']); $ldap->search ("(&(objectClass=gosaMailAccount)(|(mail=$address)"."(gosaMailAlternateAddress=$address)))", array("uid")); @@ -886,7 +889,6 @@ class mailAccount extends plugin sort ($this->gosaMailAlternateAddress); reset ($this->gosaMailAlternateAddress); - return (""); } @@ -947,6 +949,26 @@ class mailAccount extends plugin } } + + function allow_remove() + { + if (isset($this->config->current['MAILMETHOD'])){ + $method= $this->config->current['MAILMETHOD']; + if(preg_match("/kolab/i",$method)){ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->cat($this->dn); + if($ldap->count()){ + $attrs = $ldap->fetch(); + if(isset($attrs['kolabDeleteFlag'])){ + return(_("Waiting for kolab to remove mail properties.")); + }elseif(in_array("gosaMailAccount",$attrs['objectClass'])){ + return(_("Please remove the mail account first, to allow kolab to call its remove methods.")); + } + } + } + } + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: