added filter for users (still buggy)

This commit is contained in:
dechutes 2003-05-05 23:06:12 +00:00
parent 3ff083b820
commit 221bcf0e7f
1 changed files with 76 additions and 57 deletions

View File

@ -44,28 +44,18 @@ if ($_POST['new_user'] || $_POST['del_user']){
exit;
}
echo "<html><head><title>listusers</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
echo "</head><body>\n";
echo "<script src=\"../../lib/functions.js\" type=\"text/javascript\" language=\"javascript\"></script>\n";
putenv("LANG=de_DE");
putenv("LANGUAGE=de_DE");
setlocale(LC_MESSAGES, "de_DE");
setlocale(LC_ALL, "de_DE");
bindtextdomain("messages", "../locale");
textdomain("messages");
// generate attribute-description table
$attr_array; // list of LDAP attributes to show
$desc_array; // list of descriptions for the attributes
$attr_string = $_SESSION["config"]->get_userlistAttributes();
$temp_array = explode(";", $attr_string);
$hash_table = $_SESSION["ldap"]->attributeUserArray();
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) == "#") {
@ -81,8 +71,20 @@ else {
}
}
// configure search filter
// Users have the attribute "*"
$filter = "(&(|(objectClass=posixAccount) (objectClass=sambaAccount)) (!(uid=*$)))";
$filter = "(&(&(|(objectClass=posixAccount) (objectClass=sambaAccount)) (!(uid=*$)))";
for ($k = 0; $k < sizeof($desc_array); $k++) {
if ($_POST["filter" . strtolower($attr_array[$k])])
$filter = $filter . "(" . strtolower($attr_array[$k]) . "=" .
$_POST["filter" . strtolower($attr_array[$k])] . ")";
else
$_POST["filter" . strtolower($attr_array[$k])] = "*";
}
$filter = $filter . ")";
$attrs = $attr_array;
$sr = @ldap_search($_SESSION["ldap"]->server(),
$_SESSION["config"]->get_UserSuffix(),
@ -90,7 +92,9 @@ $sr = @ldap_search($_SESSION["ldap"]->server(),
if ($sr) {
$info = ldap_get_entries($_SESSION["ldap"]->server, $sr);
ldap_free_result($sr);
if ($info["count"] == 0) echo ("<br><br><font color=\"red\"><b>" . _("No Users found!") . "</b></font><br><br>");
if ($info["count"] == 0) echo ("<br><br><font color=\"red\"><b>" .
_("No Users found!") .
"</b></font><br><br>");
}
else echo ("<br><br><font color=\"red\"><b>" . _("LDAP Search failed! Please check your preferences. <br> No Users found!") . "</b></font><br><br>");
@ -106,7 +110,20 @@ echo "<table rules=\"all\" class=\"userlist\" width=\"100%\">\n";
echo "<tr class=\"userlist_head\"><th width=22 height=34></th><th></th>";
// table header
for ($k = 0; $k < sizeof($desc_array); $k++) {
echo "<th><a class=\"userlist\" href=\"listusers.php?list=" . strtolower($attr_array[$k]) . "\">" . $desc_array[$k] . "</a></th>";
echo "<th><a class=\"userlist\" href=\"listusers.php?list=" .
strtolower($attr_array[$k]) . "\">" .
$desc_array[$k] . "</a></th>";
}
echo "</tr>\n";
echo "<tr class=\"test\"><th width=22 height=34></th><th>";
echo "<input type=\"submit\" name=\"apply_filter\" value=\"" . _("Apply") . "\">";
echo "</th>";
// table header
for ($k = 0; $k < sizeof($desc_array); $k++) {
echo "<th>";
echo ("<input type=\"text\" name=\"filter" . strtolower ($attr_array[$k]) .
"\" value=\"" . $_POST["filter" . strtolower($attr_array[$k])] . "\">");
echo "</th>";
}
echo "</tr>\n";
@ -149,7 +166,9 @@ for ($i = 0; $i < sizeof($info); $i++) { // ignore last entry in array which is
echo("</tr>\n");
}
echo ("</table>");
echo ("<p>&nbsp</p>\n");
echo ("<br />");
echo ("<table align=\"left\" border=\"0\">");
echo ("<tr><td align=\"left\"><input type=\"submit\" name=\"new_user\" value=\"" . _("New User") . "\"></td>");
echo ("<td align=\"left\"><input type=\"submit\" name=\"del_user\" value=\"" . _("Delete User(s)") . "\"></td></tr>");