renamed get/set_UserModules etc. to get_AccountModules($scope)

This commit is contained in:
Roland Gruber 2004-10-17 09:36:36 +00:00
parent e257ffcb5b
commit ec33ddb514
4 changed files with 54 additions and 84 deletions

View File

@ -723,89 +723,59 @@ class Config {
}
/**
* Returns an array of all selected user modules
* Returns an array of all selected account modules
*
* @param string $scope account type
* @return array user modules
*/
function get_UserModules() {
function get_AccountModules($scope) {
switch ($scope) {
case 'user':
return explode(",", $this->usermodules);
}
/**
* Sets the selected user modules
*
* @param array $modules array with module names (not aliases!)
* @return boolean true if $modules has correct format
*/
function set_UserModules($modules) {
if (! is_array($modules)) return false;
// check module names
$available = getAvailableModules('user');
for ($i = 0; $i < sizeof($modules); $i++) {
if (! in_array($modules[$i], $available)) return false;
}
// check depends/conflicts
if (check_module_conflicts($modules, getModulesDependencies('user')) != false) return false;
if (check_module_depends($modules, getModulesDependencies('user')) != false) return false;
$this->usermodules = implode(",", $modules);
return true;
}
/**
* Returns an array of all selected group modules
*
* @return array group modules
*/
function get_GroupModules() {
break;
case 'group':
return explode(",", $this->groupmodules);
}
/**
* Sets the selected group modules
*
* @param array $modules array with module names (not aliases!)
* @return boolean true if $modules has correct format
*/
function set_GroupModules($modules) {
if (! is_array($modules)) return false;
// check module names
$available = getAvailableModules('group');
for ($i = 0; $i < sizeof($modules); $i++) {
if (! in_array($modules[$i], $available)) return false;
}
// check depends/conflicts
if (check_module_conflicts($modules, getModulesDependencies('group')) != false) return false;
if (check_module_depends($modules, getModulesDependencies('group')) != false) return false;
$this->groupmodules = implode(",", $modules);
return true;
}
/**
* Returns an array of all selected host modules
*
* @return array host modules
*/
function get_HostModules() {
break;
case 'host':
return explode(",", $this->hostmodules);
break;
default:
return array();
break;
}
}
/**
* Sets the selected host modules
* Sets the selected account modules
*
* @param array $modules array with module names (not aliases!)
* @param string $scope account type
* @return boolean true if $modules has correct format
*/
function set_HostModules($modules) {
function set_AccountModules($modules, $scope) {
if (! is_array($modules)) return false;
// check module names
$available = getAvailableModules('host');
$available = getAvailableModules($scope);
for ($i = 0; $i < sizeof($modules); $i++) {
if (! in_array($modules[$i], $available)) return false;
}
// check depends/conflicts
if (check_module_conflicts($modules, getModulesDependencies('host')) != false) return false;
if (check_module_depends($modules, getModulesDependencies('host')) != false) return false;
if (check_module_conflicts($modules, getModulesDependencies($scope)) != false) return false;
if (check_module_depends($modules, getModulesDependencies($scope)) != false) return false;
switch ($scope) {
case 'user':
$this->usermodules = implode(",", $modules);
break;
case 'group':
$this->groupmodules = implode(",", $modules);
break;
case 'host':
$this->hostmodules = implode(",", $modules);
break;
default:
break;
}
return true;
}

View File

@ -419,6 +419,7 @@ function buildUploadAccounts($scope, $data, $ids) {
$unOrdered = getAvailableModules($scope);
$ordered = array();
$predepends = array();
// get dependencies
for ($i = 0; $i < sizeof($unOrdered); $i++) {
$mod = new $unOrdered[$i]($scope);
$predepends[$unOrdered[$i]] = $mod->get_uploadPreDepends();
@ -1134,7 +1135,7 @@ class accountContainer {
* $dn is the dn of the account which should be loaded
*/
function load_account($dn) {
$modules = call_user_func(array($_SESSION['config'], 'get_'.ucfirst($this->type).'Modules'));
$modules = $_SESSION['config']->get_AccountModules($this->type);
$search = substr($dn, 0, strpos($dn, ','));
$result = ldap_search($_SESSION['ldap']->server(), $dn, $search);
$entry = ldap_first_entry($_SESSION['ldap']->server(), $result);
@ -1223,8 +1224,7 @@ class accountContainer {
* for a new account
*/
function new_account() {
$temp = ucfirst($this->type);
$modules = call_user_func(array(&$_SESSION['config'], 'get_' . $temp . 'Modules'));
$modules = $_SESSION['config']->get_AccountModules($this->type);
foreach ($modules as $module) {
$this->module[$module] = new $module($this->type);
$this->module[$module]->init($this->base);

View File

@ -131,9 +131,9 @@ if (isset($_GET["modulesback"])) {
$conf->set_scriptserver($_SESSION['conf_scriptserver']);
// 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']);
$conf->set_AccountModules($_SESSION['conf_usermodules'], 'user');
$conf->set_AccountModules($_SESSION['conf_groupmodules'], 'group');
$conf->set_AccountModules($_SESSION['conf_hostmodules'], 'host');
}
}
@ -216,9 +216,9 @@ 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><b>" . _("User modules") . ": </b>" . implode(", ", $conf->get_AccountModules('user')) . "</td></tr>\n";
echo "<tr><td><b>" . _("Group modules") . ": </b>" . implode(", ", $conf->get_AccountModules('group')) . "</td></tr>\n";
echo "<tr><td><b>" . _("Host modules") . ": </b>" . implode(", ", $conf->get_AccountModules('host')) . "</td></tr>\n";
echo "<tr><td>&nbsp;</td></tr>\n";
echo "<tr><td><input tabindex=\"$tabindex\" type=\"submit\" name=\"editmodules\" value=\"" . _("Edit modules") . "\">&nbsp;&nbsp;" .
"<a href=\"../help.php?HelpNumber=217\" target=\"lamhelp\">" . _("Help") . "</a></td></tr>\n";
@ -234,11 +234,11 @@ echo ("<p></p>");
// get list of scopes of modules
$scopes = array();
$mods = $conf->get_UserModules();
$mods = $conf->get_AccountModules('user');
for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = 'user';
$mods = $conf->get_GroupModules();
$mods = $conf->get_AccountModules('group');
for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = 'group';
$mods = $conf->get_HostModules();
$mods = $conf->get_AccountModules('host');
for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = 'host';
// get module options
@ -439,9 +439,9 @@ echo ("<p><input type=\"hidden\" name=\"passwd\" value=\"" . $passwd . "\"></p>\
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 ("<p><input type=\"hidden\" name=\"usermodules\" value=\"" . implode(",", $conf->get_AccountModules('user')) . "\"></p>\n");
echo ("<p><input type=\"hidden\" name=\"groupmodules\" value=\"" . implode(",", $conf->get_AccountModules('group')) . "\"></p>\n");
echo ("<p><input type=\"hidden\" name=\"hostmodules\" value=\"" . implode(",", $conf->get_AccountModules('host')) . "\"></p>\n");
echo ("</form>\n");
echo ("</body>\n");

View File

@ -161,19 +161,19 @@ if (!$conf->set_scriptserver($scriptserver)) {
exit;
}
if (! $conf->set_UserModules($_SESSION['conf_usermodules'])) {
if (! $conf->set_AccountModules($_SESSION['conf_usermodules'], 'user')) {
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'])) {
if (! $conf->set_AccountModules($_SESSION['conf_groupmodules'], 'group')) {
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'])) {
if (! $conf->set_AccountModules($_SESSION['conf_hostmodules'], 'host')) {
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;