From 44e3cfce7c68bdef2c7949b6ba4e8533634ce432 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 11 Jun 2004 15:44:49 +0000 Subject: [PATCH] added meta data for get_ldap_filter() --- lam/docs/modules-specification.htm | 72 +++++++++++++++++++++++++---- lam/lib/baseModule.inc | 10 ++++ lam/lib/modules.inc | 3 +- lam/lib/modules/posixAccount.inc | 10 ++-- lam/lib/modules/posixGroup.inc | 10 ++-- lam/lib/modules/sambaAccount.inc | 10 ++-- lam/lib/modules/sambaSamAccount.inc | 12 ++--- 7 files changed, 87 insertions(+), 40 deletions(-) diff --git a/lam/docs/modules-specification.htm b/lam/docs/modules-specification.htm index feec1198..cd533b51 100644 --- a/lam/docs/modules-specification.htm +++ b/lam/docs/modules-specification.htm @@ -17,10 +17,11 @@ E.g. if you create a new module and its class name is "qmail" then the filename would be "qmail.inc".

The class name of a module must contain only a-z, A-Z, 0-9, -, and _.
-
+All module classes should extend the baseModule class.

2. Class functions

-

2.1. Static 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.
@@ -69,7 +70,7 @@ a-z, A-Z, 0-9, -, _ and spaces.
The $scope parameter defines the account type ("user", "group", "host" at this time).

-

2.1.3. is_base_module

+

2.1.3. is_base_module*


@@ -77,7 +78,7 @@ the account type ("user", "group", "host" at this time).
@@ -85,16 +86,14 @@ the account type ("user", "group", "host" at this time).

Returns true if your module is a base module and otherwise false.
-$scope is the account type -("user", "group", "host" at this time).
-
+
Every account type needs at least one base module. A base module defines a full qualified account.
E.g. modules that use the object class posixAccount may be base modules as it makes sense to manage these Unix accounts. On the other hand the quota module is no base module as it needs posixAccount.

-

2.1.4. get_ldap_filter

+

2.1.4. get_ldap_filter*


function is_base_module($scope)
+ style="font-weight: bold;">function is_base_module()
@@ -160,6 +159,43 @@ your module depends on one of these modules.
=> array("exim"));

+

2.1.6. get_metaData()

+
+
+ + + + + +
function get_metaData()
+
+
+Returns an hash array including meta data for the baseModule.
+
+Example: return array("is_base" => +true);
+
+

2.1.7. get_scope()

+
+ + + + + + +
function get_scope()
+
+
+Returns the account type (user/group/host) of this module object.
+
+This function is provided by the +baseModule and should not be overwritten.

2.2. Class functions

2.2.1. Constructor

@@ -245,7 +281,7 @@ It must return the help entry as array for the submitted help identifier. The format of the array to be returned is described in section 4. "Help entry syntax".

-

2.1.5. get_profileOptions

+

2.2.5. get_profileOptions


@@ -273,7 +309,7 @@ as keywords to load and save profiles. We recommend to use the module name as prefix for them (e.g. posixAccount_homeDirectory) to avoid naming confilcts.

-

2.1.6. check_profileOptions

+

2.2.6. check_profileOptions


@@ -326,6 +362,10 @@ user to decide which fields are to be displayed on the PDF file. The format of the array to be returned is described in section 5. "PDF syntax".

+
+*: These functions do not need to be +implemented if meta data is supplied. See 6 for a list of meta data +formats.


3. Meta HTML code

@@ -515,5 +555,17 @@ which should be displayed when this help entry is called.


5. PDF syntax

+
+
+

6. Module meta data

+

6.1 is_base_module()

+    "is_base" => boolean
+
+

6.2 get_ldap_filter()

