Code

Fixed group base detection.
[gosa.git] / plugins / admin / groups / class_groupGeneric.inc
index 8ca3e3ded245c6bc8f7439827066fd9e84f393cb..a03f6a91ec3a8ac9c53f8ac9b120a2cae6d5d8ec 100644 (file)
@@ -27,7 +27,6 @@ class group extends plugin
   var $members= array();
   var $users= array();
   var $allusers= array();
-  var $department= "";
   var $saved_gidNumber= "";
   var $oldgroupType= "";
   var $orig_dn= "";
@@ -155,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 */
@@ -209,9 +210,10 @@ class group extends plugin
     /* 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);
+        $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases());
         $this->dialog->setCurrentBase($this->base);
       }
     }
@@ -224,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());
@@ -251,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){
 
@@ -283,7 +294,8 @@ class group extends plugin
       $smarty->assign("search_image", get_template_path('images/search.png'));
       $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
       $smarty->assign("tree_image", get_template_path('images/tree.png'));
-      $smarty->assign("deplist", $this->config->idepartments);
+
+      $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]);
@@ -300,9 +312,8 @@ class group extends plugin
       $this->base= $_POST['base'];
     }
 
-    $smarty->assign("bases", $this->config->idepartments);
+    $smarty->assign("bases", $this->get_allowed_bases());
     $smarty->assign("base_select", $this->base);
-    $smarty->assign("department", $this->department);
 
     if ($this->samba3){
       $domains= array();
@@ -441,14 +452,19 @@ class group extends plugin
 
     /* Search in current tree or within subtrees depending on the checkbox from filter section */
     if($gufilter['SubSearchGroup']){
-      $ldap->search($filter, array("uid", "sn","givenName"));
+      $flag = GL_SIZELIMIT | GL_SUBSEARCH;
+      $base = $gufilter['dselect'];
     }else{
-      $ldap->ls ($filter, get_people_ou().$gufilter['dselect'],array("uid", "sn", "givenName"));
+      $flag = GL_SIZELIMIT ;
+      $base = get_people_ou().$gufilter['dselect'];
     }
     $i = 0;
-    
+  
+
+    $res = get_list($filter,"users",$base,array("uid", "sn", "givenName"),$flag);
+
     /* Fetch all users and skip already used users */
-    while($attrs = $ldap->fetch()){
+    foreach($res as $attrs){
       if(in_array($attrs['uid'][0], $this->memberUid)) {
         continue;
       }
@@ -516,9 +532,22 @@ class group extends plugin
       plugin::save_object();
 
       $this->force_gid= 0;
-      $this->smbgroup= 0;
-      foreach (array("force_gid", "department", "base", "smbgroup") as $val) {
-        if ($this->acl_is_writeable("$val")  && isset($_POST["$val"])){
+
+
+      /* Only reset sambagroup flag if we are able to write this flag */
+      if($this->acl_is_writeable("sambaGroupType")){
+        $this->smbgroup = 0;
+      }
+
+      /* Get base selection */
+      if($this->acl_is_moveable() && isset($_POST['base'])){
+        $this->base = $_POST['base'];
+      }
+
+      foreach (array(
+            "force_gid"  => "gidNumber", 
+            "smbgroup"   => "sambaGroupType") as $val => $aclname) {
+        if ($this->acl_is_writeable($aclname)  && isset($_POST["$val"])){
           $this->$val= $_POST["$val"];
         }
       }
@@ -537,7 +566,7 @@ class group extends plugin
           $this->fon_group= FALSE;
         }
       }
-        if ($this->acl_is_writeable("nagios_group")){
+      if ($this->acl_is_writeable("nagios_group")){
         if (isset ($_POST['nagios_group'])){
           $this->nagios_group= TRUE;
         } else {
@@ -711,7 +740,7 @@ class group extends plugin
       $new_dn= $this->dn;
     }
 
-    if (!$this->acl_is_createable()){
+    if ($this->orig_dn == "new" && !$this->acl_is_createable()){
       $message[]= _("You have no permissions to create a group on this 'Base'.");
     }
 
@@ -860,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"),