LDAPAccountManager/lam/templates/config/confmodules.php

285 lines
8.9 KiB
PHP
Raw Normal View History

2004-02-01 12:33:21 +00:00
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
2006-03-03 17:30:35 +00:00
Copyright (C) 2004 - 2006 Roland Gruber
2004-02-01 12:33:21 +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
2004-06-02 12:48:54 +00:00
*/
2004-02-01 12:33:21 +00:00
2004-06-02 12:48:54 +00:00
/**
* confmodules lets the user select the account modules
*
* @package configuration
* @author Roland Gruber
2004-02-01 12:33:21 +00:00
*/
2004-06-02 12:48:54 +00:00
/** Access to config functions */
2006-03-26 17:51:25 +00:00
include_once('../../lib/config.inc');
2004-06-02 12:48:54 +00:00
/** Access to module lists */
2006-03-26 17:51:25 +00:00
include_once('../../lib/modules.inc');
2004-02-01 12:33:21 +00:00
// start session
session_save_path("../../sess");
@session_start();
setlanguage();
// check if config is set
2004-02-01 12:33:21 +00:00
// if not: load login page
if (!isset($_SESSION['conf_config'])) {
2004-06-02 12:48:54 +00:00
/** go back to login if password is invalid */
2004-02-01 12:33:21 +00:00
require('conflogin.php');
exit;
}
$conf = &$_SESSION['conf_config'];
2004-02-01 12:33:21 +00:00
// user pressed submit/abort button
2006-05-07 14:09:38 +00:00
if (isset($_POST['submit'])) {
// save new module settings
$_SESSION['conf_accountTypesOld'] = $_SESSION['conf_accountTypes'];
$conf->set_typeSettings($_SESSION['conf_typeSettings']);
//selection ok, back to other settings
metarefresh('confmain.php?modulesback=true');
2006-01-01 16:30:05 +00:00
exit;
2004-02-01 12:33:21 +00:00
}
2006-05-07 14:09:38 +00:00
elseif (isset($_POST['abort'])) {
// no changes
$_SESSION['conf_accountTypes'] = $_SESSION['conf_accountTypesOld'];
2004-02-01 12:33:21 +00:00
metarefresh('confmain.php?modulesback=true');
2006-01-01 16:30:05 +00:00
exit;
2004-02-01 12:33:21 +00:00
}
$types = $conf->get_ActiveTypes();
2006-01-01 16:30:05 +00:00
2004-02-01 12:33:21 +00:00
echo $_SESSION['header'];
echo "<title>" . _("LDAP Account Manager Configuration") . "</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
2006-01-01 16:30:05 +00:00
for ($i = 0; $i < sizeof($types); $i++){
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/type_" . $types[$i] . ".css\">\n";
}
2004-02-01 12:33:21 +00:00
echo "</head><body>\n";
2005-12-05 19:09:04 +00:00
echo ("<p align=\"center\"><a href=\"http://lam.sourceforge.net\" target=\"new_window\">".
2004-02-01 12:33:21 +00:00
"<img src=\"../../graphics/banner.jpg\" border=1 alt=\"LDAP Account Manager\"></a></p><hr><br>\n");
echo ("<form action=\"confmodules.php\" method=\"post\">\n");
2006-01-01 16:30:05 +00:00
echo "<h1 align=\"center\">" . _("Module selection") . "</h1>";
2004-02-01 12:33:21 +00:00
2006-01-01 16:30:05 +00:00
$account_list = array();
for ($i = 0; $i < sizeof($types); $i++) {
$account_list[] = array($types[$i], getTypeAlias($types[$i]));
}
$allDependenciesOk = true;
for ($i = 0; $i < sizeof($account_list); $i++) {
$ret = config_showAccountModules($account_list[$i][0], $account_list[$i][1]);
if (!$ret) {
$allDependenciesOk = false;
2004-02-01 12:33:21 +00:00
}
}
// submit buttons
echo "<p>\n";
// disable button if there are conflicts/depends
if ($allDependenciesOk) {
2006-03-04 10:49:55 +00:00
echo "<input type=\"submit\" value=\"" . _("Ok") . "\" name=\"submit\">\n";
2004-02-01 12:33:21 +00:00
}
else {
2006-03-04 10:49:55 +00:00
echo "<input type=\"submit\" value=\"" . _("Ok") . "\" name=\"submit\" disabled>\n";
2004-02-01 12:33:21 +00:00
}
echo "&nbsp;";
2006-03-04 10:49:55 +00:00
echo "<input type=\"submit\" value=\"" . _("Cancel") . "\" name=\"abort\">\n";
echo "</p>\n";
2004-02-01 12:33:21 +00:00
echo "<p><br><br>\n";
2005-04-24 19:41:39 +00:00
echo "(*) " . _("Base module");
// help link
echo "&nbsp;<a href=\"../help.php?HelpNumber=237\" target=\"lamhelp\">";
echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
echo "</a>\n";
echo "</p>\n";
echo "</form>\n";
echo "</body>\n";
echo "</html>\n";
/**
* Displays the module selection boxes and checks if dependencies are fulfilled.
*
* @param string $scope account type
* @param string $title title for module selection (e.g. "User modules")
* @return boolean true if all dependencies are ok
*/
function config_showAccountModules($scope, $title) {
// account modules
2006-01-01 16:30:05 +00:00
$selected_temp = $_SESSION['conf_typeSettings']['modules_' . $scope];
if (isset($selected_temp)) $selected_temp = explode(',', $selected_temp);
$available = array();
$available = getAvailableModules($scope);
$selected = array();
// only use available modules as selected
for ($i = 0; $i < sizeof($selected_temp); $i++) {
if (in_array($selected_temp[$i], $available)) $selected[] = $selected_temp[$i];
}
$no_conflicts = true;
$no_depends = true;
$no_missing_basemodule = true;
// remove modules from selection
2006-05-07 14:09:38 +00:00
if (isset($_POST[$scope . '_selected']) && isset($_POST[$scope . '_remove'])) {
$new_selected = array();
for ($i = 0; $i < sizeof($selected); $i++) {
if (! in_array($selected[$i], $_POST[$scope . '_selected'])) $new_selected[] = $selected[$i];
2004-02-01 12:33:21 +00:00
}
$selected = $new_selected;
2006-01-01 16:30:05 +00:00
$_SESSION['conf_typeSettings']['modules_' . $scope] = implode(',', $selected);
}
// add modules to selection
2006-05-07 14:09:38 +00:00
elseif (isset($_POST[$scope . '_available']) && isset($_POST[$scope . '_add'])) {
$new_selected = $selected;
for ($i = 0; $i < sizeof($_POST[$scope . '_available']); $i++) {
if (! in_array($_POST[$scope . '_available'][$i], $selected)) $new_selected[] = $_POST[$scope . '_available'][$i];
2004-02-01 12:33:21 +00:00
}
$selected = $new_selected;
2006-01-01 16:30:05 +00:00
$_SESSION['conf_typeSettings']['modules_' . $scope] = implode(',', $selected);
}
// show account modules
2007-12-31 13:13:37 +00:00
$icon = '<img alt="' . $scope . '" src="../../graphics/' . $scope . '.png">&nbsp;';
2007-12-31 12:25:13 +00:00
echo "<fieldset class=\"" . $scope . "edit\"><legend>$icon<b>" . $title . "</b></legend><br>\n";
echo "<table border=0 width=\"100%\">\n";
// select boxes
echo "<tr>\n";
echo "<td width=\"5%\"></td>\n";
echo "<td width=\"40%\">\n";
2005-04-22 08:56:47 +00:00
echo "<fieldset class=\"" . $scope . "edit\">\n";
2007-12-31 12:25:13 +00:00
echo "<legend>" . _("Selected modules") . "</legend><br>\n";
2005-04-22 08:56:47 +00:00
echo "<select class=\"" . $scope . "edit\" name=\"" . $scope . "_selected[]\" size=5 multiple>\n";
for ($i = 0; $i < sizeof($selected); $i++) {
if (in_array($selected[$i], $available)) { // selected modules must be available
if (is_base_module($selected[$i], $scope)) { // mark base modules
echo "<option value=\"" . $selected[$i] . "\">";
2006-11-13 17:43:21 +00:00
echo getModuleAlias($selected[$i], $scope) . "(" . $selected[$i] . ")(*)";
echo "</option>\n";
}
else {
echo "<option value=\"" . $selected[$i] . "\">";
2006-11-13 17:43:21 +00:00
echo getModuleAlias($selected[$i], $scope) . "(" . $selected[$i] . ")";
echo "</option>\n";
}
}
}
echo "</select>\n";
echo "</fieldset>\n";
echo "</td>\n";
echo "<td width=\"10%\" align=\"center\">\n";
echo "<p>";
echo "<input type=submit value=\"&lt;=\" name=\"" . $scope . "_add\">";
echo "<br>";
echo "<input type=submit value=\"=&gt;\" name=\"" . $scope . "_remove\">";
echo "</p>\n";
echo "</td>\n";
echo "<td width=\"40%\">\n";
2005-04-22 08:56:47 +00:00
echo "<fieldset class=\"" . $scope . "edit\">\n";
2007-12-31 12:25:13 +00:00
echo "<legend>" . _("Available modules") . "</legend><br>\n";
2005-04-22 08:56:47 +00:00
echo "<select class=\"" . $scope . "edit\" name=\"" . $scope . "_available[]\" size=5 multiple>\n";
for ($i = 0; $i < sizeof($available); $i++) {
if (! in_array($available[$i], $selected)) { // display non-selected modules
if (is_base_module($available[$i], $scope)) { // mark base modules
echo "<option value=\"" . $available[$i] . "\">";
2006-11-13 17:43:21 +00:00
echo getModuleAlias($available[$i], $scope) . "(" . $available[$i] . ")(*)";
echo "</option>\n";
}
else {
echo "<option value=\"" . $available[$i] . "\">";
2006-11-13 17:43:21 +00:00
echo getModuleAlias($available[$i], $scope) . "(" . $available[$i] . ")";
echo "</option>\n";
}
}
}
echo "</select>\n";
echo "</fieldset>\n";
echo "</td>\n";
echo "<td width=\"5%\"></td>\n";
echo "</tr>\n";
echo "</table>\n";
// check dependencies
$depends = check_module_depends($selected, getModulesDependencies($scope));
if ($depends != false) {
$no_depends = false;
echo "<p>\n";
for ($i = 0; $i < sizeof($depends); $i++) {
echo "<font color=\"red\"><b>" . _("Unsolved dependency:") . " </b>" . $depends[$i][0] . " (" .
$depends[$i][1] . ")" . "</font><br>\n";
}
echo "<p>\n";
}
// check conflicts
$conflicts = check_module_conflicts($selected, getModulesDependencies($scope));
if ($conflicts != false) {
$no_conflicts = false;
echo "<p>\n";
for ($i = 0; $i < sizeof($conflicts); $i++) {
echo "<font color=\"red\"><b>" . _("Conflicting module:") . " </b>" . $conflicts[$i][0] . " (" .
$conflicts[$i][1] . ")" . "</font><br>\n";
}
echo "<p>\n";
2004-02-01 12:33:21 +00:00
}
// check for base module
$baseCount = 0;
for ($i = 0; $i < sizeof($selected); $i++) {
if (is_base_module($selected[$i], $scope)) {
$baseCount++;
}
2004-02-01 12:33:21 +00:00
}
if ($baseCount != 1) {
$no_missing_basemodule = false;
echo "<p>\n";
echo "<font color=\"red\"><b>" . _("No or more than one base module selected!") . "</b></font><br>\n";
echo "<p>\n";
}
echo "</fieldset>\n";
2007-12-31 13:13:37 +00:00
echo "<br>\n";
return ($no_conflicts & $no_depends & $no_missing_basemodule);
}
2004-02-01 12:33:21 +00:00
?>