Code

Added fai priorities
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 5 Oct 2006 04:55:51 +0000 (04:55 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 5 Oct 2006 04:55:51 +0000 (04:55 +0000)
Fixed fai script acls

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4854 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/fai/class_faiHook.inc
plugins/admin/fai/class_faiHookEntry.inc
plugins/admin/fai/class_faiPackage.inc
plugins/admin/fai/class_faiPartitionTable.inc
plugins/admin/fai/class_faiProfile.inc
plugins/admin/fai/class_faiScript.inc
plugins/admin/fai/class_faiScriptEntry.inc
plugins/admin/fai/class_faiTemplate.inc
plugins/admin/fai/class_faiVariable.inc
plugins/admin/fai/faiHookEntry.tpl

index b289e06501c65ad2979c4d6beb452fd484ccb55e..d37c897ba33b8f0896c3fc0133c83d18ef10a1d8 100644 (file)
@@ -143,7 +143,7 @@ class faiHook 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($_SESSION['CurrentMainBase']);
+        $this->dialog->set_acl_base($this->dn);
         $this->dialog->set_acl_category("fai");
 
         $_SESSION['objectinfo'] = $obj['dn'];
@@ -166,8 +166,14 @@ class faiHook 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->set_acl_base($_SESSION['CurrentMainBase']);
+      $this->dialog->set_acl_base($c_dn);
       $this->dialog->set_acl_category("fai");
       $this->dialog->parent = &$this;
       $this->is_dialog=true;
@@ -488,14 +494,12 @@ class faiHook extends plugin
           "plDescription" => _("FAI hook"),
           "plSelfModify"  => FALSE,
           "plDepends"     => array(),
-          "plPriority"    => 0,
+          "plPriority"    => 20,
           "plSection"     => array("administration"),
           "plCategory"    => array("fai"),
           "plProvidedAcls" => array(
-            "cn"                => _("Name"),
-            "description"       => _("Description"),
-            "FAItast"           => _("Task"),
-            "FAIscript"         => _("FAI script"))
+            "cn"                => _("Name")." ("._("Read only").")",
+            "description"       => _("Description"))
           ));
   }
 }
index c73d2e886a54b9820edeac61c0aa99266349e588..b3e2227361dd4644e12f251d51c18fe26be3bc2f 100644 (file)
@@ -107,12 +107,13 @@ class faiHookEntry extends plugin
       }
     }
 
-    foreach($this->attributes as $attr){
-      if(($this->FAIstate == "freeze") || (chkacl($this->acl,$attr)!= "")){
-        $smarty->assign($attr."ACL"," disabled ");
-      }else{
-        $smarty->assign($attr."ACL","  ");
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translated){
+      $acl = $this->getacl($name);
+      if($this->FAIstate == "freezed"){
+        $acl = preg_replace("/w/","",$acl);
       }
+      $smarty->assign($name."ACL",$acl);
     }
 
     $display.= $smarty->fetch(get_template_path('faiHookEntry.tpl', TRUE));
@@ -169,6 +170,26 @@ class faiHookEntry extends plugin
     $tmp['status']  = $this->status;  
     return($tmp);
   }
+
+    /* Return plugin informations for acl handling */
+  function plInfo()
+  {
+    return (array(
+          "plShortName" => _("Hook entry"),
+          "plDescription" => _("FAI hook entry"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 21,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("fai"),
+          "plProvidedAcls" => array(
+            "cn"                => _("Name"),
+            "description"       => _("Description"),
+            "FAItask"           => _("Task"),
+            "FAIscript"         => _("FAI script"))
+          ));
+  }
+
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index f40c1eaea65bda8efa4fd7e2a31bbd13474a2c31..989ff1be3721db5cb5285e3c58a82f193bb46738 100644 (file)
@@ -548,7 +548,7 @@ class faiPackage extends plugin
           "plDescription" => _("FAI Package list"),
           "plSelfModify"  => FALSE,
           "plDepends"     => array(),
-          "plPriority"    => 0,
+          "plPriority"    => 30,
           "plSection"     => array("administration"),
           "plCategory"    => array("fai"),
           "plProvidedAcls" => array(
index 0e5e30921bcd7b8656b0d8b978f3a4e38dbdad6f..5aecea0650639d962e4f3bcab7baab549dede221 100644 (file)
@@ -491,7 +491,7 @@ class faiPartitionTable extends plugin
           "plDescription" => _("FAI partition table"),
           "plSelfModify"  => FALSE,
           "plDepends"     => array(),
-          "plPriority"    => 0,
+          "plPriority"    => 26,
           "plSection"     => array("administration"),
           "plCategory"    => array("fai"),
           "plProvidedAcls" => array(
index c1e5c8f0f2c27992794e01a9a9ab0bf201287701..2641a0b5f3de7d250728a676c5aae691be8c6b77 100644 (file)
@@ -438,7 +438,7 @@ class faiProfile extends plugin
           "plDescription" => _("FAI profile"),
           "plSelfModify"  => FALSE,
           "plDepends"     => array(),
-          "plPriority"    => 0,
+          "plPriority"    => 28,
           "plSection"     => array("administration"),
           "plCategory"    => array("fai"),
           "plProvidedAcls" => array(
index 054c3dcb628980867480066f060554e938093f16..1fbd6d64c7b8e75f7c616dfbd05d83404956055c 100644 (file)
@@ -120,8 +120,14 @@ 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->set_acl_base($_SESSION['CurrentMainBase']);
+      $this->dialog->set_acl_base($c_dn);
       $this->dialog->set_acl_category("fai");
       $this->is_dialog=true;
     }
@@ -159,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]);
+          }
         }
       }
     }
