From d3fd4ee2f4f351bc3f957d781620c1dd0781bfcc Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Tue, 19 Oct 2010 20:42:55 +0000 Subject: [PATCH] - more work on froxlor-client settings (multiserver mode) --- admin_clients.php | 47 +++++++++++++++---- .../froxlorclient/class.froxlorclient.php | 9 ---- .../froxlor/function.loadConfigArrayDir.php | 32 ++++++++++++- lng/english.lng.php | 1 + .../froxlorclients/froxlorclient_settings.tpl | 12 +++++ .../froxlorclient_settingsend.tpl | 8 ++++ .../froxlorclient_settingsoverview.tpl | 14 ++++++ 7 files changed, 104 insertions(+), 19 deletions(-) create mode 100644 templates/admin/froxlorclients/froxlorclient_settings.tpl create mode 100644 templates/admin/froxlorclients/froxlorclient_settingsend.tpl create mode 100644 templates/admin/froxlorclients/froxlorclient_settingsoverview.tpl diff --git a/admin_clients.php b/admin_clients.php index 6e1d8903..2217f7a5 100644 --- a/admin_clients.php +++ b/admin_clients.php @@ -181,7 +181,20 @@ if((int)$settings['multiserver']['enabled'] == 1) ) { $client = froxlorclient::getInstance($userinfo, $db, $id); - $settings_data = $client->getSettingsData(); + /** + * @TODO + * - decide by client type (implementation will follow) + * what settings are going to be shown here + * (parameter $client_settings, has to be an array, + * see loadConfigArrayDir-function) + */ + $client_settings = array('froxlorclient'); + + $settings_data = loadConfigArrayDir( + './actions/admin/settings/', + './actions/multiserver/clientsettings/', + $client_settings + ); $settings = $client->getSettingsArray(); if(isset($_POST['send']) @@ -190,14 +203,32 @@ if((int)$settings['multiserver']['enabled'] == 1) } else { + $_part = isset($_GET['part']) ? $_GET['part'] : ''; + + if($_part == '') + { + $_part = isset($_POST['part']) ? $_POST['part'] : ''; + } + /** - * @TODO - * - show all client settings - * - validate settings - */ - echo $header; - echo "Here you will see the clients configuration, you will know most of the settings from the 'master'-panel already"; - echo $footer; + * @TODO this has to get the client-id so the + * links "configuration" have the ID + */ + $fields = buildFormEx($settings_data, $_part); + + $settings_page = ''; + if($_part == '') + { + eval("\$settings_page .= \"" . getTemplate("froxlorclients/froxlorclient_settingsoverview") . "\";"); + } + else + { + eval("\$settings_page .= \"" . getTemplate("froxlorclients/froxlorclient_settings") . "\";"); + } + + eval("echo \"" . getTemplate("settings/settings_form_begin") . "\";"); + eval("echo \$settings_page;"); + eval("echo \"" . getTemplate("froxlorclients/froxlorclient_settingsend") . "\";"); } } /** diff --git a/lib/classes/froxlorclient/class.froxlorclient.php b/lib/classes/froxlorclient/class.froxlorclient.php index 7db3f373..191b7430 100644 --- a/lib/classes/froxlorclient/class.froxlorclient.php +++ b/lib/classes/froxlorclient/class.froxlorclient.php @@ -235,15 +235,6 @@ class froxlorclient return $this->Get('settings'); } - /** - * return the complete client-settings-data array - * for the settings page - */ - public function getSettingsData() - { - return $this->s_data; - } - /** * get a value from the internal data array * diff --git a/lib/functions/froxlor/function.loadConfigArrayDir.php b/lib/functions/froxlor/function.loadConfigArrayDir.php index 853674de..eb54b864 100644 --- a/lib/functions/froxlor/function.loadConfigArrayDir.php +++ b/lib/functions/froxlor/function.loadConfigArrayDir.php @@ -28,9 +28,20 @@ function loadConfigArrayDir() $numargs = func_num_args(); if($numargs <= 0) { return null; } + // variable that holds all dirs that will + // be parsed for inclusion $configdirs = array(); + // if one of the parameters is an array + // we assume that this is a list of + // setting-groups to be selected + $selection = null; for($x=0;$x<$numargs;$x++) { - $configdirs[] = func_get_arg($x); + $arg = func_get_arg($x); + if(is_array($arg) && isset($arg[0])) { + $selection = $arg; + } else { + $configdirs[] = $arg; + } } $data = array(); @@ -62,6 +73,23 @@ function loadConfigArrayDir() $data = array_merge_recursive($data, include($data_filename)); } } - + + // if we have specific setting-groups + // to select, we'll handle this here + // (this is for multiserver-client settings) + $_data = array(); + if($selection != null + && is_array($selection) + && isset($selection[0]) + ) { + foreach($data['groups'] as $group => $data) + { + if(in_array($group, $selection)) { + $_data[$group] = $data; + } + } + $data = $_data; + } + return $data; } diff --git a/lng/english.lng.php b/lng/english.lng.php index 4bc05ed0..03b136f7 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -1537,5 +1537,6 @@ $lng['froxlorclient']['ssh_user'] = 'SSH user'; $lng['froxlorclient']['ssh_passphrase'] = 'SSH passphrase'; $lng['froxlorclient']['ssh_pubkey'] = 'SSH public key'; $lng['froxlorclient']['ssh_privkey'] = 'SSH private key'; +$lng['admin']['froxlorclient_settings'] = 'Froxlor client settings:'; ?> diff --git a/templates/admin/froxlorclients/froxlorclient_settings.tpl b/templates/admin/froxlorclients/froxlorclient_settings.tpl new file mode 100644 index 00000000..8ef204f1 --- /dev/null +++ b/templates/admin/froxlorclients/froxlorclient_settings.tpl @@ -0,0 +1,12 @@ + + + + + $fields + + + +
 {$lng['admin']['froxlorclient_settings']} "{$client->Get('name')} + [{$lng['admin']['configfiles']['compactoverview']}]
+ +
diff --git a/templates/admin/froxlorclients/froxlorclient_settingsend.tpl b/templates/admin/froxlorclients/froxlorclient_settingsend.tpl new file mode 100644 index 00000000..27b0931d --- /dev/null +++ b/templates/admin/froxlorclients/froxlorclient_settingsend.tpl @@ -0,0 +1,8 @@ + + + + + +
+
+$footer diff --git a/templates/admin/froxlorclients/froxlorclient_settingsoverview.tpl b/templates/admin/froxlorclients/froxlorclient_settingsoverview.tpl new file mode 100644 index 00000000..b12eb586 --- /dev/null +++ b/templates/admin/froxlorclients/froxlorclient_settingsoverview.tpl @@ -0,0 +1,14 @@ + + + + + $fields + + + +
+  {$lng['admin']['configfiles']['serverconfiguration']} + [{$lng['admin']['configfiles']['overview']}] +
+   +