moved var $base to baseModule, added init() to baseModule, removed several checks from modules init() function

This commit is contained in:
Roland Gruber 2004-09-01 20:53:06 +00:00
parent 1ea3ab8ca1
commit 0cb64e5f7b
10 changed files with 31 additions and 102 deletions

View File

@ -48,6 +48,9 @@ class baseModule {
/** configuration settings of all modules */ /** configuration settings of all modules */
var $moduleSettings; var $moduleSettings;
/** name of parent accountContainer ($_SESSION[$base]) */
var $base;
/** /**
* Creates a new base module class * Creates a new base module class
* *
@ -59,6 +62,16 @@ class baseModule {
if (isset($_SESSION['config'])) $this->moduleSettings = $_SESSION['config']->get_moduleSettings(); if (isset($_SESSION['config'])) $this->moduleSettings = $_SESSION['config']->get_moduleSettings();
} }
/**
* Initializes the module after it became part of an accountContainer
*
* @param string $base the name of the accountContainer object ($_SESSION[$base])
*/
function init($base) {
$this->base = $base;
}
/** /**
* Dummy function, meta data is provided by sub classes. * Dummy function, meta data is provided by sub classes.
* *

View File

@ -59,12 +59,8 @@ class account extends baseModule {
// Constructor // Constructor
function init($base) { function init($base) {
// Get local copy of name of account_container in session // call parent init
$this->base = $base; parent::init($base);
// Do some error checks
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 object in an accountContainer object first.'), E_USER_ERROR);
if ($_SESSION[$this->base]->get_type() != 'host') trigger_error(_('account can only be used for hosts.'), E_USER_WARNING);
// load attribtues which are used in account objectClass // load attribtues which are used in account objectClass
$this->orig = $_SESSION[$this->base]->get_module_attributes('account'); $this->orig = $_SESSION[$this->base]->get_module_attributes('account');
$this->attributes = $_SESSION[$this->base]->get_module_attributes('account'); $this->attributes = $_SESSION[$this->base]->get_module_attributes('account');
@ -73,8 +69,6 @@ class account extends baseModule {
} }
// Variables // Variables
// name of account_container in session so we can read other classes in account_container
var $base;
// This variable contains all account attributes // This variable contains all account attributes
var $attributes; var $attributes;
/* If an account was loaded all attributes are kept in this array /* If an account was loaded all attributes are kept in this array

View File

@ -111,12 +111,8 @@ class inetOrgPerson extends baseModule {
* @param string $base the name of account_container in session * @param string $base the name of account_container in session
*/ */
function init($base) { function init($base) {
// Get local copy of name of account_container in session // call parent init
$this->base = $base; parent::init($base);
// Do some error checks
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);
if ($_SESSION[$this->base]->type != 'user') trigger_error(_('inetOrgPerson can only be used for users.'), E_USER_WARNING);
// load attribtues which are used in inetOrgPerson objectClass // load attribtues which are used in inetOrgPerson objectClass
// unset attributes which are "must" but not in this module // unset attributes which are "must" but not in this module
// cn will be set to uid in module posixAccount // cn will be set to uid in module posixAccount
@ -129,8 +125,6 @@ class inetOrgPerson extends baseModule {
} }
// Variables // Variables
/** name of account_container in session so we can read other classes in account_container */
var $base;
/** This variable contains all inetOrgPerson attributes */ /** This variable contains all inetOrgPerson attributes */
var $attributes; var $attributes;
/** /**

View File

@ -154,19 +154,8 @@ class posixAccount extends baseModule {
// Constructor // Constructor
function init($base) { function init($base) {
/* Return an error if posixAccount should be created without // call parent init
* base container parent::init($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 object in an accountContainer object first.'), E_USER_ERROR);
$this->base = $base;
// posixAccount is only a valid objectClass for user and host
if (!($_SESSION[$this->base]->get_type() == 'user') && !($_SESSION[$this->base]->get_type() == 'host')) trigger_error(_('posixAccount can only be used for users or hosts.'), E_USER_WARNING);
/* Check if ldap conatiner is in array and set type
* users are using inetOrgPerson-, hosts account-container
*/
if (!isset($_SESSION[$this->base]->module['inetOrgPerson']) && $_SESSION[$this->base]->type=='user') $_SESSION[$this->base]->modules['inetOrgPerson'] = new inetOrgPerson($this->base);
if (!isset($_SESSION[$this->base]->module['account']) && $_SESSION[$this->base]->type=='host') $_SESSION[$this->base]->modules['account'] = new account($this->base);
// Add Array with all attributes and type // Add Array with all attributes and type
$this->orig = $_SESSION[$this->base]->get_module_attributes('posixAccount'); $this->orig = $_SESSION[$this->base]->get_module_attributes('posixAccount');
$this->attributes = $_SESSION[$this->base]->get_module_attributes('posixAccount'); $this->attributes = $_SESSION[$this->base]->get_module_attributes('posixAccount');
@ -186,8 +175,6 @@ class posixAccount extends baseModule {
} }
// Variables // Variables
// name of accountContainer so we can read other classes in accuontArray
var $base;
// Use a unix password? // Use a unix password?
var $userPassword_no; var $userPassword_no;
// Lock account? // Lock account?

