summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1906868)
raw | patch | inline | side by side (parent: 1906868)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 23 Jun 2005 07:43:11 +0000 (07:43 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 23 Jun 2005 07:43:11 +0000 (07:43 +0000) |
index 373a4838e9df79a1103f0f8d5ae97f5de78a5c3f..81f676686198351335ac8b5eb63c9fe5f0293e47 100755 (executable)
function check()
{
$message = array();
-
+
+ if(empty($this->displayName)){
+ $message[] = _("You must specify the 'Display Name' in order to save this macro");
+ }
+
foreach($this->attributes as $attr){
if(chkacl($this->acl,$attr)){
$str = sprintf( _("Insufficient permissions, can't change attribute '%s' in goFonMacro"),$attr) ;
diff --git a/plugins/gofon/macro/class_gofonMacroParameters.inc b/plugins/gofon/macro/class_gofonMacroParameters.inc
index 9eaaab93460a3d7f1744ba1e445079c8775cbe09..74b0a6b7271af3d033b4cf513b2eeeaea731c9ed 100755 (executable)
var $base= "";
var $goFonMacroParameter =array();
var $type_shortcut= array("string" => array("selected", "", ""),
- "combo" => array("", "selected", ""),
- "bool" => array("", "", "selected"));
+ "combo" => array("", "selected", ""),
+ "bool" => array("", "", "selected"));
/* attribute list for save action */
var $attributes= array("base","goFonMacroParameter");
}
}
+ /* Load parametersettings*/
foreach($this->goFonMacroParameter as $para){
$tmp = split("!",$para);
- $num = preg_replace("/[^0-9]/","",$tmp[1]);
- $tmp2[$num]['var'] = $tmp[1];
- $tmp2[$num]['name'] = $tmp[2];
- $tmp2[$num]['type'] = $tmp[3];
- $tmp2[$num]['default'] = $tmp[4];
+ $num = $tmp[0];
+ $tmp2[$num]['name'] = $tmp[1];
+ $tmp2[$num]['type'] = $tmp[2];
+ $tmp2[$num]['default'] = $tmp[3];
+ $tmp2[$num]['var'] = "var".$num;
}
/* Assign this array */
}
function check_paras($content,$goFonMacroParameter)
- {
+ {
+ /* Check contents for parameters */
preg_match_all("/[$]\{ARG[0-9]*\}/",$content,$res,PREG_OFFSET_CAPTURE);
- $anz = count($res[0]);
$new = array();
+ /* Detect parameters with positions */
foreach($res[0] as $val){
$num = preg_replace("/[^0-9]/","",$val[0]);
$new[$num]['val'] = $val[0];
$new[$num]['num'] = $num;
}
+ /* Compare content parameter and macro parameter */
foreach($goFonMacroParameter as $gokey => $goval){
foreach($new as $nkey => $nval){
if($gokey == $nval['num']){
+ /* sign this as OK */
$goFonMacroParameter[$gokey]['check']= true;
}
}
}
+
+ /* Now check if there is new parameter in the content, which is not assigned yet */
foreach($new as $key => $val){
- $goFonMacroParameter[$key]['var']="\${ARG".$key."}";
+ /* Assign std values */
+ $goFonMacroParameter[$key]['var']="var".$key;
$goFonMacroParameter[$key]['check']= true;
+
+ /* If this is a new Parameter, name it ${ARG#} by default*/
if((!isset($goFonMacroParameter[$key]['name']))||(empty($goFonMacroParameter[$key]['name']))){
$goFonMacroParameter[$key]['name']="\${ARG".$key."}";
}
}
foreach($goFonMacroParameter as $key => $val){
+ /* All attributes with check == false, are unneeded so mark them with ['check']= false */
if(!isset($goFonMacroParameter[$key]['check'])){
$goFonMacroParameter[$key]['check']= false;
}
+ /* Ah no default given assign ="" to prevent unsigned index */
if(!isset($goFonMacroParameter[$key]['default'])){
$goFonMacroParameter[$key]['default'] = "";
}
}
+
+ /* Sort output for better reading */
asort($goFonMacroParameter);
return($goFonMacroParameter);
if (isset($_POST['phoneparameters'])){
plugin::save_object();
}
- /* read out post data, and assign it to the parameters */
+ /* read out post data, and assign it to the parameters */
/* And or delete */
foreach($_POST as $name=>$value){
return(array($str));
}
}
+
+
foreach($this->goFonMacroParameter as $key=>$val){
+ if(strstr($val['default'],"!")) {
+ $message[] = sprintf(_("The parameter %s contains invalid char. '!' is used as delimiter"),$val['name']);
+ }
switch($val['type']){
case 'bool' : $possible = array("","0","1","true","false");
if(!in_array($val['default'],$possible)) {
$message[] = sprintf(_("The parameter %s has incorrect value for type bool."),$val['name']);
};break;
case 'string' :
- case 'combo' : if(strstr($val['default'],"!")){
- $message[] = sprintf(_("The parameter %s contains invalid char. '!' is used as delimiter"),$val['name']);
- };break;
+ case 'combo' :
default : ;
-
+
}
}
return $message;
$this->attrs['goFonMacroParameter']=array();
foreach($this->goFonMacroParameter as $key=>$fonpara){
- $this->attrs['goFonMacroParameter'][]=$key."!".$fonpara['var']."!".$fonpara['name']."!".$fonpara['type']."!".$fonpara['default'];
+ $this->attrs['goFonMacroParameter'][]=$key."!".$fonpara['name']."!".$fonpara['type']."!".$fonpara['default'];
}
unset($this->attrs['base']);
diff --git a/plugins/gofon/phoneaccount/class_phoneAccount.inc b/plugins/gofon/phoneaccount/class_phoneAccount.inc
index a72200c6311bc081ffc01fee4b2b441f5ece9fb7..2659d43e8e4f57e825cd4fdfd96e54703be75c2e 100644 (file)
var $macros = array(); // List of macros for smarty select box
var $macroarray = array(); // All needed macro informations
var $macrostillavailable = false;
-
+
/* CLI vars */
var $cli_summary = "Manage users phone account";
var $cli_description = "Some longer text\nfor help";
/* attribute list for save action */
var $attributes = array("goFonDeliveryMode", "goFonForwarding", "goFonFormat",
- "goFonHardware", "goFonPIN", "telephoneNumber", "goFonMacro","macro");
+ "goFonHardware", "goFonPIN", "telephoneNumber", "goFonMacro","macro");
var $objectclasses= array("goFonAccount");
function phoneAccount ($config, $dn= NULL)
$description= "";
}
$this->hardware_list[$cn]= "$cn$description";
-
+
}
/* Prepare templating */
/* Fetch all Macros*/
while ($attrs= $ldap->fetch()){
-
+
/* Only visisble */
if((isset($attrs['goFonMacroVisible'][0]))&&($attrs['goFonMacroVisible'][0] ==1)){
-
+
/* unset Count, we don't need that here */
unset($attrs['displayName']['count']);
-
+
/* fill Selectfield variable with Macros */
if(isset($attrs['displayName'][0])){
- $this->macros[$attrs['dn']] = $attrs['displayName'][0];
+ $this->macros[$attrs['dn']] = $attrs['displayName'][0]." (".$attrs['cn'][0].")";
}else{
$this->macros[$attrs['dn']] = _("undefined");
}
/* Parse macro data, unset count for parameterarrays */
unset($attrs['goFonMacroParameter']['count']);
-
+
/* Go through available parameters and parse all attributes, like parametername, type, default ...*/
if((isset($attrs['goFonMacroParameter']))&&(is_array($attrs['goFonMacroParameter']))){
/* Split Data in readable values, by delimiter ! */
$data = split("!",$attrs['goFonMacroParameter'][$pkey]);
-
+
/* Set all attrs */
$id = $data[0];
$this->macroarray[$attrs['dn']][$id]['var'] ="var".$id;
$this->macroarray[$attrs['dn']][$id]['name'] =$data[1];
$this->macroarray[$attrs['dn']][$id]['type'] =$data[2];
$this->macroarray[$attrs['dn']][$id]['default']=$data[3];
- }//foreach
- }//is_array
- }//visible = 1
- }//while
+ }//foreach
+ }//is_array
+ }//visible = 1
+ }//while
/* Go through already saved values, for a parameter */
$tmp = split("!",$this->goFonMacro);
/* it is possible that nothing has been saved yet */
if(is_array($tmp)){
-
+
/* First value is the macroname */
$this->macro = $tmp[0];
-
+
/* Macroname saved, delete that index */
unset($tmp[0]);
/* for each parametervalues ( parameterID#value like 25#twentyfive) */
foreach($tmp as $var){
-
+
/* Split this, so we have $varar[0] = parameterID $varar[1] = SelectedValue */
$varar = split("#",$var);
-
+
/* Only insert if the parameter still exists */
if(isset($this->macroarray[$this->macro][$varar[0]])){
-
+
/* Assign value */
$this->macroarray[$this->macro][$varar[0]]['choosen']=$varar[1];
- }
}
}
+ }
/* Eventually colorize phones */
$ldap->cd($this->config->current['BASE']);
/* Assing macroselectbox values */
$smarty->assign("macros",$this->macros);
$smarty->assign("macro", $this->macro);
-
+
/* Create parameter table, skip if no parameters given */
if(!isset($this->macroarray[$this->macro])){
$macrotab="";
}else{
-
+
$macrotab ="<table>";
/* for every single parameter-> display textfile,combo, or true false switch*/
foreach($this->macroarray[$this->macro] as $paras){
}
$str.="</select>";
}
-
+
/* Display switch for true false*/
if($type == "bool"){
-
+
$str="<select name='".$var."'>";
if($choosen){
}
$str.="<select name='".$var."'>";
}
-
+
/* 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.="</table>";
}//is_array()
$smarty->assign ("phoneNumbers", $this->phoneNumbers);
}
$hl= "<select size=\"1\" name=\"goFonHardware\" title=\"".
- _("Choose your private phone")."\" ".chkacl($this->acl, "goFonHardware").">\n";
+ _("Choose your private phone")."\" ".chkacl($this->acl, "goFonHardware").">\n";
foreach ($this->hardware_list as $cn => $description){
if ($cn == $this->goFonHardware){
$selected= "selected";
if((isset($_POST['macro']))){
$this->macrostillavailable=true;
}
-
+
/* get all Postvars */
if(isset($this->macroarray[$this->macro])){
foreach($this->macroarray[$this->macro] as $key => $paras){
$this->attrs['goFonMacro']=array();
}
unset($this->attrs['macro']) ;
-
+
/* Write back to ldap */
$ldap= $this->config->get_ldap_link();
$ldap->cd($this->dn);
if (!$this->initially_was_account){
return;
}
-
+
plugin::remove_from_parent();
/* Just keep one phone number */