changed the LDAP filter syntax for base modules,

fixed dependency information,
only include files in lib/modules which end with ".inc"
This commit is contained in:
Roland Gruber 2004-06-04 11:28:22 +00:00
parent a7e7f3fc38
commit 29753a127e
12 changed files with 75 additions and 45 deletions

View File

@ -108,16 +108,20 @@ quota module is no base module as it needs posixAccount.<br>
</tbody> </tbody>
</table> </table>
<br> <br>
Returns a string that can be used as part of a LDAP filter. Usually Returns an array('or' =&gt; '...', 'and' =&gt; '...') that is used to
build the LDAP filter. Usually
used to filter object classes.<br> used to filter object classes.<br>
<span style="font-weight: bold;">$scope</span> is the account type <span style="font-weight: bold;">$scope</span> is the account type
("user", "group", "host" at this time).<br> ("user", "group", "host" at this time).<br>
<br> <br>
All filter parts of the base modules are combined with OR and used to All "or" filter parts of the base modules are combined with OR and then
find the accounts for the lists.<br> combined with the "and" parts.<br>
The resulting LDAP filter will look like this:
(&amp;(|(OR1)(OR2)(OR3))(AND1)(AND2)(AND3))<br>
<br> <br>
<span style="font-weight: bold;">Example: <span <span style="font-weight: bold;">Example: <span
style="font-style: italic;">return "(objectClass=posixAccount)"</span></span><br> style="font-style: italic;">return "('or' =&gt;
'objectClass=posixAccount', 'and' =&gt; '(!(uid=*$))')"</span></span><br>
<br> <br>
<span style="font-weight: bold; color: rgb(255, 0, 0);">This function <span style="font-weight: bold; color: rgb(255, 0, 0);">This function
is only used for base modules. Standard modules do not need to is only used for base modules. Standard modules do not need to
@ -314,12 +318,13 @@ If no errors occured the function returns an empty array.<span
This function is called when a PDF is to be created.<br> This function is called when a PDF is to be created.<br>
<span style="font-weight: bold;">$scope</span> is the account type <span style="font-weight: bold;">$scope</span> is the account type
("user", "group", "host" at this time).<br> ("user", "group", "host" at this time).<br>
It returns the fields which are printed in the PDF file for the specified It returns the fields which are printed in the PDF file for the
account type. At the monent there is no (easy) possibility for the user to specified account type. At the monent there is no (easy) possibility
decide which fields are to be displayed. Perhaps there will be a PDF config for the user to decide which fields are to be displayed. Perhaps there
tool in future releases where you can offer the user to decide which fields are will be a PDF config tool in future releases where you can offer the
to be displayed on the PDF file. The format of the array to be returned is user to decide which fields are to be displayed on the PDF file. The
described in section 5. "PDF syntax".<br> format of the array to be returned is described in section 5. "PDF
syntax".<br>
<br> <br>
<h3><br> <h3><br>
</h3> </h3>

View File

@ -37,7 +37,7 @@ while ($stay<7) {
if (is_dir($relative.'lib/modules')) { if (is_dir($relative.'lib/modules')) {
$dir = opendir($relative.'lib/modules'); $dir = opendir($relative.'lib/modules');
while ($entry = readdir($dir)) while ($entry = readdir($dir))
if (is_file($relative.'lib/modules/'.$entry)) include_once ($relative.'lib/modules/'.$entry); if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($relative.'lib/modules/'.$entry)) include_once ($relative.'lib/modules/'.$entry);
$stay=10; $stay=10;
} }
else { else {
@ -66,17 +66,26 @@ function is_base_module($name, $scope) {
function get_ldap_filter($scope) { function get_ldap_filter($scope) {
$mods = getAvailableModules($scope); $mods = getAvailableModules($scope);
$filters = array(); $filters = array();
$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)) {
$filters[] = call_user_func(array($mods[$i], "get_ldap_filter"), $scope); $modinfo = call_user_func(array($mods[$i], "get_ldap_filter"), $scope);
if (isset($modinfo['or'])) $filters['or'][] = $modinfo['or'];
if (isset($modinfo['and'])) $filters['and'][] = $modinfo['and'];
} }
} }
if (sizeof($filters) < 2) { // build OR filter
return $filters[0]; if (sizeof($filters['or']) == 1) {
$orFilter = $filters['or'][0];
} }
else { elseif (sizeof($filters['or']) > 1) {
return "(&" . implode("", $filters) . ")"; $orFilter = "(|" . implode("", $filters['or']) . ")";
} }
// add built OR filter to AND filters
if ($orFilter != '') $filters['and'][] = $orFilter;
// collapse AND filters
if (sizeof($filters['and']) < 2) return $filters['and'][0];
else return "(&" . implode("", $filters['and']) . ")";
} }
// returns a hash array (module name => dependencies) of all user module dependencies // returns a hash array (module name => dependencies) of all user module dependencies
@ -85,14 +94,11 @@ function get_ldap_filter($scope) {
// the elements of conflicts are module names // the elements of conflicts are module names
// $scope: user, group, host, .... // $scope: user, group, host, ....
function getModulesDependencies($scope) { function getModulesDependencies($scope) {
global $relative; $mods = getAvailableModules($scope);
// get module names. $deps = array();
$dir = opendir($relative . 'lib/modules'); for ($i = 0; $i < sizeof($mods); $i++) {
while ($entry = readdir($dir)) $deps = call_user_func(array($mods[$i], "get_dependencies"), $scope);
if (is_file($relative . 'lib/modules/'.$entry)) { if ($deps != -1) $return[$mods[$i]] = $deps;
$entry = substr($entry, 0, strpos($entry, '.'));
$deps = call_user_func(array($entry, "get_dependencies"), $scope);
if ($deps != -1) $return[$entry] = $deps;
} }
return $return; return $return;
} }
@ -162,7 +168,7 @@ function getAvailableModules($scope) {
// get module names. // get module names.
$dir = opendir($relative . 'lib/modules'); $dir = opendir($relative . 'lib/modules');
while ($entry = readdir($dir)) while ($entry = readdir($dir))
if (is_file($relative . 'lib/modules/'.$entry)) { if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($relative . 'lib/modules/'.$entry)) {
$entry = substr($entry, 0, strpos($entry, '.')); $entry = substr($entry, 0, strpos($entry, '.'));
if (call_user_func(array($entry, "can_manage"), $scope)) $return[] = $entry; if (call_user_func(array($entry, "can_manage"), $scope)) $return[] = $entry;
} }

View File

@ -79,7 +79,7 @@ class account {
/* 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) {
if ($scope=='host') return array('require' => array('main'), 'conflict' => array('inetOrgPerson', 'posixGroup', 'sambaDomain') ); if ($scope=='host') return array('depends' => array(), 'conflicts' => array('inetOrgPerson', 'posixGroup', 'sambaDomain') );
return -1; return -1;
} }

View File

@ -82,7 +82,7 @@ class inetOrgPerson {
/* 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) {
if ($scope=='user') return array('require' => array('main', 'posixAccount'), 'conflict' => array('account', 'posixGroup', 'sambaDomain') ); if ($scope=='user') return array('depends' => array('posixAccount'), 'conflicts' => array('account', 'posixGroup', 'sambaDomain') );
return -1; return -1;
} }

View File

@ -78,7 +78,7 @@ class main {
/* 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) {
return array('require' => array(), 'conflict' => array() ); return array('depends' => array(), 'conflicts' => array() );
} }
function module_ready() { function module_ready() {

View File

@ -140,20 +140,22 @@ class posixAccount {
} }
function is_base_module($scope) { function is_base_module($scope) {
return true; if ($scope == "user") return true;
else return false;
} }
// returns an LDAP filter for the account lists // returns an LDAP filter for the account lists
// $scope: the account type ("user", "group", "host") // $scope: the account type ("user", "group", "host")
function get_ldap_filter($scope) { function get_ldap_filter($scope) {
return "(objectClass=posixAccount)"; 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) {
if ($scope=='host') return array('require' => array('account'), 'conflict' => array() ); if ($scope=='host') return array('depends' => array('account'), 'conflicts' => array() );
if ($scope=='user') return array('require' => array('inetOrgPerson'), 'conflict' => array() ); if ($scope=='user') return array('depends' => array('inetOrgPerson'), 'conflicts' => array() );
return -1; return -1;
} }

View File

@ -135,13 +135,14 @@ class posixGroup {
// returns an LDAP filter for the account lists // returns an LDAP filter for the account lists
// $scope: the account type ("user", "group", "host") // $scope: the account type ("user", "group", "host")
function get_ldap_filter($scope) { function get_ldap_filter($scope) {
return "(objectClass=posixGroup)"; 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) {
if ($scope=='group') return array('require' => array('main'), 'conflict' => array('inetOrgPerson', 'account', 'sambaDomain') ); if ($scope=='group') return array('depends' => array(), 'conflicts' => array('inetOrgPerson', 'account', 'sambaDomain') );
return -1; return -1;
} }

View File

@ -84,8 +84,8 @@ class quota {
/* 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) {
if ($scope=='group') return array('require' => array('posixGroup'), 'conflict' => array() ); if ($scope=='group') return array('depends' => array('posixGroup'), 'conflicts' => array() );
if ($scope=='user') return array('require' => array('posixAccount'), 'conflict' => array() ); if ($scope=='user') return array('depends' => array('posixAccount'), 'conflicts' => array() );
return -1; return -1;
} }

View File

@ -133,14 +133,22 @@ class sambaAccount {
} }
function is_base_module($scope) { function is_base_module($scope) {
return false; if ($scope == "host") return true;
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) {
if ($scope=='host') return array('require' => array('account'), 'conflict' => array() ); if ($scope=='host') return array('depends' => array('account'), 'conflicts' => array() );
if ($scope=='user') return array('require' => array('inetOrgPerson'), 'conflict' => array() ); if ($scope=='user') return array('depends' => array('inetOrgPerson'), 'conflicts' => array() );
return -1; return -1;
} }

View File

@ -109,7 +109,7 @@ class sambaGroupMapping {
/* 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) {
if ($scope=='group') return array('require' => array('posixGroup'), 'conflict' => array() ); if ($scope=='group') return array('depends' => array('posixGroup'), 'conflicts' => array() );
return -1; return -1;
} }

View File

@ -133,14 +133,22 @@ class sambaSamAccount {
} }
function is_base_module($scope) { function is_base_module($scope) {
return false; if ($scope == "host") return true;
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) {
if ($scope=='host') return array('require' => array('posixAccount'), 'conflict' => array() ); if ($scope=='host') return array('depends' => array('posixAccount'), 'conflicts' => array() );
if ($scope=='user') return array('require' => array('posixAccount'), 'conflict' => array() ); if ($scope=='user') return array('depends' => array('posixAccount'), 'conflicts' => array() );
return -1; return -1;
} }

View File

@ -103,7 +103,7 @@ class shadowAccount {
/* 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) {
if ($scope=='user') return array('require' => array('inetOrgPerson'), 'conflict' => array() ); if ($scope=='user') return array('depends' => array('inetOrgPerson'), 'conflicts' => array() );
return -1; return -1;
} }