all modules now extend the baseModule,

implemented meta data for is_base_module()
This commit is contained in:
Roland Gruber 2004-06-08 18:54:37 +00:00
parent 8a6f8c3f64
commit c26001c37d
11 changed files with 90 additions and 67 deletions

View File

@ -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();

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {