Code

Fixed problem with not clickable buttons in fai package error msgs
[gosa.git] / plugins / admin / fai / class_faiScriptEntry.inc
index 617de2612d6d27e72b8d0ec6a1192ccc35c730b9..4f5cf2990f647fff755bbdeee24b3c1f3a999d13 100644 (file)
@@ -20,7 +20,7 @@ class faiScriptEntry extends plugin
   var $FAIscript     = "";
   var $description   = "";
   var $status        = "new";
-
+  var $parent        = NULL;
   var $FAIstate      = "";
   
   function faiScriptEntry ($config, $dn= NULL,$object=false)
@@ -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
@@ -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>");
@@ -96,12 +96,13 @@ class faiScriptEntry extends plugin
       $FAIprioritys[$i]=$i;
     }
 
-    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);
     }
 
     $smarty->assign("FAIprioritys",$FAIprioritys);
@@ -114,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 = "";
+          }
         }
       }
     }
@@ -129,6 +132,10 @@ class faiScriptEntry extends plugin
     /* Call common method to give check the hook */
     $message= plugin::check();
   
+    if(isset($this->parent->SubObjects[$this->cn]) && $this->cn != $this->orig_cn){
+      $message[] =_("There is already a script with the given name.");
+    }
+
     if(empty($this->cn)){
       $message[] = _("Please enter a name.");
     }
@@ -159,6 +166,28 @@ class faiScriptEntry extends plugin
     $tmp['status']  = $this->status; 
     return($tmp);
   }
+
+  
+  /* Return plugin informations for acl handling */
+  function plInfo()
+  {
+    return (array(
+          "plShortName" => _("Script entry"),
+          "plDescription" => _("FAI script entry"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 19,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("fai"),
+          "plProvidedAcls" => array(
+            "cn"              => _("Name"),
+            "description"     => _("Description"),
+            "FAIscript"       => _("Script entry"),
+            "FAIpriority"     => _("Script Priority"))
+          ));
+  }
+
+
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>