From f00390bd31ff3ebee261542e5834fa24434fb69e Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 10 Jun 2003 11:13:40 +0000 Subject: [PATCH] added combobox for suffixes --- lam/templates/lists/listgroups.php | 30 +++++++++++++++++++++++++++++- lam/templates/lists/listhosts.php | 30 +++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/lam/templates/lists/listgroups.php b/lam/templates/lists/listgroups.php index 43686f1d..030f1474 100644 --- a/lam/templates/lists/listgroups.php +++ b/lam/templates/lists/listgroups.php @@ -78,6 +78,7 @@ if ($_SESSION["config"]->get_MaxListEntries() <= 0) else $max_pageentrys = $_SESSION["config"]->get_MaxListEntries(); +// generate column attributes and descriptions for ($i = 0; $i < sizeof($temp_array); $i++) { // if value is predifined, look up description in hash_table if (substr($temp_array[$i],0,1) == "#") { @@ -93,6 +94,12 @@ for ($i = 0; $i < sizeof($temp_array); $i++) { } } +// check search suffix +if ($_POST['grp_suffix']) $grp_suffix = $_POST['grp_suffix']; // new suffix selected via combobox +elseif ($_SESSION['grp_suffix']) $grp_suffix = $_SESSION['grp_suffix']; // old suffix from session +else $grp_suffix = $_SESSION["config"]->get_GroupSuffix(); // default suffix +session_register('grp_suffix'); + // generate search filter for sort links $searchfilter = ""; for ($k = 0; $k < sizeof($desc_array); $k++) { @@ -115,7 +122,7 @@ for ($k = 0; $k < sizeof($desc_array); $k++) { $filter = $filter . ")"; $attrs = $attr_array; $sr = @ldap_search($_SESSION["ldap"]->server(), - $_SESSION["config"]->get_GroupSuffix(), + $grp_suffix, $filter, $attrs); if ($sr) { $info = ldap_get_entries($_SESSION["ldap"]->server, $sr); @@ -215,9 +222,30 @@ draw_navigation_bar(sizeof($info)); echo ("
\n"); } +// generate list of possible suffixes +$sr = @ldap_search($_SESSION["ldap"]->server(), + $_SESSION["config"]->get_GroupSuffix(), + "objectClass=organizationalunit", array("DN")); +if ($sr) { + $units = ldap_get_entries($_SESSION["ldap"]->server, $sr); + // delete first array entry which is "count" + array_shift($units); +} + echo ("

\n"); echo ("\n"); if (sizeof($info) > 0) echo ("\n"); +// print combobox with possible sub-DNs +if (sizeof($units) > 1) { +echo ("    " . _("Suffix") . ": "); +echo ("\n"); +echo (""); +} echo ("

\n"); echo ("\n"); echo "\n"; diff --git a/lam/templates/lists/listhosts.php b/lam/templates/lists/listhosts.php index f9888cd0..a9438c1a 100644 --- a/lam/templates/lists/listhosts.php +++ b/lam/templates/lists/listhosts.php @@ -78,6 +78,7 @@ if ($_SESSION["config"]->get_MaxListEntries() <= 0) else $max_pageentrys = $_SESSION["config"]->get_MaxListEntries(); +// generate column attributes and descriptions for ($i = 0; $i < sizeof($temp_array); $i++) { // if value is predifined, look up description in hash_table if (substr($temp_array[$i],0,1) == "#") { @@ -93,6 +94,12 @@ else { } } +// check search suffix +if ($_POST['hst_suffix']) $hst_suffix = $_POST['hst_suffix']; // new suffix selected via combobox +elseif ($_SESSION['hst_suffix']) $hst_suffix = $_SESSION['hst_suffix']; // old suffix from session +else $hst_suffix = $_SESSION["config"]->get_HostSuffix(); // default suffix +session_register('hst_suffix'); + // generate search filter for sort links $searchfilter = ""; for ($k = 0; $k < sizeof($desc_array); $k++) { @@ -121,7 +128,7 @@ for ($k = 0; $k < sizeof($desc_array); $k++) { $filter = $filter . ")"; $attrs = $attr_array; $sr = @ldap_search($_SESSION["ldap"]->server(), - $_SESSION["config"]->get_HostSuffix(), + $hst_suffix, $filter, $attrs); if ($sr) { $info = ldap_get_entries($_SESSION["ldap"]->server, $sr); @@ -204,9 +211,30 @@ draw_navigation_bar(sizeof($info)); echo ("
\n"); } +// generate list of possible suffixes +$sr = @ldap_search($_SESSION["ldap"]->server(), + $_SESSION["config"]->get_HostSuffix(), + "objectClass=organizationalunit", array("DN")); +if ($sr) { + $units = ldap_get_entries($_SESSION["ldap"]->server, $sr); + // delete first array entry which is "count" + array_shift($units); +} + echo ("

\n"); echo ("\n"); if (sizeof($info) > 0) echo ("\n"); +// print combobox with possible sub-DNs +if (sizeof($units) > 1) { +echo ("    " . _("Suffix") . ": "); +echo ("\n"); +echo (""); +} echo ("

\n"); echo ("\n"); echo "\n";