2009-10-03 15:44:38 +00:00
|
|
|
<?php
|
2016-12-29 18:39:34 +00:00
|
|
|
namespace LAM\CONFIG;
|
|
|
|
use \moduleCache;
|
|
|
|
use \htmlSpacer;
|
|
|
|
use \htmlTable;
|
|
|
|
use \htmlButton;
|
2017-11-25 10:39:34 +00:00
|
|
|
use \htmlResponsiveRow;
|
|
|
|
use \htmlSubTitle;
|
2009-10-03 15:44:38 +00:00
|
|
|
/*
|
|
|
|
|
2009-10-27 18:47:12 +00:00
|
|
|
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
2019-10-10 18:45:40 +00:00
|
|
|
Copyright (C) 2009 - 2019 Roland Gruber
|
2009-10-03 15:44:38 +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 edit the module settings.
|
|
|
|
*
|
|
|
|
* @package configuration
|
|
|
|
* @author Roland Gruber
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/** Access to config functions */
|
|
|
|
include_once('../../lib/config.inc');
|
|
|
|
/** Access to account types */
|
|
|
|
include_once('../../lib/types.inc');
|
2017-11-11 15:39:53 +00:00
|
|
|
/** common functions */
|
|
|
|
include_once '../../lib/configPages.inc';
|
2009-10-03 15:44:38 +00:00
|
|
|
|
|
|
|
// start session
|
|
|
|
if (strtolower(session_module_name()) == 'files') {
|
|
|
|
session_save_path("../../sess");
|
|
|
|
}
|
2018-03-10 17:48:11 +00:00
|
|
|
lam_start_session();
|
2009-10-03 15:44:38 +00:00
|
|
|
|
|
|
|
setlanguage();
|
|
|
|
|
|
|
|
// check if config is set
|
|
|
|
// if not: load login page
|
|
|
|
if (!isset($_SESSION['conf_config'])) {
|
|
|
|
/** go back to login if password is invalid */
|
|
|
|
require('conflogin.php');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if user canceled editing
|
|
|
|
if (isset($_POST['cancelSettings'])) {
|
|
|
|
metaRefresh("../login.php");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$conf = &$_SESSION['conf_config'];
|
|
|
|
|
|
|
|
$errorsToDisplay = checkInput();
|
|
|
|
|
|
|
|
// 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'])
|
|
|
|
|| isset($_POST['edittypes']) || isset($_POST['generalSettingsButton'])
|
2015-06-09 19:02:24 +00:00
|
|
|
|| isset($_POST['moduleSettings']) || isset($_POST['jobs'])) {
|
2009-10-03 15:44:38 +00:00
|
|
|
if (sizeof($errorsToDisplay) == 0) {
|
|
|
|
// go to final page
|
|
|
|
if (isset($_POST['saveSettings'])) {
|
|
|
|
metaRefresh("confsave.php");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
// go to types page
|
|
|
|
elseif (isset($_POST['edittypes'])) {
|
|
|
|
metaRefresh("conftypes.php");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
// go to modules page
|
|
|
|
elseif (isset($_POST['editmodules'])) {
|
|
|
|
metaRefresh("confmodules.php");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
// go to types page
|
|
|
|
elseif (isset($_POST['generalSettingsButton'])) {
|
|
|
|
metaRefresh("confmain.php");
|
|
|
|
exit;
|
|
|
|
}
|
2015-06-09 19:02:24 +00:00
|
|
|
// go to jobs page
|
|
|
|
elseif (isset($_POST['jobs'])) {
|
|
|
|
metaRefresh("jobs.php");
|
|
|
|
exit;
|
|
|
|
}
|
2009-10-03 15:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-29 18:39:34 +00:00
|
|
|
$allTypes = \LAM\TYPES\getTypes();
|
2009-10-03 15:44:38 +00:00
|
|
|
|
|
|
|
echo $_SESSION['header'];
|
2017-11-25 10:39:34 +00:00
|
|
|
printHeaderContents(_("LDAP Account Manager Configuration"), '../..');
|
|
|
|
echo "</head><body class=\"admin\">\n";
|
|
|
|
printJsIncludes('../..');
|
2017-11-11 15:39:53 +00:00
|
|
|
printConfigurationPageHeaderBar($conf);
|
2009-10-03 15:44:38 +00:00
|
|
|
|
|
|
|
// print error messages
|
2018-12-23 10:01:29 +00:00
|
|
|
for ($i = 0; $i < sizeof($errorsToDisplay); $i++) {
|
|
|
|
call_user_func_array('StatusMessage', $errorsToDisplay[$i]);
|
|
|
|
}
|
2009-10-03 15:44:38 +00:00
|
|
|
|
2018-12-23 10:01:29 +00:00
|
|
|
echo "<form id=\"inputForm\" action=\"moduleSettings.php\" method=\"post\" autocomplete=\"off\" onSubmit=\"saveScrollPosition('inputForm')\">\n";
|
2010-08-28 09:34:00 +00:00
|
|
|
|
2017-11-11 15:39:53 +00:00
|
|
|
printConfigurationPageTabs(ConfigurationPageTab::MODULE_SETTINGS);
|
2010-08-28 09:34:00 +00:00
|
|
|
|
|
|
|
?>
|
2017-05-10 17:23:28 +00:00
|
|
|
<input type="text" name="hiddenPreventAutocomplete" autocomplete="false" class="hidden" value="">
|
2019-10-10 18:45:40 +00:00
|
|
|
<input type="password" name="hiddenPreventAutocompletePwd1" autocomplete="false" class="hidden" value="123">
|
|
|
|
<input type="password" name="hiddenPreventAutocompletePwd2" autocomplete="false" class="hidden" value="321">
|
2010-08-28 09:34:00 +00:00
|
|
|
<?php
|
|
|
|
|
2009-10-03 15:44:38 +00:00
|
|
|
|
|
|
|
// module settings
|
2016-12-29 18:39:34 +00:00
|
|
|
$typeManager = new \LAM\TYPES\TypeManager($conf);
|
|
|
|
$types = $typeManager->getConfiguredTypes();
|
2009-10-03 15:44:38 +00:00
|
|
|
|
|
|
|
// get list of scopes of modules
|
|
|
|
$scopes = array();
|
2016-12-29 18:39:34 +00:00
|
|
|
foreach ($types as $type) {
|
|
|
|
$mods = $conf->get_AccountModules($type->getId());
|
|
|
|
for ($i = 0; $i < sizeof($mods); $i++) {
|
2017-12-18 20:52:24 +00:00
|
|
|
$scopes[$mods[$i]][] = $type->getId();
|
2016-12-29 18:39:34 +00:00
|
|
|
}
|
2009-10-03 15:44:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// get module options
|
|
|
|
$options = getConfigOptions($scopes);
|
|
|
|
// get current setting
|
|
|
|
$old_options = $conf->get_moduleSettings();
|
|
|
|
|
|
|
|
|
|
|
|
// display module boxes
|
2012-02-27 17:00:49 +00:00
|
|
|
$tabindex = 1;
|
2009-10-03 15:44:38 +00:00
|
|
|
$modules = array_keys($options);
|
|
|
|
$_SESSION['conf_types'] = array();
|
|
|
|
for ($i = 0; $i < sizeof($modules); $i++) {
|
2018-04-30 17:32:47 +00:00
|
|
|
if (empty($options[$modules[$i]])) {
|
|
|
|
continue;
|
|
|
|
}
|
2013-05-09 19:10:35 +00:00
|
|
|
$module = moduleCache::getModule($modules[$i], 'none');
|
2009-10-03 15:44:38 +00:00
|
|
|
$iconImage = $module->getIcon();
|
|
|
|
if ($iconImage != null) {
|
2013-09-29 08:08:56 +00:00
|
|
|
if (!(strpos($iconImage, 'http') === 0) && !(strpos($iconImage, '/') === 0)) {
|
|
|
|
$iconImage = '../../graphics/' . $iconImage;
|
|
|
|
}
|
2009-10-03 15:44:38 +00:00
|
|
|
}
|
2017-11-25 10:39:34 +00:00
|
|
|
$row = new htmlResponsiveRow();
|
|
|
|
$row->add(new htmlSubTitle(getModuleAlias($modules[$i], "none"), $iconImage, null, true), 12);
|
2017-11-25 13:44:12 +00:00
|
|
|
if (is_array($options[$modules[$i]])) {
|
|
|
|
foreach ($options[$modules[$i]] as $option) {
|
|
|
|
$row->add($option, 12);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$row->add($options[$modules[$i]], 12);
|
|
|
|
}
|
2017-11-25 10:39:34 +00:00
|
|
|
$configTypes = parseHtml($modules[$i], $row, $old_options, false, $tabindex, 'none');
|
2009-10-03 15:44:38 +00:00
|
|
|
$_SESSION['conf_types'] = array_merge($configTypes, $_SESSION['conf_types']);
|
|
|
|
echo "<br>";
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2014-05-26 18:42:55 +00:00
|
|
|
parseHtml(null, $buttonContainer, array(), false, $tabindex, 'none');
|
2011-01-08 19:44:08 +00:00
|
|
|
|
2013-07-24 19:58:49 +00:00
|
|
|
if ((sizeof($errorsToDisplay) == 0) && isset($_POST['scrollPositionTop']) && isset($_POST['scrollPositionLeft'])) {
|
|
|
|
// scroll to last position
|
|
|
|
echo '<script type="text/javascript">
|
|
|
|
jQuery(document).ready(function() {
|
|
|
|
jQuery(window).scrollTop(' . $_POST['scrollPositionTop'] . ');
|
|
|
|
jQuery(window).scrollLeft('. $_POST['scrollPositionLeft'] . ');
|
|
|
|
});
|
|
|
|
</script>';
|
|
|
|
}
|
|
|
|
|
2011-01-08 19:44:08 +00:00
|
|
|
echo "</form>\n";
|
2009-10-03 15:44:38 +00:00
|
|
|
echo "</body>\n";
|
|
|
|
echo "</html>\n";
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks user input and saves the entered settings.
|
|
|
|
*
|
|
|
|
* @return array list of errors
|
|
|
|
*/
|
|
|
|
function checkInput() {
|
|
|
|
if (!isset($_POST['postAvailable'])) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
$conf = &$_SESSION['conf_config'];
|
2016-12-29 18:39:34 +00:00
|
|
|
$typeManager = new \LAM\TYPES\TypeManager($conf);
|
|
|
|
$types = $typeManager->getConfiguredTypes();
|
2016-12-19 20:32:08 +00:00
|
|
|
|
2009-10-03 15:44:38 +00:00
|
|
|
// check module options
|
|
|
|
// create option array to check and save
|
2014-07-12 13:29:15 +00:00
|
|
|
$options = extractConfigOptionsFromPOST($_SESSION['conf_types']);
|
2009-10-03 15:44:38 +00:00
|
|
|
|
|
|
|
// get list of scopes of modules
|
|
|
|
$scopes = array();
|
2016-12-29 18:39:34 +00:00
|
|
|
foreach ($types as $type) {
|
|
|
|
$mods = $conf->get_AccountModules($type->getId());
|
|
|
|
for ($i = 0; $i < sizeof($mods); $i++) {
|
2017-12-20 19:44:08 +00:00
|
|
|
$scopes[$mods[$i]][] = $type->getId();
|
2016-12-29 18:39:34 +00:00
|
|
|
}
|
2009-10-03 15:44:38 +00:00
|
|
|
}
|
|
|
|
// check options
|
|
|
|
$errors = checkConfigOptions($scopes, $options);
|
|
|
|
$conf->set_moduleSettings($options);
|
|
|
|
return $errors;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|