Code

Fixed group base detection.
[gosa.git] / plugins / admin / groups / class_groupGeneric.inc
index 6fd8b858dd766a7241bae16a764d379dfb604040..a03f6a91ec3a8ac9c53f8ac9b120a2cae6d5d8ec 100644 (file)
@@ -154,7 +154,9 @@ class group extends plugin
         $this->base= dn2base($ui->dn);
       }
     } else {
-      $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn);
+
+      /* Get object base */
+      $this->base =preg_replace ("/^[^,]+,".normalizePreg(get_groups_ou())."/","",$this->dn);
     }
 
     /* This is always an account */
@@ -205,32 +207,13 @@ class group extends plugin
       $this->reload();
     }
 
-    /* Only display bases that we are able to read/write */
-    $ui = get_userinfo();
-    $bases = array();
-    if($this->dn == "new") {
-      foreach($this->config->idepartments as $dn => $name){
-        $acl = $ui->get_permissions($dn,"groups/group") ;
-        if(preg_match("/c/",$acl)){
-          $bases[$dn]=$name;
-        }
-      }
-    }else{
-      foreach($this->config->idepartments as $dn => $name){
-        $acl = $ui->get_category_permissions($dn,"groups") ;
-        if(preg_match("/w/",$acl)){
-          $bases[$dn]=$name;
-        }
-      }
-    }
-
-
     /* Base select dialog */
     $once = true;
     foreach($_POST as $name => $value){
-      if(preg_match("/^chooseBase/",$name) && $once){
+      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->get_allowed_bases());
         $this->dialog->setCurrentBase($this->base);
       }
     }
@@ -243,7 +226,9 @@ class group extends plugin
       if($this->dialog->isClosed()){
         $this->dialog = false;
       }elseif($this->dialog->isSelected()){
-        $this->base = $this->dialog->isSelected();
+        if($this->acl_is_moveable()){
+          $this->base = $this->dialog->isSelected();
+        }
         $this->dialog= false;
       }else{
         return($this->dialog->execute());
@@ -270,6 +255,13 @@ class group extends plugin
       $smarty->assign("pickupGroup",false);
     }
 
+    /* Assign base ACL */
+    $baseACL = $this->getacl("base");
+    if(!$this->acl_is_moveable()) {
+      $baseACL = preg_replace("/w/","",$baseACL);
+    }
+    $smarty->assign("baseACL",          $baseACL);
+
     /* Manage object add dialog */
     if ($this->group_dialog){
 
@@ -303,14 +295,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'));
 
-      /* Generate list of bases */
-      $check = $ui->get_module_departments("users");
-      $bases_user_select = array();
-      foreach($check as $dn_allowed){
-        $bases_user_select[$dn_allowed] = $this->config->idepartments[$dn_allowed];
-      }
-  
-      $smarty->assign("deplist", $bases_user_select);
+      $smarty->assign("deplist", $this->get_allowed_bases("users/user"));
       $smarty->assign("alphabet", generate_alphabet());
       foreach( array("dselect", "regex","SubSearchGroup") as $type){
         $smarty->assign("$type", $gufilter[$type]);
@@ -327,7 +312,7 @@ class group extends plugin
       $this->base= $_POST['base'];
     }
 
-    $smarty->assign("bases", $bases);
+    $smarty->assign("bases", $this->get_allowed_bases());
     $smarty->assign("base_select", $this->base);
 
     if ($this->samba3){
@@ -554,9 +539,13 @@ class group extends plugin
         $this->smbgroup = 0;
       }
 
+      /* Get base selection */
+      if($this->acl_is_moveable() && isset($_POST['base'])){
+        $this->base = $_POST['base'];
+      }
+
       foreach (array(
             "force_gid"  => "gidNumber", 
-            "base"       => "base", 
             "smbgroup"   => "sambaGroupType") as $val => $aclname) {
         if ($this->acl_is_writeable($aclname)  && isset($_POST["$val"])){
           $this->$val= $_POST["$val"];
@@ -900,11 +889,11 @@ class group extends plugin
 
           "plProvidedAcls"    => array(
             "cn"                => _("Name"),
-            "description"       => _("Description"),
             "base"              => _("Base"),
+            "description"       => _("Description"),
 
-            "fonGroup"         => _("Phone pickup group"),
-            "nagiosGroup"      => _("Nagios group"),
+            "fonGroup"          => _("Phone pickup group"),
+            "nagiosGroup"       => _("Nagios group"),
 
             "gidNumber"         => _("GID"),
             "memberUid"         => _("Group member"),