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