Code

Added new base method
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 19 Sep 2006 04:47:34 +0000 (04:47 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 19 Sep 2006 04:47:34 +0000 (04:47 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4717 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_plugin.inc
plugins/admin/applications/class_applicationGeneric.inc
plugins/admin/departments/class_departmentGeneric.inc
plugins/admin/groups/class_groupGeneric.inc
plugins/admin/mimetypes/class_mimetypeGeneric.inc
plugins/admin/ogroups/class_ogroup.inc
plugins/personal/generic/class_user.inc
plugins/personal/generic/main.inc

index 239e89fc5eea63d5f47a4ce629088f543e2da9d2..72994996b059e6147bc535d7160bd2141d64423d 100644 (file)
@@ -1465,6 +1465,42 @@ echo "FIXME: remove_snapshot uses old acl's<br>";
     return  $ui->get_permissions($this->acl_base, $this->acl_category.get_class($this), $attribute,$skip_write);
   }
 
+  /* Get all allowed bases to move an object to or to create a new object.
+     Idepartments also contains all base departments which lead to the allowed bases */
+  function acl_get_bases($category = "")
+  {
+    $ui = get_userinfo();
+    $deps = array();
+    /* Set category */ 
+    if(empty($category)){
+      $category = $this->acl_category.get_class($this);
+    }
+
+    /* Is this a new object ? Or just an edited existing object */
+    if(!$this->initially_was_account && $this->is_account){
+      $new = true;
+    }else{
+      $new = false;
+    }
+
+    /* Add current base */      
+    if(isset($this->base) && isset($this->config->idepartments[$this->base])){
+      $deps[$this->base] = $this->config->idepartments[$this->base];
+    }else{
+      echo "No default base found. <br>";
+    }
+
+    foreach($this->config->idepartments as $dn => $name){
+      $acl = $ui->get_permissions($dn,$category);
+      if($new && preg_match("/c/",$acl)){
+        $deps[$dn] = $name;
+      }elseif(!$new && preg_match("/m/",$acl)){
+        $deps[$dn] = $name;
+      }
+    }
+    return($deps);
+  }
 
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index 21c7de4619e8b865518b9028eb6a6724a3f2be06..68b2ac8f59a1c23d226b214d7cc378c9fbfbc978 100644 (file)
@@ -154,7 +154,7 @@ class application extends plugin
 
     /* Fill templating stuff */
     $smarty->assign("cn", $this->cn);
-    $smarty->assign("bases", $this->config->idepartments);
+    $smarty->assign("bases", $this->acl_get_bases());
     if ($this->dn == "new"){
       $smarty->assign("selectmode", "");
       $smarty->assign("namemode", "");
@@ -168,7 +168,7 @@ class application extends plugin
     foreach($_POST as $name => $value){
       if(preg_match("/^chooseBase/",$name) && $once){
         $once = false;
-        $this->dialog = new baseSelectDialog($this->config,$this);
+        $this->dialog = new baseSelectDialog($this->config,$this,$this->acl_get_bases());
         $this->dialog->setCurrentBase($this->base);
       }
     }
index 8bda169974fddf5c49e6a1e9c7e87056511de19f..a29b3edc428c0e57137064cd3290e5c38b0b2634 100644 (file)
@@ -101,21 +101,12 @@ class department extends plugin
       $smarty->assign($name."ACL",$this->getacl($name));
     }
 
-    /* Get bases */
-    $ui = get_userinfo();
-    $check = $ui->get_module_departments("department");
-    $check[] = $this->base;
-    $bases = array();
-    foreach($check as $dn_allowed){
-      $bases[$dn_allowed] = $this->config->idepartments[$dn_allowed];
-    }
-
                /* Base select dialog */
                $once = true;
                foreach($_POST as $name => $value){
                        if((preg_match("/^chooseBase/",$name) && $once) && ($this->acl_is_moveable())){
                                $once = false;
-                               $this->dialog = new baseSelectDialog($this->config,$this,$bases);
+                               $this->dialog = new baseSelectDialog($this->config,$this,$this->acl_get_bases());
                                $this->dialog->setCurrentBase($this->base);
                        }
                }
@@ -136,6 +127,7 @@ class department extends plugin
                }
 
                /* Hide all departments, that are subtrees of this department */
+    $bases = $this->acl_get_bases();
                if(($this->dn == "new")||($this->dn == "")){
                        $tmp = $bases;
                }else{
index c7c47dd8588b099caf2a953bec0d2bc38e899233..ef5341b243f322cc00803d30007f1eb191ec58e8 100644 (file)
@@ -205,21 +205,13 @@ class group extends plugin
       $this->reload();
     }
 
-    /* Get bases */
-    $ui = get_userinfo();
-    $check = $ui->get_module_departments("groups");
-    $bases = array();
-    foreach($check as $dn_allowed){
-      $bases[$dn_allowed] = $this->config->idepartments[$dn_allowed];
-    }
-
     /* Base select dialog */
     $once = true;
     foreach($_POST as $name => $value){
       if((preg_match("/^chooseBase/",$name) && $once) && ($this->acl_is_moveable())){
           
         $once = false;
-        $this->dialog = new baseSelectDialog($this->config,$this,$bases);
+        $this->dialog = new baseSelectDialog($this->config,$this,$this->acl_get_bases());
         $this->dialog->setCurrentBase($this->base);
       }
     }
@@ -301,15 +293,7 @@ class group extends plugin
       $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
       $smarty->assign("tree_image", get_template_path('images/tree.png'));
 
-      /* Get bases */
-      $ui = get_userinfo();
-      $check = $ui->get_module_departments("groups");
-      $bases = array();
-      foreach($check as $dn_allowed){
-        $bases[$dn_allowed] = $this->config->idepartments[$dn_allowed];
-      }
-      $smarty->assign("deplist", $bases_user_select);
+      $smarty->assign("deplist", $this->acl_get_bases("users/user"));
       $smarty->assign("alphabet", generate_alphabet());
       foreach( array("dselect", "regex","SubSearchGroup") as $type){
         $smarty->assign("$type", $gufilter[$type]);
@@ -326,7 +310,7 @@ class group extends plugin
       $this->base= $_POST['base'];
     }
 
-    $smarty->assign("bases", $bases);
+    $smarty->assign("bases", $this->acl_get_bases());
     $smarty->assign("base_select", $this->base);
 
     if ($this->samba3){
index cdadb5be263880255efca9e61257bd7cca4d1afd..37d45ca794e07734f7743737838f3ae7dab85edb 100644 (file)
@@ -165,7 +165,7 @@ class mimetype extends plugin
     foreach($_POST as $name => $value){
       if(preg_match("/^chooseBase/",$name) && $once){
         $once = false;
-        $this->dialog = new baseSelectDialog($this->config,$this);
+        $this->dialog = new baseSelectDialog($this->config,$this,$this->acl_get_bases());
         echo $this->base;
         $this->dialog->setCurrentBase($this->base);
       }
@@ -313,7 +313,7 @@ class mimetype extends plugin
       $fields = array($field1,$field2);
       $DivEApps -> AddEntry($fields);
     }
-    $smarty->assign("bases",                                           $this->config->idepartments);           
+    $smarty->assign("bases",                                           $this->acl_get_bases());                
     $smarty->assign("base_select",                                     $this->base);           
     $smarty->assign("isReleaseMimeType",                       $this->isReleaseMimeType);
     $smarty->assign("gotoMimeFilePatterns",                    $DivPatterns->DrawList());
index 6add554439bbe6f3e92cd7b35abcc6019b525818..f619d71f9a6f3db95db91b4bc7a1ca9045fd8e47 100644 (file)
@@ -182,21 +182,12 @@ class ogroup extends plugin
     }
     $smarty->assign("baseACL",          $baseACL);
 
-
-    /* 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];
-    }
-
     /* Base select dialog */
     $once = true;
     foreach($_POST as $name => $value){
       if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_moveable()){
         $once = false;
-        $this->dialog = new baseSelectDialog($this->config,$this,$bases);
+        $this->dialog = new baseSelectDialog($this->config,$this,$this->acl_get_bases());
         $this->dialog->setCurrentBase($this->base);
       }
     }
@@ -315,7 +306,7 @@ class ogroup extends plugin
     }
 
     /* Assign variables */
-    $smarty->assign("bases", $bases);
+    $smarty->assign("bases", $this->acl_get_bases());
     $smarty->assign("base_select", $this->base);
     $smarty->assign("department", $this->department);
     $smarty->assign("members", $this->convert_list($this->memberList));
index df0c7c983f189ce66dd6f5803d13a8d48c47f2ee..117b015d90c736c294ce0aa9afe73525443a9ece 100644 (file)
@@ -1230,22 +1230,7 @@ class user extends plugin
   function allowedBasesToMoveTo()
   {
     /* 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]);
-      }
-    }
+    $bases  = $this->acl_get_bases();
     return($bases);
   } 
 
index 729d9d5c15e4b348d9e1f87f87770dced9a624db..ef1fa7c712a26bc20b9c935fb13b809266b84360 100644 (file)
@@ -141,7 +141,7 @@ if (!$remove_lock){
   $info = "";
 
   /* Show page footer depending on the mode */
-  if (!$user->cert_dialog && !$user->picture_dialog && $user->is_account){
+  if (!$user->cert_dialog && !$user->picture_dialog && !$user->dialog && $user->is_account){
     $display.= "<p class=\"plugbottom\">";
 
     /* Are we in edit mode? */