From 6ce5f9d1d3c1af28446a20828462a49f1c1c6599 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Mon, 14 Jun 2004 16:05:36 +0000 Subject: [PATCH] moved get_alias() to baseModule --- lam/docs/modules-specification.htm | 10 +++------- lam/lib/baseModule.inc | 13 +++++++++++++ lam/lib/modules.inc | 13 +++++++++---- lam/lib/modules/account.inc | 5 ++--- lam/lib/modules/inetOrgPerson.inc | 5 ++--- lam/lib/modules/main.inc | 5 ++--- lam/lib/modules/posixAccount.inc | 7 +++---- lam/lib/modules/posixGroup.inc | 7 +++---- lam/lib/modules/quota.inc | 5 ++--- lam/lib/modules/sambaAccount.inc | 6 ++---- lam/lib/modules/sambaGroupMapping.inc | 5 ++--- lam/lib/modules/sambaSamAccount.inc | 7 +++---- lam/lib/modules/shadowAccount.inc | 5 ++--- 13 files changed, 48 insertions(+), 45 deletions(-) diff --git a/lam/docs/modules-specification.htm b/lam/docs/modules-specification.htm index 81fbfba8..d0e8bec6 100644 --- a/lam/docs/modules-specification.htm +++ b/lam/docs/modules-specification.htm @@ -22,9 +22,6 @@ All module classes should extend the baseModule class.

2. Class functions

2.1. Functions that have to work without superior accountContainer

-These functions are called without instanciating an object of the -module class. They must not depend on class variables and are only -allowed to call other static functions.


2.1.1. can_manage

@@ -54,7 +51,7 @@ otherwise false.
function get_alias($scope)
+ style="font-weight: bold;">function get_alias()
@@ -64,9 +61,8 @@ This function returns a more descriptive string than the class name. Alias names are used for the buttons of the account pages and the module selection of the configuration wizard.
Please take care that your alias name is not too long. It may contain -a-z, A-Z, 0-9, -, _ and spaces.
-The $scope parameter defines -the account type ("user", "group", "host" at this time).
+any character but should not include parts that may be interpreted by +the browser (e.g. '<' or '>').

2.1.3. is_base_module*