View File

@ -169,18 +169,11 @@ class posixGroup extends baseModule {
// Constructor // Constructor
function init($base) { function init($base) {
/* Return an error if posixGroup should be created without // call parent init
* base container parent::init($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 object in an accountContainer object first.'), E_USER_ERROR);
$this->base = $base;
// posixGroup is only a valid objectClass for user and host
if ($_SESSION[$this->base]->get_type() != 'group') trigger_error(_('posixGroup can only be used for groups.'), E_USER_WARNING);
// Add Array with all attributes and type // Add Array with all attributes and type
$this->attributes = $_SESSION[$this->base]->get_module_attributes('posixGroup'); $this->attributes = $_SESSION[$this->base]->get_module_attributes('posixGroup');
$_SESSION[$this->base]->add_attributes ('posixGroup'); $_SESSION[$this->base]->add_attributes ('posixGroup');
$this->alias = _('posixGroup');
// Make references to attributes which already esists in ldap // Make references to attributes which already esists in ldap
$newattributes = array_keys($this->attributes); $newattributes = array_keys($this->attributes);
$module = array_keys($_SESSION[$this->base]->module); $module = array_keys($_SESSION[$this->base]->module);
@ -196,8 +189,6 @@ class posixGroup extends baseModule {
// Variables // Variables
// name of accountContainer so we can read other classes in accuontArray
var $base;
// Use a unix password? // Use a unix password?
var $userPassword_no; var $userPassword_no;
// Lock account? // Lock account?

View File

@ -64,16 +64,8 @@ class quota extends baseModule {
// Constructor // Constructor
function init($base) { function init($base) {
$this->base = $base; // call parent init
if (!$base) trigger_error(_('Please create a base object with $var = new accountContainer();'), E_USER_ERROR); parent::init($base);
if (!is_string($base)) trigger_error(_('Please create a new module in an accountContainer object first.'), E_USER_ERROR);
// quota is only a valid objectClass for user and host
if (!($_SESSION[$this->base]->get_type() == 'user') && !($_SESSION[$this->base]->get_type() == 'group')) trigger_error(_('quota can only be used for users or groups.'), E_USER_WARNING);
/* Check if ldap conatiner is in array and set type
* users are using inetOrgPerson-, hosts account-container
*/
if (!isset($_SESSION[$this->base]->module['posixAccount']) && $_SESSION[$this->base]->type=='user') $_SESSION[$this->base]->modules['posixAccount'] = new posixGroup($this->base);
if (!isset($_SESSION[$this->base]->module['posixGroup']) && $_SESSION[$this->base]->type=='group') $_SESSION[$this->base]->modules['posixGroup'] = new posixGroup($this->base);
// Get basic quotas for new account // Get basic quotas for new account
$output_array = $_SESSION[$this->base]->lamdaemon(array("+ quota get " . $_SESSION[$this->base]->type)); $output_array = $_SESSION[$this->base]->lamdaemon(array("+ quota get " . $_SESSION[$this->base]->type));
// process quotas // process quotas
@ -102,8 +94,6 @@ class quota extends baseModule {
} }
// Variables // Variables
// name of accountContainer so we can read other classes in accuontArray
var $base;
var $quota; var $quota;

View File

@ -180,18 +180,8 @@ class sambaAccount extends baseModule {
// Constructor // Constructor
function init($base) { function init($base) {
/* Return an error if sambaAccount should be created without // call parent init
* base container parent::init($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 object in an accountContainer object first.'), E_USER_ERROR);
$this->base = $base;
// sambaAccount is only a valid objectClass for user and host
if (!($_SESSION[$this->base]->get_type() == 'user') && !($_SESSION[$this->base]->get_type() == 'host')) trigger_error(_('sambaAccount can only be used for users or hosts.'), E_USER_WARNING);
/* Check if ldap conatiner is in array and set type
* users are using inetOrgPerson-, hosts account-container
*/
if (!isset($_SESSION[$this->base]->module['posixAccount'])) $_SESSION[$this->base]->modules['posixAccount'] = new posixAccount($this->base);
// Add Array with all attributes and type // Add Array with all attributes and type
$this->attributes = $_SESSION[$this->base]->get_module_attributes('sambaAccount'); $this->attributes = $_SESSION[$this->base]->get_module_attributes('sambaAccount');
$_SESSION[$this->base]->add_attributes ('sambaAccount'); $_SESSION[$this->base]->add_attributes ('sambaAccount');
@ -211,8 +201,6 @@ class sambaAccount extends baseModule {
} }
// Variables // Variables
// name of accountContainer so we can read other classes in accuontArray
var $base;
// This variable contains all inetOrgPerson attributes // This variable contains all inetOrgPerson attributes
var $attributes; var $attributes;
/* If an account was loaded all attributes are kept in this array /* If an account was loaded all attributes are kept in this array

View File

@ -102,14 +102,8 @@ class sambaGroupMapping extends baseModule {
// Constructor // Constructor
function init($base) { function init($base) {
/* Return an error if sambaGroupMapping should be created without // call parent init
* base container parent::init($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 object in an accountContainer object first.'), E_USER_ERROR);
$this->base = $base;
// sambaGroupMapping is only a valid objectClass for user and host
if ($_SESSION[$this->base]->get_type() != 'group') trigger_error(_('sambaGroupMapping can only be used for groups.'), E_USER_WARNING);
// Add Array with all attributes and type // Add Array with all attributes and type
$this->attributes = $_SESSION[$this->base]->get_module_attributes('sambaGroupMapping'); $this->attributes = $_SESSION[$this->base]->get_module_attributes('sambaGroupMapping');
$_SESSION[$this->base]->add_attributes ('sambaGroupMapping'); $_SESSION[$this->base]->add_attributes ('sambaGroupMapping');
@ -128,8 +122,6 @@ class sambaGroupMapping extends baseModule {
} }
// Variables // Variables
// name of accountContainer so we can read other classes in accuontArray
var $base;
// This variable contains all inetOrgPerson attributes // This variable contains all inetOrgPerson attributes
var $attributes; var $attributes;

View File

@ -113,18 +113,8 @@ class sambaSamAccount extends baseModule {
// Constructor // Constructor
function init($base) { function init($base) {
/* Return an error if sambaSamAccount should be created without // call parent init
* base container parent::init($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 object in an accountContainer object first.'), E_USER_ERROR);
$this->base = $base;
// sambaSamAccount is only a valid objectClass for user and host
if (!($_SESSION[$this->base]->get_type() == 'user') && !($_SESSION[$this->base]->get_type() == 'host')) trigger_error(_('sambaSamAccount can only be used for users or hosts.'), E_USER_WARNING);
/* Check if ldap conatiner is in array and set type
* users are using inetOrgPerson-, hosts account-container
*/
if (!isset($_SESSION[$this->base]->module['posixAccount'])) $_SESSION[$this->base]->modules['posixAccount'] = new posixAccount($this->base);
// Add Array with all attributes and type // Add Array with all attributes and type
$this->attributes = $_SESSION[$this->base]->get_module_attributes('sambaSamAccount'); $this->attributes = $_SESSION[$this->base]->get_module_attributes('sambaSamAccount');
$_SESSION[$this->base]->add_attributes ('sambaSamAccount'); $_SESSION[$this->base]->add_attributes ('sambaSamAccount');
@ -144,8 +134,6 @@ class sambaSamAccount extends baseModule {
} }
// Variables // Variables
// name of accountContainer so we can read other classes in accuontArray
var $base;
// This variable contains all inetOrgPerson attributes // This variable contains all inetOrgPerson attributes
var $attributes; var $attributes;
/* If an account was loaded all attributes are kept in this array /* If an account was loaded all attributes are kept in this array

View File

@ -147,14 +147,8 @@ class shadowAccount extends baseModule {
// Constructor // Constructor
function init($base) { function init($base) {
/* Return an error if shadowAccount should be created without // call parent init
* base container parent::init($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 object in an accountContainer object first.'), E_USER_ERROR);
$this->base = $base;
// shadowAccount is only a valid objectClass for user and host
if (!($_SESSION[$this->base]->get_type() == 'user')) trigger_error(_('shadowAccount can only be used for users.'), E_USER_WARNING);
// Add Array with all attributes and type // Add Array with all attributes and type
$this->attributes = $_SESSION[$this->base]->get_module_attributes('shadowAccount'); $this->attributes = $_SESSION[$this->base]->get_module_attributes('shadowAccount');
$_SESSION[$this->base]->add_attributes ('shadowAccount'); $_SESSION[$this->base]->add_attributes ('shadowAccount');
@ -170,8 +164,6 @@ class shadowAccount extends baseModule {
} }
// Variables // Variables
// name of accountContainer so we can read other classes in accuontArray
var $base;
// This variable contains all inetOrgPerson attributes // This variable contains all inetOrgPerson attributes
var $attributes; var $attributes;
/* If an account was loaded all attributes are kept in this array /* If an account was loaded all attributes are kept in this array