Code

Updated mailAccount.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 24 Jun 2008 11:33:08 +0000 (11:33 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 24 Jun 2008 11:33:08 +0000 (11:33 +0000)
-Ensure that the entered mail address is uniq. (alias, mail, gosaMailAlternateAddress)

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11415 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/mail/personal/mail/class_mailAccount.inc

index aecfc14a1977f6e4f5f77046159d4c2515924d64..f2f332f208a8f62b2b430e1c73a0631c951f194e 100644 (file)
@@ -940,12 +940,18 @@ class mailAccount extends plugin
         $message[]= msgPool::invalid(_("Mail address"),"","","your-domain@your-domain.com");
       }
     }
+
     $ldap->cd($this->config->current['BASE']);
-    $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=".$this->mail.")(gosaMailAlternateAddress=".$this->mail."))(!(uid=".$this->uid."))(!(cn=".$this->uid.")))", array("uid"));
+    $filter = "(&(!(objectClass=gosaUserTemplate))(!(uid=".$this->uid."))".
+      "(objectClass=gosaMailAccount)".
+      "(|(mail=".$this->mail.")(alias=".$this->mail.")(gosaMailAlternateAddress=".$this->mail.")))";
+
+    $ldap->search($filter,array("uid"));
     if ($ldap->count() != 0){
       $message[]= msgPool::duplicated(_("Mail address"));
     }
 
+
     /* Check quota */
     if ($this->gosaMailQuota != '' && $this->acl_is_writeable("gosaMailQuota")){
       if (!is_numeric($this->gosaMailQuota)) {
@@ -1046,8 +1052,8 @@ class mailAccount extends plugin
 
       /* Is this address already assigned in LDAP? */
       $ldap->cd ($this->config->current['BASE']);
-      $ldap->search ("(&(objectClass=gosaMailAccount)(|(mail=$address)"."(gosaMailAlternateAddress=$address)))", array("uid"));
-      $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=$address)"."(gosaMailAlternateAddress=$address)))", array("uid"));
+      $ldap->search ("(&(!(objectClass=gosaUserTemplate))(objectClass=gosaMailAccount)(|(mail=$address)".
+          "(alias=$address)(gosaMailAlternateAddress=$address)))", array("uid"));
 
       if ($ldap->count() > 0){
         $attrs= $ldap->fetch ();