Code

Script & Hook acl improvements
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 6 Oct 2006 04:24:45 +0000 (04:24 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 6 Oct 2006 04:24:45 +0000 (04:24 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4859 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/fai/class_faiHook.inc
plugins/admin/fai/class_faiHookEntry.inc
plugins/admin/fai/class_faiScript.inc
plugins/admin/fai/class_faiScriptEntry.inc

index d37c897ba33b8f0896c3fc0133c83d18ef10a1d8..f86302e93e26f8ddf762ce32b811b4f1b5d33fc7 100644 (file)
@@ -151,14 +151,23 @@ class faiHook extends plugin
         $this->is_dialog=true;
       }
       if(preg_match("/^deletescript_/",$name)&&($once)){
-        $once = false;
-        $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= $name['dn'];
+        if($dn == "new"){
+          $dn = $_SESSION['CurrentMainBase'];
+        }
+        $acl = $this->ui -> get_permissions($dn,"fai/faiScriptEntry")  ;
+
+        if(preg_match("/d/",$acl)){
+          $once = false;
+          $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]);
+          }
         }
       }
     }
@@ -256,17 +265,29 @@ class faiHook extends plugin
 
     $divlist = new divSelectBox("FAIhooks");
     $divlist->setHeight(400);
-    if($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'])."'>
@@ -276,7 +297,7 @@ class faiHook 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());
index b3e2227361dd4644e12f251d51c18fe26be3bc2f..9a9450c77c9731b6a6fe035623e8af53e795b807 100644 (file)
@@ -79,9 +79,9 @@ class faiHookEntry extends plugin
     }
 
     /* Create download button*/
-    if($this->dn != "new"){
+    if($this->dn != "new" && $this->acl_is_readable("FAIscript")){
       $smarty->assign("DownMe","<a href='getFAIscript.php?id=".base64_encode($this->dn)."'>
-        <input type='button' value='"._("Download")."'>
+          <img src='images/save.png' alt='"._("Download")."' title='"._("Download")."' border=0 class='center'>
         </a>");
     }else{
       $smarty->assign("DownMe","");  
@@ -125,10 +125,12 @@ class faiHookEntry extends plugin
   {
     if((isset($_POST['SubObjectFormSubmitted'])) && ($this->FAIstate != "freeze")){
       foreach($this->attributes as $attrs){
-        if(isset($_POST[$attrs])){
-          $this->$attrs = $_POST[$attrs];
-        }else{
-          $this->$attrs = "";
+        if($this->acl_is_writeable($attrs)){
+          if(isset($_POST[$attrs])){
+            $this->$attrs = $_POST[$attrs];
+          }else{
+            $this->$attrs = "";
+          }
         }
       }
     }
index 1fbd6d64c7b8e75f7c616dfbd05d83404956055c..24d04753449c0608bdb1fdb7fbb316b78bd0c186 100644 (file)
@@ -269,7 +269,8 @@ class faiScript extends plugin
       if($dn == "new"){
         $dn = $_SESSION['CurrentMainBase'];
       }
-      $acl = $this->ui -> get_permissions($dn,"fai/faiScriptEntry")  ;
+      $ui = get_userinfo();
+      $acl = $ui->get_permissions($dn,"fai/faiScriptEntry")  ;
       $act = "";
       
       if($this->FAIstate == "freeze"){
@@ -281,7 +282,8 @@ class faiScript extends plugin
         }
       }
 
-      if(($this->SubObjects[$key]['status'] == "new") || ($this->SubObjects[$key]['dn'] == "new")){
+      $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'])."' >
index 2a56bcb0d92afd6a73c4ef4220f2c1d1487b3f5a..f7473c553f4f135c9855df5a53b32d3dfd2eaf53 100644 (file)
@@ -84,7 +84,7 @@ class faiScriptEntry extends plugin
     }
 
      /* Create download button*/
-    if($this->dn != "new"){
+    if($this->dn != "new" && $this->acl_is_readable("FAIscript")){
       $smarty->assign("DownMe","<a href='getFAIscript.php?id=".base64_encode($this->dn)."'>
         <input type='button' value='"._("Download")."'>
         </a>");