Code

Updated function that returns all available bases (Allowed to move to)
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 6 Sep 2006 04:40:34 +0000 (04:40 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 6 Sep 2006 04:40:34 +0000 (04:40 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4600 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/personal/generic/class_user.inc

index 17c92f0a410d80afcc8916baf23ad8571824dbd1..3b4e2037435928ff7ed55a229fd26de6bc5c2f68 100644 (file)
@@ -1228,43 +1228,24 @@ class user extends plugin
    */
   function allowedBasesToMoveTo()
   {
-    $allowed = array();
-    $ret_all = false;
-    if($this->uid == $_SESSION['ui']->username){
-      $ldap= $this->config->get_ldap_link(); 
-      $ldap->cd($this->config->current['BASE']); 
-      $ldap->search("(&(objectClass=posixGroup)(memberUid=".$_SESSION['ui']->username."))",array("gosaSubtreeACL"));
-       
-      while($attrs = $ldap->fetch()){
-    
-        if(isset($attrs['gosaSubtreeACL'])){
-        
-          foreach($attrs['gosaSubtreeACL'] as $attr){
-            if((preg_match("/:user#/",$attr))||(preg_match("/:all/",$attr))){
-              $s =  preg_replace("/^.*ou=groups,/","",$attrs['dn']);
-
-              foreach($this->config->idepartments as $key => $dep) {
-                if(preg_match("/".$s."/i",$key)){
-                  $allowed[$key] = $dep;
-                }
-              }
-            }
-          }
-        }
+    /* Get bases */
+    $ui     = get_userinfo();
+    $check  = $ui->get_module_departments("ogroups");
+    $bases  = array();
+
+    foreach($check as $dn_allowed){
+      $bases[$dn_allowed] = $this->config->idepartments[$dn_allowed];
+    }
+
+    foreach($bases as $key => $base ){
+      $acl =  $ui->get_permissions($key,"users/user");
+     
+      /* Remove those bases, which are not allowed to move to, but keep current base ...  */ 
+      if(!preg_match("/m/",$acl) && $key != $this->base){
+        unset($bases[$key]);
       }
-      if(count($allowed) == 0){
-        foreach($this->config->idepartments as $key => $dep) {
-          if($this->base==$key){
-            $allowed[$key] = $dep;
-          }
-        }
-      }  
-  
-      return($allowed);
-      
-    }else{
-      return($this->config->idepartments);
     }
+    return($bases);
   }