@@ -247,16 +263,24 @@ class faiScript extends plugin
      */
     $divlist = new divSelectBox("FAIscripts");
     $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){
 
+      $dn= $name['dn'];
+      if($dn == "new"){
+        $dn = $_SESSION['CurrentMainBase'];
+      }
+      $acl = $this->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")."'>";
+        }
+      }
+
       if(($this->SubObjects[$key]['status'] == "new") || ($this->SubObjects[$key]['dn'] == "new")){
         $down = "";
       }else{
@@ -267,7 +291,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());
@@ -484,7 +508,7 @@ class faiScript extends plugin
           "plDescription" => _("FAI script"),
           "plSelfModify"  => FALSE,
           "plDepends"     => array(),
-          "plPriority"    => 0,
+          "plPriority"    => 18,
           "plSection"     => array("administration"),
           "plCategory"    => array("fai"),
           "plProvidedAcls" => array(
index 2c6bcf0709760777023bec5b0f4c01398ca42d02..2a56bcb0d92afd6a73c4ef4220f2c1d1487b3f5a 100644 (file)
@@ -63,7 +63,7 @@ class faiScriptEntry extends plugin
     $smarty     = get_smarty();
     $display = "";
   
-    if(isset($_POST['ImportUpload'])){
+    if(isset($_POST['ImportUpload']) && $this->acl_is_writeable("FAIscript")){
       if(($_FILES['ImportFile']['error']!=0)){
         print_red(_("Please select a valid file."));
       }else
@@ -115,10 +115,12 @@ class faiScriptEntry 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 = "";
+          }
         }
       }
     }
@@ -170,7 +172,7 @@ class faiScriptEntry extends plugin
           "plDescription" => _("FAI script entry"),
           "plSelfModify"  => FALSE,
           "plDepends"     => array(),
-          "plPriority"    => 0,
+          "plPriority"    => 19,
           "plSection"     => array("administration"),
           "plCategory"    => array("fai"),
           "plProvidedAcls" => array(
index 161d4fdcbfc438f5f945f84b9f945f858a0f694a..4255fb71b205a03c3330d38a5c32d46768f1d40e 100644 (file)
@@ -452,7 +452,7 @@ class faiTemplate extends plugin
           "plDescription" => _("FAI template"),
           "plSelfModify"  => FALSE,
           "plDepends"     => array(),
-          "plPriority"    => 0,
+          "plPriority"    => 24,
           "plSection"     => array("administration"),
           "plCategory"    => array("fai"),
           "plProvidedAcls" => array(
index ccc6170b6a1664490966b39433ac14abae69d9bd..0ab95a14d19261e834ff35214e7db8c17ca2f2f1 100644 (file)
@@ -385,7 +385,7 @@ class faiVariable extends plugin
           "plDescription" => _("FAI variable"),
           "plSelfModify"  => FALSE,
           "plDepends"     => array(),
-          "plPriority"    => 0,
+          "plPriority"    => 22,
           "plSection"     => array("administration"),
           "plCategory"    => array("fai"),
           "plProvidedAcls" => array(
index ad25455ce0f51fa7594c614c8323b29df3c78ce4..2ab571413e707cbe16306a6c1e2124a91809e25f 100644 (file)
@@ -9,7 +9,9 @@
                                                        {t}Name{/t}{$must}&nbsp;
                                                </td>
                                                <td>
-                                                       <input value="{$cn}" size="45" name="cn" {$cnACL}>
+{render acl=$cnACL}
+                                                       <input value="{$cn}" size="45" name="cn">
+{/render}
                                                </td>
                                        </tr>
                                        <tr>
@@ -17,7 +19,9 @@
                                                        {t}Description{/t}&nbsp;
                                                </td>
                                                <td>
-                                                       <input value="{$description}" size="45" name="description" {$descriptionACL}>
+{render acl=$descriptionACL}
+                                                       <input value="{$description}" size="45" name="description">
+{/render}
                                                </td>
                                        </tr>
                                </table>
                                                        <LABEL for="FAItask">
                                                        {t}Task{/t}&nbsp;
                                                        </LABEL>
-                                                       <select name="FAItask" title="{t}Choose an existing FAI task{/t}" {$FAItaskACL}>
+{render acl=$FAItaskACL}
+                                                       <select name="FAItask" title="{t}Choose an existing FAI task{/t}">
                                                                {html_options values=$tasks output=$tasks selected=$FAItask}
                                                        </select>
+{/render}
                                                </td>
                                        </tr>
                                </table>
 <table width="99%" summary="">
     <tr>
         <td>
+{render acl=$FAIscriptACL}
             <textarea name="FAIscript" style="width:100%;height:300px;" id="FAIscript" >{$FAIscript}</textarea>
+{/render}
         </td>
     </tr>
 </table>
 <br>
 <div>
-    <input type="file" name="ImportFile" {$FAIscriptACL}>&nbsp;
-    <input type="submit" name="ImportUpload" value="{t}Import script{/t}" {$FAIscriptACL}>
+{render acl=$FAIscriptACL}
+    <input type="file" name="ImportFile">&nbsp;
+{/render}
+{render acl=$FAIscriptACL}
+    <input type="submit" name="ImportUpload" value="{t}Import script{/t}" >
+{/render}
+{render acl=$FAIscriptACL}
        {$DownMe}
+{/render}
 </div>
 
 <p class="seperator">&nbsp;</p>
 <br>
 <div style="align:right;" align="right">
-       <input type="submit" value="{t}Apply{/t}"       name="SaveSubObject" {$cnACL}>&nbsp;
+       <input type="submit" value="{t}Apply{/t}"       name="SaveSubObject">&nbsp;
        <input type="submit" value="{t}Cancel{/t}"      name="CancelSubObject">
 </div>
 <!-- Place cursor -->