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

View File

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

View File

@ -131,9 +131,9 @@ if (isset($_GET["modulesback"])) {
$conf->set_scriptserver($_SESSION['conf_scriptserver']); $conf->set_scriptserver($_SESSION['conf_scriptserver']);
// check if modules were edited // check if modules were edited
if ($_GET["moduleschanged"] == "true") { if ($_GET["moduleschanged"] == "true") {
$conf->set_UserModules($_SESSION['conf_usermodules']); $conf->set_AccountModules($_SESSION['conf_usermodules'], 'user');
$conf->set_GroupModules($_SESSION['conf_groupmodules']); $conf->set_AccountModules($_SESSION['conf_groupmodules'], 'group');
$conf->set_HostModules($_SESSION['conf_hostmodules']); $conf->set_AccountModules($_SESSION['conf_hostmodules'], 'host');
} }
} }
@ -216,9 +216,9 @@ echo ("<fieldset><legend><b>" . _("Account modules") . "</b></legend>");
echo ("<table border=0>"); echo ("<table border=0>");
// Account modules // Account modules
echo "<tr><td><b>" . _("User modules") . ": </b>" . implode(", ", $conf->get_UserModules()) . "</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_GroupModules()) . "</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_HostModules()) . "</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>&nbsp;</td></tr>\n";
echo "<tr><td><input tabindex=\"$tabindex\" type=\"submit\" name=\"editmodules\" value=\"" . _("Edit modules") . "\">&nbsp;&nbsp;" . 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"; "<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 // get list of scopes of modules
$scopes = array(); $scopes = array();
$mods = $conf->get_UserModules(); $mods = $conf->get_AccountModules('user');
for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = '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'; 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'; for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = 'host';
// get module options // 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"); echo ("<p><input type=\"hidden\" name=\"filename\" value=\"" . $filename . "\"></p>\n");
// modules // modules
echo ("<p><input type=\"hidden\" name=\"usermodules\" value=\"" . implode(",", $conf->get_UserModules()) . "\"></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_GroupModules()) . "\"></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_HostModules()) . "\"></p>\n"); echo ("<p><input type=\"hidden\" name=\"hostmodules\" value=\"" . implode(",", $conf->get_AccountModules('host')) . "\"></p>\n");
echo ("</form>\n"); echo ("</form>\n");
echo ("</body>\n"); echo ("</body>\n");

View File

@ -161,19 +161,19 @@ if (!$conf->set_scriptserver($scriptserver)) {
exit; 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 ("<font color=\"red\"><b>" . _("Saving user modules failed!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>"); echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit; 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 ("<font color=\"red\"><b>" . _("Saving group modules failed!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>"); echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit; 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 ("<font color=\"red\"><b>" . _("Saving host modules failed!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>"); echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit; exit;