Code

Removed duplicated save_object
[gosa.git] / plugins / admin / fai / class_faiScriptEntry.inc
index f028561f4e91d46881535eabc03ee615d168a80c..35ba0b38baa38b093de517d52d068c9cd3b442d1 100644 (file)
@@ -21,8 +21,9 @@ class faiScriptEntry extends plugin
   var $description   = "";
   var $status        = "new";
 
+  var $FAIstate      = "";
   
-  function faiHookEntry ($config, $dn= NULL,$object=false)
+  function faiScriptEntry ($config, $dn= NULL,$object=false)
   {
     plugin::plugin ($config, $dn);
     if($dn != "new"){
@@ -32,8 +33,13 @@ class faiScriptEntry extends plugin
         $oname = $name;
         $this->$oname=$value;
       }
+
+      if(isset($this->attrs['FAIstate'][0])){
+        $this->FAIstate = $this->attrs['FAIstate'][0];
+      }
+
     }else{
-      if(count($object)){
+      if(is_array($object)&&count($object)){
         $this->orig_cn= $object['cn'];
         $this->dn=$object['dn'];
         foreach($object as $name=>$value){
@@ -77,9 +83,27 @@ class faiScriptEntry extends plugin
       } 
     }
 
+     /* Create download button*/
+    if($this->dn != "new"){
+      $smarty->assign("DownMe","<a href='getFAIscript.php?id=".base64_encode($this->dn)."' target='_blank'>
+        <input type='button' value='"._("Download")."'>
+        </a>");
+    }else{
+      $smarty->assign("DownMe","");
+    }
+
     for($i =0 ; $i < 100 ; $i++){
       $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","  ");
+      }
+    }
+
     $smarty->assign("FAIprioritys",$FAIprioritys);
     $display.= $smarty->fetch(get_template_path('faiScriptEntry.tpl', TRUE));
     return($display);
@@ -88,7 +112,7 @@ class faiScriptEntry extends plugin
   /* Save data to object */
   function save_object()
   {
-    if(isset($_POST['SubObjectFormSubmitted'])){
+    if((isset($_POST['SubObjectFormSubmitted'])) && ($this->FAIstate != "freeze")){
       foreach($this->attributes as $attrs){
         if(isset($_POST[$attrs])){
           $this->$attrs = $_POST[$attrs];
@@ -96,14 +120,14 @@ class faiScriptEntry extends plugin
           $this->$attrs = "";
         }
       }
-      $this->FAIscript= recode("DOS..LATIN1", $this->FAIscript);
     }
   }
 
   /* Check supplied data */
   function check()
   {
-    $message= array();
+    /* Call common method to give check the hook */
+    $message= plugin::check();
   
     if(empty($this->cn)){
       $message[] = _("Please enter a name.");
@@ -123,6 +147,9 @@ class faiScriptEntry extends plugin
       $tmp[$attrs] = $this->$attrs;
     }
 
+    /* Strip out dos newlines */
+    $tmp['FAIscript']= strtr($this->FAIscript, array("\x0D" => ""));
+
     if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){
       $tmp['remove']['from']  = $this->orig_cn;
       $tmp['remove']['to']    = $tmp['cn'];