-filter textboxes now saved during page changes

-fixed refresh of ldap entries (entries are reread if refresh button pressed or page is not called from self
-number of users found now displayed
This commit is contained in:
dechutes 2003-05-21 22:51:05 +00:00
parent 4cf1fab3b6
commit 9732d921d6
1 changed files with 36 additions and 15 deletions

View File

@ -31,6 +31,9 @@ include_once ("../../lib/status.inc");
session_save_path("../../sess");
@session_start();
// copy HTTP-GET variables to HTTP-POST
$_POST = $_POST + $_GET;
// check if button was pressed and if we have to add/delete a user
if ($_POST['new_user'] || $_POST['del_user']){
// add new user
@ -90,6 +93,16 @@ if (!$sortattrib)
$sortattrib = strtolower($attr_array[0]);
// generate search filter for sort links
$searchfilter = "";
for ($k = 0; $k < sizeof($desc_array); $k++) {
if ($_POST["filter" . strtolower($attr_array[$k])]) {
$searchfilter = $searchfilter . "&filter" .
strtolower($attr_array[$k]) . "=".
$_POST["filter" . strtolower($attr_array[$k])];
}
}
// configure search filter
// Users have the attribute "*"
$filter = "(&(&(|(objectClass=posixAccount) (objectClass=sambaAccount)) (!(uid=*$)))";
@ -102,10 +115,9 @@ for ($k = 0; $k < sizeof($desc_array); $k++) {
}
$filter = $filter . ")";
// read entries only from ldap server if not yet stored in session or if refresh
// button is pressed or if filter is applied
if ($_SESSION["userlist"] && !$_POST['refresh'] && !$_POST["apply_filter"]) {
if ($_SESSION["userlist"] && $_GET["norefresh"]) {
if ($_GET["sort"] == 1)
usort ($_SESSION["userlist"], "cmp_array");
$userinfo = $_SESSION["userlist"];
@ -120,6 +132,7 @@ if ($_SESSION["userlist"] && !$_POST['refresh'] && !$_POST["apply_filter"]) {
if ($userinfo["count"] == 0)
StatusMessage("WARN", "", _("No Users found!"));
// delete first array entry which is "count"
array_shift($userinfo);
$_SESSION["userlist"] = $userinfo;
}
@ -143,11 +156,11 @@ echo "<tr class=\"userlist_head\"><th width=22 height=34></th><th></th>\n";
// table header
for ($k = 0; $k < sizeof ($desc_array); $k++) {
if ($sortattrib == strtolower($attr_array[$k]))
echo "<th style=\"background-color:#DDDDAC\">\n";
echo "<th class=\"userlist_activecolumn\">\n";
else
echo "<th>\n";
echo "<a class=\"userlist\" href=\"listusers.php?sort=1&sortattrib=" .
strtolower($attr_array[$k]) . "\">" .
echo "<a class=\"userlist\" href=\"listusers.php?norefresh=1&sort=1&sortattrib=" .
strtolower($attr_array[$k]) . $searchfilter . "\">" .
$desc_array[$k] . "</a></th>\n";
}
echo "</tr>\n";
@ -212,31 +225,39 @@ function draw_navigation_bar ($user_count) {
global $max_pageentrys;
global $page;
global $sortattrib;
global $searchfilter;
echo ("<table width=\"100%\" border=\"0\" style=\"background-color:#DDDDDD\">\n");
echo ("<table class=\"userlist_navbar\" width=\"100%\" border=\"0\"\n");
echo ("<tr>");
echo ("<td style=\"color:#AAAAAA\"><input type=\"submit\" name=\"refresh\" value=\"" . _("Refresh") . "\">&nbsp;&nbsp;");
echo ("<td class=\"userlist_navbar\"><input type=\"submit\" name=\"refresh\" value=\"" . _("Refresh") . "\">&nbsp;&nbsp;");
if ($page != 1)
echo ("<a class=\"userlist\" href=\"listusers.php?page=" .
($page - 1) . "&sortattrib=" . $sortattrib . "\">&lt;=</a>");
echo ("<a class=\"userlist\" href=\"listusers.php?norefresh=1&page=" .
($page - 1) . "&sortattrib=" . $sortattrib .
$searchfilter . "\">&lt;=</a>");
else
echo ("&lt;=");
echo ("&nbsp;");
if ($page < ($user_count / $max_pageentrys))
echo ("<a class=\"userlist\" href=\"listusers.php?page=" .
($page + 1) . "&sortattrib=" . $sortattrib . "\">=&gt;</a>");
echo ("<a class=\"userlist\" href=\"listusers.php?norefresh=1&page=" .
($page + 1) . "&sortattrib=" . $sortattrib . $searchfilter . "\">=&gt;</a>");
else
echo ("=&gt;</td>");
echo ("=&gt;");
echo ("</td>");
echo ("<td class=\"userlist_navbartext\">");
echo "&nbsp;" . $user_count . " " . _("Users found");
echo ("</td>");
echo ("<td style=\"color:darkred\" align=\"right\">");
echo ("<td class=\"userlist_activepage\" align=\"right\">");
for ($i = 0; $i < ($user_count / $max_pageentrys); $i++) {
if ($i == $page - 1)
echo ("&nbsp;" . ($i + 1));
else
echo ("&nbsp;<a class=\"userlist\" href=\"listusers.php?page=" .
echo ("&nbsp;<a class=\"userlist\" href=\"listusers.php?norefresh=1&page=" .
($i + 1) .
"&sortattrib=" . $sortattrib . "\">" . ($i + 1) . "</a>");
"&sortattrib=" . $sortattrib . $searchfilter .
"\">" . ($i + 1) . "</a>");
}
echo ("</td></tr></table>");
}