Code

Fixed groupMail saving.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 22 Nov 2007 09:02:41 +0000 (09:02 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 22 Nov 2007 09:02:41 +0000 (09:02 +0000)
Acl were generated and then resetted again, via $this->attrs['acl'] = array();
-Removed duplicated code.
-Fixed acl assignement.
-- When a member of the mail group, has toggled his mailAccount from inactive to active, the acl entry wasn't updated.

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

plugins/admin/groups/class_groupMail.inc

index 8b5fa3c81cac479af99267ac5f86c3ef435cdab5..58c2a5e663b9deb832da6b62c4bf0ae398395979 100644 (file)
@@ -778,21 +778,41 @@ I: Only insider delivery */
     $this->attrs['gosaMailForwardingAddress'] = $this->gosaMailForwardingAddress;
     $this->attrs['gosaSharedFolderTarget']    = "share+".$this->uid;
 
+    /* Only do IMAP actions if we are not a template */
+    if(preg_match("/olab/i",$this->mmethod)){
+      if (empty($this->gosaMailServer)||is_array($this->gosaMailServer)){
+        if(isset($this->attrs['gosaMailServer'][0])){
+          $this->gosaMailServer = $this->attrs['gosaMailServer'][0];
+        }
+      }
+    }  
+
+    /* Exchange '%member%' pseudo entry */
+    $memberacl= $this->imapacl['%members%'];
+
+    foreach ($this->members as $user){
+      if (!isset($this->imapacl[$user])){
+        $this->imapacl[$user]= $memberacl;
+      }
+    }
     if(preg_match("/olab/i",$this->mmethod)){
+
       /* Save acl's */
       $this->attrs['acl']= array();
       foreach ($this->imapacl as $user => $acl){
-        if ($user == ""){
+        if ($user == "" || preg_match("/%members%/",$user)){
           continue;
         }
         $ldap->search("(&(objectClass=person)(|(uid=".$user.")(mail=".$user.")))",array("mail"));
         $mail = $ldap->fetch();
-        if($mail){
-          if(isset($mail['mail'][0])){
-            $this->attrs['acl'][]= $mail['mail'][0]." $acl";
-          }
+        if(isset($mail['mail'][0])){
+          $sacl = $mail['mail'][0]." ".$acl;
         }else{
-          $this->attrs['acl'][]= "$user $acl";
+          $sacl= "$user $acl";
+        }
+        if(!in_array($sacl,$this->attrs['acl'])){
+          $this->attrs['acl'][]= $sacl;
         }
       }
    
@@ -802,63 +822,17 @@ I: Only insider delivery */
         $this->attrs['kolabFolderType'] = array();
       }
     }else{
+
       /* Save acl's */
       $this->attrs['acl']= array();
       foreach ($this->imapacl as $user => $acl){
-        if ($user == ""){
+        if ($user == "" || preg_match("/%members%/",$user)){
           continue;
         }
         $this->attrs['acl'][]= "$user $acl";
       }
     }
 
-    /* Only do IMAP actions if we are not a template */
-    if(preg_match("/olab/i",$this->mmethod)){
-      if (empty($this->gosaMailServer)||is_array($this->gosaMailServer)){
-        if(isset($this->attrs['gosaMailServer'][0])){
-          $this->gosaMailServer = $this->attrs['gosaMailServer'][0];
-        }
-      }
-    }  
-
-
-    /* Exchange '%member%' pseudo entry */
-    $memberacl= $this->imapacl['%members%'];
-
-    foreach ($this->members as $user){
-      if(preg_match("/olab/i",$this->mmethod)){
-        $ldap->cd($this->config->current['BASE']);
-        $ldap->search("(&(objectClass=person)(|(mail=".$user.")(uid=".$user.")))",array("mail"));
-        $at = $ldap->fetch();
-        if(isset($at['mail'][0])){
-          $user = $at['mail'][0];
-        }
-      }
-      if (!isset($this->imapacl[$user])){
-        $this->imapacl[$user]= $memberacl;
-      }
-    }
-    $this->attrs['acl'] = array();
-    
-    
-    foreach($this->imapacl as $user => $acl){
-
-      /* Remove empty user entry, to avoid entry like this im imap 
-       *   "" lrs
-       */
-      if(empty($user)){
-        unset($this->imapacl[$user]);
-      }
-   
-      /* Skip invalid values */
-      if(preg_match("/%members%/",$user) || empty($user)){
-        continue;
-      }
-
-      /* Append ldap acl entries */
-      $this->attrs['acl'][] = $user." ".$acl;
-    }
-
     if ((!$this->is_template)&&(!empty($this->gosaMailServer))){
       $method= new $this->method($this->config);
       $method->fixAttributesOnStore($this);
@@ -1079,6 +1053,17 @@ I: Only insider delivery */
     /* Reset alternate mail addresses */
     $this->gosaMailAlternateAddress = array();
   }
+
+  
+  /* Remove given ACL for given member (uid,mail) ..
+   */
+  function removeUserAcl($index )
+  {
+    if(isset($this->imapacl[$index])){
+      unset($this->imapacl[$index]);
+    }
+  }
+
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>