diff --git a/lam/templates/lists/listusers.php b/lam/templates/lists/listusers.php index b41bbe49..d4b735dd 100644 --- a/lam/templates/lists/listusers.php +++ b/lam/templates/lists/listusers.php @@ -82,11 +82,15 @@ for ($i = 0; $i < sizeof($temp_array); $i++) { } } +$sortattrib = $_GET["sortattrib"]; +if (!$sortattrib) + $sortattrib = strtolower($attr_array[0]); + + // configure search filter // Users have the attribute "*" $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])] . ")"; @@ -99,7 +103,7 @@ $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 ($_GET["sort"]) + if ($_GET["sort"] == 1) usort ($_SESSION["userlist"], "cmp_array"); $userinfo = $_SESSION["userlist"]; } else { @@ -135,7 +139,11 @@ echo "\n"; echo ""; // table header for ($k = 0; $k < sizeof ($desc_array); $k++) { - echo ""; } @@ -143,7 +151,8 @@ echo "\n"; echo ""; -// table header + +// print input boxes for filters for ($k = 0; $k < sizeof ($desc_array); $k++) { echo "
"; + else + echo ""; + echo "" . $desc_array[$k] . "
"; echo ""; echo ""; echo ("search_username($user); // DN entry // if user was found in LDAP make link, otherwise just print name @@ -215,18 +225,19 @@ echo "\n"; function draw_navigation_bar ($user_count) { global $max_pageentrys; global $page; + global $sortattrib; echo (""); echo (""); echo (""); @@ -236,7 +247,7 @@ function draw_navigation_bar ($user_count) { echo (" " . ($i + 1)); else echo (" " . ($i + 1) . ""); + "&sortattrib=" . $sortattrib . "\">" . ($i + 1) . ""); } echo ("
  "); if ($page != 1) - echo ("<="); + echo ("<="); else echo ("<="); echo (" "); if ($page < ($user_count / $max_pageentrys)) - echo ("=>"); + echo ("=>"); else echo ("=>
"); } @@ -246,13 +257,13 @@ function draw_navigation_bar ($user_count) { // rows are sorted with the first attribute entry of the sort column // if objects have attributes with multiple values the others are ignored function cmp_array($a, $b) { - // list specifies the sort column - global $list; + // sortattrib specifies the sort column + global $sortattrib; global $attr_array; - // sort by first attribute with name $list - if (!$list) $list = strtolower($attr_array[0]); - if ($a[$list][0] == $b[$list][0]) return 0; - else if ($a[$list][0] == max($a[$list][0], $b[$list][0])) return 1; + // sort by first attribute with name $sortattrib + if ($a[$sortattrib][0] == $b[$sortattrib][0]) return 0; + else if ($a[$sortattrib][0] == + max($a[$sortattrib][0], $b[$sortattrib][0])) return 1; else return -1; }