From b20d36ea2985a3b3db14cc10c1aea5b60d56a995 Mon Sep 17 00:00:00 2001 From: cajus Date: Tue, 21 Jun 2005 17:51:11 +0000 Subject: [PATCH] Layout and functional changes, code simplifying git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@789 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/gofon/macro/class_gofonMacro.inc | 2 +- .../macro/class_gofonMacroParameters.inc | 155 ++++++++---------- plugins/gofon/macro/parameter.tpl | 5 +- 3 files changed, 70 insertions(+), 92 deletions(-) diff --git a/plugins/gofon/macro/class_gofonMacro.inc b/plugins/gofon/macro/class_gofonMacro.inc index 30bfc156d..373a4838e 100755 --- a/plugins/gofon/macro/class_gofonMacro.inc +++ b/plugins/gofon/macro/class_gofonMacro.inc @@ -48,7 +48,7 @@ class macro extends plugin /* Do we represent a valid group? */ if (!$this->is_account && $this->parent == NULL){ $display= "\"\" ". - _("This 'dn' is no application.").""; + _("This 'dn' is no phone macro.").""; return ($display); } diff --git a/plugins/gofon/macro/class_gofonMacroParameters.inc b/plugins/gofon/macro/class_gofonMacroParameters.inc index def581f1b..f8f93a19a 100755 --- a/plugins/gofon/macro/class_gofonMacroParameters.inc +++ b/plugins/gofon/macro/class_gofonMacroParameters.inc @@ -9,11 +9,15 @@ class macroParameter extends plugin /* 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); @@ -54,67 +58,60 @@ class macroParameter extends plugin $this->goFonMacroParameter[] = $tmp3; } } - - foreach($this->goFonMacroParameter as $para){ + foreach($this->goFonMacroParameter as $para){ $tmp = split("!",$para); $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; } -function check_paras($content,$goFonMacroParameter) + function check_paras($content,$goFonMacroParameter) { - preg_match_all("/[$]\{ARG[0-9]*\}/",$content,$res,PREG_OFFSET_CAPTURE); + preg_match_all("/[$]\{ARG[0-9]*\}/",$content,$res,PREG_OFFSET_CAPTURE); - $anz = count($res[0]); - $new = array(); + $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($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($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($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; + foreach($goFonMacroParameter as $key => $val){ + if(!isset($goFonMacroParameter[$key]['check'])){ + $goFonMacroParameter[$key]['check']= false; } - if(!isset($goFonMacroParameter[$key]['default'])){ - $goFonMacroParameter[$key]['default'] = ""; + if(!isset($goFonMacroParameter[$key]['default'])){ + $goFonMacroParameter[$key]['default'] = ""; } } - asort($goFonMacroParameter); - return($goFonMacroParameter); + asort($goFonMacroParameter); + return($goFonMacroParameter); } - - - - - - function execute() { /* Variables */ @@ -125,14 +122,14 @@ function check_paras($content,$goFonMacroParameter) $content = $_SESSION['macroManagment']->macrotabs->by_object['macro']->goFonMacroContent; if(strstr($content,"ARG")){ - $vorpos = strpos($content,"ARG"); - $rest = substr($content,$vorpos, strlen($content)); + $vorpos = strpos($content,"ARG"); + $rest = substr($content,$vorpos, strlen($content)); } /* Do we represent a valid group? */ if (!$this->is_account && $this->parent == NULL){ $display= "\"\" ". - _("This 'dn' is no application.").""; + _("This 'dn' is no phone macro.").""; return ($display); } @@ -156,6 +153,10 @@ function check_paras($content,$goFonMacroParameter) $this->goFonMacroParameter[]=array("name"=>"new","type"=>"string","default"=>"test"); } + + #FIXME: Der Transfer der momentanen Variablen muss nach save_object(), + # damit kann in save() auf den execute() Aufruf verzichtet werden! + /* read out post data, and assign it to the parameters */ /* And or delete */ foreach($_POST as $name=>$value){ @@ -170,48 +171,40 @@ function check_paras($content,$goFonMacroParameter) unset($this->goFonMacroParameter[$nr]); }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]; + $this->goFonMacroParameter[$key]['name'] = $_POST["varname".$key]; + $this->goFonMacroParameter[$key]['type'] = $_POST["vartype".$key]; + $this->goFonMacroParameter[$key]['default']= $_POST["default".$key]; } } /*generate Table which shows als parameters */ - - $FonParas = $this->check_paras($content,$this->goFonMacroParameter); - + + $FonParas = $this->check_paras($content,$this->goFonMacroParameter); + foreach($FonParas as $key=>$para) { - if(isset($para['type'])){ - if($para['type']=="string") { - $sel1 = "selected"; - $sel2 = ""; - $sel3 = ""; - }elseif($para['type']=="combo"){ - $sel1 = ""; - $sel2 = "selected"; - $sel3 = "" ; + /* Select correct item of combobox */ + if(isset($para['type'])){ + list($sel1, $sel2, $sel3)= $this->type_shortcut[$para['type']]; }else{ - $sel1 = ""; - $sel3 = "selected"; - $sel2 = "" ; + list($sel1, $sel2, $sel3)= array("", "", ""); } - }else{ - $sel1 = ""; - $sel3 = ""; - $sel2 = "" ; - } + #FIXME: Der Name des Parameters ist nicht gesetzt + # -> Argument (ARG#) Name [....] Typ [...^] Default [....] + + /* Assemble output table */ $vars .=" ".$para['name']." @@ -223,46 +216,28 @@ function check_paras($content,$goFonMacroParameter) $vars.=""._("Unused").""; $vars.=" "; } - - $vars.=" "; - + $vars.=" "; } /* 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(); } } @@ -272,13 +247,13 @@ function check_paras($content,$goFonMacroParameter) 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; } @@ -287,12 +262,14 @@ function check_paras($content,$goFonMacroParameter) function save() { /* Post checks */ + + # FIXME: das hat hier nix zu suchen... $this->execute(); plugin::save(); $this->attrs['goFonMacroParameter']=array(); - + foreach($this->goFonMacroParameter as $key=>$fonpara){ $this->attrs['goFonMacroParameter'][]=$key."!".$fonpara['name']."!".$fonpara['type']."!".$fonpara['default']; } diff --git a/plugins/gofon/macro/parameter.tpl b/plugins/gofon/macro/parameter.tpl index 4db0d31f6..7d71e3d98 100755 --- a/plugins/gofon/macro/parameter.tpl +++ b/plugins/gofon/macro/parameter.tpl @@ -3,7 +3,7 @@ - @@ -19,7 +19,8 @@
{t}Number{/t} + {t}Argument{/t} {t}Name{/t}
-

 

+ +