Code

Input fields must be disabled in case of missing ACL
[gosa.git] / plugins / gofon / phoneaccount / class_phoneAccount.inc
index 0574074ad03e3a48d54bb7023700c111d45b216a..0a9601386ec7c9856418606a92106ee48cc99018 100644 (file)
@@ -221,7 +221,7 @@ class phoneAccount extends plugin
       $macrotab="";
     }else{
 
-      $macrotab ="<table>";
+      $macrotab ="<table summary=\""._("Parameter")."\">";
       /* for every single parameter-> display textfile,combo, or true false switch*/
       foreach($this->macroarray[$this->macro] as $paras){
 
@@ -238,12 +238,12 @@ class phoneAccount extends plugin
         switch ($type){
 
           case "combo":
-            $str= "<select name='".$var."' ".chkacl($this->acl, "goFonMacro").">";
+            $str= "<select name='".$var."' ".chkacl($this->acl, "goFonMacro")."  ".chkacl($this->acl, "goFonMacro").">";
             foreach(split(":",$default) as $choice){
               if($choosen==$choice){
-                $str.= "\n<option name='".$var."' value='".$choice."' selected>".$choice."</option>";
+                $str.= "\n<option value='".$choice."' selected>".$choice."&nbsp;</option>";
               }else{
-                $str.= "\n<option name='".$var."' value='".$choice."'>".$choice."</option>";
+                $str.= "\n<option value='".$choice."'>".$choice."&nbsp;</option>";
               }
             }
             $str.="</select>";
@@ -252,9 +252,9 @@ class phoneAccount extends plugin
 
           case "bool":
             if(!$choosen){
-              $str="\n<input type='checkbox' name='".$var."' value='1'>";
+              $str="\n<input type='checkbox' name='".$var."' value='1' ".chkacl($this->acl, "goFonMacro")." >";
             }else{
-              $str="\n<input type='checkbox' name='".$var."' value='1' checked>";
+              $str="\n<input type='checkbox' name='".$var."' value='1' checked  ".chkacl($this->acl, "goFonMacro").">";
             }
             $macrotab.= "<td colspan='2'>$str&nbsp;$name";
             break;
@@ -330,6 +330,7 @@ class phoneAccount extends plugin
     /* Transfer ACL's */
     foreach($this->attributes as $val){
       $smarty->assign($val."ACL", chkacl($this->acl, "$val"));
+      $smarty->assign($val,$this->$val);
     }
 
     /* Fill arrays */
@@ -352,7 +353,7 @@ class phoneAccount extends plugin
       } else {
         $color= "";
       }
-      $hl.= "  <option $color label=\"$cn\" value=\"$cn\" $selected>$description</option>\n";
+      $hl.= "  <option $color label=\"$cn\" value=\"$cn\" $selected>$description&nbsp;</option>\n";
     }
     $hl.= "</select>\n";
     $smarty->assign ("hardware_list", $hl);
@@ -453,6 +454,16 @@ class phoneAccount extends plugin
       $message[]= sprintf(_("You need to specify at least one phone number!"));
     }
 
+    if(($this->goFonPIN)==""){
+      $this->goFonPIN = array();
+    }else{
+      if(strcmp ((int)($this->goFonPIN),($this->goFonPIN))){
+        $message[] = sprintf(_("The given PIN is not valid, only numbers are allowed for this type."));
+      }elseif(strlen($this->goFonPIN) < 4){
+        $message[] = sprintf(_("The given PIN is too short"));
+      }
+
+    }
     /* Check timestamps and phonenumbers */
     foreach ($this->forwarders as $fw){
 
@@ -511,6 +522,9 @@ class phoneAccount extends plugin
     }
     unset($this->attrs['macro'])  ;
 
+    if($this->attrs['goFonMacro']==""){
+      $this->attrs['goFonMacro']=array();
+    }
     /* Write back to ldap */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->dn);
@@ -577,6 +591,11 @@ class phoneAccount extends plugin
 
   function remove_from_parent()
   {
+    /* unset macro attr, it will cause an error */
+    $tmp = array_flip($this->attributes);
+    unset($tmp['macro']);
+    $this->attributes=array_flip($tmp);
+  
     /* Cancel if there's nothing to do here */
     if (!$this->initially_was_account){
       return;