2006-01-01 16:30:05 +00:00
|
|
|
<?php
|
2016-12-28 18:53:49 +00:00
|
|
|
namespace LAM\CONFIG;
|
|
|
|
use \htmlTable;
|
|
|
|
use \htmlSubTitle;
|
|
|
|
use \htmlImage;
|
|
|
|
use \htmlOutputText;
|
|
|
|
use \htmlSpacer;
|
|
|
|
use \htmlButton;
|
|
|
|
use \htmlElement;
|
|
|
|
use \htmlGroup;
|
|
|
|
use \htmlTableExtendedInputField;
|
|
|
|
use \LAMConfig;
|
|
|
|
use \htmlTableExtendedInputCheckbox;
|
2006-01-01 16:30:05 +00:00
|
|
|
/*
|
|
|
|
$Id$
|
|
|
|
|
2009-10-27 18:47:12 +00:00
|
|
|
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
2016-12-19 16:05:47 +00:00
|
|
|
Copyright (C) 2004 - 2016 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'])
|
2015-06-09 19:02:24 +00:00
|
|
|
|| isset($_POST['moduleSettings']) || isset($_POST['jobs'])) {
|
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;
|
|
|
|
}
|
2015-06-09 19:02:24 +00:00
|
|
|
// go to jobs page
|
|
|
|
elseif (isset($_POST['jobs'])) {
|
|
|
|
metaRefresh("jobs.php");
|
|
|
|
exit;
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-12 13:40:32 +00:00
|
|
|
$typeSettings = $conf->get_typeSettings();
|
2016-12-28 18:53:49 +00:00
|
|
|
$allScopes = \LAM\TYPES\getTypes();
|
|
|
|
$typeManager = new \LAM\TYPES\TypeManager($conf);
|
|
|
|
$activeTypes = $typeManager->getConfiguredTypes();
|
|
|
|
$activeScopes = array();
|
|
|
|
foreach ($activeTypes as $activeType) {
|
|
|
|
$activeScopes[] = $activeType->getScope();
|
|
|
|
}
|
|
|
|
$activeScopes = array_unique($activeScopes);
|
|
|
|
$availableScopes = array();
|
|
|
|
foreach ($allScopes as $scope) {
|
|
|
|
$scopeObj = new $scope();
|
|
|
|
if (!in_array($scope, $activeScopes) || $scopeObj->supportsMultipleConfigs()) {
|
|
|
|
$availableScopes[$scope] = $scopeObj->getAlias();
|
2010-04-04 12:52:20 +00:00
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
2016-12-28 18:53:49 +00:00
|
|
|
natcasesort($availableScopes);
|
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);
|
2012-11-02 17:45:35 +00:00
|
|
|
$cssFiles = array();
|
|
|
|
$cssEntry = $cssDir->read();
|
|
|
|
while ($cssEntry !== false) {
|
|
|
|
if (substr($cssEntry, strlen($cssEntry) - 4, 4) == '.css') {
|
|
|
|
$cssFiles[] = $cssEntry;
|
|
|
|
}
|
|
|
|
$cssEntry = $cssDir->read();
|
|
|
|
}
|
|
|
|
sort($cssFiles);
|
|
|
|
foreach ($cssFiles as $cssEntry) {
|
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";
|
2017-03-11 10:38:22 +00:00
|
|
|
echo "<link rel=\"icon\" href=\"../../graphics/logo136.png\">\n";
|
2006-01-01 16:30:05 +00:00
|
|
|
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">
|
2014-03-29 11:04:14 +00:00
|
|
|
<a class="lamLogo" href="http://www.ldap-account-manager.org/" target="new_window">LDAP Account Manager</a>
|
2010-07-30 16:08:20 +00:00
|
|
|
</td>
|
2012-11-02 18:16:36 +00:00
|
|
|
<td align="right">
|
|
|
|
<?php echo _('Server profile') . ': ' . $conf->getName(); ?>
|
|
|
|
|
|
|
|
</td>
|
2010-07-30 16:08:20 +00:00
|
|
|
</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=\" \">";
|
2015-06-09 19:02:24 +00:00
|
|
|
echo "<input name=\"jobs\" type=\"submit\" value=\" \">";
|
2010-08-28 09:34:00 +00:00
|
|
|
echo "</div>\n";
|
2016-11-14 18:17:10 +00:00
|
|
|
|
2010-08-28 09:34:00 +00:00
|
|
|
// 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>';
|
2015-06-09 19:02:24 +00:00
|
|
|
if (isLAMProVersion()) {
|
|
|
|
echo '<li id="jobs" class="ui-state-default ui-corner-top" onmouseover="jQuery(this).addClass(\'tabs-hover\');" onmouseout="jQuery(this).removeClass(\'tabs-hover\');">';
|
|
|
|
echo '<a href="#" onclick="document.getElementsByName(\'jobs\')[0].click();"><img src="../../graphics/clock.png" alt=""> ';
|
|
|
|
echo _('Jobs') . '</a>';
|
|
|
|
echo '</li>';
|
|
|
|
}
|
2010-08-28 09:34:00 +00:00
|
|
|
echo '</ul>';
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
jQuery(document).ready(function() {
|
2013-04-02 18:54:39 +00:00
|
|
|
jQuery('#edittypes').addClass('ui-tabs-active');
|
2010-08-28 09:34:00 +00:00
|
|
|
jQuery('#edittypes').addClass('ui-state-active');
|
2013-01-19 13:18:52 +00:00
|
|
|
jQuery('#edittypes').addClass('user-bright');
|
2010-08-28 09:34:00 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2013-01-19 13:18:52 +00:00
|
|
|
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom user-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
|
2016-12-28 18:53:49 +00:00
|
|
|
if (sizeof($availableScopes) > 0) {
|
2010-11-14 20:35:34 +00:00
|
|
|
$container->addElement(new htmlSubTitle(_("Available account types")), true);
|
|
|
|
$availableContainer = new htmlTable();
|
2016-12-28 18:53:49 +00:00
|
|
|
foreach ($availableScopes 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));
|
2016-12-28 18:53:49 +00:00
|
|
|
$availableContainer->addElement(new htmlOutputText(\LAM\TYPES\getTypeDescription($key)));
|
2010-11-14 20:35:34 +00:00
|
|
|
$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
|
|
|
}
|
|
|
|
|
2014-07-12 13:29:15 +00:00
|
|
|
$_SESSION['conftypes_optionTypes'] = array();
|
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();
|
2016-12-28 18:53:49 +00:00
|
|
|
foreach ($activeTypes as $activeType) {
|
2010-11-14 20:35:34 +00:00
|
|
|
// title
|
2013-04-29 18:16:14 +00:00
|
|
|
$titleGroup = new htmlGroup();
|
2013-05-01 12:36:17 +00:00
|
|
|
$titleGroup->colspan = 6;
|
2016-12-28 18:53:49 +00:00
|
|
|
$titleGroup->addElement(new htmlImage('../../graphics/' . $activeType->getScope() . '.png'));
|
|
|
|
$titleText = new htmlOutputText($activeType->getAlias());
|
2010-11-14 20:35:34 +00:00
|
|
|
$titleText->setIsBold(true);
|
2013-04-29 18:16:14 +00:00
|
|
|
$titleGroup->addElement($titleText);
|
|
|
|
$titleGroup->addElement(new htmlSpacer('10px', null));
|
2016-12-28 18:53:49 +00:00
|
|
|
$titleGroup->addElement(new htmlOutputText($activeType->getBaseType()->getDescription()));
|
2013-04-29 18:16:14 +00:00
|
|
|
$activeContainer->addElement($titleGroup);
|
|
|
|
// delete button
|
2016-12-28 18:53:49 +00:00
|
|
|
$delButton = new htmlButton('rem_'. $activeType->getId(), 'del.png', true);
|
2013-04-29 18:16:14 +00:00
|
|
|
$delButton->alignment = htmlElement::ALIGN_RIGHT;
|
|
|
|
$delButton->setTitle(_("Remove this account type"));
|
|
|
|
$activeContainer->addElement($delButton, true); //del.png
|
|
|
|
$activeContainer->addElement(new htmlSpacer(null, '5px'), true);
|
2006-02-03 15:37:59 +00:00
|
|
|
// LDAP suffix
|
2016-12-28 18:53:49 +00:00
|
|
|
$suffixInput = new htmlTableExtendedInputField(_("LDAP suffix"), 'suffix_' . $activeType->getId(), $typeSettings['suffix_' . $activeType->getId()], '202');
|
2010-11-14 20:35:34 +00:00
|
|
|
$suffixInput->setFieldSize(40);
|
|
|
|
$activeContainer->addElement($suffixInput);
|
2013-05-01 12:36:17 +00:00
|
|
|
$activeContainer->addElement(new htmlSpacer('20px', null));
|
2006-02-03 15:37:59 +00:00
|
|
|
// list attributes
|
2016-12-28 18:53:49 +00:00
|
|
|
if (isset($typeSettings['attr_' . $activeType->getId()])) {
|
|
|
|
$attributes = $typeSettings['attr_' . $activeType->getId()];
|
2006-02-03 15:37:59 +00:00
|
|
|
}
|
|
|
|
else {
|
2017-04-25 18:14:59 +00:00
|
|
|
$attributes = $activeType->getBaseType()->getDefaultListAttributes();
|
2006-02-03 15:37:59 +00:00
|
|
|
}
|
2016-12-28 18:53:49 +00:00
|
|
|
$attrsInput = new htmlTableExtendedInputField(_("List attributes"), 'attr_' . $activeType->getId(), $attributes, '206');
|
2010-11-14 20:35:34 +00:00
|
|
|
$attrsInput->setFieldSize(40);
|
2016-11-14 18:17:10 +00:00
|
|
|
$attrsInput->setFieldMaxLength(1000);
|
2016-12-19 16:05:47 +00:00
|
|
|
$activeContainer->addElement($attrsInput, true);
|
|
|
|
// custom label
|
|
|
|
$customLabel = '';
|
2016-12-28 18:53:49 +00:00
|
|
|
if (isset($typeSettings['customLabel_' . $activeType->getId()])) {
|
|
|
|
$customLabel = $typeSettings['customLabel_' . $activeType->getId()];
|
2016-12-19 16:05:47 +00:00
|
|
|
}
|
2016-12-28 18:53:49 +00:00
|
|
|
$customLabelInput = new htmlTableExtendedInputField(_('Custom label'), 'customLabel_' . $activeType->getId(), $customLabel, '264');
|
2016-12-19 16:05:47 +00:00
|
|
|
$customLabelInput->setFieldSize(40);
|
|
|
|
$activeContainer->addElement($customLabelInput);
|
|
|
|
$activeContainer->addElement(new htmlSpacer('20px', null));
|
|
|
|
// LDAP filter
|
|
|
|
$filter = '';
|
2016-12-28 18:53:49 +00:00
|
|
|
if (isset($typeSettings['filter_' . $activeType->getId()])) {
|
|
|
|
$filter = $typeSettings['filter_' . $activeType->getId()];
|
2016-12-19 16:05:47 +00:00
|
|
|
}
|
2016-12-28 18:53:49 +00:00
|
|
|
$filterInput = new htmlTableExtendedInputField(_("Additional LDAP filter"), 'filter_' . $activeType->getId(), $filter, '260');
|
2016-12-19 16:05:47 +00:00
|
|
|
$filterInput->setFieldSize(40);
|
|
|
|
$activeContainer->addElement($filterInput, true);
|
2014-07-12 13:29:15 +00:00
|
|
|
// type options
|
2016-12-28 18:53:49 +00:00
|
|
|
$typeConfigOptions = $activeType->getBaseType()->get_configOptions();
|
2014-07-12 13:29:15 +00:00
|
|
|
if (!empty($typeConfigOptions)) {
|
|
|
|
foreach ($typeConfigOptions as $typeConfigOption) {
|
|
|
|
$activeContainer->addElement($typeConfigOption, true);
|
|
|
|
}
|
|
|
|
// save option types to session
|
|
|
|
ob_start();
|
|
|
|
$dummyIndex = 1;
|
|
|
|
$typeConfigOptionTypes = parseHtml(null, $typeConfigOptions, array(), true, $dummyIndex, 'user');
|
|
|
|
ob_end_clean();
|
|
|
|
$_SESSION['conftypes_optionTypes'] = array_merge($_SESSION['conftypes_optionTypes'], $typeConfigOptionTypes);
|
|
|
|
}
|
2013-04-29 18:16:14 +00:00
|
|
|
// advanced options
|
2016-12-19 16:05:47 +00:00
|
|
|
$advancedOptions = new htmlTable();
|
|
|
|
$advancedOptions->colspan = 30;
|
|
|
|
// read-only
|
2014-01-15 20:48:52 +00:00
|
|
|
if (isLAMProVersion() && ($conf->getAccessLevel() == LAMConfig::ACCESS_ALL)) {
|
|
|
|
$isReadOnly = false;
|
2016-12-28 18:53:49 +00:00
|
|
|
if (isset($typeSettings['readOnly_' . $activeType->getId()])) {
|
|
|
|
$isReadOnly = $typeSettings['readOnly_' . $activeType->getId()];
|
2014-01-15 20:48:52 +00:00
|
|
|
}
|
2016-12-28 18:53:49 +00:00
|
|
|
$readOnly = new htmlTableExtendedInputCheckbox('readOnly_' . $activeType->getId(), $isReadOnly, _('Read-only'), '265');
|
|
|
|
$readOnly->setElementsToDisable(array('hideNewButton_' . $activeType->getId(), 'hideDeleteButton_' . $activeType->getId()));
|
2016-12-19 16:05:47 +00:00
|
|
|
$advancedOptions->addElement($readOnly);
|
|
|
|
$advancedOptions->addElement(new htmlSpacer('20px', null));
|
2014-01-15 20:48:52 +00:00
|
|
|
}
|
2016-12-19 16:05:47 +00:00
|
|
|
// hidden type
|
|
|
|
$hidden = false;
|
2016-12-28 18:53:49 +00:00
|
|
|
if (isset($typeSettings['hidden_' . $activeType->getId()])) {
|
|
|
|
$hidden = $typeSettings['hidden_' . $activeType->getId()];
|
2013-09-28 11:46:52 +00:00
|
|
|
}
|
2016-12-28 18:53:49 +00:00
|
|
|
$advancedOptions->addElement(new htmlTableExtendedInputCheckbox('hidden_' . $activeType->getId(), $hidden, _('Hidden'), '261'));
|
2013-05-01 12:36:17 +00:00
|
|
|
if (isLAMProVersion() && ($conf->getAccessLevel() == LAMConfig::ACCESS_ALL)) {
|
2016-12-19 16:05:47 +00:00
|
|
|
$advancedOptions->addElement(new htmlSpacer('20px', null));
|
2013-05-01 12:36:17 +00:00
|
|
|
// hide button to create new accounts
|
|
|
|
$hideNewButton = false;
|
2016-12-28 18:53:49 +00:00
|
|
|
if (isset($typeSettings['hideNewButton_' . $activeType->getId()])) {
|
|
|
|
$hideNewButton = $typeSettings['hideNewButton_' . $activeType->getId()];
|
2013-05-01 12:36:17 +00:00
|
|
|
}
|
2016-12-28 18:53:49 +00:00
|
|
|
$advancedOptions->addElement(new htmlTableExtendedInputCheckbox('hideNewButton_' . $activeType->getId(), $hideNewButton, _('No new entries'), '262'));
|
2016-12-19 16:05:47 +00:00
|
|
|
$advancedOptions->addElement(new htmlSpacer('20px', null));
|
2013-05-01 12:36:17 +00:00
|
|
|
// hide button to delete accounts
|
|
|
|
$hideDeleteButton = false;
|
2016-12-28 18:53:49 +00:00
|
|
|
if (isset($typeSettings['hideDeleteButton_' . $activeType->getId()])) {
|
|
|
|
$hideDeleteButton = $typeSettings['hideDeleteButton_' . $activeType->getId()];
|
2013-05-01 12:36:17 +00:00
|
|
|
}
|
2016-12-28 18:53:49 +00:00
|
|
|
$advancedOptions->addElement(new htmlTableExtendedInputCheckbox('hideDeleteButton_' . $activeType->getId(), $hideDeleteButton, _('Disallow delete'), '263'), true);
|
2013-05-01 12:36:17 +00:00
|
|
|
}
|
2013-04-29 18:16:14 +00:00
|
|
|
$activeContainer->addElement($advancedOptions, true);
|
2016-11-14 18:17:10 +00:00
|
|
|
|
2010-11-14 20:35:34 +00:00
|
|
|
$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;
|
2014-07-12 13:29:15 +00:00
|
|
|
$dynamicTypeOptions = array();
|
|
|
|
foreach ($_SESSION['conftypes_optionTypes'] as $key => $value) {
|
|
|
|
if (isset($typeSettings[$key])) {
|
|
|
|
$dynamicTypeOptions[$key] = explode(LAMConfig::LINE_SEPARATOR, $typeSettings[$key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
parseHtml(null, $container, $dynamicTypeOptions, false, $tabindex, 'user');
|
2010-11-14 20:35:34 +00:00
|
|
|
|
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'];
|
2016-12-28 18:53:49 +00:00
|
|
|
$typeManager = new \LAM\TYPES\TypeManager($conf);
|
2009-07-12 13:40:32 +00:00
|
|
|
$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);
|
|
|
|
}
|
|
|
|
// set suffixes
|
|
|
|
elseif (substr($key, 0, 7) == "suffix_") {
|
2014-10-01 18:45:15 +00:00
|
|
|
$typeSettings[$key] = trim($_POST[$key]);
|
2017-04-25 18:03:38 +00:00
|
|
|
$type = $typeManager->getConfiguredType(substr($postKeys[$i], 7));
|
2009-07-12 13:40:32 +00:00
|
|
|
if (strlen($_POST[$key]) < 1) {
|
2017-04-25 18:03:38 +00:00
|
|
|
$errors[] = array("ERROR", _("LDAP Suffix is invalid!"), $type->getAlias());
|
2009-07-12 13:40:32 +00:00
|
|
|
}
|
|
|
|
}
|
2013-01-01 20:46:28 +00:00
|
|
|
// set attributes
|
2009-07-12 13:40:32 +00:00
|
|
|
elseif (substr($key, 0, 5) == "attr_") {
|
|
|
|
$typeSettings[$key] = $_POST[$key];
|
2017-04-25 18:03:38 +00:00
|
|
|
$type = $typeManager->getConfiguredType(substr($postKeys[$i], 5));
|
2009-08-14 18:06:15 +00:00
|
|
|
if (!is_string($_POST[$key]) || !preg_match("/^((#[^:;]+)|([^:;]*:[^:;]+))(;((#[^:;]+)|([^:;]*:[^:;]+)))*$/", $_POST[$key])) {
|
2017-04-25 18:03:38 +00:00
|
|
|
$errors[] = array("ERROR", _("List attributes are invalid!"), $type->getAlias());
|
2009-07-12 13:40:32 +00:00
|
|
|
}
|
|
|
|
}
|
2013-01-01 20:46:28 +00:00
|
|
|
// set filter
|
2013-09-28 11:46:52 +00:00
|
|
|
elseif (substr($key, 0, strlen('filter_')) == "filter_") {
|
|
|
|
$typeSettings[$key] = $_POST[$key];
|
|
|
|
}
|
|
|
|
// set custom label
|
|
|
|
elseif (strpos($key, 'customLabel_') === 0) {
|
2013-01-01 20:46:28 +00:00
|
|
|
$typeSettings[$key] = $_POST[$key];
|
|
|
|
}
|
2013-01-09 20:09:48 +00:00
|
|
|
}
|
2014-07-12 13:29:15 +00:00
|
|
|
$typeConfigOptions = extractConfigOptionsFromPOST($_SESSION['conftypes_optionTypes']);
|
2016-12-28 18:53:49 +00:00
|
|
|
foreach ($accountTypes as $accountType) {
|
2013-05-01 12:36:17 +00:00
|
|
|
// set hidden
|
2016-12-28 18:53:49 +00:00
|
|
|
$key = "hidden_" . $accountType;
|
2013-05-01 12:36:17 +00:00
|
|
|
$typeSettings[$key] = (isset($_POST[$key]) && ($_POST[$key] == 'on'));
|
|
|
|
if (isLAMProVersion() && ($conf->getAccessLevel() == LAMConfig::ACCESS_ALL)) {
|
|
|
|
// set if new entries are allowed
|
2016-12-28 18:53:49 +00:00
|
|
|
$key = "hideNewButton_" . $accountType;
|
2013-05-01 12:36:17 +00:00
|
|
|
$typeSettings[$key] = (isset($_POST[$key]) && ($_POST[$key] == 'on'));
|
|
|
|
// set if deletion of entries is allowed
|
2016-12-28 18:53:49 +00:00
|
|
|
$key = "hideDeleteButton_" . $accountType;
|
2013-05-01 12:36:17 +00:00
|
|
|
$typeSettings[$key] = (isset($_POST[$key]) && ($_POST[$key] == 'on'));
|
2014-01-15 20:48:52 +00:00
|
|
|
// set if account type is read-only
|
2016-12-28 18:53:49 +00:00
|
|
|
$key = "readOnly_" . $accountType;
|
2014-01-15 20:48:52 +00:00
|
|
|
$typeSettings[$key] = (isset($_POST[$key]) && ($_POST[$key] == 'on'));
|
2013-01-01 20:46:28 +00:00
|
|
|
}
|
2014-07-12 13:29:15 +00:00
|
|
|
// check dynamic type settings
|
2016-12-28 18:53:49 +00:00
|
|
|
$typeObj = $typeManager->getConfiguredType($accountType)->getBaseType();
|
2014-07-12 13:29:15 +00:00
|
|
|
$typeMessages = $typeObj->check_configOptions($typeConfigOptions);
|
|
|
|
if (!empty($typeMessages)) {
|
|
|
|
$errors = array_merge($errors, $typeMessages);
|
|
|
|
}
|
|
|
|
}
|
2016-12-28 18:53:49 +00:00
|
|
|
// new type
|
|
|
|
foreach ($_POST as $key => $value) {
|
|
|
|
// check if add button was pressed
|
|
|
|
if (substr($key, 0, 4) == "add_") {
|
|
|
|
$scope = substr($key, 4);
|
|
|
|
$accountTypes[] = $typeManager->generateNewTypeId($scope);
|
|
|
|
}
|
|
|
|
}
|
2014-07-12 13:29:15 +00:00
|
|
|
// add dynamic type settings
|
|
|
|
foreach ($typeConfigOptions as $key => $value) {
|
|
|
|
$typeSettings[$key] = implode(LAMConfig::LINE_SEPARATOR, $value);
|
2009-07-12 13:40:32 +00:00
|
|
|
}
|
|
|
|
// save input
|
|
|
|
$conf->set_typeSettings($typeSettings);
|
|
|
|
$conf->set_ActiveTypes($accountTypes);
|
|
|
|
return $errors;
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|