immediately open new server profiles

This commit is contained in:
Roland Gruber 2011-12-10 09:08:27 +00:00
parent c57efe1a4c
commit a6b51fd66d
3 changed files with 70 additions and 61 deletions

View File

@ -50,7 +50,7 @@ if (isset($_POST['passwd'])) $passwd = $_POST['passwd'];
// check if password was entered // check if password was entered
// if not: load login page // if not: load login page
if (!isset($passwd) && !isset($_SESSION['conf_isAuthenticated'])) { if (!isset($passwd) && !(isset($_SESSION['conf_isAuthenticated']) && isset($_SESSION['conf_config']))) {
$_SESSION['conf_message'] = _("No password was entered!"); $_SESSION['conf_message'] = _("No password was entered!");
/** go back to login if password is empty */ /** go back to login if password is empty */
metaRefresh('conflogin.php'); metaRefresh('conflogin.php');
@ -83,6 +83,10 @@ if (isset($_POST['cancelSettings'])) {
} }
$errorsToDisplay = array(); $errorsToDisplay = array();
if (isset($_SESSION['conf_messages']) && is_array($_SESSION['conf_messages'])) {
$errorsToDisplay = array_merge($errorsToDisplay, $_SESSION['conf_messages']);
unset($_SESSION['conf_messages']);
}
// check if button was pressed and if we have to save the settings or go to another tab // 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']) if (isset($_POST['saveSettings']) || isset($_POST['editmodules'])
@ -156,7 +160,7 @@ foreach ($jsFiles as $jsEntry) {
<?php <?php
if (!$conf->isWritable()) { if (!$conf->isWritable()) {
StatusMessage('WARN', 'The config file is not writable.', 'Your changes cannot be saved until you make the file writable for the webserver user.'); StatusMessage('WARN', _('The config file is not writable.'), _('Your changes cannot be saved until you make the file writable for the webserver user.'));
echo "<br>"; echo "<br>";
} }

View File

@ -85,10 +85,10 @@ for ($i = 0; $i < sizeof($sessionKeys); $i++) {
} }
if ($result === LAMConfig::SAVE_OK) { if ($result === LAMConfig::SAVE_OK) {
metaRefresh('../login.php?configSaveOk=1&amp;configSaveFile=' . $conf->getPath()); metaRefresh('../login.php?configSaveOk=1&amp;configSaveFile=' . $conf->getName());
} }
else { else {
metaRefresh('../login.php?configSaveFailed=1&amp;configSaveFile=' . $conf->getPath()); metaRefresh('../login.php?configSaveFailed=1&amp;configSaveFile=' . $conf->getName());
} }
?> ?>

View File

@ -43,52 +43,6 @@ if (strtolower(session_module_name()) == 'files') {
setlanguage(); setlanguage();
echo $_SESSION['header'];
?>
<title>
<?php
echo _("Profile management");
?>
</title>
<?php
// include all CSS files
$cssDirName = dirname(__FILE__) . '/../../style';
$cssDir = dir($cssDirName);
while ($cssEntry = $cssDir->read()) {
if (substr($cssEntry, strlen($cssEntry) - 4, 4) != '.css') continue;
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/" . $cssEntry . "\">\n";
}
?>
<link rel="shortcut icon" type="image/x-icon" href="../../graphics/favicon.ico">
</head>
<body>
<table border=0 width="100%" class="lamHeader ui-corner-all">
<tr>
<td align="left" height="30">
<a class="lamHeader" href="http://www.ldap-account-manager.org/" target="new_window">&nbsp;<img src="../../graphics/logo32.png" width=24 height=24 class="align-middle" alt="LDAP Account Manager">&nbsp;&nbsp;LDAP Account Manager</a>
</td>
<td align="right" height=20>
<a href="conflogin.php"><IMG alt="configuration" src="../../graphics/undo.png">&nbsp;<?php echo _("Back to profile login") ?></a>
</td>
</tr>
</table>
<br>
<?php
// include all JavaScript files
$jsDirName = dirname(__FILE__) . '/../lib';
$jsDir = dir($jsDirName);
$jsFiles = array();
while ($jsEntry = $jsDir->read()) {
if (substr($jsEntry, strlen($jsEntry) - 3, 3) != '.js') continue;
$jsFiles[] = $jsEntry;
}
sort($jsFiles);
foreach ($jsFiles as $jsEntry) {
echo "<script type=\"text/javascript\" src=\"../lib/" . $jsEntry . "\"></script>\n";
}
$cfg = new LAMCfgMain(); $cfg = new LAMCfgMain();
// check if submit button was pressed // check if submit button was pressed
@ -116,7 +70,11 @@ if (isset($_POST['submit'])) {
$conf = new LAMConfig($_POST['addprofile']); $conf = new LAMConfig($_POST['addprofile']);
$conf->set_Passwd($_POST['addpassword']); $conf->set_Passwd($_POST['addpassword']);
$conf->save(); $conf->save();
$msg = _("Created new profile."); $_SESSION['conf_isAuthenticated'] = $_POST['addprofile'];
$_SESSION['conf_config'] = $conf;
$_SESSION['conf_messages'][] = array('INFO', _("Created new profile."), $_POST['addprofile']);
metaRefresh('confmain.php');
exit;
} }
else { else {
$error = _("Unable to create new profile!"); $error = _("Unable to create new profile!");
@ -168,19 +126,66 @@ if (isset($_POST['submit'])) {
$configMain = null; $configMain = null;
$msg = _("New default profile set successfully."); $msg = _("New default profile set successfully.");
} }
// print messages
if (isset($error) || isset($msg)) {
if (isset($error)) {
StatusMessage("ERROR", $error);
}
if (isset($msg)) {
StatusMessage("INFO", $msg);
}
}
else exit;
} }
echo $_SESSION['header'];
?>
<title>
<?php
echo _("Profile management");
?>
</title>
<?php
// include all CSS files
$cssDirName = dirname(__FILE__) . '/../../style';
$cssDir = dir($cssDirName);
while ($cssEntry = $cssDir->read()) {
if (substr($cssEntry, strlen($cssEntry) - 4, 4) != '.css') continue;
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/" . $cssEntry . "\">\n";
}
?>
<link rel="shortcut icon" type="image/x-icon" href="../../graphics/favicon.ico">
</head>
<body>
<table border=0 width="100%" class="lamHeader ui-corner-all">
<tr>
<td align="left" height="30">
<a class="lamHeader" href="http://www.ldap-account-manager.org/" target="new_window">&nbsp;<img src="../../graphics/logo32.png" width=24 height=24 class="align-middle" alt="LDAP Account Manager">&nbsp;&nbsp;LDAP Account Manager</a>
</td>
<td align="right" height=20>
<a href="conflogin.php"><IMG alt="configuration" src="../../graphics/undo.png">&nbsp;<?php echo _("Back to profile login") ?></a>
</td>
</tr>
</table>
<br>
<?php
// include all JavaScript files
$jsDirName = dirname(__FILE__) . '/../lib';
$jsDir = dir($jsDirName);
$jsFiles = array();
while ($jsEntry = $jsDir->read()) {
if (substr($jsEntry, strlen($jsEntry) - 3, 3) != '.js') continue;
$jsFiles[] = $jsEntry;
}
sort($jsFiles);
foreach ($jsFiles as $jsEntry) {
echo "<script type=\"text/javascript\" src=\"../lib/" . $jsEntry . "\"></script>\n";
}
// print messages
if (isset($error) || isset($msg)) {
if (isset($error)) {
StatusMessage("ERROR", $error);
}
if (isset($msg)) {
StatusMessage("INFO", $msg);
}
}
// check if config.cfg is valid // check if config.cfg is valid
if (!isset($cfg->default)) { if (!isset($cfg->default)) {
StatusMessage("ERROR", _("Please set up your master configuration file (config/config.cfg) first!"), ""); StatusMessage("ERROR", _("Please set up your master configuration file (config/config.cfg) first!"), "");