Code

Added Sorting
[gosa.git] / plugins / admin / fai / class_faiHookEntry.inc
index 70ed9f85606219ec467b0bab41550f46870b7dac..c372b81eaa4d2df73082a756aa1f8b954d3a5270 100644 (file)
@@ -9,17 +9,19 @@ class faiHookEntry extends plugin
 
   /* attribute list for save action */
   var $ignore_account= TRUE;
-  var $attributes   = array("Object_cn","Object_description","Object_FAIscript","Object_FAItask");
+  var $attributes   = array("cn","description","FAIscript","FAItask");
   var $objectclasses= array();
 
   var $orig_cn              = "";
-
-  var $Object_dn            = "";
-  var $Object_cn            = "";
-  var $Object_FAItask       = "";
-  var $Object_FAIscript     = "";
-  var $Object_description   = "";
-  var $Object_status        = "new";
+  var $tasks                = array("chboot", "configure", "debconf", "extrbase", "faiend", "finish",
+                                    "install", "instsoft", "mirror", "mountdisks", "partition", "prepareapt",
+                                    "savelog", "softupdate", "sysinfo"," updatebase");
+  var $dn            = "";
+  var $cn            = "";
+  var $FAItask       = "";
+  var $FAIscript     = "";
+  var $description   = "";
+  var $status        = "new";
   
   function faiHookEntry ($config, $dn= NULL,$object=false)
   {
@@ -28,11 +30,11 @@ class faiHookEntry extends plugin
       $this->orig_cn= $object['cn'];
       $this->dn=$object['dn'];
       foreach($object as $name=>$value){
-        $oname = "Object_".$name;
+        $oname = $name;
         $this->$oname=$value;
       }
     }else{
-      $this->Object_status = "new";
+      $this->status = "new";
       $this->orig_cn       = false;
     }
   }
@@ -52,9 +54,10 @@ class faiHookEntry extends plugin
         print_red(_("Selected file is empty."));
       }else{
         $str = utf8_encode(file_get_contents($_FILES['ImportFile']['tmp_name']));
-        $this->Object_FAIscript = $str;
+        $this->FAIscript = $str;
       }
     }
+    $smarty->assign("tasks", $this->tasks);
 
      /* Magic quotes GPC, escapes every ' " \, to solve some security risks
      * If we post the escaped strings they will be escaped again
@@ -82,6 +85,7 @@ class faiHookEntry extends plugin
           $this->$attrs = "";
         }
       }
+      $this->FAIscript= recode("DOS..LATIN1", $this->FAIscript);
     }
   }
 
@@ -89,21 +93,14 @@ class faiHookEntry extends plugin
   function check()
   {
     $message= array();
-    if(empty($this->Object_FAItask)) {
-      $message[]=_("Please enter a value for task.");
-    }
-    if(empty($this->Object_FAIscript)) {
+    if(empty($this->FAIscript)) {
       $message[]=_("Please enter a value for script.");
     }
 
-    if(empty($this->Object_cn)){
+    if(empty($this->cn)){
       $message[] = _("Please enter a name.");
     }
 
-    if(preg_match("/[^0-9a-z]/i",$this->Object_cn)){
-      $message[] = _("Please enter a valid name. Only a-Z 0-9 are allowed.");
-    }
-  
     return ($message);
   }
  
@@ -111,8 +108,7 @@ class faiHookEntry extends plugin
   {
     $tmp=array();
     foreach($this->attributes as $attrs){ 
-      $attr = preg_replace("/^Object_/","",$attrs);
-      $tmp[$attr] = $this->$attrs;
+      $tmp[$attrs] = $this->$attrs;
     }
 
     if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){
@@ -121,7 +117,7 @@ class faiHookEntry extends plugin
     }
   
     $tmp['dn']      = $this->dn;  
-    $tmp['status']  = $this->Object_status;  
+    $tmp['status']  = $this->status;  
     return($tmp);
   }
 }