Code

Update shared folder when a user updates his mailAccount plugin.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 22 Nov 2007 09:06:56 +0000 (09:06 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 22 Nov 2007 09:06:56 +0000 (09:06 +0000)
-If he removes the mail extension from his account, then remove the acl entry from all sharedFolder too.

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

plugins/personal/mail/class_mailAccount.inc

index ba53438af09be97ebeaa4d219d8fc1ee50b6a731..5f1056d6ab9aba552727f2b9c1df72dad687885c 100644 (file)
@@ -761,6 +761,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));
   }
@@ -924,6 +927,7 @@ class mailAccount extends plugin
       $this->handle_post_events("add", array('uid'=>$this->uid));
     }
 
+    $this->updateSharedFolder();
   }
 
 
@@ -1152,6 +1156,28 @@ class mailAccount extends plugin
       }
     }
   }
+
+  /* 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: