From 89809d76d6a7cb8dc098d7b9320473d4961b9c54 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 21 Jun 2005 12:39:54 +0000 Subject: [PATCH] some changes, parameters are now detected automaticaly git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@782 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../macro/class_gofonMacroParameters.inc | 116 ++++++++++++++---- 1 file changed, 93 insertions(+), 23 deletions(-) diff --git a/plugins/gofon/macro/class_gofonMacroParameters.inc b/plugins/gofon/macro/class_gofonMacroParameters.inc index f12da521e..5f0beab9d 100755 --- a/plugins/gofon/macro/class_gofonMacroParameters.inc +++ b/plugins/gofon/macro/class_gofonMacroParameters.inc @@ -51,23 +51,70 @@ class macroParameter extends plugin $tmp3 = $this->goFonMacroParameter; $this->goFonMacroParameter =array(); if(!empty($tmp3)) { - $this->goFonMacroParameter[] = $tmp3; + $this->goFonMacroParameter[] = $tmp3; } } + + foreach($this->goFonMacroParameter as $para){ - /* Create a better sorted array */ - 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]['name'] = $tmp[1]; + $tmp2[$num]['type'] = $tmp[2]; + $tmp2[$num]['default'] = $tmp[3]; } - + /* 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]['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 */ @@ -75,6 +122,13 @@ class macroParameter extends plugin $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= "\"\" ". @@ -125,40 +179,56 @@ class macroParameter extends plugin } /*generate Table which shows als parameters */ - foreach($this->goFonMacroParameter as $key=>$para) { + + $FonParas = $this->check_paras($content,$this->goFonMacroParameter); + + foreach($FonParas as $key=>$para) { + if(isset($para['type'])){ if($para['type']=="string") { $sel1 = "selected"; $sel2 = ""; - }else{ + $sel3 = ""; + }elseif($para['type']=="combo"){ $sel1 = ""; $sel2 = "selected"; + $sel3 = "" ; + }else{ + $sel1 = ""; + $sel3 = "selected"; + $sel2 = "" ; } + }else{ + $sel1 = ""; + $sel3 = ""; + $sel2 = "" ; + } $vars .=" - ".$key." - + + ".$para['name']." - - "; + "; + if($para['check']==true) { + $vars.=_("Ok"); + $vars.=" "; + }else{ + $vars.=_("Unused"); + $vars.=" "; + } + + $vars.=" "; } - /* Display add renew button */ - $vars .=" - - - - - "; /* Checkboxes */ $smarty->assign("base_select", $this->base); $smarty->assign("vars", $vars); @@ -222,7 +292,7 @@ class macroParameter extends plugin plugin::save(); $this->attrs['goFonMacroParameter']=array(); - + foreach($this->goFonMacroParameter as $key=>$fonpara){ $this->attrs['goFonMacroParameter'][]=$key."!".$fonpara['name']."!".$fonpara['type']."!".$fonpara['default']; } -- 2.30.2