+    "ldap_filter" => array
+
+   Example: array('or' => +'objectClass=posixAccount', 'and' => '(!(uid=*$))') diff --git a/lam/lib/baseModule.inc b/lam/lib/baseModule.inc index 8d81882b..997d5499 100644 --- a/lam/lib/baseModule.inc +++ b/lam/lib/baseModule.inc @@ -85,6 +85,16 @@ class baseModule { else return false; } + /** + * returns an LDAP filter for the account lists + * + * @return string LDAP filter + */ + function get_ldap_filter() { + if (isset($this->meta['ldap_filter'])) return $this->meta['ldap_filter']; + else return ""; + } + // TODO implement missing interface } diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 9f91b3cc..e375d426 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -72,7 +72,8 @@ function get_ldap_filter($scope) { $orFilter = ''; for ($i = 0; $i < sizeof($mods); $i++) { if (is_base_module($mods[$i], $scope)) { - $modinfo = call_user_func(array($mods[$i], "get_ldap_filter"), $scope); + $module = new $mods[$i]($scope); + $modinfo = $module->get_ldap_filter(); if (isset($modinfo['or'])) $filters['or'][] = $modinfo['or']; if (isset($modinfo['and'])) $filters['and'][] = $modinfo['and']; } diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index cc9a54f5..932a5f48 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -62,7 +62,10 @@ class posixAccount extends baseModule { function get_metaData() { $return = array(); if ($this->get_scope() == "user") { + // this is a base module $return["is_base"] = true; + // LDAP filter + $return["ldap_filter"] = array('or' => "(objectClass=posixAccount)", 'and' => "(!(uid=*$))"); } return $return; } @@ -153,13 +156,6 @@ class posixAccount extends baseModule { else return false; } - // returns an LDAP filter for the account lists - // $scope: the account type ("user", "group", "host") - function get_ldap_filter($scope) { - if ($scope == "user") return array('or' => "(objectClass=posixAccount)", 'and' => "(!(uid=*$))"); - 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 492b2173..d7b46490 100644 --- a/lam/lib/modules/posixGroup.inc +++ b/lam/lib/modules/posixGroup.inc @@ -62,7 +62,10 @@ class posixGroup extends baseModule { function get_metaData() { $return = array(); if ($this->get_scope() == "group") { + // this is a base module $return["is_base"] = true; + // LDAP filter + $return["ldap_filter"] = array('or' => "(objectClass=posixGroup)"); } return $return; } @@ -142,13 +145,6 @@ class posixGroup extends baseModule { else return false; } - // returns an LDAP filter for the account lists - // $scope: the account type ("user", "group", "host") - function get_ldap_filter($scope) { - if ($scope == "group") return array('or' => "(objectClass=posixGroup)"); - 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 52d478bb..0a54c808 100644 --- a/lam/lib/modules/sambaAccount.inc +++ b/lam/lib/modules/sambaAccount.inc @@ -62,7 +62,10 @@ class sambaAccount extends baseModule { function get_metaData() { $return = array(); if ($this->get_scope() == "host") { + // this is a base module $return["is_base"] = true; + // LDAP filter + $return["ldap_filter"] = array('and' => '(uid=*$)', 'or' => "(objectClass=posixAccount)"); } return $return; } @@ -146,13 +149,6 @@ class sambaAccount extends baseModule { else return false; } - // returns an LDAP filter for the account lists - // $scope: the account type ("user", "group", "host") - function get_ldap_filter($scope) { - if ($scope == "host") return array('and' => '(uid=*$)', 'or' => "(objectClass=posixAccount)"); - 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 3ffb3926..a44b2c0b 100644 --- a/lam/lib/modules/sambaSamAccount.inc +++ b/lam/lib/modules/sambaSamAccount.inc @@ -62,7 +62,10 @@ class sambaSamAccount extends baseModule { function get_metaData() { $return = array(); if ($this->get_scope() == "host") { + // this is a base module $return["is_base"] = true; + // LDAP filter + $return["ldap_filter"] = array('and' => '(uid=*$)', 'or' => "(objectClass=posixAccount)"); } return $return; } @@ -146,14 +149,7 @@ class sambaSamAccount extends baseModule { else return false; } - // returns an LDAP filter for the account lists - // $scope: the account type ("user", "group", "host") - function get_ldap_filter($scope) { - if ($scope == "host") return array('and' => '(uid=*$)', 'or' => "(objectClass=posixAccount)"); - else return false; - } - -/* This function returns a list with all required modules + /* This function returns a list with all required modules */ function get_dependencies($scope) { if ($scope=='host') return array('depends' => array('posixAccount'), 'conflicts' => array() );