made get_profileOptions() non-static

This commit is contained in:
Roland Gruber 2004-04-03 14:47:33 +00:00
parent f988f4726d
commit a32c4a106b
11 changed files with 36 additions and 39 deletions

View File

@ -24,6 +24,8 @@ $Id$
*/ */
include_once("cache.inc");
/* We have to include all modules /* We have to include all modules
* before start session * before start session
*/ */
@ -165,15 +167,14 @@ function getAvailableModules($scope) {
// $scope = user, group, host, ... // $scope = user, group, host, ...
function getProfileOptions($scope) { function getProfileOptions($scope) {
// get module names. // create new account container if needed
$dir = opendir('../../lib/modules'); if (! isset($_SESSION["profile_account_$scope"])) {
while ($entry = readdir($dir)) $_SESSION["profile_account_$scope"] = new accountContainer($scope, "profile_account_$scope");
if (is_file('../../lib/modules/'.$entry)) { $_SESSION["profile_account_$scope"]->new_account();
$entry = substr($entry, 0, strpos($entry, '.'));
if (call_user_func(array($entry, "can_manage"), $scope)) $return[$entry] = call_user_func(array($entry, "get_profileOptions"), $scope);
}
return $return;
} }
// get options
return $_SESSION["profile_account_$scope"]->getProfileOptions();
}
// checks if the profile options are valid // checks if the profile options are valid
// $scope: user, group, host, ... // $scope: user, group, host, ...
@ -224,7 +225,7 @@ class accountContainer {
/* This variale stores the type /* This variale stores the type
* of account. Current unix, group, host are supported * of account. Current unix, group, host are supported
*/ */
var $scope; var $type;
var $ldap; // This is a reference to the ldap class in session var $ldap; // This is a reference to the ldap class in session
var $config; // This is a reference to the config class in session var $config; // This is a reference to the config class in session
// Localized part of HTML-Header // Localized part of HTML-Header
@ -701,25 +702,17 @@ class accountContainer {
return 0; return 0;
} }
// TODO function can be removed? /**
function display_profile($post) { * Returns an hash array containing all profile options
*/
function getProfileOptions() {
$return = array(); $return = array();
$post = array(); $modules = array_keys($this->module);
$module = array_keys ($this->module); foreach ($modules as $singlemodule) {
foreach ($module as $singlemodule) { $return[$singlemodule] = $this->module[$singlemodule]->get_profileOptions();
// get list of display functions.
$list = $this->module[$singlemodule]->pages();
foreach ($list as $item) {
$function = 'display_html_' . $item;
$page = $this->module[$singlemodule]->$function($post,true);
//eval($function);
foreach ( $page as $item )
$return[$singlemodule][] = $item;
//$return = array_merge($return, $page);
}
}
return $return;
} }
return $return;
}
// TODO remove this function? // TODO remove this function?
function proccess_profile($post) { function proccess_profile($post) {
@ -742,8 +735,8 @@ class accountContainer {
* for a new account * for a new account
*/ */
function new_account() { function new_account() {
$function = '$modules = $_SESSION[$this->config]->get_'.ucfirst($this->type).'Modules();'; $temp = ucfirst($this->type);
eval ($function); $modules = call_user_func(array(&$_SESSION['config'], 'get_' . $temp . 'Modules'));
foreach ($modules as $module) $this->module[$module] = new $module($this->base); foreach ($modules as $module) $this->module[$module] = new $module($this->base);
$module = array_keys ($this->module); $module = array_keys ($this->module);

View File

@ -198,8 +198,8 @@ class account {
return 0; return 0;
} }
function get_profileOptions($scope) { function get_profileOptions() {
if ($scope == "host") return array(); return array();
} }
// checks if the values of a new or modified profile are valid // checks if the values of a new or modified profile are valid

View File

@ -303,8 +303,8 @@ class inetOrgPerson {
return 0; return 0;
} }
function get_profileOptions($scope) { function get_profileOptions() {
if ($scope == "user") return array(); return array();
} }
// checks if the values of a new or modified profile are valid // checks if the values of a new or modified profile are valid

View File

@ -286,6 +286,10 @@ class main {
return $return; return $return;
} }
function get_profileOptions() {
return array();
}
} }
?> ?>

View File

@ -669,7 +669,7 @@ class posixAccount {
} }
function get_profileOptions($scope) { function get_profileOptions() {
$return = array(); $return = array();
// TODO fill in correct groups // TODO fill in correct groups
$return[] = array (0 => array ('kind' => 'text', 'text' => _('Primary group')), $return[] = array (0 => array ('kind' => 'text', 'text' => _('Primary group')),

View File

@ -585,7 +585,7 @@ class posixGroup {
return $return; return $return;
} }
function get_profileOptions($scope) { function get_profileOptions() {
$return = array(); $return = array();
$return[] = array (0 => array ( 'kind' => 'text', 'text' => _("Groupname")), $return[] = array (0 => array ( 'kind' => 'text', 'text' => _("Groupname")),
1 => array ('kind' => 'input', 'name' => 'cn', 'type' => 'text', 'size' => '20', 'maxlength' => '20'), 1 => array ('kind' => 'input', 'name' => 'cn', 'type' => 'text', 'size' => '20', 'maxlength' => '20'),

View File

@ -293,7 +293,7 @@ class quota {
return 0; return 0;
} }
function get_profileOptions($scope) { function get_profileOptions() {
$return = array(); $return = array();
return $return; return $return;
} }

View File

@ -606,7 +606,7 @@ class sambaAccount {
return $return; return $return;
} }
function get_profileOptions($scope) { function get_profileOptions() {
$return = array(); $return = array();
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ), $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ),
1 => array ( 'kind' => 'input', 'type' => 'text', 'name' => 'domain', 'size' => '20', 'maxlength' => '255', 'value' => $this->attributes['domain'][0]), 1 => array ( 'kind' => 'input', 'type' => 'text', 'name' => 'domain', 'size' => '20', 'maxlength' => '255', 'value' => $this->attributes['domain'][0]),

View File

@ -305,7 +305,7 @@ class sambaGroupMapping {
return 0; return 0;
} }
function get_profileOptions($scope) { function get_profileOptions() {
$return = array(); $return = array();
// TODO fill in correct domains // TODO fill in correct domains
$return[] = array (0 => array ('kind' => 'text', 'text' => _('Domain')), $return[] = array (0 => array ('kind' => 'text', 'text' => _('Domain')),

View File

@ -621,7 +621,7 @@ class sambaSamAccount {
return $return; return $return;
} }
function get_profileOptions($scope) { function get_profileOptions() {
$return = array(); $return = array();
// TODO fill in correct groups // TODO fill in correct groups
$return[] = array(0 => array('kind' => 'text', 'text' => _('Domain')), $return[] = array(0 => array('kind' => 'text', 'text' => _('Domain')),

View File

@ -256,7 +256,7 @@ class shadowAccount {
return 0; return 0;
} }
function get_profileOptions($scope) { function get_profileOptions() {
$return = array(); $return = array();
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Password warn') ), $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Password warn') ),
1 => array ( 'kind' => 'input', 'name' => 'shadowWarning', 'type' => 'text', 'size' => '4', 'maxlength' => '4', 'value' => $this->attributes['shadowWarning'][0] ), 1 => array ( 'kind' => 'input', 'name' => 'shadowWarning', 'type' => 'text', 'size' => '4', 'maxlength' => '4', 'value' => $this->attributes['shadowWarning'][0] ),