added module selection
This commit is contained in:
parent
88d5245784
commit
1aa6f8de59
|
@ -3,7 +3,7 @@
|
|||
$Id$
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
|
||||
Copyright (C) 2003-04 Roland Gruber
|
||||
Copyright (C) 2003 - 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
|
||||
|
@ -25,6 +25,7 @@ $Id$
|
|||
*/
|
||||
|
||||
include_once("status.inc");
|
||||
include_once("modules.inc");
|
||||
|
||||
// sets language settings for automatic translation
|
||||
function setlanguage() {
|
||||
|
@ -259,6 +260,9 @@ class Config {
|
|||
if (!in_array("samba3", $saved)) array_push($file_array, "\n\n# Set to \"yes\" only if you use the new Samba 3.x schema.\n" . "samba3: " . $this->samba3 . "\n");
|
||||
if (!in_array("cachetimeout", $saved)) array_push($file_array, "\n\n# Number of minutes LAM caches LDAP searches.\n" . "cacheTimeout: " . $this->cachetimeout . "\n");
|
||||
if (!in_array("pwdhash", $saved)) array_push($file_array, "\n\n# Password hash algorithm (CRYPT/MD5/SMD5/SHA/SSHA/PLAIN).\n" . "pwdhash: " . $this->pwdhash . "\n");
|
||||
if (!in_array("usermodules", $saved)) array_push($file_array, "\n\n# List of used user modules\n" . "usermodules: " . $this->usermodules . "\n");
|
||||
if (!in_array("groupmodules", $saved)) array_push($file_array, "\n\n# List of used group modules\n" . "groupmodules: " . $this->groupmodules . "\n");
|
||||
if (!in_array("hostmodules", $saved)) array_push($file_array, "\n\n# List of used host modules\n" . "hostmodules: " . $this->hostmodules . "\n");
|
||||
$file = fopen($conffile, "w");
|
||||
if ($file) {
|
||||
for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]);
|
||||
|
@ -295,7 +299,10 @@ class Config {
|
|||
echo "<b>" . _("Default language") . ": </b>" . $this->defaultLanguage . "<br>";
|
||||
echo "<b>" . _("Path to external script") . ": </b>" . $this->scriptPath . "<br>";
|
||||
echo "<b>" . _("Server of external script") . ": </b>" . $this->scriptServer . "<br>";
|
||||
echo "<b>" . _("List of valid users") . ": </b>" . $this->Admins . "<br><br>";
|
||||
echo "<b>" . _("List of valid users") . ": </b>" . $this->Admins . "<br>";
|
||||
echo "<b>" . _("User modules") . ": </b>" . $this->usermodules . "<br>";
|
||||
echo "<b>" . _("Group modules") . ": </b>" . $this->groupmodules . "<br>";
|
||||
echo "<b>" . _("Host modules") . ": </b>" . $this->hostmodules . "<br><br>";
|
||||
echo "<b>" . _("Text for user PDF") . ": </b>" . $this->get_pdftext();
|
||||
}
|
||||
|
||||
|
@ -712,13 +719,18 @@ class Config {
|
|||
function set_UserModules($modules) {
|
||||
if (! is_array($modules)) return false;
|
||||
// check module names
|
||||
// TODO check against available module names
|
||||
$available = getAvailableUserModules();
|
||||
for ($i = 0; $i < sizeof($modules); $i++) {
|
||||
if (! in_array($modules[$i], $available)) return false;
|
||||
}
|
||||
// TODO: check depends/conflicts
|
||||
$this->usermodules = implode(",", $modules);
|
||||
return true;
|
||||
}
|
||||
|
||||
// returns an array of all selected group modules
|
||||
function get_GroupModules() {
|
||||
return explode(",", $this->usermodules);
|
||||
return explode(",", $this->groupmodules);
|
||||
}
|
||||
|
||||
// sets the selected group modules
|
||||
|
@ -727,13 +739,18 @@ class Config {
|
|||
function set_GroupModules($modules) {
|
||||
if (! is_array($modules)) return false;
|
||||
// check module names
|
||||
// TODO check against available module names
|
||||
$available = getAvailableGroupModules();
|
||||
for ($i = 0; $i < sizeof($modules); $i++) {
|
||||
if (! in_array($modules[$i], $available)) return false;
|
||||
}
|
||||
// TODO: check depends/conflicts
|
||||
$this->groupmodules = implode(",", $modules);
|
||||
return true;
|
||||
}
|
||||
|
||||
// returns an array of all selected host modules
|
||||
function get_HostModules() {
|
||||
return explode(",", $this->usermodules);
|
||||
return explode(",", $this->hostmodules);
|
||||
}
|
||||
|
||||
// sets the selected host modules
|
||||
|
@ -742,8 +759,13 @@ class Config {
|
|||
function set_HostModules($modules) {
|
||||
if (! is_array($modules)) return false;
|
||||
// check module names
|
||||
// TODO check against available module names
|
||||
$available = getAvailableHostModules();
|
||||
for ($i = 0; $i < sizeof($modules); $i++) {
|
||||
if (! in_array($modules[$i], $available)) return false;
|
||||
}
|
||||
// TODO: check depends/conflicts
|
||||
$this->hostmodules = implode(",", $modules);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,6 +57,9 @@ unset($_SESSION['conf_scriptserver']);
|
|||
unset($_SESSION['conf_samba3']);
|
||||
unset($_SESSION['conf_pwdhash']);
|
||||
unset($_SESSION['conf_filename']);
|
||||
unset($_SESSION['conf_usermodules']);
|
||||
unset($_SESSION['conf_groupmodules']);
|
||||
unset($_SESSION['conf_hostmodules']);
|
||||
|
||||
// remove config wizard settings
|
||||
unset($_SESSION['confwiz_config']);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
$Id$
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
|
||||
Copyright (C) 2003 Roland Gruber
|
||||
Copyright (C) 2003-04 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
|
||||
|
@ -33,9 +33,9 @@ session_save_path("../../sess");
|
|||
setlanguage();
|
||||
|
||||
// check if button was pressed and if we have to save the setting or go back to login
|
||||
if ($_POST['back'] || $_POST['submitconf']){
|
||||
if ($_POST['back'] || $_POST['submitconf'] || $_POST['editmodules']){
|
||||
// save settings
|
||||
if ($_POST['submitconf']){
|
||||
if ($_POST['submitconf'] || $_POST['editmodules']){
|
||||
// save HTTP-POST variables in session
|
||||
$_SESSION['conf_passwd'] = $_POST['passwd'];
|
||||
$_SESSION['conf_passwd1'] = $_POST['passwd1'];
|
||||
|
@ -63,9 +63,19 @@ if ($_POST['back'] || $_POST['submitconf']){
|
|||
$_SESSION['conf_scriptpath'] = $_POST['scriptpath'];
|
||||
$_SESSION['conf_scriptserver'] = $_POST['scriptserver'];
|
||||
$_SESSION['conf_pdf_usertext'] = $_POST['pdf_usertext'];
|
||||
$_SESSION['conf_usermodules'] = explode(",", $_POST['usermodules']);
|
||||
$_SESSION['conf_groupmodules'] = explode(",", $_POST['groupmodules']);
|
||||
$_SESSION['conf_hostmodules'] = explode(",", $_POST['hostmodules']);
|
||||
$_SESSION['conf_filename'] = $_POST['filename'];
|
||||
}
|
||||
// go to final page
|
||||
if ($_POST['submitconf']){
|
||||
metaRefresh("confsave.php");
|
||||
}
|
||||
// go to modules page
|
||||
elseif ($_POST['editmodules']){
|
||||
metaRefresh("confmodules.php");
|
||||
}
|
||||
// back to login
|
||||
else if ($_POST['back']){
|
||||
metaRefresh("../login.php");
|
||||
|
@ -75,6 +85,7 @@ if ($_POST['back'] || $_POST['submitconf']){
|
|||
|
||||
// get password if register_globals is off
|
||||
if ($_POST['passwd']) $passwd = $_POST['passwd'];
|
||||
if ($_GET["modulesback"] == "true") $passwd = $_SESSION['conf_passwd'];
|
||||
|
||||
// check if password was entered
|
||||
// if not: load login page
|
||||
|
@ -84,16 +95,53 @@ if (! $passwd) {
|
|||
exit;
|
||||
}
|
||||
|
||||
include_once ('../../lib/config.inc');
|
||||
$filename = $_POST['filename'];
|
||||
if ($_GET["modulesback"] == "true") $filename = $_SESSION['conf_filename'];
|
||||
$conf = new Config($filename);
|
||||
|
||||
// check if password is valid
|
||||
// if not: load login page
|
||||
include_once ('../../lib/config.inc');
|
||||
$conf = new Config($_POST['filename']);
|
||||
if (!(($conf->get_Passwd()) == $passwd)) {
|
||||
$message = _("The password is invalid! Please try again.");
|
||||
require('conflogin.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// check if user comes from modules page
|
||||
if ($_GET["modulesback"] == "true") {
|
||||
// load config values from session
|
||||
$conf->set_samba3($_SESSION['conf_samba3']);
|
||||
$conf->set_ServerURL($_SESSION['conf_serverurl']);
|
||||
$conf->set_cacheTimeout($_SESSION['conf_cachetimeout']);
|
||||
$conf->set_Adminstring($_SESSION['conf_admins']);
|
||||
$conf->set_UserSuffix($_SESSION['conf_suffusers']);
|
||||
$conf->set_GroupSuffix($_SESSION['conf_suffgroups']);
|
||||
$conf->set_HostSuffix($_SESSION['conf_suffhosts']);
|
||||
$conf->set_DomainSuffix($_SESSION['conf_suffdomains']);
|
||||
$conf->set_minUID($_SESSION['conf_minUID']);
|
||||
$conf->set_maxUID($_SESSION['conf_maxUID']);
|
||||
$conf->set_minGID($_SESSION['conf_minGID']);
|
||||
$conf->set_maxGID($_SESSION['conf_maxGID']);
|
||||
$conf->set_minMachine($_SESSION['conf_minMach']);
|
||||
$conf->set_maxMachine($_SESSION['conf_maxMach']);
|
||||
$conf->set_userlistAttributes($_SESSION['conf_usrlstattr']);
|
||||
$conf->set_grouplistAttributes($_SESSION['conf_grplstattr']);
|
||||
$conf->set_hostlistAttributes($_SESSION['conf_hstlstattr']);
|
||||
$conf->set_MaxListEntries($_SESSION['conf_maxlistentries']);
|
||||
$conf->set_defaultLanguage($_SESSION['conf_lang']);
|
||||
$conf->set_scriptpath($_SESSION['conf_scriptpath']);
|
||||
$conf->set_scriptserver($_SESSION['conf_scriptserver']);
|
||||
$conf->set_pwdhash($_SESSION['conf_pwdhash']);
|
||||
$conf->set_pdftext($_SESSION['conf_pdf_usertext']);
|
||||
// check if modules were edited
|
||||
if ($_GET["moduleschanged"] == "true") {
|
||||
$conf->set_UserModules($_SESSION['conf_usermodules']);
|
||||
$conf->set_GroupModules($_SESSION['conf_groupmodules']);
|
||||
$conf->set_HostModules($_SESSION['conf_hostmodules']);
|
||||
}
|
||||
}
|
||||
|
||||
echo $_SESSION['header'];
|
||||
|
||||
echo ("<title>" . _("LDAP Account Manager Configuration") . "</title>\n");
|
||||
|
@ -173,6 +221,23 @@ echo ("<td><a href=\"../help.php?HelpNumber=214\" target=\"lamhelp\">" . _("Help
|
|||
|
||||
echo ("</table>");
|
||||
echo ("</fieldset>");
|
||||
|
||||
echo ("<p></p>");
|
||||
|
||||
echo ("<fieldset><legend><b>" . _("Account modules") . "</b></legend>");
|
||||
echo ("<table border=0>");
|
||||
|
||||
// Account modules
|
||||
echo "<tr><td><b>" . _("User modules") . ": </b>" . implode(", ", $conf->get_UserModules()) . "</td></tr>\n";
|
||||
echo "<tr><td><b>" . _("Group modules") . ": </b>" . implode(", ", $conf->get_GroupModules()) . "</td></tr>\n";
|
||||
echo "<tr><td><b>" . _("Host modules") . ": </b>" . implode(", ", $conf->get_HostModules()) . "</td></tr>\n";
|
||||
echo "<tr><td> </td></tr>\n";
|
||||
echo "<tr><td><input type=\"submit\" name=\"editmodules\" value=\"" . _("Edit modules") . "\"> " .
|
||||
"<a href=\"../help.php?HelpNumber=217\" target=\"lamhelp\">" . _("Help") . "</a></td></tr>\n";
|
||||
|
||||
echo ("</table>");
|
||||
echo ("</fieldset>");
|
||||
|
||||
echo ("<p></p>");
|
||||
|
||||
echo ("<fieldset><legend><b>" . _("Samba settings") . "</b></legend>");
|
||||
|
@ -188,6 +253,7 @@ echo ("<td><a href=\"../help.php?HelpNumber=213\" target=\"lamhelp\">" . _("Help
|
|||
|
||||
echo ("</table>");
|
||||
echo ("</fieldset>");
|
||||
|
||||
echo ("<p></p>");
|
||||
|
||||
echo ("<fieldset><legend><b>" . _("Ranges") . "</b></legend>");
|
||||
|
@ -197,6 +263,7 @@ echo ("<table border=0>");
|
|||
echo ("<tr><td align=\"right\"><b>".
|
||||
_("Minimum UID number") . " *: </b>".
|
||||
"<input size=6 type=\"text\" name=\"minUID\" value=\"" . $conf->get_minUID() . "\"></td>\n");
|
||||
echo "<td> </td>\n";
|
||||
// maxUID
|
||||
echo ("<td align=\"right\"><b>" . _("Maximum UID number") . " *: </b>".
|
||||
"<input size=6 type=\"text\" name=\"maxUID\" value=\"" . $conf->get_maxUID() . "\"></td>\n");
|
||||
|
@ -206,6 +273,7 @@ echo ("<td><a href=\"../help.php?HelpNumber=203\" target=\"lamhelp\">" . _("Help
|
|||
echo ("<tr><td align=\"right\"><b>".
|
||||
_("Minimum GID number") . " *: </b>".
|
||||
"<input size=6 type=\"text\" name=\"minGID\" value=\"" . $conf->get_minGID() . "\"></td>\n");
|
||||
echo "<td> </td>\n";
|
||||
// maxGID
|
||||
echo ("<td align=\"right\"><b>" . _("Maximum GID number")." *: </b>".
|
||||
"<input size=6 type=\"text\" name=\"maxGID\" value=\"" . $conf->get_maxGID() . "\"></td>\n");
|
||||
|
@ -215,6 +283,7 @@ echo ("<td><a href=\"../help.php?HelpNumber=204\" target=\"lamhelp\">" . _("Help
|
|||
echo ("<tr><td align=\"right\"><b>".
|
||||
_("Minimum Machine number") . " **: </b>".
|
||||
"<input size=6 type=\"text\" name=\"minMach\" value=\"" . $conf->get_minMachine() . "\"></td>\n");
|
||||
echo "<td> </td>\n";
|
||||
// maxMach
|
||||
echo ("<td align=\"right\"><b>" . _("Maximum Machine number") . " **: </b>".
|
||||
"<input size=6 type=\"text\" name=\"maxMach\" value=\"" . $conf->get_maxMachine() . "\"></td>\n");
|
||||
|
@ -342,22 +411,20 @@ echo ("<table border=0>\n");
|
|||
// admin list
|
||||
echo ("<tr><td align=\"right\"><b>".
|
||||
_("List of valid users") . " *: </b></td>".
|
||||
"<td colspan=2><input size=50 type=\"text\" name=\"admins\" value=\"" . $conf->get_Adminstring() . "\"></td>\n");
|
||||
"<td><input size=50 type=\"text\" name=\"admins\" value=\"" . $conf->get_Adminstring() . "\"></td>\n");
|
||||
echo ("<td><a href=\"../help.php?HelpNumber=207\" target=\"lamhelp\">" . _("Help") . "</a></td></tr>\n");
|
||||
echo ("</table>\n");
|
||||
|
||||
echo ("<p></p>\n");
|
||||
echo ("<tr><td colspan=3> </td></tr>\n");
|
||||
|
||||
echo ("<table border=0>\n");
|
||||
// new password
|
||||
echo ("<tr><td bgcolor=\"red\" align=\"right\"><b>".
|
||||
_("New Password") . ": </b></td>".
|
||||
"<td bgcolor=\"red\" align=\"left\"><input type=\"password\" name=\"passwd1\"></td>\n");
|
||||
echo ("<tr><td align=\"right\"><font color=\"red\"><b>".
|
||||
_("New Password") . ": </b></font></td>".
|
||||
"<td align=\"left\"><input type=\"password\" name=\"passwd1\"></td>\n");
|
||||
echo ("<td rowspan=2><a href=\"../help.php?HelpNumber=212\" target=\"lamhelp\">" . _("Help") . "</a></td></tr>\n");
|
||||
// reenter password
|
||||
echo ("<tr><td bgcolor=\"red\" align=\"right\"><b>".
|
||||
_("Reenter Password") . ": </b></td>".
|
||||
"<td bgcolor=\"red\" align=\"left\"><input type=\"password\" name=\"passwd2\"></td></tr>\n");
|
||||
echo ("<tr><td align=\"right\"><font color=\"red\"><b>".
|
||||
_("Reenter Password") . ": </b></font></td>".
|
||||
"<td align=\"left\"><input type=\"password\" name=\"passwd2\"></td></tr>\n");
|
||||
echo ("</table>\n");
|
||||
echo ("</fieldset>\n");
|
||||
echo ("<p></p>\n");
|
||||
|
@ -385,7 +452,12 @@ echo ("<p>*** = ". _("required for Samba 3 accounts") . "</p>");
|
|||
echo ("<p><input type=\"hidden\" name=\"passwd\" value=\"" . $passwd . "\"></p>\n");
|
||||
|
||||
// config file
|
||||
echo ("<p><input type=\"hidden\" name=\"filename\" value=\"" . $_POST['filename'] . "\"></p>\n");
|
||||
echo ("<p><input type=\"hidden\" name=\"filename\" value=\"" . $filename . "\"></p>\n");
|
||||
|
||||
// modules
|
||||
echo ("<p><input type=\"hidden\" name=\"usermodules\" value=\"" . implode(",", $conf->get_UserModules()) . "\"></p>\n");
|
||||
echo ("<p><input type=\"hidden\" name=\"groupmodules\" value=\"" . implode(",", $conf->get_GroupModules()) . "\"></p>\n");
|
||||
echo ("<p><input type=\"hidden\" name=\"hostmodules\" value=\"" . implode(",", $conf->get_HostModules()) . "\"></p>\n");
|
||||
|
||||
echo ("</form>\n");
|
||||
echo ("</body>\n");
|
||||
|
|
|
@ -0,0 +1,518 @@
|
|||
<?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
|
||||
|
||||
|
||||
confmodules lets the user select the account modules
|
||||
|
||||
*/
|
||||
include_once ('../../lib/config.inc');
|
||||
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()) {
|
||||
require('conflogin.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// user pressed submit/abort button
|
||||
if ($_POST['submit']) {
|
||||
metarefresh('confmain.php?modulesback=true&moduleschanged=true');
|
||||
}
|
||||
elseif ($_POST['abort']) {
|
||||
metarefresh('confmain.php?modulesback=true');
|
||||
}
|
||||
|
||||
echo $_SESSION['header'];
|
||||
|
||||
echo "<title>" . _("LDAP Account Manager Configuration") . "</title>\n";
|
||||
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
|
||||
echo "</head><body>\n";
|
||||
|
||||
echo ("<p align=\"center\"><a href=\"http://lam.sf.net\" target=\"new_window\">".
|
||||
"<img src=\"../../graphics/banner.jpg\" border=1 alt=\"LDAP Account Manager\"></a></p><hr><br>\n");
|
||||
|
||||
echo ("<form action=\"confmodules.php\" method=\"post\">\n");
|
||||
echo "<p align=\"center\"><big><b>" . _("Module selection") . "</b></big><br><br></p>";
|
||||
|
||||
// module dependencies
|
||||
$user_deps = getUserModuleDependencies();
|
||||
$group_deps = getGroupModuleDependencies();
|
||||
$host_deps = getHostModuleDependencies();
|
||||
|
||||
// user modules
|
||||
$selected_users = array();
|
||||
$selected_users = $_SESSION['conf_usermodules'];
|
||||
$available_users = array();
|
||||
$available_users = getAvailableUserModules();
|
||||
$no_conflicts_user = true;
|
||||
$no_depends_user = true;
|
||||
|
||||
// remove modules from selection
|
||||
if ($_POST['user_selected'] && ($_POST['user_remove'])) {
|
||||
$new_selected_users = array();
|
||||
for ($i = 0; $i < sizeof($selected_users); $i++) {
|
||||
if (! in_array($selected_users[$i], $_POST['user_selected'])) $new_selected_users[] = $selected_users[$i];
|
||||
}
|
||||
$selected_users = $new_selected_users;
|
||||
$_SESSION['conf_usermodules'] = $selected_users;
|
||||
}
|
||||
// add modules to selection
|
||||
elseif ($_POST['user_available'] && ($_POST['user_add'])) {
|
||||
$new_selected_users = $selected_users;
|
||||
for ($i = 0; $i < sizeof($_POST['user_available']); $i++) {
|
||||
if (! in_array($_POST['user_available'][$i], $selected_users)) $new_selected_users[] = $_POST['user_available'][$i];
|
||||
}
|
||||
$selected_users = $new_selected_users;
|
||||
$_SESSION['conf_usermodules'] = $selected_users;
|
||||
}
|
||||
|
||||
// group modules
|
||||
$selected_groups = array();
|
||||
$selected_groups = $_SESSION['conf_groupmodules'];
|
||||
$available_groups = array();
|
||||
$available_groups = getAvailableGroupModules();
|
||||
$no_conflicts_group = true;
|
||||
$no_depends_group = true;
|
||||
|
||||
// remove modules from selection
|
||||
if ($_POST['group_selected'] && ($_POST['group_remove'])) {
|
||||
$new_selected_groups = array();
|
||||
for ($i = 0; $i < sizeof($selected_groups); $i++) {
|
||||
if (! in_array($selected_groups[$i], $_POST['group_selected'])) $new_selected_groups[] = $selected_groups[$i];
|
||||
}
|
||||
$selected_groups = $new_selected_groups;
|
||||
$_SESSION['conf_groupmodules'] = $selected_groups;
|
||||
}
|
||||
// add modules to selection
|
||||
elseif ($_POST['group_available'] && ($_POST['group_add'])) {
|
||||
$new_selected_groups = $selected_groups;
|
||||
for ($i = 0; $i < sizeof($_POST['group_available']); $i++) {
|
||||
if (! in_array($_POST['group_available'][$i], $selected_groups)) $new_selected_groups[] = $_POST['group_available'][$i];
|
||||
}
|
||||
$selected_groups = $new_selected_groups;
|
||||
$_SESSION['conf_groupmodules'] = $selected_groups;
|
||||
}
|
||||
|
||||
// host modules
|
||||
$selected_hosts = array();
|
||||
$selected_hosts = $_SESSION['conf_hostmodules'];
|
||||
$available_hosts = array();
|
||||
$available_hosts = getAvailableHostModules();
|
||||
$no_conflicts_host = true;
|
||||
$no_depends_host = true;
|
||||
|
||||
// remove modules from selection
|
||||
if ($_POST['host_selected'] && ($_POST['host_remove'])) {
|
||||
$new_selected_hosts = array();
|
||||
for ($i = 0; $i < sizeof($selected_hosts); $i++) {
|
||||
if (! in_array($selected_hosts[$i], $_POST['host_selected'])) $new_selected_hosts[] = $selected_hosts[$i];
|
||||
}
|
||||
$selected_hosts = $new_selected_hosts;
|
||||
$_SESSION['conf_hostmodules'] = $selected_hosts;
|
||||
}
|
||||
// add modules to selection
|
||||
elseif ($_POST['host_available'] && ($_POST['host_add'])) {
|
||||
$new_selected_hosts = $selected_hosts;
|
||||
for ($i = 0; $i < sizeof($_POST['host_available']); $i++) {
|
||||
if (! in_array($_POST['host_available'][$i], $selected_hosts)) $new_selected_hosts[] = $_POST['host_available'][$i];
|
||||
}
|
||||
$selected_hosts = $new_selected_hosts;
|
||||
$_SESSION['conf_hostmodules'] = $selected_hosts;
|
||||
}
|
||||
|
||||
// show user modules
|
||||
echo "<fieldset class=\"useredit-bright\"><legend class=\"useredit-bright\"><b>" . _("User modules") . "</b></legend>\n";
|
||||
echo "<table border=0 width=\"100%\">\n";
|
||||
// select boxes
|
||||
echo "<tr>\n";
|
||||
echo "<td> </td>\n";
|
||||
echo "<td>\n";
|
||||
echo "<fieldset class=\"useredit-bright\">\n";
|
||||
echo "<legend class=\"useredit-bright\">" . _("Selected user modules") . "</legend>\n";
|
||||
echo "<select class=\"useredit-bright\" name=\"user_selected[]\" size=5 multiple>\n";
|
||||
for ($i = 0; $i < sizeof($selected_users); $i++) {
|
||||
if (in_array($selected_users[$i], $available_users)) echo "<option>" . $selected_users[$i] . "</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
echo "</fieldset>\n";
|
||||
echo "</td>\n";
|
||||
echo "<td> </td>\n";
|
||||
echo "<td align=\"center\">\n";
|
||||
echo "<p>";
|
||||
echo "<input type=submit value=\"<=\" name=\"user_add\">";
|
||||
echo "<br>";
|
||||
echo "<input type=submit value=\"=>\" name=\"user_remove\">";
|
||||
echo "</p>\n";
|
||||
echo "</td>\n";
|
||||
echo "<td> </td>\n";
|
||||
echo "<td>\n";
|
||||
echo "<fieldset class=\"useredit-bright\">\n";
|
||||
echo "<legend class=\"useredit-bright\">" . _("Available user modules") . "</legend>\n";
|
||||
echo "<select class=\"useredit-bright\" name=\"user_available[]\" size=5 multiple>\n";
|
||||
for ($i = 0; $i < sizeof($available_users); $i++) {
|
||||
if (! in_array($available_users[$i], $selected_users)) echo "<option>" . $available_users[$i] . "</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
echo "</fieldset>\n";
|
||||
echo "</td>\n";
|
||||
echo "<td> </td>\n";
|
||||
echo "</tr>\n";
|
||||
echo "</table>\n";
|
||||
$user_depends = user_depends($selected_users);
|
||||
if ($user_depends != false) {
|
||||
$no_depends_user = false;
|
||||
echo "<p>\n";
|
||||
for ($i = 0; $i < sizeof($user_depends); $i++) {
|
||||
echo "<font color=\"red\"><b>" . _("Unsolved dependency: ") . "</b>" . $user_depends[$i][0] . " (" .
|
||||
$user_depends[$i][1] . ")" . "</font><br>\n";
|
||||
}
|
||||
echo "<p>\n";
|
||||
}
|
||||
$user_conflicts = user_conflicts($selected_users);
|
||||
if ($user_conflicts != false) {
|
||||
$no_conflicts_user = false;
|
||||
echo "<p>\n";
|
||||
for ($i = 0; $i < sizeof($user_conflicts); $i++) {
|
||||
echo "<font color=\"red\"><b>" . _("Conflicting module: ") . "</b>" . $user_conflicts[$i][0] . " (" .
|
||||
$user_conflicts[$i][1] . ")" . "</font><br>\n";
|
||||
}
|
||||
echo "<p>\n";
|
||||
}
|
||||
echo "</fieldset>\n";
|
||||
|
||||
echo "<p></p>\n";
|
||||
|
||||
// show group modules
|
||||
echo "<fieldset class=\"groupedit-bright\"><legend class=\"groupedit-bright\"><b>" . _("Group modules") . "</b></legend>\n";
|
||||
echo "<table border=0 width=\"100%\">\n";
|
||||
// select boxes
|
||||
echo "<tr>\n";
|
||||
echo "<td> </td>\n";
|
||||
echo "<td>\n";
|
||||
echo "<fieldset class=\"groupedit-bright\">\n";
|
||||
echo "<legend class=\"groupedit-bright\">" . _("Selected group modules") . "</legend>\n";
|
||||
echo "<select class=\"groupedit-bright\" name=\"group_selected[]\" size=5 multiple>\n";
|
||||
for ($i = 0; $i < sizeof($selected_groups); $i++) {
|
||||
if (in_array($selected_groups[$i], $available_groups)) echo "<option>" . $selected_groups[$i] . "</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
echo "</fieldset>\n";
|
||||
echo "</td>\n";
|
||||
echo "<td> </td>\n";
|
||||
echo "<td align=\"center\">\n";
|
||||
echo "<p>";
|
||||
echo "<input type=submit value=\"<=\" name=\"group_add\">";
|
||||
echo "<br>";
|
||||
echo "<input type=submit value=\"=>\" name=\"group_remove\">";
|
||||
echo "</p>\n";
|
||||
echo "</td>\n";
|
||||
echo "<td> </td>\n";
|
||||
echo "<td>\n";
|
||||
echo "<fieldset class=\"groupedit-bright\">\n";
|
||||
echo "<legend class=\"groupedit-bright\">" . _("Available group modules") . "</legend>\n";
|
||||
echo "<select class=\"groupedit-bright\" name=\"group_available[]\" size=5 multiple>\n";
|
||||
for ($i = 0; $i < sizeof($available_groups); $i++) {
|
||||
if (! in_array($available_groups[$i], $selected_groups)) echo "<option>" . $available_groups[$i] . "</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
echo "</fieldset>\n";
|
||||
echo "</td>\n";
|
||||
echo "<td> </td>\n";
|
||||
echo "</tr>\n";
|
||||
echo "</table>\n";
|
||||
$group_depends = group_depends($selected_groups);
|
||||
if ($group_depends != false) {
|
||||
$no_depends_group = false;
|
||||
echo "<p>\n";
|
||||
for ($i = 0; $i < sizeof($group_depends); $i++) {
|
||||
echo "<font color=\"red\"><b>" . _("Unsolved dependency: ") . "</b>" . $group_depends[$i][0] . " (" .
|
||||
$group_depends[$i][1] . ")" . "</font><br>\n";
|
||||
}
|
||||
echo "<p>\n";
|
||||
}
|
||||
$group_conflicts = group_conflicts($selected_groups);
|
||||
if ($group_conflicts != false) {
|
||||
$no_conflicts_group = false;
|
||||
echo "<p>\n";
|
||||
for ($i = 0; $i < sizeof($group_conflicts); $i++) {
|
||||
echo "<font color=\"red\"><b>" . _("Conflicting module: ") . "</b>" . $group_conflicts[$i][0] . " (" .
|
||||
$group_conflicts[$i][1] . ")" . "</font><br>\n";
|
||||
}
|
||||
echo "<p>\n";
|
||||
}
|
||||
echo "</fieldset>\n";
|
||||
|
||||
echo "<p></p>\n";
|
||||
|
||||
// show host modules
|
||||
echo "<fieldset class=\"hostedit-bright\"><legend class=\"hostedit-bright\"><b>" . _("Host modules") . "</b></legend>\n";
|
||||
echo "<table border=0 width=\"100%\">\n";
|
||||
// select boxes
|
||||
echo "<tr>\n";
|
||||
echo "<td> </td>\n";
|
||||
echo "<td>\n";
|
||||
echo "<fieldset class=\"hostedit-bright\">\n";
|
||||
echo "<legend class=\"hostedit-bright\">" . _("Selected host modules") . "</legend>\n";
|
||||
echo "<select class=\"hostedit-bright\" name=\"host_selected[]\" size=5 multiple>\n";
|
||||
for ($i = 0; $i < sizeof($selected_hosts); $i++) {
|
||||
if (in_array($selected_hosts[$i], $available_hosts)) echo "<option>" . $selected_hosts[$i] . "</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
echo "</fieldset>\n";
|
||||
echo "</td>\n";
|
||||
echo "<td> </td>\n";
|
||||
echo "<td align=\"center\">\n";
|
||||
echo "<p>";
|
||||
echo "<input type=submit value=\"<=\" name=\"host_add\">";
|
||||
echo "<br>";
|
||||
echo "<input type=submit value=\"=>\" name=\"host_remove\">";
|
||||
echo "</p>\n";
|
||||
echo "</td>\n";
|
||||
echo "<td> </td>\n";
|
||||
echo "<td>\n";
|
||||
echo "<fieldset class=\"hostedit-bright\">\n";
|
||||
echo "<legend class=\"hostedit-bright\">" . _("Available host modules") . "</legend>\n";
|
||||
echo "<select class=\"hostedit-bright\" name=\"host_available[]\" size=5 multiple>\n";
|
||||
for ($i = 0; $i < sizeof($available_hosts); $i++) {
|
||||
if (! in_array($available_hosts[$i], $selected_hosts)) echo "<option>" . $available_hosts[$i] . "</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
echo "</fieldset>\n";
|
||||
echo "</td>\n";
|
||||
echo "<td> </td>\n";
|
||||
echo "</tr>\n";
|
||||
echo "</table>\n";
|
||||
$host_depends = host_depends($selected_hosts);
|
||||
if ($host_depends != false) {
|
||||
$no_depends_host = false;
|
||||
echo "<p>\n";
|
||||
for ($i = 0; $i < sizeof($host_depends); $i++) {
|
||||
echo "<font color=\"red\"><b>" . _("Unsolved dependency: ") . "</b>" . $host_depends[$i][0] . " (" .
|
||||
$host_depends[$i][1] . ")" . "</font><br>\n";
|
||||
}
|
||||
echo "<p>\n";
|
||||
}
|
||||
$host_conflicts = host_conflicts($selected_hosts);
|
||||
if ($host_conflicts != false) {
|
||||
$no_conflicts_host = false;
|
||||
echo "<p>\n";
|
||||
for ($i = 0; $i < sizeof($host_conflicts); $i++) {
|
||||
echo "<font color=\"red\"><b>" . _("Conflicting module: ") . "</b>" . $host_conflicts[$i][0] . " (" .
|
||||
$host_conflicts[$i][1] . ")" . "</font><br>\n";
|
||||
}
|
||||
echo "<p>\n";
|
||||
}
|
||||
echo "</fieldset>\n";
|
||||
|
||||
// submit buttons
|
||||
echo "<p>\n";
|
||||
// disable button if there are conflicts/depends
|
||||
if ($no_conflicts_user && $no_conflicts_group && $no_conflicts_host && $no_depends_user && $no_depends_group && $no_depends_host) {
|
||||
echo "<input type=\"submit\" value=\"Submit\" name=\"submit\">\n";
|
||||
}
|
||||
else {
|
||||
echo "<input type=\"submit\" value=\"Submit\" name=\"submit\" disabled>\n";
|
||||
}
|
||||
echo " ";
|
||||
echo "<input type=\"submit\" value=\"Abort\" name=\"abort\">\n";
|
||||
echo "</p>\n";
|
||||
|
||||
echo "</form>\n";
|
||||
echo "</body>\n";
|
||||
echo "</html>\n";
|
||||
|
||||
// checks if there are missing dependencies between user modules
|
||||
// $selected is an array of selected module names
|
||||
// returns false if no misssing dependency was found
|
||||
// returns an array of array(selected module, depending module) if missing dependencies were found
|
||||
function user_depends($selected) {
|
||||
global $user_deps;
|
||||
$ret = array();
|
||||
for ($m = 0; $m < sizeof($selected); $m++) {
|
||||
for ($i = 0; $i < sizeof($user_deps[$selected[$m]]['depends']); $i++) {
|
||||
// check if we have OR-combined modules
|
||||
if (is_array($user_deps[$selected[$m]]['depends'][$i])) {
|
||||
// one of the elements is needed
|
||||
$found = false;
|
||||
$depends = $user_deps[$selected[$m]]['depends'][$i];
|
||||
for ($d = 0; $d < sizeof($depends); $d++) {
|
||||
if (in_array($depends[$d], $selected)) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (! $found) {
|
||||
$ret[] = array($selected[$m], implode(" || ", $depends));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// single dependency
|
||||
if (! in_array($user_deps[$selected[$m]]['depends'][$i], $selected)) {
|
||||
$ret[] = array($selected[$m], $user_deps[$selected[$m]]['depends'][$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sizeof($ret) > 0) return $ret;
|
||||
else return false;
|
||||
}
|
||||
|
||||
// checks if there are conflicts between user modules
|
||||
// $selected is an array of selected module names
|
||||
// returns false if no conflict was found
|
||||
// returns an array of array(selected module, conflicting module) if conflicts were found
|
||||
function user_conflicts($selected) {
|
||||
global $user_deps;
|
||||
$ret = array();
|
||||
for ($m = 0; $m < sizeof($selected); $m++) {
|
||||
for ($i = 0; $i < sizeof($user_deps[$selected[$m]]['conflicts']); $i++) {
|
||||
if (in_array($user_deps[$selected[$m]]['conflicts'][$i], $selected)) {
|
||||
$ret[] = array($selected[$m], $user_deps[$selected[$m]]['conflicts'][$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sizeof($ret) > 0) return $ret;
|
||||
else return false;
|
||||
}
|
||||
|
||||
// checks if there are missing dependencies between group modules
|
||||
// $selected is an array of selected module names
|
||||
// returns false if no misssing dependency was found
|
||||
// returns an array of array(selected module, depending module) if missing dependencies were found
|
||||
function group_depends($selected) {
|
||||
global $group_deps;
|
||||
$ret = array();
|
||||
for ($m = 0; $m < sizeof($selected); $m++) {
|
||||
for ($i = 0; $i < sizeof($group_deps[$selected[$m]]['depends']); $i++) {
|
||||
// check if we have OR-combined modules
|
||||
if (is_array($group_deps[$selected[$m]]['depends'][$i])) {
|
||||
// one of the elements is needed
|
||||
$found = false;
|
||||
$depends = $group_deps[$selected[$m]]['depends'][$i];
|
||||
for ($d = 0; $d < sizeof($depends); $d++) {
|
||||
if (in_array($depends[$d], $selected)) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (! $found) {
|
||||
$ret[] = array($selected[$m], implode(" || ", $depends));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// single dependency
|
||||
if (! in_array($group_deps[$selected[$m]]['depends'][$i], $selected)) {
|
||||
$ret[] = array($selected[$m], $group_deps[$selected[$m]]['depends'][$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sizeof($ret) > 0) return $ret;
|
||||
else return false;
|
||||
}
|
||||
|
||||
// checks if there are conflicts between group modules
|
||||
// $selected is an array of selected module names
|
||||
// returns false if no conflict was found
|
||||
// returns an array of array(selected module, conflicting module) if conflicts were found
|
||||
function group_conflicts($selected) {
|
||||
global $group_deps;
|
||||
$ret = array();
|
||||
for ($m = 0; $m < sizeof($selected); $m++) {
|
||||
for ($i = 0; $i < sizeof($group_deps[$selected[$m]]['conflicts']); $i++) {
|
||||
if (in_array($group_deps[$selected[$m]]['conflicts'][$i], $selected)) {
|
||||
$ret[] = array($selected[$m], $group_deps[$selected[$m]]['conflicts'][$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sizeof($ret) > 0) return $ret;
|
||||
else return false;
|
||||
}
|
||||
|
||||
// checks if there are missing dependencies between host modules
|
||||
// $selected is an array of selected module names
|
||||
// returns false if no misssing dependency was found
|
||||
// returns an array of array(selected module, depending module) if missing dependencies were found
|
||||
function host_depends($selected) {
|
||||
global $host_deps;
|
||||
$ret = array();
|
||||
for ($m = 0; $m < sizeof($selected); $m++) {
|
||||
for ($i = 0; $i < sizeof($host_deps[$selected[$m]]['depends']); $i++) {
|
||||
// check if we have OR-combined modules
|
||||
if (is_array($host_deps[$selected[$m]]['depends'][$i])) {
|
||||
// one of the elements is needed
|
||||
$found = false;
|
||||
$depends = $host_deps[$selected[$m]]['depends'][$i];
|
||||
for ($d = 0; $d < sizeof($depends); $d++) {
|
||||
if (in_array($depends[$d], $selected)) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (! $found) {
|
||||
$ret[] = array($selected[$m], implode(" || ", $depends));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// single dependency
|
||||
if (! in_array($host_deps[$selected[$m]]['depends'][$i], $selected)) {
|
||||
$ret[] = array($selected[$m], $host_deps[$selected[$m]]['depends'][$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sizeof($ret) > 0) return $ret;
|
||||
else return false;
|
||||
}
|
||||
|
||||
// checks if there are conflicts between host modules
|
||||
// $selected is an array of selected module names
|
||||
// returns false if no conflict was found
|
||||
// returns an array of array(selected module, conflicting module) if conflicts were found
|
||||
function host_conflicts($selected) {
|
||||
global $host_deps;
|
||||
$ret = array();
|
||||
for ($m = 0; $m < sizeof($selected); $m++) {
|
||||
for ($i = 0; $i < sizeof($host_deps[$selected[$m]]['conflicts']); $i++) {
|
||||
if (in_array($host_deps[$selected[$m]]['conflicts'][$i], $selected)) {
|
||||
$ret[] = array($selected[$m], $host_deps[$selected[$m]]['conflicts'][$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sizeof($ret) > 0) return $ret;
|
||||
else return false;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
|
@ -201,6 +201,24 @@ if (!$conf->set_pdftext($pdftext)) {
|
|||
exit;
|
||||
}
|
||||
|
||||
if (! $conf->set_UserModules($_SESSION['conf_usermodules'])) {
|
||||
echo ("<font color=\"red\"><b>" . _("Saving user modules failed!") . "</b></font>");
|
||||
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (! $conf->set_GroupModules($_SESSION['conf_groupmodules'])) {
|
||||
echo ("<font color=\"red\"><b>" . _("Saving group modules failed!") . "</b></font>");
|
||||
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (! $conf->set_HostModules($_SESSION['conf_hostmodules'])) {
|
||||
echo ("<font color=\"red\"><b>" . _("Saving host modules failed!") . "</b></font>");
|
||||
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// check if password was changed
|
||||
if ($passwd1) {
|
||||
|
@ -251,5 +269,8 @@ unset($_SESSION['conf_samba3']);
|
|||
unset($_SESSION['conf_pwdhash']);
|
||||
unset($_SESSION['conf_pdf_usertext']);
|
||||
unset($_SESSION['conf_filename']);
|
||||
unset($_SESSION['conf_usermodules']);
|
||||
unset($_SESSION['conf_groupmodules']);
|
||||
unset($_SESSION['conf_hostmodules']);
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue