Code

Beautified FAI templates
[gosa.git] / gosa-plugins / fai / admin / fai / class_faiScriptEntry.inc
index 91c04d67bfba5905f459772c6d4c756ed264bb56..a0ba363c99bb006685447226502687eefeee6e2c 100644 (file)
@@ -20,7 +20,7 @@ class faiScriptEntry extends plugin
   
   function faiScriptEntry (&$config, $dn= NULL,$object=false)
   {
-    plugin::plugin ($config, $dn);
+    plugin::plugin ($config, NULL);
     if($dn != "new"){
       $this->orig_cn= $object['cn'];
       $this->dn=$object['dn'];
@@ -78,15 +78,13 @@ class faiScriptEntry extends plugin
     }
 
     /* File download requested */
-    if(isset($_GET['getFAIScript'])){
+    if(isset($_POST['download'])){
       send_binary_content(stripslashes($this->FAIscript),$this->cn.".FAIscript");
     }
 
     /* Create download button*/
     if($this->dn != "new" && $this->acl_is_readable("FAIscript")){
-      $smarty->assign("DownMe","<a href='?plug=".$_GET['plug']."&getFAIScript'>
-        <img src='images/save.png' alt='"._("Download")."' title='"._("Download")."' border=0 class='center'>
-        </a>");
+      $smarty->assign("DownMe", image('images/save.png','download',_("Download")));
     }else{
       $smarty->assign("DownMe","");
     }
@@ -137,11 +135,16 @@ class faiScriptEntry extends plugin
       $message[] = msgPool::duplicated(_("Name"));
     }
 
-    if(empty($this->cn)){
+    $c = trim($this->cn);
+    if($c == ""){
       $message[] = msgPool::required(_("Name"));
     }
+    if(preg_match("/[^a-z0-9_\-]/i",$c)){
+      $message[] = msgPool::invalid(_("Name"),$c,"/[a-z0-9_\-]/i");
+    }
 
-    if(empty($this->FAIscript)){
+    $s = trim($this->FAIscript);
+    if($s == ""){
       $message[]= msgPool::required(_("Script"));
     }