Code

Added command verifier
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 11 May 2010 10:18:27 +0000 (10:18 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 11 May 2010 10:18:27 +0000 (10:18 +0000)
-Not yet finished, but works

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18363 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/addons/configViewer/class_commandVerifier.inc [new file with mode: 0644]
gosa-core/plugins/addons/configViewer/class_configViewer.inc
gosa-core/plugins/addons/configViewer/commandVerifier.tpl [new file with mode: 0644]

diff --git a/gosa-core/plugins/addons/configViewer/class_commandVerifier.inc b/gosa-core/plugins/addons/configViewer/class_commandVerifier.inc
new file mode 100644 (file)
index 0000000..a784ca7
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+
+
+class commandVerifier
+{
+    private $property = NULL;
+    private $config = NULL;
+
+    private $command = "";
+    
+    function __construct($config, $property)
+    {
+        $this->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);
+    }
+}
+
+
+?>
index c2231037baba1247be79b12a8c6eceaf13fee833..f4a5584b63b152f4994b3b9806487ed44e0f5f3f 100644 (file)
@@ -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 = "<input style='width:{$isize}' type='text' value=\"{$value}\" name=\"{$name}\">";
+                $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 = "<input style='width:{$isize}' type='text' value=\"{$value}\" name=\"{$name}\">";
diff --git a/gosa-core/plugins/addons/configViewer/commandVerifier.tpl b/gosa-core/plugins/addons/configViewer/commandVerifier.tpl
new file mode 100644 (file)
index 0000000..1c912d3
--- /dev/null
@@ -0,0 +1,21 @@
+
+
+<h3>{t}Command property verifier{/t}</h3>
+
+<p>
+    {t}The command to check for{/t}
+    <input type='text' name='command' value="{$value}" style='width: 100%;'>
+</p>
+
+<p>
+    {t}The generated output{/t}
+    <textarea size=10 style='width:100%'>{$output}</textarea>
+</p>
+
+<button type='submit' name='execute'>{t}Test{/t}</button> 
+
+<hr>
+<div class="plugin-actions">
+    <button type='submit' name='commandVerifier_save'>{msgPool type='okButton'}</button>
+    <button type='submit' name='commandVerifier_cancel'>{msgPool type='cancelButton'}</button>
+</div>