From ba537fe5d2cc464870d3714b2b3a336ebda90ed9 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 11 May 2010 10:18:27 +0000 Subject: [PATCH] Added command verifier -Not yet finished, but works git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18363 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../configViewer/class_commandVerifier.inc | 48 +++++++++++++++++++ .../configViewer/class_configViewer.inc | 19 +++++++- .../addons/configViewer/commandVerifier.tpl | 21 ++++++++ 3 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 gosa-core/plugins/addons/configViewer/class_commandVerifier.inc create mode 100644 gosa-core/plugins/addons/configViewer/commandVerifier.tpl diff --git a/gosa-core/plugins/addons/configViewer/class_commandVerifier.inc b/gosa-core/plugins/addons/configViewer/class_commandVerifier.inc new file mode 100644 index 000000000..a784ca74f --- /dev/null +++ b/gosa-core/plugins/addons/configViewer/class_commandVerifier.inc @@ -0,0 +1,48 @@ +config = &$config; + $this->property = &$property; + $this->command = $this->property->getValue(TRUE); + } + + function execute() + { + $smarty = get_smarty(); + + $output= ""; + + if(isset($_POST['execute'])){ + exec ($this->command, $ret,$code); + $ret = implode($ret,'\n'); + $output = "code: {$code}\nreturn: {$ret}"; + } + + + $smarty->assign('value', htmlentities($this->command,ENT_COMPAT,'UTF-8')); + $smarty->assign('output', $output); + return($smarty->fetch(get_template_path('commandVerifier.tpl', 'TRUE'))); + } + + function save_object() + { + if(isset($_POST['command'])) $this->command = get_post('command'); + } + + function save() + { + $this->property->setValue($this->command); + } +} + + +?> diff --git a/gosa-core/plugins/addons/configViewer/class_configViewer.inc b/gosa-core/plugins/addons/configViewer/class_configViewer.inc index c2231037b..f4a5584b6 100644 --- a/gosa-core/plugins/addons/configViewer/class_configViewer.inc +++ b/gosa-core/plugins/addons/configViewer/class_configViewer.inc @@ -44,7 +44,21 @@ class configViewer extends management if(isset($_POST[$post]) && $prop->getStatus() != 'removed'){ $prop->setValue(get_post($post)); } + + // Open the command verify dialog + if(isset($_POST["testCommand_{$post}"])){ + $this->dialogObject = new commandVerifier($this->config,$prop); + } + } + + if(isset($_POST['commandVerifier_save'])){ + $this->dialogObject->save(); + $this->closeDialogs(); + } + if(isset($_POST['commandVerifier_cancel'])){ + $this->closeDialogs(); } + return(management::execute()); } @@ -157,12 +171,15 @@ class configViewer extends management } } break; + case 'command': + $res = ""; + $res.= image('images/lists/edit.png', "testCommand_{$name}", _("Test the given command.")); + break; case 'dn': case 'rdn': case 'uri': case 'path': case 'file': - case 'command': case 'string': case 'integer': $res = ""; diff --git a/gosa-core/plugins/addons/configViewer/commandVerifier.tpl b/gosa-core/plugins/addons/configViewer/commandVerifier.tpl new file mode 100644 index 000000000..1c912d3e2 --- /dev/null +++ b/gosa-core/plugins/addons/configViewer/commandVerifier.tpl @@ -0,0 +1,21 @@ + + +

{t}Command property verifier{/t}

+ +

+ {t}The command to check for{/t} + +

+ +

+ {t}The generated output{/t} + +

+ + + +
+
+ + +
-- 2.30.2