Code

Fixed ogroup saving
[gosa.git] / plugins / admin / fai / class_faiScript.inc
index 18f95aef3914979b9e15bf083de9f0ed5186c5c6..24d04753449c0608bdb1fdb7fbb316b78bd0c186 100644 (file)
@@ -43,21 +43,12 @@ class faiScript extends plugin
     /* Load Attributes */
     plugin::plugin ($config, $dn);
 
-    $this->acl ="#all#";
-    
     /* If "dn==new" we try to create a new entry
      * Else we must read all objects from ldap which belong to this entry.
      * First read SubObjects from ldap ... and then the partition definitions for the SubObjects.
      */
     if($dn != "new"){
 
-      /* Set acls
-       */
-      $ui   = get_userinfo();
-      $acl  = get_permissions ($this->dn, $ui->subtreeACL);
-      $acli = get_module_permission($acl, "FAIclass", $this->dn);
-      $this->acl=$acli;
-
       $this->dn =$dn;
 
       /* Get FAIstate
@@ -129,8 +120,15 @@ class faiScript extends plugin
 
     /* Add new sub object */
     if(isset($_POST['AddSubObject'])){
+
+      $c_dn = $this->dn;
+      if($c_dn == "new"){
+        $c_dn = $_SESSION['CurrentMainBase'];
+      }
+
       $this->dialog= new $this->subClassName($this->config,"new");
-      $this->dialog->acl = $this->acl;
+      $this->dialog->set_acl_base($c_dn);
+      $this->dialog->set_acl_category("fai");
       $this->is_dialog=true;
     }
 
@@ -154,6 +152,8 @@ class faiScript extends plugin
           $obj  = $this->get_object_attributes($obj,$this->sub_Load_Later);
         }
         $this->dialog= new $this->subClassName($this->config,$this->dn,$obj);
+        $this->dialog->set_acl_base($this->dn);
+        $this->dialog->set_acl_category("fai");
 
 
         $_SESSION['objectinfo'] = $obj['dn'];
@@ -165,10 +165,20 @@ class faiScript extends plugin
         $entry = preg_replace("/^deletescript_/","",$name);
         $entry = base64_decode(preg_replace("/_.*/","",$entry));
 
-        if(($this->SubObjects[$entry]['status'] == "edited")||($this->SubObjects[$entry]['status'] == "FreshLoaded")){
-          $this->SubObjects[$entry]['status']= "delete";
-        }else{
-          unset($this->SubObjects[$entry]);
+    
+        $dn = $this->SubObjects[$entry]['dn'];
+
+        if($dn == "new"){
+          $dn = $_SESSION['CurrentMainBase'];
+        }
+        $acl = $this->ui -> get_permissions($dn,"fai/faiScriptEntry")  ;
+
+        if(preg_match("/d/",$acl)){
+          if(($this->SubObjects[$entry]['status'] == "edited")||($this->SubObjects[$entry]['status'] == "FreshLoaded")){
+            $this->SubObjects[$entry]['status']= "delete";
+          }else{
+             unset($this->SubObjects[$entry]);
+          }
         }
       }
     }
@@ -179,7 +189,8 @@ class faiScript extends plugin
     if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){
       $script = $_POST['SubObject'][0];
       $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$script]);
-      $this->dialog->acl = $this->acl;
+      $this->dialog->set_acl_base($_SESSION['CurrentMainBase']);
+      $this->dialog->set_acl_category("fai");
       $_SESSION['objectinfo'] = $this->SubObjects[$script]['dn'];
       $this->is_dialog=true;
     }
@@ -252,17 +263,27 @@ class faiScript extends plugin
      */
     $divlist = new divSelectBox("FAIscripts");
     $divlist->setHeight(400);
