Code

Added FAIstate update
[gosa.git] / plugins / admin / ogroups / class_ogroup.inc
index 9a220b980b699612ef27147d7f581d6740786937..57444b14c5d75e6396696e503e1337294319363e 100644 (file)
@@ -85,12 +85,6 @@ class ogroup extends plugin
      $this->base = $_SESSION['CurrentMainBase'];
     }
 
-     /* set permissions */
-    $ui= get_userinfo();
-    $acl= get_permissions ($ui->dn, $ui->subtreeACL);
-    $this->acl= get_module_permission($acl, "ogroup", $ui->dn);
-
-
     /* Load member data */
     $this->reload();
   }
@@ -176,18 +170,39 @@ class ogroup extends plugin
     /* Load templating engine */
     $smarty= get_smarty();
 
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->getacl($name));
+    }
+
+    /* Create base acls */
+    $baseACL = $this->getacl("base",(!is_object($this->parent) && !isset($_SESSION['edit'])));
+    if(!$this->acl_is_moveable()) {
+      $baseACL = preg_replace("/w/","",$baseACL);
+    }
+    $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){
+      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,$bases);
         $this->dialog->setCurrentBase($this->base);
       }
     }
 
     /* Dialog handling */
-    if(is_object($this->dialog)){
+    if(is_object($this->dialog) && $this->acl_is_moveable()){
       /* Must be called before save_object */
       $this->dialog->save_object();
 
@@ -267,8 +282,7 @@ class ogroup extends plugin
     }
 
     /* Bases / Departments */
-   
-      if (isset($_POST['base'])){
+      if ((isset($_POST['base'])) && ($this->acl_is_moveable())){
         $this->base= $_POST['base'];
       }
 
@@ -301,7 +315,7 @@ class ogroup extends plugin
     }
 
     /* Assign variables */
-    $smarty->assign("bases", $this->config->idepartments);
+    $smarty->assign("bases", $bases);
     $smarty->assign("base_select", $this->base);
     $smarty->assign("department", $this->department);
     $smarty->assign("members", $this->convert_list($this->memberList));
@@ -312,12 +326,6 @@ class ogroup extends plugin
     /* Fields */
     foreach ($this->attributes as $val){
       $smarty->assign("$val", $this->$val);
-      $smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
-    }
-
-    /* Assign ACL's */
-    foreach (array("base", "members") as $val){
-      $smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
     }
 
     return ($smarty->fetch (get_template_path('generic.tpl', TRUE)));
@@ -330,11 +338,7 @@ class ogroup extends plugin
     /* Save additional values for possible next step */
     if (isset($_POST['ogroupedit'])){
       plugin::save_object();
-
-      if (chkacl ($this->acl, "base") == "" && isset($_POST["base"])){
-        $this->base= $_POST["base"];
-      }
-
+  
     }
   }
 
@@ -649,15 +653,12 @@ class ogroup extends plugin
       $message[]= _("There is already an object with this cn.");
     } 
 
-    $ui= get_userinfo();
-    $acl= get_permissions ($new_dn, $ui->subtreeACL);
-    $acl= get_module_permission($acl, "group", $new_dn);
-    if (chkacl($acl, "create") != ""){
+    if ($this->orig_dn == "new" && !$this->acl_is_createable()){
       $message[]= _("You have no permissions to create a group on this 'Base'.");
     }
 
     /* must: cn */
-    if ($this->cn == "" && chkacl ($this->acl, "cn") == ""){
+    if ($this->cn == "" && $this->acl_is_writeable("cn")){
       $message[]= "The required field 'Name' is not set.";
     }
 
@@ -760,6 +761,7 @@ class ogroup extends plugin
                                                       "objectClass"  => "gosaGroupOfNames")),
           "plProvidedAcls"=> array(
             "cn"                => _("Name"),
+            "base"              => _("Base"),
             "description"       => _("Description"),
             "member"            => _("Member"))
           ));