diff --git a/lam/docs/modules-specification.htm b/lam/docs/modules-specification.htm
index cd533b51..81fbfba8 100644
--- a/lam/docs/modules-specification.htm
+++ b/lam/docs/modules-specification.htm
@@ -35,17 +35,15 @@ allowed to call other static functions.
function can_manage($scope)
+ style="font-weight: bold;">function can_manage()
|
Returns true if this module
-can manage accounts of type $scope,
+can manage accounts of the current type,
otherwise false.
-The $scope parameter defines
-the account type ("user", "group", "host" at this time).
2.1.2. get_alias
@@ -558,10 +556,17 @@ which should be displayed when this help entry is called.
6. Module meta data
-6.1 is_base_module()
+6.1 can_manage()
+
+ "account_types" => array
+
+ Example:
+array("user", "host")
+
+6.2 is_base_module()
"is_base" => boolean
-6.2 get_ldap_filter()
+6.3 get_ldap_filter()
"ldap_filter" => array
Example:scope;
}
-
+
+ /**
+ * Returns true if this module fits for the current scope.
+ *
+ * @return boolean true if module fits
+ */
+ function can_manage() {
+ if (is_array($this->meta["account_types"]) && in_array($this->scope, $this->meta["account_types"])) return true;
+ else return false;
+ }
+
/**
* Returns true if this module is enough to provide a sensible account.
*
diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc
index e375d426..672d96ca 100644
--- a/lam/lib/modules.inc
+++ b/lam/lib/modules.inc
@@ -164,8 +164,12 @@ function check_module_conflicts($selected, $deps) {
else return false;
}
-// returns an array with all available user module names
-// $scope = user, group, host, ...
+/**
+* Returns an array with all available user module names
+*
+* @param string $scope account type (user, group, host)
+* @return array list of possible modules
+*/
function getAvailableModules($scope) {
global $relative;
$return = array();
@@ -174,7 +178,8 @@ function getAvailableModules($scope) {
while ($entry = readdir($dir))
if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($relative . 'lib/modules/'.$entry)) {
$entry = substr($entry, 0, strpos($entry, '.'));
- if (call_user_func(array($entry, "can_manage"), $scope)) $return[] = $entry;
+ $temp = new $entry($scope);
+ if ($temp->can_manage()) $return[] = $entry;
}
return $return;
}
diff --git a/lam/lib/modules/account.inc b/lam/lib/modules/account.inc
index 68e8ec9b..770e949b 100644
--- a/lam/lib/modules/account.inc
+++ b/lam/lib/modules/account.inc
@@ -38,6 +38,19 @@ $Id$
*/
class account extends baseModule {
+
+ /**
+ * Returns meta data that is interpreted by parent class
+ *
+ * @return array array with meta data
+ */
+ function get_metaData() {
+ $return = array();
+ // manages host accounts
+ $return["account_types"] = array("host");
+ return $return;
+ }
+
// Constructor
function init($base) {
// Get local copy of name of account_container in session
@@ -67,11 +80,6 @@ class account extends baseModule {
return _('Account');
}
- function can_manage($scope) {
- if ($scope == "host") return true;
- else 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 cdc29db9..d7a24147 100644
--- a/lam/lib/modules/inetOrgPerson.inc
+++ b/lam/lib/modules/inetOrgPerson.inc
@@ -37,6 +37,19 @@ $Id$
*/
class inetOrgPerson extends baseModule {
+
+ /**
+ * Returns meta data that is interpreted by parent class
+ *
+ * @return array array with meta data
+ */
+ function get_metaData() {
+ $return = array();
+ // manages user accounts
+ $return["account_types"] = array("user");
+ return $return;
+ }
+
// Constructor
function init($base) {
// Get local copy of name of account_container in session
@@ -70,11 +83,6 @@ class inetOrgPerson extends baseModule {
return _('Personal');
}
- function can_manage($scope) {
- if ($scope == "user") return true;
- else 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 76746000..0c5395ca 100644
--- a/lam/lib/modules/main.inc
+++ b/lam/lib/modules/main.inc
@@ -44,6 +44,19 @@ $Id$
* It also chooses which page to show.
*/
class main extends baseModule {
+
+ /**
+ * Returns meta data that is interpreted by parent class
+ *
+ * @return array array with meta data
+ */
+ function get_metaData() {
+ $return = array();
+ // manages no accounts
+ $return["account_types"] = array();
+ return $return;
+ }
+
// Constructor
function init($base) {
// Set counter to first page
@@ -67,10 +80,6 @@ class main extends baseModule {
return _('main');
}
- function can_manage($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 932a5f48..623eddca 100644
--- a/lam/lib/modules/posixAccount.inc
+++ b/lam/lib/modules/posixAccount.inc
@@ -61,6 +61,9 @@ class posixAccount extends baseModule {
*/
function get_metaData() {
$return = array();
+ // manages user and host accounts
+ $return["account_types"] = array("user", "host");
+ // user specific data
if ($this->get_scope() == "user") {
// this is a base module
$return["is_base"] = true;
@@ -150,12 +153,6 @@ class posixAccount extends baseModule {
return "Unix";
}
- function can_manage($scope) {
- if ($scope == "host") return true;
- elseif ($scope == "user") return true;
- else return false;
- }
-
/* 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 d7b46490..39f1162a 100644
--- a/lam/lib/modules/posixGroup.inc
+++ b/lam/lib/modules/posixGroup.inc
@@ -61,6 +61,8 @@ class posixGroup extends baseModule {
*/
function get_metaData() {
$return = array();
+ // manages group accounts
+ $return["account_types"] = array("group");
if ($this->get_scope() == "group") {
// this is a base module
$return["is_base"] = true;
@@ -140,11 +142,6 @@ class posixGroup extends baseModule {
return _('Unix');
}
- function can_manage($scope) {
- if ($scope == "group") return true;
- else return false;
- }
-
/* 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 3e3315c9..c4172bd1 100644
--- a/lam/lib/modules/quota.inc
+++ b/lam/lib/modules/quota.inc
@@ -22,6 +22,19 @@ $Id$
class quota extends baseModule {
+
+ /**
+ * Returns meta data that is interpreted by parent class
+ *
+ * @return array array with meta data
+ */
+ function get_metaData() {
+ $return = array();
+ // manages user and group accounts
+ $return["account_types"] = array("user", "group");
+ return $return;
+ }
+
// Constructor
function init($base) {
$this->base = $base;
@@ -71,12 +84,6 @@ class quota extends baseModule {
return _('Quota');
}
- function can_manage($scope) {
- if ($scope == "group") return true;
- elseif ($scope == "user") return true;
- else 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 0a54c808..863a45da 100644
--- a/lam/lib/modules/sambaAccount.inc
+++ b/lam/lib/modules/sambaAccount.inc
@@ -61,6 +61,8 @@ class sambaAccount extends baseModule {
*/
function get_metaData() {
$return = array();
+ // manages user and host accounts
+ $return["account_types"] = array("user", "host");
if ($this->get_scope() == "host") {
// this is a base module
$return["is_base"] = true;
@@ -143,12 +145,6 @@ class sambaAccount extends baseModule {
return _('Samba 2');
}
- function can_manage($scope) {
- if ($scope == "host") return true;
- elseif ($scope == "user") return true;
- else return false;
- }
-
/* 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 4b8b8bcd..aca149c7 100644
--- a/lam/lib/modules/sambaGroupMapping.inc
+++ b/lam/lib/modules/sambaGroupMapping.inc
@@ -53,6 +53,19 @@ $Id$
* 'attributes': this is a list of arrays with all ldap attributes wich are allowed for this account
*/
class sambaGroupMapping extends baseModule {
+
+ /**
+ * Returns meta data that is interpreted by parent class
+ *
+ * @return array array with meta data
+ */
+ function get_metaData() {
+ $return = array();
+ // manages group accounts
+ $return["account_types"] = array("group");
+ return $return;
+ }
+
// Constructor
function init($base) {
/* Return an error if sambaGroupMapping should be created without
@@ -97,11 +110,6 @@ class sambaGroupMapping extends baseModule {
return _('Samba 3');
}
- function can_manage($scope) {
- if ($scope == "group") return true;
- else 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 a44b2c0b..16be44ae 100644
--- a/lam/lib/modules/sambaSamAccount.inc
+++ b/lam/lib/modules/sambaSamAccount.inc
@@ -61,6 +61,8 @@ class sambaSamAccount extends baseModule {
*/
function get_metaData() {
$return = array();
+ // manages user and host accounts
+ $return["account_types"] = array("user", "host");
if ($this->get_scope() == "host") {
// this is a base module
$return["is_base"] = true;
@@ -143,12 +145,6 @@ class sambaSamAccount extends baseModule {
return _('Samba 3');
}
- function can_manage($scope) {
- if ($scope == "host") return true;
- elseif ($scope == "user") return true;
- else return false;
- }
-
/* 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 edbfa1cc..fd516f57 100644
--- a/lam/lib/modules/shadowAccount.inc
+++ b/lam/lib/modules/shadowAccount.inc
@@ -53,6 +53,19 @@ $Id$
* 'attributes': this is a list of arrays with all ldap attributes wich are allowed for this account
*/
class shadowAccount extends baseModule {
+
+ /**
+ * Returns meta data that is interpreted by parent class
+ *
+ * @return array array with meta data
+ */
+ function get_metaData() {
+ $return = array();
+ // manages user accounts
+ $return["account_types"] = array("user");
+ return $return;
+ }
+
// Constructor
function init($base) {
/* Return an error if shadowAccount should be created without
@@ -91,11 +104,6 @@ class shadowAccount extends baseModule {
return _('Shadow');
}
- function can_manage($scope) {
- if ($scope == "user") return true;
- else return false;
- }
-
/* This function returns a list with all required modules
*/
function get_dependencies($scope) {