From a32c4a106bc709f365186f07ea403118ef6b60c4 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 3 Apr 2004 14:47:33 +0000 Subject: [PATCH] made get_profileOptions() non-static --- lam/lib/modules.inc | 49 ++++++++++++--------------- lam/lib/modules/account.inc | 4 +-- lam/lib/modules/inetOrgPerson.inc | 4 +-- lam/lib/modules/main.inc | 4 +++ lam/lib/modules/posixAccount.inc | 2 +- lam/lib/modules/posixGroup.inc | 2 +- lam/lib/modules/quota.inc | 2 +- lam/lib/modules/sambaAccount.inc | 2 +- lam/lib/modules/sambaGroupMapping.inc | 2 +- lam/lib/modules/sambaSamAccount.inc | 2 +- lam/lib/modules/shadowAccount.inc | 2 +- 11 files changed, 36 insertions(+), 39 deletions(-) diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 2ef8d89c..aabc6dbe 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -24,6 +24,8 @@ $Id$ */ +include_once("cache.inc"); + /* We have to include all modules * before start session */ @@ -165,15 +167,14 @@ function getAvailableModules($scope) { // $scope = user, group, host, ... function getProfileOptions($scope) { - // get module names. - $dir = opendir('../../lib/modules'); - while ($entry = readdir($dir)) - if (is_file('../../lib/modules/'.$entry)) { - $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; + // create new account container if needed + if (! isset($_SESSION["profile_account_$scope"])) { + $_SESSION["profile_account_$scope"] = new accountContainer($scope, "profile_account_$scope"); + $_SESSION["profile_account_$scope"]->new_account(); } + // get options + return $_SESSION["profile_account_$scope"]->getProfileOptions(); +} // checks if the profile options are valid // $scope: user, group, host, ... @@ -224,7 +225,7 @@ class accountContainer { /* This variale stores the type * 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 $config; // This is a reference to the config class in session // Localized part of HTML-Header @@ -701,25 +702,17 @@ class accountContainer { return 0; } - // TODO function can be removed? - function display_profile($post) { + /** + * Returns an hash array containing all profile options + */ + function getProfileOptions() { $return = array(); - $post = array(); - $module = array_keys ($this->module); - foreach ($module as $singlemodule) { - // 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; + $modules = array_keys($this->module); + foreach ($modules as $singlemodule) { + $return[$singlemodule] = $this->module[$singlemodule]->get_profileOptions(); } + return $return; + } // TODO remove this function? function proccess_profile($post) { @@ -742,8 +735,8 @@ class accountContainer { * for a new account */ function new_account() { - $function = '$modules = $_SESSION[$this->config]->get_'.ucfirst($this->type).'Modules();'; - eval ($function); + $temp = ucfirst($this->type); + $modules = call_user_func(array(&$_SESSION['config'], 'get_' . $temp . 'Modules')); foreach ($modules as $module) $this->module[$module] = new $module($this->base); $module = array_keys ($this->module); diff --git a/lam/lib/modules/account.inc b/lam/lib/modules/account.inc index 9e601836..a231c52b 100644 --- a/lam/lib/modules/account.inc +++ b/lam/lib/modules/account.inc @@ -198,8 +198,8 @@ class account { return 0; } - function get_profileOptions($scope) { - if ($scope == "host") return array(); + function get_profileOptions() { + return array(); } // checks if the values of a new or modified profile are valid diff --git a/lam/lib/modules/inetOrgPerson.inc b/lam/lib/modules/inetOrgPerson.inc index b5afcbc0..3c3c0d7f 100644 --- a/lam/lib/modules/inetOrgPerson.inc +++ b/lam/lib/modules/inetOrgPerson.inc @@ -303,8 +303,8 @@ class inetOrgPerson { return 0; } - function get_profileOptions($scope) { - if ($scope == "user") return array(); + function get_profileOptions() { + return array(); } // checks if the values of a new or modified profile are valid diff --git a/lam/lib/modules/main.inc b/lam/lib/modules/main.inc index 2a6c1590..7d7530c3 100644 --- a/lam/lib/modules/main.inc +++ b/lam/lib/modules/main.inc @@ -286,6 +286,10 @@ class main { return $return; } + function get_profileOptions() { + return array(); + } + } ?> diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index edc736bd..2faf59d0 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -669,7 +669,7 @@ class posixAccount { } - function get_profileOptions($scope) { + function get_profileOptions() { $return = array(); // TODO fill in correct groups $return[] = array (0 => array ('kind' => 'text', 'text' => _('Primary group')), diff --git a/lam/lib/modules/posixGroup.inc b/lam/lib/modules/posixGroup.inc index ab400914..09f6ff32 100644 --- a/lam/lib/modules/posixGroup.inc +++ b/lam/lib/modules/posixGroup.inc @@ -585,7 +585,7 @@ class posixGroup { return $return; } - function get_profileOptions($scope) { + function get_profileOptions() { $return = array(); $return[] = array (0 => array ( 'kind' => 'text', 'text' => _("Groupname")), 1 => array ('kind' => 'input', 'name' => 'cn', 'type' => 'text', 'size' => '20', 'maxlength' => '20'), diff --git a/lam/lib/modules/quota.inc b/lam/lib/modules/quota.inc index f823b95e..0f73eea8 100644 --- a/lam/lib/modules/quota.inc +++ b/lam/lib/modules/quota.inc @@ -293,7 +293,7 @@ class quota { return 0; } - function get_profileOptions($scope) { + function get_profileOptions() { $return = array(); return $return; } diff --git a/lam/lib/modules/sambaAccount.inc b/lam/lib/modules/sambaAccount.inc index 17620b5b..e50dd538 100644 --- a/lam/lib/modules/sambaAccount.inc +++ b/lam/lib/modules/sambaAccount.inc @@ -606,7 +606,7 @@ class sambaAccount { return $return; } - function get_profileOptions($scope) { + function get_profileOptions() { $return = array(); $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]), diff --git a/lam/lib/modules/sambaGroupMapping.inc b/lam/lib/modules/sambaGroupMapping.inc index 4bb0d8a2..377d7982 100644 --- a/lam/lib/modules/sambaGroupMapping.inc +++ b/lam/lib/modules/sambaGroupMapping.inc @@ -305,7 +305,7 @@ class sambaGroupMapping { return 0; } - function get_profileOptions($scope) { + function get_profileOptions() { $return = array(); // TODO fill in correct domains $return[] = array (0 => array ('kind' => 'text', 'text' => _('Domain')), diff --git a/lam/lib/modules/sambaSamAccount.inc b/lam/lib/modules/sambaSamAccount.inc index ead01b99..34dc2bbd 100644 --- a/lam/lib/modules/sambaSamAccount.inc +++ b/lam/lib/modules/sambaSamAccount.inc @@ -621,7 +621,7 @@ class sambaSamAccount { return $return; } - function get_profileOptions($scope) { + function get_profileOptions() { $return = array(); // TODO fill in correct groups $return[] = array(0 => array('kind' => 'text', 'text' => _('Domain')), diff --git a/lam/lib/modules/shadowAccount.inc b/lam/lib/modules/shadowAccount.inc index a6735587..e2094eee 100644 --- a/lam/lib/modules/shadowAccount.inc +++ b/lam/lib/modules/shadowAccount.inc @@ -256,7 +256,7 @@ class shadowAccount { return 0; } - function get_profileOptions($scope) { + function get_profileOptions() { $return = array(); $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] ),