diff --git a/plugins/gofon/macro/class_gofonMacroParameters.inc b/plugins/gofon/macro/class_gofonMacroParameters.inc
index f12da521e502ca04762eebf2472c6b6785e14ce6..67f8bce0619930c125b59a7a399f2d4233a7711f 100755 (executable)
/* application attributes */
var $base= "";
var $goFonMacroParameter =array();
+ var $type_shortcut= array("string" => array("selected", "", ""),
+ "combo" => array("", "selected", ""),
+ "bool" => array("", "", "selected"));
/* attribute list for save action */
var $attributes= array("base","goFonMacroParameter");
var $objectclasses= array("top", "goFonMacro");
+
function macroParameter ($config, $dn= NULL)
{
plugin::plugin ($config, $dn);
$tmp3 = $this->goFonMacroParameter;
$this->goFonMacroParameter =array();
if(!empty($tmp3)) {
- $this->goFonMacroParameter[] = $tmp3;
+ $this->goFonMacroParameter[] = $tmp3;
}
}
- /* Create a better sorted array */
- foreach($this->goFonMacroParameter as $para) {
+ foreach($this->goFonMacroParameter as $para){
$tmp = split("!",$para);
- $tmp2[$tmp[0]]['name'] = $tmp[1];
- $tmp2[$tmp[0]]['type'] = $tmp[2];
- $tmp2[$tmp[0]]['default'] = $tmp[3];
+ $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];
}
/* Assign this array */
- $this->goFonMacroParameter = $tmp2;
+ $this->goFonMacroParameter = $tmp2;
+ }
+
+ function check_paras($content,$goFonMacroParameter)
+ {
+ preg_match_all("/[$]\{ARG[0-9]*\}/",$content,$res,PREG_OFFSET_CAPTURE);
+
+ $anz = count($res[0]);
+ $new = array();
+
+ foreach($res[0] as $val){
+ $num = preg_replace("/[^0-9]/","",$val[0]);
+ $new[$num]['val'] = $val[0];
+ $new[$num]['num'] = $num;
+ }
+
+ foreach($goFonMacroParameter as $gokey => $goval){
+ foreach($new as $nkey => $nval){
+ if($gokey == $nval['num']){
+ $goFonMacroParameter[$gokey]['check']= true;
+ }
+ }
+ }
+ foreach($new as $key => $val){
+ $goFonMacroParameter[$key]['var']="\${ARG".$key."}";
+ $goFonMacroParameter[$key]['check']= true;
+ if((!isset($goFonMacroParameter[$key]['name']))||(empty($goFonMacroParameter[$key]['name']))){
+ $goFonMacroParameter[$key]['name']="\${ARG".$key."}";
+ }
+ }
+
+ foreach($goFonMacroParameter as $key => $val){
+ if(!isset($goFonMacroParameter[$key]['check'])){
+ $goFonMacroParameter[$key]['check']= false;
+ }
+ if(!isset($goFonMacroParameter[$key]['default'])){
+ $goFonMacroParameter[$key]['default'] = "";
+ }
+ }
+ asort($goFonMacroParameter);
+ return($goFonMacroParameter);
}
+
function execute()
{
/* Variables */
$tmp = array();
$number = 0;
+ $content = $_SESSION['macroManagment']->macrotabs->by_object['macro']->goFonMacroContent;
+
+ if(strstr($content,"ARG")){
+ $vorpos = strpos($content,"ARG");
+ $rest = substr($content,$vorpos, strlen($content));
+ }
+
/* Do we represent a valid group? */
if (!$this->is_account && $this->parent == NULL){
$display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\"> <b>".
- _("This 'dn' is no application.")."</b>";
+ _("This 'dn' is no phone macro.")."</b>";
return ($display);
}
}
$number= count($this->goFonMacroParameter);
$number++;
- $this->goFonMacroParameter[]=array("name"=>"new","type"=>"string","default"=>"test");
+ $this->goFonMacroParameter[]=array("var"=>"var","name"=>"new","type"=>"string","default"=>"test");
}
- /* read out post data, and assign it to the parameters */
- /* And or delete */
- foreach($_POST as $name=>$value){
-
- /* Test if there is a variable begining with "del" */
- if(preg_match("/del/",$name)){
-
- /* Extract entry id to delete */
- $nr = str_replace("del","",$name) ;
-
- /* unset entry */
- unset($this->goFonMacroParameter[$nr]);
+ /*generate Table which shows als parameters */
- }elseif(preg_match("/number/",$name)){
- /* Set Post vars */
- $key = $_POST[$name];
- $this->goFonMacroParameter[$key]['name'] =$_POST["varname".$key];
- $this->goFonMacroParameter[$key]['type'] =$_POST["vartype".$key];
- $this->goFonMacroParameter[$key]['default'] =$_POST["default".$key];
- }
- }
+ $FonParas = $this->check_paras($content,$this->goFonMacroParameter);
- /*generate Table which shows als parameters */
- foreach($this->goFonMacroParameter as $key=>$para) {
+ foreach($FonParas as $key=>$para) {
- if($para['type']=="string") {
- $sel1 = "selected";
- $sel2 = "";
+ /* Select correct item of combobox */
+ if(isset($para['type'])){
+ list($sel1, $sel2, $sel3)= $this->type_shortcut[$para['type']];
}else{
- $sel1 = "";
- $sel2 = "selected";
+ list($sel1, $sel2, $sel3)= array("", "", "");
}
+ /* Assemble output table */
$vars .="<tr>
- <td>".$key."<input name=\"number".$key."\" value='".$key."' type='hidden'> </td>
- <td><input name='varname".$key."' value='".$para['name']."'></td>
+ <input name=\"number".$key."\" value='".$key."' type='hidden'>
+ <td><input name='var".$key."' type='hidden' value='".$para['var']."'>".$para['var']."</td>
+ <td><input name='varname".$key."' value='".$para['name']."'></td>
<td>
<select name='vartype".$key."'>
- <option name='vartype".$key."' value='string' ".$sel1.">string</option>
- <option name='vartype".$key."' value='combo' ".$sel2.">combo</option>
- <option name='vartype".$key."' value='bool' ".$sel2.">bool</option>
+ <option name='vartype".$key."' value='string' ".$sel1.">"._("String")."</option>
+ <option name='vartype".$key."' value='combo' ".$sel2.">"._("Combobox")."</option>
+ <option name='vartype".$key."' value='bool' ".$sel3.">"._("Bool")."</option>
</select>
</td>
<td><input name='default".$key."' value='".$para['default']."'></td>
- <td><input name='del".$key."' value='delete' type='submit'></td>
- </tr>";
-
+ <td>";
+ if($para['check']==true) {
+ $vars.="</td><td></td>";
+ }else{
+ $vars.="<b>"._("Unused")."</b></td>";
+ $vars.=" <td><input name='del".$key."' value='delete' type='submit'></td>";
+ }
+ $vars.=" </tr>";
}
- /* Display add renew button */
- $vars .="<tr>
- <td colspan=5>
- <input name='addvar' value="._("Add")." type='submit'>
- <input name='actvar' value="._("Refresh")." type='submit'>
- </td>
- </tr>";
/* Checkboxes */
$smarty->assign("base_select", $this->base);
$smarty->assign("vars", $vars);
-
/* Show main page */
return($smarty->fetch (get_template_path('parameter.tpl', TRUE)));
}
+
function remove_from_parent()
{
- /*
- $ldap= $this->config->get_ldap_link();
- $ldap->rmDir($this->dn);
-
- /* Optionally execute a command after we're done * /
- $this->handle_post_events("remove");
-
- /* Delete references to object groups * /
- $ldap->cd ($this->config->current['BASE']);
- $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
- while ($ldap->fetch()){
- $og= new ogroup($this->config, $ldap->getDN());
- unset($og->member[$this->dn]);
- $og->save ();
- }
- */
}
/* Save data to object */
function save_object()
{
- if (isset($_POST['cn'])){
+ if (isset($_POST['phoneparameters'])){
plugin::save_object();
}
+ /* read out post data, and assign it to the parameters */
+ /* And or delete */
+ foreach($_POST as $name=>$value){
+
+ /* Test if there is a variable begining with "del" */
+ if(preg_match("/del/",$name)){
+
+ /* Extract entry id to delete */
+ $nr = str_replace("del","",$name) ;
+
+ /* unset entry */
+ unset($this->goFonMacroParameter[$nr]);
+
+ }elseif(preg_match("/number/",$name)){
+
+ /* Set Post vars */
+ $key = $_POST[$name];
+
+ $this->goFonMacroParameter[$key]['var'] = $_POST["var".$key];
+ $this->goFonMacroParameter[$key]['name'] = $_POST["varname".$key];
+ $this->goFonMacroParameter[$key]['type'] = $_POST["vartype".$key];
+ $this->goFonMacroParameter[$key]['default']= $_POST["default".$key];
+ }
+ }
+
}
function check()
{
$message = array();
-
+
foreach($this->attributes as $attr){
if(chkacl($this->acl,$attr)){
- $str = sprintf( _("Insufficient permissions, can't change attribute '%s' in goFonMacro"),$attr) ;
+ $str = sprintf( _("Insufficient permissions, can't change attribute '%s' in goFonMacro."),$attr) ;
return(array($str));
- }
}
+ }
return $message;
}
function save()
{
/* Post checks */
- $this->execute();
plugin::save();
$this->attrs['goFonMacroParameter']=array();
foreach($this->goFonMacroParameter as $key=>$fonpara){
- $this->attrs['goFonMacroParameter'][]=$key."!".$fonpara['name']."!".$fonpara['type']."!".$fonpara['default'];
+ $this->attrs['goFonMacroParameter'][]=$key."!".$fonpara['var']."!".$fonpara['name']."!".$fonpara['type']."!".$fonpara['default'];
}
unset($this->attrs['base']);