added meta data for get_ldap_filter()

This commit is contained in:
Roland Gruber 2004-06-11 15:44:49 +00:00
parent f1722aaee8
commit 44e3cfce7c
7 changed files with 87 additions and 40 deletions

View File

@ -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".<br> filename would be "qmail.inc".<br>
<br> <br>
The class name of a module must contain only a-z, A-Z, 0-9, -, and _.<br> The class name of a module must contain only a-z, A-Z, 0-9, -, and _.<br>
<br> All module classes should extend the baseModule class.<br>
<br> <br>
<h2>2. Class functions</h2> <h2>2. Class functions</h2>
<h3>2.1. Static functions</h3> <h3>2.1. Functions that have to work without superior accountContainer<br>
</h3>
These functions are called without instanciating an object of the These functions are called without instanciating an object of the
module class. They must not depend on class variables and are only module class. They must not depend on class variables and are only
allowed to call other static functions.<br> allowed to call other static functions.<br>
@ -69,7 +70,7 @@ a-z, A-Z, 0-9, -, _ and spaces.<br>
The <span style="font-weight: bold;">$scope</span> parameter defines The <span style="font-weight: bold;">$scope</span> parameter defines
the account type ("user", "group", "host" at this time).<br> the account type ("user", "group", "host" at this time).<br>
<br> <br>
<h3>2.1.3. is_base_module</h3> <h3>2.1.3. is_base_module*</h3>
<br> <br>
<table style="text-align: left; width: 300px; height: 30px;" border="0" <table style="text-align: left; width: 300px; height: 30px;" border="0"
cellspacing="2" cellpadding="2"> cellspacing="2" cellpadding="2">
@ -77,7 +78,7 @@ the account type ("user", "group", "host" at this time).<br>
<tr> <tr>
<td <td
style="vertical-align: top; background-color: rgb(204, 204, 204); text-align: center;"><span style="vertical-align: top; background-color: rgb(204, 204, 204); text-align: center;"><span
style="font-weight: bold;">function is_base_module($scope)</span><br> style="font-weight: bold;">function is_base_module()</span><br>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -85,16 +86,14 @@ the account type ("user", "group", "host" at this time).<br>
<br> <br>
Returns <span style="font-weight: bold;">true</span> if your module is Returns <span style="font-weight: bold;">true</span> if your module is
a base module and otherwise <span style="font-weight: bold;">false</span>.<br> a base module and otherwise <span style="font-weight: bold;">false</span>.<br>
<span style="font-weight: bold;">$scope</span> is the account type <span style="font-weight: bold;"></span><br>
("user", "group", "host" at this time).<br>
<br>
Every account type needs at least one base module. A base module Every account type needs at least one base module. A base module
defines a full qualified account.<br> defines a full qualified account.<br>
E.g. modules that use the object class posixAccount may be base modules 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 as it makes sense to manage these Unix accounts. On the other hand the
quota module is no base module as it needs posixAccount.<br> quota module is no base module as it needs posixAccount.<br>
<br> <br>
<h3>2.1.4. get_ldap_filter</h3> <h3>2.1.4. get_ldap_filter*</h3>
<br> <br>
<table style="text-align: left; width: 300px; height: 30px;" border="0" <table style="text-align: left; width: 300px; height: 30px;" border="0"
cellspacing="2" cellpadding="2"> cellspacing="2" cellpadding="2">
@ -160,6 +159,43 @@ your module depends on one of these modules.<br>
=&gt; array("exim"));</span><br =&gt; array("exim"));</span><br
style="font-weight: bold; font-style: italic;"> style="font-weight: bold; font-style: italic;">
<br> <br>
<h3>2.1.6. get_metaData()</h3>
<br>
<table cellpadding="2" cellspacing="2" border="0"
style="text-align: left; width: 300px;">
<tbody>
<tr>
<td
style="vertical-align: top; background-color: rgb(204, 204, 204); text-align: center;"><span
style="font-weight: bold;">function get_metaData()</span><br>
</td>
</tr>
</tbody>
</table>
<br>
Returns an hash array including meta data for the baseModule.<br>
<br>
<span style="font-weight: bold;">Example: return array("is_base" =&gt;
true);</span><br style="font-weight: bold;">
<br>
<h3>2.1.7. get_scope()</h3>
<br>
<table cellpadding="2" cellspacing="2" border="0"
style="text-align: left; width: 300px;">
<tbody>
<tr>
<td
style="vertical-align: top; background-color: rgb(204, 204, 204); text-align: center;"><span
style="font-weight: bold;">function get_scope()</span><br>
</td>
</tr>
</tbody>
</table>
<br>
Returns the account type (user/group/host) of this module object.<br>
<span style="font-weight: bold;"></span><br>
<span style="font-weight: bold;">This function is provided by the
baseModule and should not be overwritten.</span><br>
<br> <br>
<h3>2.2. Class functions</h3> <h3>2.2. Class functions</h3>
<h3>2.2.1. Constructor</h3> <h3>2.2.1. Constructor</h3>
@ -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 identifier. The format of the array to be returned is described in
section 4. "Help entry syntax".<br> section 4. "Help entry syntax".<br>
<br> <br>
<h3>2.1.5. get_profileOptions</h3> <h3>2.2.5. get_profileOptions</h3>
<br> <br>
<table cellpadding="2" cellspacing="2" border="0" <table cellpadding="2" cellspacing="2" border="0"
style="text-align: left; width: 300px; height: 30px;"> style="text-align: left; width: 300px; height: 30px;">
@ -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 name as prefix for them (e.g. posixAccount_homeDirectory) to avoid
naming confilcts.<br> naming confilcts.<br>
<br> <br>
<h3>2.1.6. check_profileOptions</h3> <h3>2.2.6. check_profileOptions</h3>
<br> <br>
<table style="text-align: left; width: 400px; height: 30px;" border="0" <table style="text-align: left; width: 400px; height: 30px;" border="0"
cellspacing="2" cellpadding="2"> cellspacing="2" cellpadding="2">
@ -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 format of the array to be returned is described in section 5. "PDF
syntax".<br> syntax".<br>
<br> <br>
<br>
<span style="font-weight: bold;">*: These functions do not need to be
implemented if meta data is supplied. See 6 for a list of meta data
formats.</span><br>
<h3><br> <h3><br>
</h3> </h3>
<h2>3. Meta HTML code</h2> <h2>3. Meta HTML code</h2>
@ -515,5 +555,17 @@ which should be displayed when this help entry is called.
<h3><br> <h3><br>
</h3> </h3>
<h2>5. PDF syntax</h2> <h2>5. PDF syntax</h2>
<br>
<br>
<h2>6. Module meta data</h2>
<h3>6.1 is_base_module()</h3>
&nbsp;&nbsp;&nbsp; "is_base" =&gt; boolean<br>
<br>
<h3>6.2 get_ldap_filter()</h3>
&nbsp;&nbsp;&nbsp; "ldap_filter" =&gt; array<br>
<br>
<span style="font-weight: bold;">&nbsp;&nbsp; Example:</span><span
style="font-style: italic; font-weight: bold;"> array('or' =&gt;
'objectClass=posixAccount', 'and' =&gt; '(!(uid=*$))')</span>
</body> </body>
</html> </html>

View File

@ -85,6 +85,16 @@ class baseModule {
else return false; 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 // TODO implement missing interface
} }

View File

@ -72,7 +72,8 @@ function get_ldap_filter($scope) {
$orFilter = ''; $orFilter = '';
for ($i = 0; $i < sizeof($mods); $i++) { for ($i = 0; $i < sizeof($mods); $i++) {
if (is_base_module($mods[$i], $scope)) { 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['or'])) $filters['or'][] = $modinfo['or'];
if (isset($modinfo['and'])) $filters['and'][] = $modinfo['and']; if (isset($modinfo['and'])) $filters['and'][] = $modinfo['and'];
} }

View File

@ -62,7 +62,10 @@ class posixAccount extends baseModule {
function get_metaData() { function get_metaData() {
$return = array(); $return = array();
if ($this->get_scope() == "user") { if ($this->get_scope() == "user") {
// this is a base module
$return["is_base"] = true; $return["is_base"] = true;
// LDAP filter
$return["ldap_filter"] = array('or' => "(objectClass=posixAccount)", 'and' => "(!(uid=*$))");
} }
return $return; return $return;
} }
@ -153,13 +156,6 @@ class posixAccount extends baseModule {
else return false; 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 /* This function returns a list with all required modules
*/ */
function get_dependencies($scope) { function get_dependencies($scope) {

View File

@ -62,7 +62,10 @@ class posixGroup extends baseModule {
function get_metaData() { function get_metaData() {
$return = array(); $return = array();
if ($this->get_scope() == "group") { if ($this->get_scope() == "group") {
// this is a base module
$return["is_base"] = true; $return["is_base"] = true;
// LDAP filter
$return["ldap_filter"] = array('or' => "(objectClass=posixGroup)");
} }
return $return; return $return;
} }
@ -142,13 +145,6 @@ class posixGroup extends baseModule {
else return false; 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 /* This function returns a list with all required modules
*/ */
function get_dependencies($scope) { function get_dependencies($scope) {

View File

@ -62,7 +62,10 @@ class sambaAccount extends baseModule {
function get_metaData() { function get_metaData() {
$return = array(); $return = array();
if ($this->get_scope() == "host") { if ($this->get_scope() == "host") {
// this is a base module
$return["is_base"] = true; $return["is_base"] = true;
// LDAP filter
$return["ldap_filter"] = array('and' => '(uid=*$)', 'or' => "(objectClass=posixAccount)");
} }
return $return; return $return;
} }
@ -146,13 +149,6 @@ class sambaAccount extends baseModule {
else return false; 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) { function get_dependencies($scope) {

View File

@ -62,7 +62,10 @@ class sambaSamAccount extends baseModule {
function get_metaData() { function get_metaData() {
$return = array(); $return = array();
if ($this->get_scope() == "host") { if ($this->get_scope() == "host") {
// this is a base module
$return["is_base"] = true; $return["is_base"] = true;
// LDAP filter
$return["ldap_filter"] = array('and' => '(uid=*$)', 'or' => "(objectClass=posixAccount)");
} }
return $return; return $return;
} }
@ -146,14 +149,7 @@ class sambaSamAccount extends baseModule {
else return false; else return false;
} }
// returns an LDAP filter for the account lists /* This function returns a list with all required modules
// $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) { function get_dependencies($scope) {
if ($scope=='host') return array('depends' => array('posixAccount'), 'conflicts' => array() ); if ($scope=='host') return array('depends' => array('posixAccount'), 'conflicts' => array() );