diff --git a/lam/lib/baseModule.inc b/lam/lib/baseModule.inc index 1cf421d5..ad74a2ee 100644 --- a/lam/lib/baseModule.inc +++ b/lam/lib/baseModule.inc @@ -105,6 +105,19 @@ class baseModule { else return ""; } + /** + * Returns an alias name for the module. + * + * This alias is used in various places instead of the less descriptive class name. + * The alias also has less syntax restrictions and may contain spaces or special characters. + * + * @return string alias name + */ + function get_alias() { + if (isset($this->meta['alias'])) return $this->meta['alias']; + else return get_class($this); + } + // TODO implement missing interface } diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 672d96ca..3ec73731 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -48,11 +48,16 @@ while ($stay<7) { } } -// returns the alias name of a module -// $name: the module name -// $scope: the account type ("user", "group", "host") +/** +* Returns the alias name of a module +* +* @param string $name the module name +* @param string $scope the account type ("user", "group", "host") +* @return string alias name +*/ function getModuleAlias($name, $scope) { - return call_user_func(array($name, "get_alias"), $scope); + $module = new $name($scope); + return $module->get_alias(); } // returns if the module is a base module diff --git a/lam/lib/modules/account.inc b/lam/lib/modules/account.inc index 770e949b..2e6bf754 100644 --- a/lam/lib/modules/account.inc +++ b/lam/lib/modules/account.inc @@ -48,6 +48,8 @@ class account extends baseModule { $return = array(); // manages host accounts $return["account_types"] = array("host"); + // alias name + $return["alias"] = _('Account'); return $return; } @@ -76,9 +78,6 @@ class account extends baseModule { */ var $orig; - function get_alias($scope) { - return _('Account'); - } /* This function returns a list with all required modules */ diff --git a/lam/lib/modules/inetOrgPerson.inc b/lam/lib/modules/inetOrgPerson.inc index d7a24147..e5a602b5 100644 --- a/lam/lib/modules/inetOrgPerson.inc +++ b/lam/lib/modules/inetOrgPerson.inc @@ -47,6 +47,8 @@ class inetOrgPerson extends baseModule { $return = array(); // manages user accounts $return["account_types"] = array("user"); + // alias name + $return["alias"] = _('Personal'); return $return; } @@ -79,9 +81,6 @@ class inetOrgPerson extends baseModule { */ var $orig; - function get_alias($scope) { - return _('Personal'); - } /* This function returns a list with all required modules */ diff --git a/lam/lib/modules/main.inc b/lam/lib/modules/main.inc index 0c5395ca..361b7bbd 100644 --- a/lam/lib/modules/main.inc +++ b/lam/lib/modules/main.inc @@ -54,6 +54,8 @@ class main extends baseModule { $return = array(); // manages no accounts $return["account_types"] = array(); + // alias name + $return["alias"] = _('Main'); return $return; } @@ -76,9 +78,6 @@ class main extends baseModule { // name of accountContainer so we can read other classes in accuontArray var $base; - function get_alias($scope) { - return _('main'); - } /* This function returns a list with all required modules */ diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index 623eddca..9b80e177 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -70,6 +70,8 @@ class posixAccount extends baseModule { // LDAP filter $return["ldap_filter"] = array('or' => "(objectClass=posixAccount)", 'and' => "(!(uid=*$))"); } + // alias name + $return["alias"] = _("Unix"); return $return; } @@ -127,6 +129,7 @@ class posixAccount extends baseModule { var $groups_orig; var $createhomedir; + /* $attribute['userPassword'] can't accessed directly because it's enrcypted * To read / write password function userPassword is needed * This function will return the unencrypted password when @@ -149,10 +152,6 @@ class posixAccount extends baseModule { } } - function get_alias($scope) { - return "Unix"; - } - /* This function returns a list with all required modules */ function get_dependencies($scope) { diff --git a/lam/lib/modules/posixGroup.inc b/lam/lib/modules/posixGroup.inc index 39f1162a..f1ed1e6c 100644 --- a/lam/lib/modules/posixGroup.inc +++ b/lam/lib/modules/posixGroup.inc @@ -69,6 +69,8 @@ class posixGroup extends baseModule { // LDAP filter $return["ldap_filter"] = array('or' => "(objectClass=posixGroup)"); } + // alias name + $return["alias"] = _('Unix'); return $return; } @@ -99,6 +101,7 @@ class posixGroup extends baseModule { $this->changegids=false; } + // Variables // name of accountContainer so we can read other classes in accuontArray var $base; @@ -138,10 +141,6 @@ class posixGroup extends baseModule { } } - function get_alias($scope) { - return _('Unix'); - } - /* This function returns a list with all required modules */ function get_dependencies($scope) { diff --git a/lam/lib/modules/quota.inc b/lam/lib/modules/quota.inc index c4172bd1..b4a0711d 100644 --- a/lam/lib/modules/quota.inc +++ b/lam/lib/modules/quota.inc @@ -32,6 +32,8 @@ class quota extends baseModule { $return = array(); // manages user and group accounts $return["account_types"] = array("user", "group"); + // alias name + $return["alias"] = _('Quota'); return $return; } @@ -80,9 +82,6 @@ class quota extends baseModule { var $quota; - function get_alias($scope) { - return _('Quota'); - } /* This function returns a list with all required modules */ diff --git a/lam/lib/modules/sambaAccount.inc b/lam/lib/modules/sambaAccount.inc index 863a45da..d78e9d40 100644 --- a/lam/lib/modules/sambaAccount.inc +++ b/lam/lib/modules/sambaAccount.inc @@ -69,6 +69,8 @@ class sambaAccount extends baseModule { // LDAP filter $return["ldap_filter"] = array('and' => '(uid=*$)', 'or' => "(objectClass=posixAccount)"); } + // alias name + $return["alias"] = _('Samba 2'); return $return; } @@ -141,10 +143,6 @@ class sambaAccount extends baseModule { } } - function get_alias($scope) { - return _('Samba 2'); - } - /* This function returns a list with all required modules */ function get_dependencies($scope) { diff --git a/lam/lib/modules/sambaGroupMapping.inc b/lam/lib/modules/sambaGroupMapping.inc index aca149c7..e24909ed 100644 --- a/lam/lib/modules/sambaGroupMapping.inc +++ b/lam/lib/modules/sambaGroupMapping.inc @@ -63,6 +63,8 @@ class sambaGroupMapping extends baseModule { $return = array(); // manages group accounts $return["account_types"] = array("group"); + // alias name + $return["alias"] = _('Samba 3'); return $return; } @@ -106,9 +108,6 @@ class sambaGroupMapping extends baseModule { // Array of well known rids var $rids; - function get_alias($scope) { - return _('Samba 3'); - } /* This function returns a list with all required modules */ diff --git a/lam/lib/modules/sambaSamAccount.inc b/lam/lib/modules/sambaSamAccount.inc index 16be44ae..b23d32f7 100644 --- a/lam/lib/modules/sambaSamAccount.inc +++ b/lam/lib/modules/sambaSamAccount.inc @@ -69,6 +69,8 @@ class sambaSamAccount extends baseModule { // LDAP filter $return["ldap_filter"] = array('and' => '(uid=*$)', 'or' => "(objectClass=posixAccount)"); } + // alias name + $return["alias"] = _('Samba 3'); return $return; } @@ -118,6 +120,7 @@ class sambaSamAccount extends baseModule { // Array of well known rids var $rids; + /* $attribute['sambaLMPassword'] and sambaNTPassword can't accessed directly because it's enrcypted * To read / write password function userPassword is needed * This function will return the unencrypted password when @@ -141,10 +144,6 @@ class sambaSamAccount extends baseModule { } } - function get_alias($scope) { - return _('Samba 3'); - } - /* This function returns a list with all required modules */ function get_dependencies($scope) { diff --git a/lam/lib/modules/shadowAccount.inc b/lam/lib/modules/shadowAccount.inc index fd516f57..4f0c9fcd 100644 --- a/lam/lib/modules/shadowAccount.inc +++ b/lam/lib/modules/shadowAccount.inc @@ -63,6 +63,8 @@ class shadowAccount extends baseModule { $return = array(); // manages user accounts $return["account_types"] = array("user"); + // alias name + $return["alias"] = _('Shadow'); return $return; } @@ -100,9 +102,6 @@ class shadowAccount extends baseModule { */ var $orig; - function get_alias($scope) { - return _('Shadow'); - } /* This function returns a list with all required modules */