From 27e5f9a911cef6d041066b7f0c6af5911979a9b4 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Mon, 23 Feb 2004 16:55:51 +0000 Subject: [PATCH] added get_ldap_filter --- lam/lib/modules.inc | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 0061b8a9..8ed31570 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -44,21 +44,44 @@ while ($stay<7) { } // returns the alias name of a module +// $name: the module name +// $scope: the account type ("user", "group", "host") function getModuleAlias($name, $scope) { return call_user_func(array($name, "get_alias"), $scope); } // returns if the module is a base module +// $name: the module name +// $scope: the account type ("user", "group", "host") function is_base_module($name, $scope) { return call_user_func(array($name, "is_base_module"), $scope); } +// returns a LDAP filter used by the account lists +// return value is of type "(...)" +// $scope: the account type ("user", "group", "host") +function get_ldap_filter($scope) { + $mods = getAvailableModules($scope); + $filters = array(); + for ($i = 0; $i < sizeof($mods); $i++) { + if (is_base_module($mods[$i], $scope)) { + $filters[] = call_user_func(array($mods[$i], "get_ldap_filter"), $scope); + } + } + if (sizeof($filters) < 2) { + return $filters[0]; + } + else { + return "(&" . implode("", $filters) . ")"; + } +} + // returns a hash array (module name => dependencies) of all user module dependencies // dependencies contains an array with two sub arrays: depends, conflicts // the elements of depends are either module names or an array of module names (OR-case) // the elements of conflicts are module names +// $scope: user, group, host, .... function getModulesDependencies($scope) { - // scope = suer, group, host, .... // get module names. $dir = opendir('../../lib/modules'); while ($entry = readdir($dir))