Code

Made faiScript w3c conform
[gosa.git] / gosa-plugins / fai / admin / fai / class_faiHookEntry.inc
index fd983aecaf50d8859f5cdf5b8985c687f15a1557..09b5d8dbfb4cb528ea11ee4d4f0882e639643de8 100644 (file)
@@ -23,7 +23,7 @@ class faiHookEntry extends plugin
   
   function faiHookEntry (&$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'];
@@ -31,11 +31,6 @@ class faiHookEntry extends plugin
         $oname = $name;
         $this->$oname=$value;
       }
-
-      if(isset($this->attrs['FAIstate'][0])){
-        $this->FAIstate = $this->attrs['FAIstate'][0];
-      }
-
     }elseif(is_array($object)){
       if(count($object)){
         $this->orig_cn= $object['cn'];
@@ -110,10 +105,7 @@ class faiHookEntry extends plugin
 
     $tmp = $this->plInfo();
     foreach($tmp['plProvidedAcls'] as $name => $translated){
-      $acl = $this->getacl($name);
-      if($this->FAIstate == "freezed"){
-        $acl = preg_replace("/w/","",$acl);
-      }
+      $acl = $this->getacl($name, preg_match("/freeze/",$this->FAIstate));
       $smarty->assign($name."ACL",$acl);
     }
    
@@ -122,6 +114,7 @@ class faiHookEntry extends plugin
     }else{
       $smarty->assign("FAIscript" , htmlentities($this->FAIscript));
     }
+    $smarty->assign("freeze" , preg_match("/freeze/",$this->FAIstate));
     $display.= $smarty->fetch(get_template_path('faiHookEntry.tpl', TRUE));
     return($display);
   }
@@ -152,12 +145,17 @@ class faiHookEntry extends plugin
       $message[]= msgPool::duplicated(_("Name"));
     }
 
-    if(empty($this->FAIscript)) {
-      $message[]= msgPool::required(_("Script"));
+    $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->cn)){
-      $message[]= msgPool::required(_("Name"));
+    $s = trim($this->FAIscript);
+    if($s == ""){
+      $message[]= msgPool::required(_("Script"));
     }
 
     return ($message);