From b61e8c69c5ea016b4872b905be06200a3b7ac923 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 3 Oct 2009 15:44:38 +0000 Subject: [PATCH] added separate page for module settings --- lam/templates/config/confmain.php | 96 ++------ lam/templates/config/confmodules.php | 25 +- lam/templates/config/conftypes.php | 23 +- lam/templates/config/moduleSettings.php | 288 ++++++++++++++++++++++++ 4 files changed, 351 insertions(+), 81 deletions(-) create mode 100644 lam/templates/config/moduleSettings.php diff --git a/lam/templates/config/confmain.php b/lam/templates/config/confmain.php index b47beedb..32dd3776 100644 --- a/lam/templates/config/confmain.php +++ b/lam/templates/config/confmain.php @@ -85,7 +85,9 @@ if (isset($_POST['cancelSettings'])) { $errorsToDisplay = array(); // check if button was pressed and if we have to save the settings or go to another tab -if (isset($_POST['saveSettings']) || isset($_POST['editmodules']) || isset($_POST['edittypes']) || isset($_POST['generalSettingsButton'])) { +if (isset($_POST['saveSettings']) || isset($_POST['editmodules']) + || isset($_POST['edittypes']) || isset($_POST['generalSettingsButton']) + || isset($_POST['moduleSettings'])) { $errorsToDisplay = checkInput(); if (sizeof($errorsToDisplay) == 0) { // go to final page @@ -103,6 +105,11 @@ if (isset($_POST['saveSettings']) || isset($_POST['editmodules']) || isset($_POS metaRefresh("conftypes.php"); exit; } + // go to module settings page + elseif (isset($_POST['moduleSettings'])) { + metaRefresh("moduleSettings.php"); + exit; + } } } @@ -173,6 +180,18 @@ echo "\n"; echo ">\n"; echo "\n"; echo ''; + // module settings + echo "\n"; + echo "\n"; + echo "
\n"; + $buttonStyle = 'background-image: url(../../graphics/moduleSettings.png);'; + echo "\n"; + echo "
\n"; + echo ''; + echo " "; + // spacer echo " "; // save button echo "\n"; @@ -300,43 +319,6 @@ echo (""); echo ("
"); - -// module settings -$types = $conf->get_ActiveTypes(); - -// get list of scopes of modules -$scopes = array(); -for ($m = 0; $m < sizeof($types); $m++) { - $mods = $conf->get_AccountModules($types[$m]); - for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = $types[$m]; -} - -// get module options -$options = getConfigOptions($scopes); -// get current setting -$old_options = $conf->get_moduleSettings(); - - -// display module boxes -$modules = array_keys($options); -$_SESSION['conf_types'] = array(); -for ($i = 0; $i < sizeof($modules); $i++) { - if (sizeof($options[$modules[$i]]) < 1) continue; - echo "
\n"; - $icon = ''; - $module = new $modules[$i]('none'); - $iconImage = $module->getIcon(); - if ($iconImage != null) { - $icon = '' . $iconImage . ' '; - } - echo "$icon" . getModuleAlias($modules[$i], "none") . "
\n"; - $configTypes = parseHtml($modules[$i], $options[$modules[$i]], $old_options, true, $tabindex, 'config'); - $_SESSION['conf_types'] = array_merge($configTypes, $_SESSION['conf_types']); - echo "
\n"; - echo "
"; -} - - echo ("
\"language.png\" " . _("Language settings") . "
\n"); echo ("\n"); @@ -608,44 +590,6 @@ function checkInput() { } } - // check module options - // create option array to check and save - $options = array(); - $opt_keys = array_keys($_SESSION['conf_types']); - for ($i = 0; $i < sizeof($opt_keys); $i++) { - $element = $opt_keys[$i]; - // text fields - if ($_SESSION['conf_types'][$element] == "text") { - $options[$element] = array($_POST[$element]); - } - // checkboxes - elseif ($_SESSION['conf_types'][$element] == "checkbox") { - if (isset($_POST[$element]) && ($_POST[$element] == "on")) $options[$element] = array('true'); - else $options[$element] = array('false'); - } - // dropdownbox - elseif ($_SESSION['conf_types'][$element] == "select") { - $options[$element] = array($_POST[$element]); - } - // multiselect - elseif ($_SESSION['conf_types'][$element] == "multiselect") { - $options[$element] = $_POST[$element]; // value is already an array - } - // textarea - elseif ($_SESSION['conf_types'][$element] == "textarea") { - $options[$element] = explode("\r\n", $_POST[$element]); - } - } - - // get list of scopes of modules - $scopes = array(); - for ($m = 0; $m < sizeof($types); $m++) { - $mods = $conf->get_AccountModules($types[$m]); - for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = $types[$m]; - } - // check options - $errors = array_merge($errors, checkConfigOptions($scopes, $options)); - $conf->set_moduleSettings($options); return $errors; } diff --git a/lam/templates/config/confmodules.php b/lam/templates/config/confmodules.php index 5e1eacb5..533c693d 100644 --- a/lam/templates/config/confmodules.php +++ b/lam/templates/config/confmodules.php @@ -63,23 +63,30 @@ $conf = &$_SESSION['conf_config']; $errorsToDisplay = checkInput(); // check if button was pressed and if we have to save the settings or go to another tab -if (isset($_POST['saveSettings']) || isset($_POST['editmodules']) || isset($_POST['edittypes']) || isset($_POST['generalSettingsButton'])) { +if (isset($_POST['saveSettings']) || isset($_POST['editmodules']) + || isset($_POST['edittypes']) || isset($_POST['generalSettingsButton']) + || isset($_POST['moduleSettings'])) { if (sizeof($errorsToDisplay) == 0) { // go to final page if (isset($_POST['saveSettings'])) { metaRefresh("confsave.php"); exit; } - // go to modules page + // go to types page elseif (isset($_POST['edittypes'])) { metaRefresh("conftypes.php"); exit; } - // go to types page + // go to general page elseif (isset($_POST['generalSettingsButton'])) { metaRefresh("confmain.php"); exit; } + // go to module settings page + elseif (isset($_POST['moduleSettings'])) { + metaRefresh("moduleSettings.php"); + exit; + } } } @@ -139,6 +146,18 @@ echo "\n"; echo ">\n"; echo "
\n"; echo ''; + // module settings + echo "\n"; + echo "\n"; + echo "
\n"; + $buttonStyle = 'background-image: url(../../graphics/moduleSettings.png);'; + echo "\n"; + echo "
\n"; + echo ''; + echo " "; + // spacer echo " "; // save button echo "\n"; diff --git a/lam/templates/config/conftypes.php b/lam/templates/config/conftypes.php index 74686e8f..dcff38bc 100644 --- a/lam/templates/config/conftypes.php +++ b/lam/templates/config/conftypes.php @@ -62,7 +62,9 @@ $conf = &$_SESSION['conf_config']; $errorsToDisplay = checkInput(); // check if button was pressed and if we have to save the settings or go to another tab -if (isset($_POST['saveSettings']) || isset($_POST['editmodules']) || isset($_POST['edittypes']) || isset($_POST['generalSettingsButton'])) { +if (isset($_POST['saveSettings']) || isset($_POST['editmodules']) + || isset($_POST['edittypes']) || isset($_POST['generalSettingsButton']) + || isset($_POST['moduleSettings'])) { if (sizeof($errorsToDisplay) == 0) { // check if all types have modules $activeTypes = $conf->get_ActiveTypes(); @@ -84,11 +86,16 @@ if (isset($_POST['saveSettings']) || isset($_POST['editmodules']) || isset($_POS metaRefresh("confmodules.php"); exit; } - // go to types page + // go to general page elseif (isset($_POST['generalSettingsButton'])) { metaRefresh("confmain.php"); exit; } + // go to module settings page + elseif (isset($_POST['moduleSettings'])) { + metaRefresh("moduleSettings.php"); + exit; + } } } @@ -154,6 +161,18 @@ echo "\n"; echo ">\n"; echo "\n"; echo ''; + // module settings + echo "\n"; + echo "\n"; + echo "
\n"; + $buttonStyle = 'background-image: url(../../graphics/moduleSettings.png);'; + echo "\n"; + echo "
\n"; + echo ''; + echo " "; + // spacer echo " "; // save button echo "\n"; diff --git a/lam/templates/config/moduleSettings.php b/lam/templates/config/moduleSettings.php new file mode 100644 index 00000000..69620119 --- /dev/null +++ b/lam/templates/config/moduleSettings.php @@ -0,0 +1,288 @@ +" . _("LDAP Account Manager Configuration") . "\n"; +echo "\n"; +echo "\n"; +for ($i = 0; $i < sizeof($allTypes); $i++){ + echo "\n"; +} +echo "\n"; +echo "\n"; + +echo ("

". + "\"LDAP


\n

 

\n"); + +// print error messages +for ($i = 0; $i < sizeof($errorsToDisplay); $i++) call_user_func_array('StatusMessage', $errorsToDisplay[$i]); + +echo ("
\n"); +echo "\n"; +echo "\n"; + +echo "
"; +// show tabs +echo ""; +echo "\n"; + $buttonSpace = '         '; + // general settings + echo "'; + // account types + echo "'; + // module selection + echo "'; + // module settings + echo "'; + echo ""; + // spacer + echo ""; + // save button + echo "'; + // cancel button + echo "'; + echo "
\n"; + echo "\n"; + echo "
\n"; + $buttonStyle = 'background-image: url(../../graphics/bigTools.png);'; + echo "\n"; + echo "
\n"; + echo '
\n"; + echo "\n"; + echo "
\n"; + $buttonStyle = 'background-image: url(../../graphics/gear.png);'; + echo "\n"; + echo "
\n"; + echo '
\n"; + echo "\n"; + echo "
\n"; + $buttonStyle = 'background-image: url(../../graphics/modules.png);'; + echo "\n"; + echo "
\n"; + echo '
\n"; + echo "\n"; + echo "
\n"; + $buttonStyle = 'background-image: url(../../graphics/moduleSettings.png);'; + echo "\n"; + echo "
\n"; + echo '
  \n"; + echo "\n"; + echo "
\n"; + $buttonStyle = 'background-image: url(../../graphics/pass.png);'; + echo "\n"; + echo "
\n"; + echo '
\n"; + echo "\n"; + echo "
\n"; + $buttonStyle = 'background-image: url(../../graphics/fail.png);'; + echo "\n"; + echo "
\n"; + echo '
\n"; +// end tabs +echo "


\n"; + +// module settings +$types = $conf->get_ActiveTypes(); + +// get list of scopes of modules +$scopes = array(); +for ($m = 0; $m < sizeof($types); $m++) { + $mods = $conf->get_AccountModules($types[$m]); + for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = $types[$m]; +} + +// get module options +$options = getConfigOptions($scopes); +// get current setting +$old_options = $conf->get_moduleSettings(); + + +// display module boxes +$modules = array_keys($options); +$_SESSION['conf_types'] = array(); +for ($i = 0; $i < sizeof($modules); $i++) { + if (sizeof($options[$modules[$i]]) < 1) continue; + echo "
\n"; + $icon = ''; + $module = new $modules[$i]('none'); + $iconImage = $module->getIcon(); + if ($iconImage != null) { + $icon = '' . $iconImage . ' '; + } + echo "$icon" . getModuleAlias($modules[$i], "none") . "
\n"; + $configTypes = parseHtml($modules[$i], $options[$modules[$i]], $old_options, true, $tabindex, 'config'); + $_SESSION['conf_types'] = array_merge($configTypes, $_SESSION['conf_types']); + echo "
\n"; + echo "
"; +} + +echo "\n"; + +echo "



\n"; +echo '
'; +echo "
\n"; +echo "\n"; +echo "\n"; + + +/** + * Checks user input and saves the entered settings. + * + * @return array list of errors + */ +function checkInput() { + if (!isset($_POST['postAvailable'])) { + return array(); + } + $conf = &$_SESSION['conf_config']; + $types = $conf->get_ActiveTypes(); + + // check module options + // create option array to check and save + $options = array(); + $opt_keys = array_keys($_SESSION['conf_types']); + for ($i = 0; $i < sizeof($opt_keys); $i++) { + $element = $opt_keys[$i]; + // text fields + if ($_SESSION['conf_types'][$element] == "text") { + $options[$element] = array($_POST[$element]); + } + // checkboxes + elseif ($_SESSION['conf_types'][$element] == "checkbox") { + if (isset($_POST[$element]) && ($_POST[$element] == "on")) $options[$element] = array('true'); + else $options[$element] = array('false'); + } + // dropdownbox + elseif ($_SESSION['conf_types'][$element] == "select") { + $options[$element] = array($_POST[$element]); + } + // multiselect + elseif ($_SESSION['conf_types'][$element] == "multiselect") { + $options[$element] = $_POST[$element]; // value is already an array + } + // textarea + elseif ($_SESSION['conf_types'][$element] == "textarea") { + $options[$element] = explode("\r\n", $_POST[$element]); + } + } + + // get list of scopes of modules + $scopes = array(); + for ($m = 0; $m < sizeof($types); $m++) { + $mods = $conf->get_AccountModules($types[$m]); + for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = $types[$m]; + } + // check options + $errors = checkConfigOptions($scopes, $options); + $conf->set_moduleSettings($options); + return $errors; +} + +?> + + + +