From ce5f6e812f1b9b158c01643e28c37751685e05c0 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 28 May 2010 13:45:34 +0000 Subject: [PATCH] show login if settings were saved --- lam/lib/config.inc | 10 +++++++--- lam/templates/config/confsave.php | 21 +++++++++------------ lam/templates/login.php | 9 +++++++++ 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/lam/lib/config.inc b/lam/lib/config.inc index b969350c..e4909c47 100644 --- a/lam/lib/config.inc +++ b/lam/lib/config.inc @@ -168,6 +168,10 @@ class LAMConfig { const ACCESS_PASSWORD_CHANGE = 20; const ACCESS_READ_ONLY = 0; + /* return codes for saving configuration file */ + const SAVE_OK = 0; + const SAVE_FAIL = 1; + /* login method: predefined list or LDAP search */ const LOGIN_LIST = 'list'; const LOGIN_SEARCH = 'search'; @@ -413,10 +417,10 @@ class LAMConfig { for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]); fclose($file); @chmod ($conffile, 0600); - StatusMessage("INFO", _("Your settings were successfully saved.") , " (" . $conffile . ")"); + return LAMConfig::SAVE_OK; } else { - StatusMessage("ERROR", _("Cannot open config file!") . " (" . $conffile . ")"); + return LAMConfig::SAVE_FAIL; } } } @@ -444,7 +448,7 @@ class LAMConfig { * * @return string path on filesystem */ - private function getPath() { + public function getPath() { return substr(__FILE__, 0, strlen(__FILE__) - 15) . "/config/" . $this->file . ".conf"; } diff --git a/lam/templates/config/confsave.php b/lam/templates/config/confsave.php index b39dc674..29aacfa2 100644 --- a/lam/templates/config/confsave.php +++ b/lam/templates/config/confsave.php @@ -76,22 +76,19 @@ if ((!isset($_SESSION['conf_isAuthenticated']) || !($_SESSION['conf_isAuthentica $_SESSION['conf_isAuthenticated'] = $conf->getName(); -// page head -echo $_SESSION['header']; -echo "" . _("LDAP Account Manager Configuration") . "\n"; -echo "\n"; -echo "\n"; -echo "\n"; -echo ("

". - "\"LDAP




"); -$conf->save(); -echo ("




" . _("Back to Login") . ""); -echo(""); +$result = $conf->save(); + // remove settings from session $sessionKeys = array_keys($_SESSION); for ($i = 0; $i < sizeof($sessionKeys); $i++) { if (substr($sessionKeys[$i], 0, 5) == "conf_") unset($_SESSION[$sessionKeys[$i]]); } -exit(); + +if ($result === LAMConfig::SAVE_OK) { + metaRefresh('../login.php?configSaveOk=1&configSaveFile=' . $conf->getPath()); +} +else { + metaRefresh('../login.php?configSaveFailed=1&configSaveFile=' . $conf->getPath()); +} ?> \ No newline at end of file diff --git a/lam/templates/login.php b/lam/templates/login.php index ac60caf0..c92db33a 100644 --- a/lam/templates/login.php +++ b/lam/templates/login.php @@ -211,6 +211,15 @@ function display_LoginPage($config_object) { StatusMessage("INFO", _("Your settings were successfully saved.")); echo "
"; } + // check if a server profile was saved + if (isset($_GET['configSaveOk'])) { + StatusMessage("INFO", _("Your settings were successfully saved."), htmlspecialchars($_GET['configSaveFile'])); + echo "
"; + } + elseif (isset($_GET['configSaveFailed'])) { + StatusMessage("ERROR", _("Cannot open config file!"), htmlspecialchars($_GET['configSaveFile'])); + echo "
"; + } ?>