Code

fixed checkbox
[gosa.git] / plugins / admin / fai / class_faiScriptEntry.inc
index 9f93babfa4346dade117d9b4ee80462798b076ca..d25af193635eb4537b436f683e190b6d1eebf2a0 100644 (file)
@@ -9,17 +9,17 @@ class faiScriptEntry extends plugin
 
   /* attribute list for save action */
   var $ignore_account= TRUE;
-  var $attributes   = array("Object_cn","Object_description","Object_FAIpriority","Object_FAIscript");
+  var $attributes   = array("cn","description","FAIpriority","FAIscript");
   var $objectclasses= array();
 
   var $orig_cn              = "";
 
-  var $Object_dn            = "";
-  var $Object_cn            = "";
-  var $Object_FAIpriority   = "";
-  var $Object_FAIscript     = "";
-  var $Object_description   = "";
-  var $Object_status        = "new";
+  var $dn            = "";
+  var $cn            = "";
+  var $FAIpriority   = "0";
+  var $FAIscript     = "";
+  var $description   = "";
+  var $status        = "new";
   
   function faiScriptEntry ($config, $dn= NULL,$object=false)
   {
@@ -28,17 +28,20 @@ class faiScriptEntry 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;
     }
   }
 
   function execute()
   {
+       /* Call parent execute */
+       plugin::execute();
+
     /* Fill templating stuff */
     $smarty     = get_smarty();
     $display = "";
@@ -51,20 +54,23 @@ class faiScriptEntry 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;
       }
     }
 
   
-
     foreach($this->attributes as $attrs){
-      $smarty->assign($attrs,stripslashes($this->$attrs));
+      if(get_magic_quotes_gpc()){
+       $smarty->assign($attrs,stripslashes($this->$attrs));
+      }else{
+       $smarty->assign($attrs,($this->$attrs));
+      } 
     }
 
-    for($i =1 ; $i <= 100 ; $i++){
-      $Object_FAIprioritys[$i]=$i;
+    for($i =0 ; $i < 100 ; $i++){
+      $FAIprioritys[$i]=$i;
     }
-    $smarty->assign("Object_FAIprioritys",$Object_FAIprioritys);
+    $smarty->assign("FAIprioritys",$FAIprioritys);
     $display.= $smarty->fetch(get_template_path('faiScriptEntry.tpl', TRUE));
     return($display);
   }
@@ -80,6 +86,7 @@ class faiScriptEntry extends plugin
           $this->$attrs = "";
         }
       }
+      $this->FAIscript= recode("DOS..LATIN1", $this->FAIscript);
     }
   }
 
@@ -88,14 +95,14 @@ class faiScriptEntry extends plugin
   {
     $message= array();
   
-    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.");
+    if(empty($this->FAIscript)){
+      $message[]=_("Please enter a script.");
     }
+
     return ($message);
   }
  
@@ -103,8 +110,7 @@ class faiScriptEntry 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)){
@@ -113,7 +119,7 @@ class faiScriptEntry extends plugin
     }
   
     $tmp['dn']      = $this->dn;  
-    $tmp['status']  = $this->Object_status; 
+    $tmp['status']  = $this->status; 
     return($tmp);
   }
 }