diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 745d8502..9f91b3cc 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -26,6 +26,8 @@ $Id$ include_once("cache.inc"); include_once("account.inc"); +/** parent class of account modules */ +include_once("baseModule.inc"); /* We have to include all modules * before start session @@ -57,7 +59,8 @@ function getModuleAlias($name, $scope) { // $name: the module name // $scope: the account type ("user", "group", "host") function is_base_module($name, $scope) { - return call_user_func(array($name, "is_base_module"), $scope); + $module = new $name($scope); + return $module->is_base_module(); } // returns a LDAP filter used by the account lists @@ -235,7 +238,8 @@ class accountContainer { $this->config = 'config'; $this->cache = 'cache'; $this->header2 = 'header'; - $this->module['main'] = new main($this->base); + $this->module['main'] = new main($this->type); + $this->module['main']->init($this->base); // create cache if needed if (!isset($_SESSION['cache'])) { $_SESSION['cache'] = new cache(); @@ -699,7 +703,10 @@ class accountContainer { $attr = ldap_get_attributes($_SESSION[$this->ldap]->server(), $entry); foreach ($modules as $module) { - if (!isset($this->module[$module])) $this->module[$module] = new $module($this->base); + if (!isset($this->module[$module])) { + $this->module[$module] = new $module($this->type); + $this->module[$module]->init($this->base); + } $this->module[$module]->load_attributes($attr); } @@ -762,7 +769,10 @@ class accountContainer { function new_account() { $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); + foreach ($modules as $module) { + $this->module[$module] = new $module($this->type); + $this->module[$module]->init($this->base); + } $module = array_keys ($this->module); $modulelist = array(); diff --git a/lam/lib/modules/account.inc b/lam/lib/modules/account.inc index 8064ae85..ada2e4a4 100644 --- a/lam/lib/modules/account.inc +++ b/lam/lib/modules/account.inc @@ -37,9 +37,9 @@ $Id$ * */ -class account { +class account extends baseModule { // Constructor - function account($base) { + function init($base) { // Get local copy of name of account_container in session $this->base = $base; // Do some error checks @@ -72,10 +72,6 @@ class account { else return false; } - function is_base_module($scope) { - return false; - } - /* This function returns a list with all required modules */ function get_dependencies($scope) { diff --git a/lam/lib/modules/inetOrgPerson.inc b/lam/lib/modules/inetOrgPerson.inc index 3106556b..e4bb81fc 100644 --- a/lam/lib/modules/inetOrgPerson.inc +++ b/lam/lib/modules/inetOrgPerson.inc @@ -36,9 +36,9 @@ $Id$ * $base is the name of account_container in session */ -class inetOrgPerson { +class inetOrgPerson extends baseModule { // Constructor - function inetOrgPerson($base) { + function init($base) { // Get local copy of name of account_container in session $this->base = $base; // Do some error checks @@ -75,10 +75,6 @@ class inetOrgPerson { else return false; } - function is_base_module($scope) { - return false; - } - /* This function returns a list with all required modules */ function get_dependencies($scope) { diff --git a/lam/lib/modules/main.inc b/lam/lib/modules/main.inc index 50e03fe2..76746000 100644 --- a/lam/lib/modules/main.inc +++ b/lam/lib/modules/main.inc @@ -43,9 +43,9 @@ $Id$ * ldap functions in this module are only dummy functions * It also chooses which page to show. */ -class main { +class main extends baseModule { // Constructor - function main($base) { + function init($base) { // Set counter to first page $this->current_page = 0; // reset subpage counter @@ -71,10 +71,6 @@ class main { return false; } - function is_base_module($scope) { - return false; - } - /* This function returns a list with all required modules */ function get_dependencies($scope) { diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index 88e129ff..aa48723d 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -52,9 +52,23 @@ $Id$ * type: 'user' or 'host' * 'attributes': this is a list of arrays with all ldap attributes wich are allowed for this account */ -class posixAccount { +class posixAccount extends baseModule { + + /** + * Returns meta data that is interpreted by parent class + * + * @return array array with meta data + */ + function get_metaData() { + $return = array(); + if ($this->get_scope() == "user") { + $return["is_base"] = true; + } + return $return; + } + // Constructor - function posixAccount($base) { + function init($base) { /* Return an error if posixAccount should be created without * base container */ @@ -139,11 +153,6 @@ class posixAccount { else return false; } - function is_base_module($scope) { - if ($scope == "user") return true; - else return false; - } - // returns an LDAP filter for the account lists // $scope: the account type ("user", "group", "host") function get_ldap_filter($scope) { diff --git a/lam/lib/modules/posixGroup.inc b/lam/lib/modules/posixGroup.inc index 90b33caa..40c5762b 100644 --- a/lam/lib/modules/posixGroup.inc +++ b/lam/lib/modules/posixGroup.inc @@ -52,9 +52,23 @@ $Id$ * type: 'user' or 'host' * 'attributes': this is a list of arrays with all ldap attributes wich are allowed for this account */ -class posixGroup { +class posixGroup extends baseModule { + + /** + * Returns meta data that is interpreted by parent class + * + * @return array array with meta data + */ + function get_metaData() { + $return = array(); + if ($this->get_scope() == "group") { + $return["is_base"] = true; + } + return $return; + } + // Constructor - function posixGroup($base) { + function init($base) { /* Return an error if posixGroup should be created without * base container */ @@ -128,10 +142,6 @@ class posixGroup { else return false; } - function is_base_module($scope) { - return true; - } - // returns an LDAP filter for the account lists // $scope: the account type ("user", "group", "host") function get_ldap_filter($scope) { diff --git a/lam/lib/modules/quota.inc b/lam/lib/modules/quota.inc index f0931210..1d793f51 100644 --- a/lam/lib/modules/quota.inc +++ b/lam/lib/modules/quota.inc @@ -21,9 +21,9 @@ $Id$ */ -class quota { +class quota extends baseModule { // Constructor - function quota($base) { + function init($base) { $this->base = $base; if (!$base) trigger_error(_('Please create a base object with $var = new accountContainer();'), E_USER_ERROR); if (!is_string($base)) trigger_error(_('Please create a new module in an accountContainer object first.'), E_USER_ERROR); @@ -77,10 +77,6 @@ class quota { else return false; } - function is_base_module($scope) { - return false; - } - /* This function returns a list with all required modules */ function get_dependencies($scope) { diff --git a/lam/lib/modules/sambaAccount.inc b/lam/lib/modules/sambaAccount.inc index 21a98598..4b21cbd8 100644 --- a/lam/lib/modules/sambaAccount.inc +++ b/lam/lib/modules/sambaAccount.inc @@ -52,9 +52,23 @@ $Id$ * type: 'user' or 'host' * 'attributes': this is a list of arrays with all ldap attributes wich are allowed for this account */ -class sambaAccount { +class sambaAccount extends baseModule { + + /** + * Returns meta data that is interpreted by parent class + * + * @return array array with meta data + */ + function get_metaData() { + $return = array(); + if ($this->get_scope() == "host") { + $return["is_base"] = true; + } + return $return; + } + // Constructor - function sambaAccount($base) { + function init($base) { /* Return an error if sambaAccount should be created without * base container */ @@ -132,11 +146,6 @@ class sambaAccount { else return false; } - function is_base_module($scope) { - if ($scope == "host") return true; - else return false; - } - // returns an LDAP filter for the account lists // $scope: the account type ("user", "group", "host") function get_ldap_filter($scope) { diff --git a/lam/lib/modules/sambaGroupMapping.inc b/lam/lib/modules/sambaGroupMapping.inc index ebf110cb..2515335c 100644 --- a/lam/lib/modules/sambaGroupMapping.inc +++ b/lam/lib/modules/sambaGroupMapping.inc @@ -52,9 +52,9 @@ $Id$ * type: 'user' or 'host' * 'attributes': this is a list of arrays with all ldap attributes wich are allowed for this account */ -class sambaGroupMapping { +class sambaGroupMapping extends baseModule { // Constructor - function sambaGroupMapping($base) { + function init($base) { /* Return an error if sambaGroupMapping should be created without * base container */ @@ -102,10 +102,6 @@ class sambaGroupMapping { else return false; } - function is_base_module($scope) { - return false; - } - /* This function returns a list with all required modules */ function get_dependencies($scope) { diff --git a/lam/lib/modules/sambaSamAccount.inc b/lam/lib/modules/sambaSamAccount.inc index 42c82566..ef04b1a4 100644 --- a/lam/lib/modules/sambaSamAccount.inc +++ b/lam/lib/modules/sambaSamAccount.inc @@ -52,9 +52,23 @@ $Id$ * type: 'user' or 'host' * 'attributes': this is a list of arrays with all ldap attributes wich are allowed for this account */ -class sambaSamAccount { +class sambaSamAccount extends baseModule { + + /** + * Returns meta data that is interpreted by parent class + * + * @return array array with meta data + */ + function get_metaData() { + $return = array(); + if ($this->get_scope() == "host") { + $return["is_base"] = true; + } + return $return; + } + // Constructor - function sambaSamAccount($base) { + function init($base) { /* Return an error if sambaSamAccount should be created without * base container */ @@ -132,11 +146,6 @@ class sambaSamAccount { else return false; } - function is_base_module($scope) { - if ($scope == "host") return true; - else return false; - } - // returns an LDAP filter for the account lists // $scope: the account type ("user", "group", "host") function get_ldap_filter($scope) { diff --git a/lam/lib/modules/shadowAccount.inc b/lam/lib/modules/shadowAccount.inc index 21b28487..d3ea154d 100644 --- a/lam/lib/modules/shadowAccount.inc +++ b/lam/lib/modules/shadowAccount.inc @@ -52,9 +52,9 @@ $Id$ * type: 'user' or 'host' * 'attributes': this is a list of arrays with all ldap attributes wich are allowed for this account */ -class shadowAccount { +class shadowAccount extends baseModule { // Constructor - function shadowAccount($base) { + function init($base) { /* Return an error if shadowAccount should be created without * base container */ @@ -96,10 +96,6 @@ class shadowAccount { else return false; } - function is_base_module($scope) { - return false; - } - /* This function returns a list with all required modules */ function get_dependencies($scope) {