diff --git a/plugins/gofon/phoneaccount/class_phoneAccount.inc b/plugins/gofon/phoneaccount/class_phoneAccount.inc
index 3b3a00f818c05996a80dac85fe2a83d7ec66ff4a..a3a489ba6e94da317d9bc46cbaa534d0ef885e82 100644 (file)
$ldap->search("(objectClass=goFonMacro)", array("*"));
/* Add none for no macro*/
- $this->macros['none']=_("none");
+ $this->macros['none']=_("no macro");
$this->macro ="none";
}//is_array
}//visible = 1
}//while
+
/* Go through already saved values, for a parameter */
$tmp = split("!",$this->goFonMacro);
$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){
$str = $default;
/* in case of a combo box display a combobox with selected attr */
- if($type == "combo"){
- $str="<select name='".$var."' >";
- foreach(split(":",$default) as $choice){
- if($choosen==$choice){
- $str.="\n<option name='".$var."' value='".$choice."' selected>".$choice."</option>";
- }else{
- $str.="\n<option name='".$var."' value='".$choice."'>".$choice."</option>";
+ $macrotab.= "<tr>";
+ switch ($type){
+
+ case "combo":
+ $str= "<select name='".$var."' ".chkacl($this->acl, "goFonMacro").">";
+ foreach(split(":",$default) as $choice){
+ if($choosen==$choice){
+ $str.= "\n<option value='".$choice."' selected>".$choice." </option>";
+ }else{
+ $str.= "\n<option value='".$choice."'>".$choice." </option>";
+ }
}
- }
- $str.="</select>";
- }
-
- /* Display switch for true false*/
- if($type == "bool"){
+ $str.="</select>";
+ $macrotab.= "<td>$name</td><td>$str";
+ break;
- $str="<select name='".$var."'>";
+ case "bool":
+ if(!$choosen){
+ $str="\n<input type='checkbox' name='".$var."' value='1'>";
+ }else{
+ $str="\n<input type='checkbox' name='".$var."' value='1' checked>";
+ }
+ $macrotab.= "<td colspan='2'>$str $name";
+ break;
- if($choosen){
- $str.="<option name='".$var."' value='0'>"._("false")."</option>";
- $str.="<option name='".$var."' value='1' selected>"._("true")."</option>";
- }else{
- $str.="<option name='".$var."' value='0' selected>"._("false")."</option>";
- $str.="<option name='".$var."' value='1'>"._("true")."</option>";
- }
- $str.="<select name='".$var."'>";
- }
+ case "string":
+ $str="<input name='".$var."' value='".$choosen."' ".chkacl($this->acl, "goFonMacro").">";
+ $macrotab.= "<td>$name</td><td>$str";
+ break;
- /* display simple textfield */
- if($type=="string"){
- $str="<input name='".$var."' value='".$choosen."'>";
}
-
- /* create table entry*/
- $macrotab.= "\n<tr><td>".$name."</td><td>".$str."</td></tr>";
+ $macrotab.= "</td</tr>";
}
$macrotab.="</table>";
/* Transfer ACL's */
foreach($this->attributes as $val){
$smarty->assign($val."ACL", chkacl($this->acl, "$val"));
+ $smarty->assign($val,$this->$val);
}
/* Fill arrays */
} else {
$color= "";
}
- $hl.= " <option $color label=\"$cn\" value=\"$cn\" $selected>$description</option>\n";
+ $hl.= " <option $color label=\"$cn\" value=\"$cn\" $selected>$description </option>\n";
}
$hl.= "</select>\n";
$smarty->assign ("hardware_list", $hl);
}
$smarty->assign("forwarder_list", $forwarder_list);
-
-
- /* Check box */
- if ($this->parent->by_object['mailAccount'] &&
- $this->parent->by_object['mailAccount']->is_account &&
- preg_match("/M/i", $this->goFonDeliveryMode)){
- $smarty->assign("fon_to_mail", "checked");
- } else {
- $smarty->assign("fon_to_mail", "");
- }
-
- if (!isset($this->parent->by_object['mailAccount'])) {
- $smarty->assign("has_mailaccount", "false");
- $this->has_mailAccount= false;
- } elseif ( !$this->parent->by_object['mailAccount']->is_account){
- $smarty->assign("has_mailaccount", "false");
- $this->has_mailAccount= false;
- } else {
- $smarty->assign("has_mailaccount", "true");
- }
-
/* Show main page */
$display.= $smarty->fetch(get_template_path('generic.tpl', TRUE, dirname(__FILE__)));
return($display);
}
}
- /* Check if mail account is active and correct the internal
- reference to represent the current status. */
- if ($this->parent->by_object['mailAccount']->is_account){
- $this->has_mailAccount= TRUE;
- }
-
/* Every macro in the select box are available */
if((isset($_POST['macro']))){
$this->macrostillavailable=true;
if(isset($_POST[$paras['var']])){
$this->macroarray[$this->macro][$key]['choosen'] = $_POST[$paras['var']];
}
+
+ /* Checkboxes are special, they are not Posted if they are not selected, so the won't be changed with the above code
+ We need this code below to read and save checkboxes correct
+ */
+ if($this->macroarray[$this->macro][$key]['type']=="bool"){
+ if(isset($_POST[$this->macroarray[$this->macro][$key]['var']])) {
+ $this->macroarray[$this->macro][$key]['choosen']=$_POST[$paras['var']];
+ }else{
+ $this->macroarray[$this->macro][$key]['choosen']=false;
+ }
+ }
}
}
}
$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){
{
plugin::save();
- /* goFonAccount has "mail" as must! Block if no mailaddress is specified... */
- if (isset($this->parent->by_object['mailAccount']) &&
- !$this->parent->by_object['mailAccount']->is_account) {
-
- $this->goFonDeliveryMode= preg_replace("/M/i", "", $this->goFonDeliveryMode);
- }
-
/* Save arrays */
$this->attrs['telephoneNumber']= array();
foreach ($this->phoneNumbers as $number){
}
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);
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;