show login if settings were saved

This commit is contained in:
Roland Gruber 2010-05-28 13:45:34 +00:00
parent 2af31b832b
commit ce5f6e812f
3 changed files with 25 additions and 15 deletions

View File

@ -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";
}

View File

@ -76,22 +76,19 @@ if ((!isset($_SESSION['conf_isAuthenticated']) || !($_SESSION['conf_isAuthentica
$_SESSION['conf_isAuthenticated'] = $conf->getName();
// page head
echo $_SESSION['header'];
echo "<title>" . _("LDAP Account Manager Configuration") . "</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
echo "<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"../../graphics/favicon.ico\">\n";
echo "</head><body>\n";
echo ("<p align=\"center\"><a href=\"http://www.ldap-account-manager.org/\" target=\"new_window\">".
"<img src=\"../../graphics/banner.jpg\" border=1 alt=\"LDAP Account Manager\"></a></p><hr><br><br>");
$conf->save();
echo ("<br><br><br><br><br><a href=\"../login.php\" target=\"_top\">" . _("Back to Login") . "</a>");
echo("</body></html>");
$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&amp;configSaveFile=' . $conf->getPath());
}
else {
metaRefresh('../login.php?configSaveFailed=1&amp;configSaveFile=' . $conf->getPath());
}
?>

View File

@ -211,6 +211,15 @@ function display_LoginPage($config_object) {
StatusMessage("INFO", _("Your settings were successfully saved."));
echo "<br>";
}
// check if a server profile was saved
if (isset($_GET['configSaveOk'])) {
StatusMessage("INFO", _("Your settings were successfully saved."), htmlspecialchars($_GET['configSaveFile']));
echo "<br>";
}
elseif (isset($_GET['configSaveFailed'])) {
StatusMessage("ERROR", _("Cannot open config file!"), htmlspecialchars($_GET['configSaveFile']));
echo "<br>";
}
?>
<div style="position:relative; z-index:5;">
<table width="650" align="center" border="2" rules="none" bgcolor="white">