From 13dcc099b7e178611caf7df9df99f7ba1f3c3194 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 22 Nov 2007 09:35:26 +0000 Subject: [PATCH] Fixed saving of users which are member in a sharedFolder. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7849 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/groups/class_groupMail.inc | 93 +++++++++------------ plugins/personal/mail/class_mailAccount.inc | 26 ++++++ 2 files changed, 65 insertions(+), 54 deletions(-) diff --git a/plugins/admin/groups/class_groupMail.inc b/plugins/admin/groups/class_groupMail.inc index 46a521a8a..952aab3e5 100644 --- a/plugins/admin/groups/class_groupMail.inc +++ b/plugins/admin/groups/class_groupMail.inc @@ -840,21 +840,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; } } @@ -864,63 +884,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); @@ -1171,6 +1145,17 @@ I: Only insider delivery */ "acl" => _("Permissions")) )); } + + + /* 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: diff --git a/plugins/personal/mail/class_mailAccount.inc b/plugins/personal/mail/class_mailAccount.inc index f1a5cd7dc..cf0db8591 100644 --- a/plugins/personal/mail/class_mailAccount.inc +++ b/plugins/personal/mail/class_mailAccount.inc @@ -696,6 +696,9 @@ class mailAccount extends plugin } } + /* Update shared folder membership, ACL may need to be updated */ + $this->updateSharedFolder(); + /* Optionally execute a command after we're done */ $this->handle_post_events("remove",array("uid" => $this->uid)); } @@ -884,6 +887,7 @@ class mailAccount extends plugin $this->handle_post_events("add", array("uid" => $this->uid)); } + $this->updateSharedFolder(); } @@ -1168,6 +1172,28 @@ class mailAccount extends plugin "gosaMailDeliveryModeC" => _("Use custom sieve script")) // This is flag of gosaMailDeliveryMode )); } + + /* Upated shared folder ACLs + */ + function updateSharedFolder() + { + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=posixGroup)(objectClass=gosaMailAccount)(memberUid=".$this->uid."))",array('dn','cn')); + if(class_exists("grouptabs")){ + while($attrs = $ldap->fetch()){ + $tmp = new grouptabs($this->config, $this->config->data['TABS']['GROUPTABS'], $attrs['dn']); + if(isset($tmp->by_object['mailgroup'])){ + $tmp->by_object['mailgroup']->members= $tmp->by_object['group']->memberUid; + if(!$this->is_account){ + $tmp->by_object['mailgroup']->removeUserAcl($this->uid); + $tmp->by_object['mailgroup']->removeUserAcl($this->mail); + } + $tmp->by_object['mailgroup']->save(); + } + } + } + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -- 2.30.2