LDAPAccountManager/lam/templates/config/confmodules.php

279 lines
8.7 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)
Copyright (C) 2004 Roland Gruber
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 */
2004-02-01 12:33:21 +00:00
include_once ('../../lib/config.inc');
2004-06-02 12:48:54 +00:00
/** Access to module lists */
2004-02-01 12:33:21 +00:00
include_once ('../../lib/modules.inc');
// start session
session_save_path("../../sess");
@session_start();
setlanguage();
$conf = new Config($_SESSION['conf_filename']);
$passwd = $_SESSION['conf_passwd'];
// check if password is correct
// if not: load login page
if ($passwd != $conf->get_Passwd()) {
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;
}
// user pressed submit/abort button
if ($_POST['submit']) {
//selection ok, back to other settings
2004-02-01 12:33:21 +00:00
metarefresh('confmain.php?modulesback=true&amp;moduleschanged=true');
2006-01-01 16:30:05 +00:00
exit;
2004-02-01 12:33:21 +00:00
}
elseif ($_POST['abort']) {
// no changes
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
}
2006-01-01 16:30:05 +00:00
$types = $_SESSION['conf_accountTypes'];
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) {
echo "<input type=\"submit\" value=\"" . _("Submit") . "\" name=\"submit\">\n";
2004-02-01 12:33:21 +00:00
}
else {
echo "<input type=\"submit\" value=\"" . _("Submit") . "\" name=\"submit\" disabled>\n";
2004-02-01 12:33:21 +00:00
}
echo "&nbsp;";
echo "<input type=\"submit\" value=\"" . _("Abort") . "\" 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
if ($_POST[$scope . '_selected'] && ($_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
elseif ($_POST[$scope . '_available'] && ($_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
2005-04-22 08:56:47 +00:00
echo "<fieldset class=\"" . $scope . "edit\"><legend><b>" . $title . "</b></legend>\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";
echo "<legend>" . _("Selected modules") . "</legend>\n";
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] . "\">";
echo $selected[$i] . "(" . getModuleAlias($selected[$i], $scope) . ")(*)";
echo "</option>\n";
}
else {
echo "<option value=\"" . $selected[$i] . "\">";
echo $selected[$i] . "(" . getModuleAlias($selected[$i], $scope) . ")";
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";
echo "<legend>" . _("Available modules") . "</legend>\n";
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] . "\">";
echo $available[$i] . "(" . getModuleAlias($available[$i], $scope) . ")(*)";
echo "</option>\n";
}
else {
echo "<option value=\"" . $available[$i] . "\">";
echo $available[$i] . "(" . getModuleAlias($available[$i], $scope) . ")";
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";
echo "<p></p>\n";
return ($no_conflicts & $no_depends & $no_missing_basemodule);
}
2004-02-01 12:33:21 +00:00
?>