Code

Beautified FAI templates
[gosa.git] / gosa-plugins / fai / admin / fai / class_faiVariableEntry.inc
index 92ba68d200ccd181d2f7490c5e50946f97febf28..dd88739559bbda247393bf731682347c82ecd506 100644 (file)
@@ -26,11 +26,6 @@ class faiVariableEntry extends plugin
         $oname = $name;
         $this->$oname=addslashes($value);
       }
-
-      if(isset($this->attrs['FAIstate'][0])){
-        $this->FAIstate = $this->attrs['FAIstate'][0];
-      }
-
     }else{
       $this->status = "new";
       $this->orig_cn       = false;
@@ -59,23 +54,20 @@ class faiVariableEntry 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);
     }
 
-
-
+    $smarty->assign("freeze",preg_match("/freeze/",$this->FAIstate));
     $display.= $smarty->fetch(get_template_path('faiVariableEntry.tpl', TRUE));
     return($display);
   }
 
+
   /* Save data to object */
   function save_object()
   {
-     if((isset($_POST['SubObjectFormSubmitted'])) && ($this->FAIstate != "freeze")){
+     if((isset($_POST['SubObjectFormSubmitted'])) && !preg_match("/freeze/", $this->FAIstate)){
       foreach($this->attributes as $attrs){
         if($this->acl_is_writeable($attrs)){
           if(isset($_POST[$attrs])){
@@ -95,16 +87,20 @@ class faiVariableEntry extends plugin
     $message= plugin::check();
 
     if(isset($this->parent->SubObjects[$this->cn]) && $this->cn != $this->orig_cn){
-      $message[] = msgPool::duplicate(_("Name"));
+      $message[] = msgPool::duplicated(_("Name"));
     }
     
-    if(empty($this->FAIvariableContent)) {
+    if($this->FAIvariableContent == "") {
       $message[]= msgPool::required(_("Content")); 
     }
-   
-    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");
+    }
 
     return ($message);
   }