-    if((chkacl($this->acl,"cn")!="") || ($this->FAIstate == "freeze")){
-      $img_edit = "<input type='image' src='images/edit.png'      name='editscript_%s'    title='"._("edit")."' alt='"._("edit")."'>";
-      $img_remo = "";
-    }else{
-      $img_edit = "<input type='image' src='images/edit.png'      name='editscript_%s'    title='"._("edit")."' alt='"._("edit")."'>";
-      $img_remo = "<input type='image' src='images/edittrash.png' name='deletescript_%s'  title='"._("delete")."' alt='"._("delete")."'>";
-    }
-
     foreach($this->getList(true) as $key => $name){
 
-      if(($this->SubObjects[$key]['status'] == "new") || ($this->SubObjects[$key]['dn'] == "new")){
+      $dn= $name['dn'];
+      if($dn == "new"){
+        $dn = $_SESSION['CurrentMainBase'];
+      }
+      $ui = get_userinfo();
+      $acl = $ui->get_permissions($dn,"fai/faiScriptEntry")  ;
+      $act = "";
+      
+      if($this->FAIstate == "freeze"){
+        $act .= "<input type='image' src='images/edit.png'      name='editscript_%s'    title='"._("edit")."' alt='"._("edit")."'>";
+      }else{
+        $act .= "<input type='image' src='images/edit.png'      name='editscript_%s'    title='"._("edit")."' alt='"._("edit")."'>";
+        if(preg_match("/d/",$acl)){
+          $act .="<input type='image' src='images/edittrash.png' name='deletescript_%s'  title='"._("delete")."' alt='"._("delete")."'>";
+        }
+      }
+
+      $s_acl = $ui->get_permissions($dn,"fai/faiScriptEntry","FAIscript")  ;
+      if(($this->SubObjects[$key]['status'] == "new") || ($this->SubObjects[$key]['dn'] == "new") || !preg_match("/r/",$s_acl)){
         $down = "";
       }else{
         $down = "<a href='getFAIscript.php?id=".base64_encode($name['dn'])."' >
@@ -272,7 +293,7 @@ class faiScript extends plugin
 
       $divlist->AddEntry(array( array("string"=>$name['name']),
             array("string"=>$down , "attach" => "style='width:20px;'"),
-            array("string"=>str_replace("%s",base64_encode($key),$img_edit.$img_remo),
+            array("string"=>str_replace("%s",base64_encode($key),$act),
               "attach"=>"style='border-right: 0px;width:50px;text-align:right;'")));
     }
     $smarty->assign("Entry_divlist",$divlist->DrawList());
@@ -288,8 +309,16 @@ class faiScript extends plugin
       }
     }
 
-    foreach($this->attributes as $attr){
-      $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
+    $tmp = $this->plInfo();
+    $this->ui = get_userinfo();
+
+    $c_dn = $this->dn;  
+    if($c_dn == "new"){
+      $c_dn = $_SESSION['CurrentMainBase'];
+    }
+    $smarty->assign("sub_object_is_addable", preg_match("/c/",$this->ui->get_permissions($c_dn,"fai/faiScriptEntry")) && $this->FAIstate!="freeze");
+    foreach($tmp['plProvidedAcls'] as $name => $translated){
+      $smarty->assign($name."ACL",$this->getacl($name));
     }
 
     $display.= $smarty->fetch(get_template_path('faiScript.tpl', TRUE));
@@ -481,14 +510,12 @@ class faiScript extends plugin
           "plDescription" => _("FAI script"),
           "plSelfModify"  => FALSE,
           "plDepends"     => array(),
-          "plPriority"    => 0,
+          "plPriority"    => 18,
           "plSection"     => array("administration"),
           "plCategory"    => array("fai"),
           "plProvidedAcls" => array(
-            "cn"                => _("Name"),
-            "description"       => _("Description"),
-            "FAIpriority"       => _("Script priority"),
-            "FAIscript"         => _("FAI script"))
+            "cn"                => _("Name")." ("._("Readonly").")",
+            "description"       => _("Description"))
           ));
   }
 }