2006-01-01 16:30:05 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
$Id$
|
|
|
|
|
2009-10-27 18:47:12 +00:00
|
|
|
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
2011-01-01 19:46:44 +00:00
|
|
|
Copyright (C) 2004 - 2011 Roland Gruber
|
2006-01-01 16:30:05 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Here the user can select the account types.
|
|
|
|
*
|
|
|
|
* @package configuration
|
|
|
|
* @author Roland Gruber
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/** Access to config functions */
|
2006-03-26 17:51:25 +00:00
|
|
|
include_once('../../lib/config.inc');
|
2006-01-01 16:30:05 +00:00
|
|
|
/** Access to account types */
|
2006-03-26 17:51:25 +00:00
|
|
|
include_once('../../lib/types.inc');
|
2006-01-01 16:30:05 +00:00
|
|
|
|
|
|
|
// start session
|
2009-07-08 18:03:28 +00:00
|
|
|
if (strtolower(session_module_name()) == 'files') {
|
|
|
|
session_save_path("../../sess");
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
@session_start();
|
|
|
|
|
|
|
|
setlanguage();
|
|
|
|
|
2006-01-31 16:57:12 +00:00
|
|
|
// check if config is set
|
2006-01-01 16:30:05 +00:00
|
|
|
// if not: load login page
|
2006-01-31 16:57:12 +00:00
|
|
|
if (!isset($_SESSION['conf_config'])) {
|
2006-01-01 16:30:05 +00:00
|
|
|
/** go back to login if password is invalid */
|
|
|
|
require('conflogin.php');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2009-07-12 13:40:32 +00:00
|
|
|
// check if user canceled editing
|
|
|
|
if (isset($_POST['cancelSettings'])) {
|
|
|
|
metaRefresh("../login.php");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2006-01-31 16:57:12 +00:00
|
|
|
$conf = &$_SESSION['conf_config'];
|
|
|
|
|
2009-07-12 13:40:32 +00:00
|
|
|
$errorsToDisplay = checkInput();
|
2006-01-01 16:30:05 +00:00
|
|
|
|
2009-07-12 13:40:32 +00:00
|
|
|
// check if button was pressed and if we have to save the settings or go to another tab
|
2009-10-03 15:44:38 +00:00
|
|
|
if (isset($_POST['saveSettings']) || isset($_POST['editmodules'])
|
|
|
|
|| isset($_POST['edittypes']) || isset($_POST['generalSettingsButton'])
|
|
|
|
|| isset($_POST['moduleSettings'])) {
|
2009-07-12 13:40:32 +00:00
|
|
|
if (sizeof($errorsToDisplay) == 0) {
|
2009-08-02 12:54:25 +00:00
|
|
|
// check if all types have modules
|
|
|
|
$activeTypes = $conf->get_ActiveTypes();
|
|
|
|
for ($i = 0; $i < sizeof($activeTypes); $i++) {
|
|
|
|
$selectedModules = $conf->get_AccountModules($activeTypes[$i]);
|
|
|
|
if (sizeof($selectedModules) == 0) {
|
|
|
|
// go to module selection
|
|
|
|
metaRefresh("confmodules.php");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
2009-07-12 13:40:32 +00:00
|
|
|
// go to final page
|
|
|
|
if (isset($_POST['saveSettings'])) {
|
|
|
|
metaRefresh("confsave.php");
|
|
|
|
exit;
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
2009-07-12 13:40:32 +00:00
|
|
|
// go to modules page
|
|
|
|
elseif (isset($_POST['editmodules'])) {
|
|
|
|
metaRefresh("confmodules.php");
|
|
|
|
exit;
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
2009-10-03 15:44:38 +00:00
|
|
|
// go to general page
|
2009-07-12 13:40:32 +00:00
|
|
|
elseif (isset($_POST['generalSettingsButton'])) {
|
|
|
|
metaRefresh("confmain.php");
|
|
|
|
exit;
|
2006-01-08 17:34:14 +00:00
|
|
|
}
|
2009-10-03 15:44:38 +00:00
|
|
|
// go to module settings page
|
|
|
|
elseif (isset($_POST['moduleSettings'])) {
|
|
|
|
metaRefresh("moduleSettings.php");
|
|
|
|
exit;
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-12 13:40:32 +00:00
|
|
|
$typeSettings = $conf->get_typeSettings();
|
2006-01-01 16:30:05 +00:00
|
|
|
$allTypes = getTypes();
|
2009-07-12 13:40:32 +00:00
|
|
|
$activeTypes = $conf->get_ActiveTypes();
|
2006-01-01 16:30:05 +00:00
|
|
|
$availableTypes = array();
|
|
|
|
for ($i = 0; $i < sizeof($allTypes); $i++) {
|
2010-04-04 12:52:20 +00:00
|
|
|
if (!in_array($allTypes[$i], $activeTypes)) {
|
|
|
|
$availableTypes[$allTypes[$i]] = getTypeAlias($allTypes[$i]);
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
2010-04-04 12:52:20 +00:00
|
|
|
natcasesort($availableTypes);
|
2006-01-01 16:30:05 +00:00
|
|
|
|
|
|
|
echo $_SESSION['header'];
|
|
|
|
|
|
|
|
echo "<title>" . _("LDAP Account Manager Configuration") . "</title>\n";
|
2010-08-28 09:34:00 +00:00
|
|
|
|
|
|
|
// include all CSS files
|
|
|
|
$cssDirName = dirname(__FILE__) . '/../../style';
|
|
|
|
$cssDir = dir($cssDirName);
|
|
|
|
while ($cssEntry = $cssDir->read()) {
|
|
|
|
if (substr($cssEntry, strlen($cssEntry) - 4, 4) != '.css') continue;
|
2010-09-13 20:05:58 +00:00
|
|
|
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/" . $cssEntry . "\">\n";
|
2010-08-28 09:34:00 +00:00
|
|
|
}
|
|
|
|
|
2008-01-01 13:06:51 +00:00
|
|
|
echo "<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"../../graphics/favicon.ico\">\n";
|
2006-01-01 16:30:05 +00:00
|
|
|
for ($i = 0; $i < sizeof($allTypes); $i++){
|
|
|
|
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/type_" . $allTypes[$i] . ".css\">\n";
|
|
|
|
}
|
|
|
|
echo "</head><body>\n";
|
2010-01-01 17:39:38 +00:00
|
|
|
// include all JavaScript files
|
|
|
|
$jsDirName = dirname(__FILE__) . '/../lib';
|
|
|
|
$jsDir = dir($jsDirName);
|
2010-08-28 12:27:06 +00:00
|
|
|
$jsFiles = array();
|
2010-01-01 17:39:38 +00:00
|
|
|
while ($jsEntry = $jsDir->read()) {
|
|
|
|
if (substr($jsEntry, strlen($jsEntry) - 3, 3) != '.js') continue;
|
2010-08-28 12:27:06 +00:00
|
|
|
$jsFiles[] = $jsEntry;
|
|
|
|
}
|
|
|
|
sort($jsFiles);
|
|
|
|
foreach ($jsFiles as $jsEntry) {
|
2010-01-01 17:39:38 +00:00
|
|
|
echo "<script type=\"text/javascript\" src=\"../lib/" . $jsEntry . "\"></script>\n";
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
|
2010-07-30 16:08:20 +00:00
|
|
|
?>
|
2010-08-31 18:05:17 +00:00
|
|
|
<table border=0 width="100%" class="lamHeader ui-corner-all">
|
2010-07-30 16:08:20 +00:00
|
|
|
<tr>
|
|
|
|
<td align="left" height="30">
|
|
|
|
<a class="lamHeader" href="http://www.ldap-account-manager.org/" target="new_window"> <img src="../../graphics/logo32.png" width=24 height=24 class="align-middle" alt="LDAP Account Manager"> LDAP Account Manager</a>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<br>
|
|
|
|
<?php
|
2006-01-01 16:30:05 +00:00
|
|
|
|
|
|
|
// print error messages
|
2009-07-12 13:40:32 +00:00
|
|
|
for ($i = 0; $i < sizeof($errorsToDisplay); $i++) call_user_func_array('StatusMessage', $errorsToDisplay[$i]);
|
2006-01-01 16:30:05 +00:00
|
|
|
|
|
|
|
echo ("<form action=\"conftypes.php\" method=\"post\">\n");
|
2010-08-28 09:34:00 +00:00
|
|
|
|
|
|
|
// hidden submit buttons which are clicked by tabs
|
|
|
|
echo "<div style=\"display: none;\">\n";
|
|
|
|
echo "<input name=\"generalSettingsButton\" type=\"submit\" value=\" \">";
|
|
|
|
echo "<input name=\"edittypes\" type=\"submit\" value=\" \">";
|
|
|
|
echo "<input name=\"editmodules\" type=\"submit\" value=\" \">";
|
|
|
|
echo "<input name=\"moduleSettings\" type=\"submit\" value=\" \">";
|
|
|
|
echo "</div>\n";
|
|
|
|
|
|
|
|
// tabs
|
|
|
|
echo '<div class="ui-tabs ui-widget ui-widget-content ui-corner-all">';
|
|
|
|
|
|
|
|
echo '<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">';
|
2011-01-08 19:44:08 +00:00
|
|
|
echo '<li id="generalSettingsButton" class="ui-state-default ui-corner-top" onmouseover="jQuery(this).addClass(\'tabs-hover\');" onmouseout="jQuery(this).removeClass(\'tabs-hover\');">';
|
2010-08-28 09:34:00 +00:00
|
|
|
echo '<a href="#" onclick="document.getElementsByName(\'generalSettingsButton\')[0].click();"><img src="../../graphics/tools.png" alt=""> ';
|
|
|
|
echo _('General settings') . '</a>';
|
|
|
|
echo '</li>';
|
|
|
|
echo '<li id="edittypes" class="ui-state-default ui-corner-top">';
|
|
|
|
echo '<a href="#" onclick="document.getElementsByName(\'edittypes\')[0].click();"><img src="../../graphics/gear.png" alt=""> ';
|
|
|
|
echo _('Account types') . '</a>';
|
|
|
|
echo '</li>';
|
2011-01-08 19:44:08 +00:00
|
|
|
echo '<li id="editmodules" class="ui-state-default ui-corner-top" onmouseover="jQuery(this).addClass(\'tabs-hover\');" onmouseout="jQuery(this).removeClass(\'tabs-hover\');">';
|
2010-08-28 09:34:00 +00:00
|
|
|
echo '<a href="#" onclick="document.getElementsByName(\'editmodules\')[0].click();"><img src="../../graphics/modules.png" alt=""> ';
|
|
|
|
echo _('Modules') . '</a>';
|
|
|
|
echo '</li>';
|
2011-01-08 19:44:08 +00:00
|
|
|
echo '<li id="moduleSettings" class="ui-state-default ui-corner-top" onmouseover="jQuery(this).addClass(\'tabs-hover\');" onmouseout="jQuery(this).removeClass(\'tabs-hover\');">';
|
2010-08-28 09:34:00 +00:00
|
|
|
echo '<a href="#" onclick="document.getElementsByName(\'moduleSettings\')[0].click();"><img src="../../graphics/modules.png" alt=""> ';
|
|
|
|
echo _('Module settings') . '</a>';
|
|
|
|
echo '</li>';
|
|
|
|
echo '</ul>';
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
jQuery(document).ready(function() {
|
|
|
|
jQuery('#edittypes').addClass('ui-tabs-selected');
|
|
|
|
jQuery('#edittypes').addClass('ui-state-active');
|
2010-11-14 20:35:34 +00:00
|
|
|
jQuery('#edittypes').addClass('userlist-bright');
|
2010-08-28 09:34:00 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2010-11-14 20:35:34 +00:00
|
|
|
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom userlist-bright">
|
2010-08-28 09:34:00 +00:00
|
|
|
<?php
|
|
|
|
|
2010-11-14 20:35:34 +00:00
|
|
|
$container = new htmlTable();
|
2006-01-01 16:30:05 +00:00
|
|
|
|
|
|
|
// show available types
|
2006-02-03 15:37:59 +00:00
|
|
|
if (sizeof($availableTypes) > 0) {
|
2010-11-14 20:35:34 +00:00
|
|
|
$container->addElement(new htmlSubTitle(_("Available account types")), true);
|
|
|
|
$availableContainer = new htmlTable();
|
2010-04-04 12:52:20 +00:00
|
|
|
foreach ($availableTypes as $key => $value) {
|
2010-11-14 20:35:34 +00:00
|
|
|
$availableContainer->addElement(new htmlImage('../../graphics/' . $key . '.png'));
|
|
|
|
$availableContainer->addElement(new htmlOutputText($value));
|
|
|
|
$availableContainer->addElement(new htmlSpacer('10px', null));
|
|
|
|
$availableContainer->addElement(new htmlOutputText(getTypeDescription($key)));
|
|
|
|
$button = new htmlButton('add_' . $key, 'add.png', true);
|
|
|
|
$button->setTitle(_("Add"));
|
|
|
|
$availableContainer->addElement($button, true);
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
2010-11-14 20:35:34 +00:00
|
|
|
$availableContainer->addElement(new htmlSpacer(null, '20px'), true);
|
|
|
|
$container->addElement($availableContainer, true);
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
|
|
|
|
2006-02-03 15:37:59 +00:00
|
|
|
// show active types
|
|
|
|
if (sizeof($activeTypes) > 0) {
|
2010-11-14 20:35:34 +00:00
|
|
|
$container->addElement(new htmlSubTitle(_("Active account types")), true);
|
|
|
|
$activeContainer = new htmlTable();
|
2006-02-03 15:37:59 +00:00
|
|
|
for ($i = 0; $i < sizeof($activeTypes); $i++) {
|
2010-11-14 20:35:34 +00:00
|
|
|
// title
|
|
|
|
$activeContainer->addElement(new htmlImage('../../graphics/' . $activeTypes[$i] . '.png'));
|
|
|
|
$titleText = new htmlOutputText(getTypeAlias($activeTypes[$i]));
|
|
|
|
$titleText->setIsBold(true);
|
|
|
|
$activeContainer->addElement($titleText);
|
|
|
|
$activeContainer->addElement(new htmlSpacer('10px', null));
|
|
|
|
$activeContainer->addElement(new htmlOutputText(getTypeDescription($activeTypes[$i])), true);
|
2006-02-03 15:37:59 +00:00
|
|
|
// LDAP suffix
|
2010-11-14 20:35:34 +00:00
|
|
|
$suffixText = new htmlOutputText(_("LDAP suffix"));
|
|
|
|
$suffixText->colspan = 2;
|
|
|
|
$activeContainer->addElement($suffixText);
|
|
|
|
$activeContainer->addElement(new htmlSpacer('10px', null));
|
|
|
|
$suffixInput = new htmlInputField('suffix_' . $activeTypes[$i], $typeSettings['suffix_' . $activeTypes[$i]]);
|
|
|
|
$suffixInput->setFieldSize(40);
|
|
|
|
$activeContainer->addElement($suffixInput);
|
|
|
|
$activeContainer->addElement(new htmlHelpLink('202'), true);
|
2006-02-03 15:37:59 +00:00
|
|
|
// list attributes
|
2009-07-12 13:40:32 +00:00
|
|
|
if (isset($typeSettings['attr_' . $activeTypes[$i]])) {
|
|
|
|
$attributes = $typeSettings['attr_' . $activeTypes[$i]];
|
2006-02-03 15:37:59 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$attributes = getDefaultListAttributes($activeTypes[$i]);
|
|
|
|
}
|
2010-11-14 20:35:34 +00:00
|
|
|
$attrsText = new htmlOutputText(_("List attributes"));
|
|
|
|
$attrsText->colspan = 2;
|
|
|
|
$activeContainer->addElement($attrsText);
|
|
|
|
$activeContainer->addElement(new htmlSpacer('10px', null));
|
|
|
|
$attrsInput = new htmlInputField('attr_' . $activeTypes[$i], $attributes);
|
|
|
|
$attrsInput->setFieldSize(40);
|
|
|
|
$activeContainer->addElement($attrsInput);
|
|
|
|
$activeContainer->addElement(new htmlHelpLink('206'), true);
|
|
|
|
// delete button
|
|
|
|
$delButton = new htmlButton('rem_'. $activeTypes[$i], _("Remove this account type"));
|
|
|
|
$delButton->colspan = 5;
|
|
|
|
$delButton->setIconClass('deleteButton');
|
|
|
|
$activeContainer->addElement($delButton, true); //del.png
|
|
|
|
|
|
|
|
$activeContainer->addElement(new htmlSpacer(null, '40px'), true);
|
2006-02-03 15:37:59 +00:00
|
|
|
}
|
2010-11-14 20:35:34 +00:00
|
|
|
$container->addElement($activeContainer, true);
|
2006-02-03 15:37:59 +00:00
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
|
2010-11-14 20:35:34 +00:00
|
|
|
$tabindex = 1;
|
|
|
|
parseHtml(null, $container, array(), false, $tabindex, 'user');
|
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
echo "<input type=\"hidden\" name=\"postAvailable\" value=\"yes\">\n";
|
|
|
|
|
2011-01-08 19:44:08 +00:00
|
|
|
echo "</div></div>";
|
|
|
|
|
|
|
|
$buttonContainer = new htmlTable();
|
|
|
|
$buttonContainer->addElement(new htmlSpacer(null, '10px'), true);
|
|
|
|
$saveButton = new htmlButton('saveSettings', _('Save'));
|
|
|
|
$saveButton->setIconClass('saveButton');
|
|
|
|
$buttonContainer->addElement($saveButton);
|
|
|
|
$cancelButton = new htmlButton('cancelSettings', _('Cancel'));
|
|
|
|
$cancelButton->setIconClass('cancelButton');
|
|
|
|
$buttonContainer->addElement($cancelButton, true);
|
|
|
|
$buttonContainer->addElement(new htmlSpacer(null, '10px'), true);
|
|
|
|
parseHtml(null, $buttonContainer, array(), false, $tabindex, 'user');
|
|
|
|
|
|
|
|
echo "</form>\n";
|
2006-01-01 16:30:05 +00:00
|
|
|
echo "</body>\n";
|
|
|
|
echo "</html>\n";
|
|
|
|
|
|
|
|
|
2009-07-12 13:40:32 +00:00
|
|
|
/**
|
|
|
|
* Checks user input and saves the entered settings.
|
|
|
|
*
|
|
|
|
* @return array list of errors
|
|
|
|
*/
|
|
|
|
function checkInput() {
|
|
|
|
if (!isset($_POST['postAvailable'])) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
$errors = array();
|
|
|
|
$conf = &$_SESSION['conf_config'];
|
|
|
|
$typeSettings = $conf->get_typeSettings();
|
|
|
|
$accountTypes = $conf->get_ActiveTypes();
|
|
|
|
$postKeys = array_keys($_POST);
|
|
|
|
for ($i = 0; $i < sizeof($postKeys); $i++) {
|
|
|
|
$key = $postKeys[$i];
|
|
|
|
// check if remove button was pressed
|
|
|
|
if (substr($key, 0, 4) == "rem_") {
|
|
|
|
$type = substr($key, 4);
|
|
|
|
$accountTypes = array_flip($accountTypes);
|
|
|
|
unset($accountTypes[$type]);
|
|
|
|
$accountTypes = array_flip($accountTypes);
|
|
|
|
$accountTypes = array_values($accountTypes);
|
|
|
|
}
|
|
|
|
// check if add button was pressed
|
|
|
|
else if (substr($key, 0, 4) == "add_") {
|
|
|
|
$type = substr($key, 4);
|
|
|
|
$accountTypes[] = $type;
|
|
|
|
}
|
|
|
|
// set suffixes
|
|
|
|
elseif (substr($key, 0, 7) == "suffix_") {
|
|
|
|
$typeSettings[$key] = $_POST[$key];
|
|
|
|
$type = substr($postKeys[$i], 7);
|
|
|
|
if (strlen($_POST[$key]) < 1) {
|
|
|
|
$errors[] = array("ERROR", _("LDAP Suffix is invalid!"), getTypeAlias($type));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif (substr($key, 0, 5) == "attr_") {
|
|
|
|
$typeSettings[$key] = $_POST[$key];
|
|
|
|
$type = substr($postKeys[$i], 5);
|
2009-08-14 18:06:15 +00:00
|
|
|
if (!is_string($_POST[$key]) || !preg_match("/^((#[^:;]+)|([^:;]*:[^:;]+))(;((#[^:;]+)|([^:;]*:[^:;]+)))*$/", $_POST[$key])) {
|
2009-07-12 13:40:32 +00:00
|
|
|
$errors[] = array("ERROR", _("List attributes are invalid!"), getTypeAlias($type));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// save input
|
|
|
|
$conf->set_typeSettings($typeSettings);
|
|
|
|
$conf->set_ActiveTypes($accountTypes);
|
|
|
|
return $errors;
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|