From: hickert Date: Thu, 22 Nov 2007 12:09:32 +0000 (+0000) Subject: Fixed cyrus shared folder acls to work again. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=434844d5c7663b2b6fda7242577d0f290ebfebfc;p=gosa.git Fixed cyrus shared folder acls to work again. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7851 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/groups/class_groupMail.inc b/plugins/admin/groups/class_groupMail.inc index 58c2a5e66..fb5e15ba0 100644 --- a/plugins/admin/groups/class_groupMail.inc +++ b/plugins/admin/groups/class_groupMail.inc @@ -789,50 +789,73 @@ I: Only insider delivery */ /* 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 */ + /* Prepare kolab attributes to be written */ + if(preg_match("/olab/i",$this->mmethod)){ $this->attrs['acl']= array(); - foreach ($this->imapacl as $user => $acl){ - if ($user == "" || preg_match("/%members%/",$user)){ - continue; - } - $ldap->search("(&(objectClass=person)(|(uid=".$user.")(mail=".$user.")))",array("mail")); - $mail = $ldap->fetch(); - if(isset($mail['mail'][0])){ - $sacl = $mail['mail'][0]." ".$acl; - }else{ - $sacl= "$user $acl"; - } - if(!in_array($sacl,$this->attrs['acl'])){ - $this->attrs['acl'][]= $sacl; - } - } - if(!empty($this->kolabFolderType_Type)){ $this->attrs['kolabFolderType'] = $this->kolabFolderType_Type.".".$this->kolabFolderType_SubType; }else{ $this->attrs['kolabFolderType'] = array(); } }else{ + $this->attrs['acl']= array();; + unset($this->attrs['acl']); + } - /* Save acl's */ - $this->attrs['acl']= array(); - foreach ($this->imapacl as $user => $acl){ - if ($user == "" || preg_match("/%members%/",$user)){ - continue; + /* Get naming attribute for mail accounts */ + $tmp = new $this->method($this->config); + $uattrib = $tmp->uattrib; + + /* Create ACL array + * In case of kolab also create attrs['acl'] to save acls in ldap. + */ + foreach ($this->imapacl as $user => $acl){ + + /* Skip placeholder */ + if ($user == "" || preg_match("/%members%/",$user)){ + continue; + } + + /* Check if your is a real GOsa user + * If user is a real GOsa user but do not have an email address - SKIP adding acls + * If user is a real GOsa user with an emal address - add acls + */ + $ldap->search("(&(objectClass=person)(|(uid=".$user.")(mail=".$user.")))",array("mail","uid")); + if($ldap->count()){ + $attrs = $ldap->fetch(); + + /* Has the user a valid mail account? */ + if(isset($attrs['mail'][0])){ + + $name = $attrs[$uattrib][0]; + + /* In case of kolab methods add acl attribute too */ + if(preg_match("/olab/i",$this->mmethod)){ + $this->attrs['acl'][]= $name." ".$acl; + } + $this->imapacl[$name] = $acl; + }else{ + + /* User has no mail extension */ + unset($this->imapacl[$user]); } - $this->attrs['acl'][]= "$user $acl"; + }else{ + /* Seems to be a manually added acl */ + + /* In case of kolab methods add acl attribute too */ + if(preg_match("/olab/i",$this->mmethod)){ + $this->attrs['acl'][]= $user." ".$acl; + } + $this->imapacl[$user] = $acl; } } - + if ((!$this->is_template)&&(!empty($this->gosaMailServer))){ $method= new $this->method($this->config); $method->fixAttributesOnStore($this);