diff --git a/lam/templates/lists/listusers.php b/lam/templates/lists/listusers.php index 88383834..7c008319 100644 --- a/lam/templates/lists/listusers.php +++ b/lam/templates/lists/listusers.php @@ -20,9 +20,6 @@ $Id$ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// must be put in config file ... -// maximum count of user entries shown on one page -$max_pageentrys = 3; include_once ("../../lib/config.inc"); include_once("../../lib/ldap.inc"); @@ -63,6 +60,10 @@ $page = $_GET["page"]; if (!$page) $page = 1; +// maximum count of user entries shown on one page +$max_pageentrys = $_SESSION["config"]->get_MaxListEntries(); + + 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) == "#") { @@ -92,12 +93,13 @@ 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 ($_GET["sort"]) usort ($_SESSION["userlist"], "cmp_array"); $userinfo = $_SESSION["userlist"]; } else { - $attrs = $attr_array; $sr = @ldap_search($_SESSION["ldap"]->server(), $_SESSION["config"]->get_UserSuffix(), @@ -117,22 +119,12 @@ if ($_SESSION["userlist"] && !$_POST['refresh'] && !$_POST["apply_filter"]) { "

"); } +$user_count = sizeof ($_SESSION["userlist"]); + echo ("
\n"); - - // create navigation bar on top of user table -echo (""); -echo (""); -echo (""); -for ($i = 0; $i < (sizeof ($userinfo) / $max_pageentrys); $i++) { - if ($i == $page - 1) - echo (""); - else - echo (""); -} -echo ("
" . ($i + 1) . "" . ($i + 1) . "
"); +draw_navigation_bar ($user_count); echo ("
"); // print user table header @@ -200,6 +192,9 @@ for ($i = 0; $i < sizeof ($userinfo); $i++) { // ignore last entry in array whic echo (""); echo ("
"); +draw_navigation_bar ($user_count); +echo ("
"); + echo (""); echo (""); @@ -208,6 +203,42 @@ echo ("
\n"); echo ("
\n"); echo "\n"; +/** + * @brief draws a navigation bar to switch between pages + * + * + * @return void + */ +function draw_navigation_bar ($user_count) { + global $max_pageentrys; + global $page; + + echo (""); + echo (""); + echo (""); + + echo ("
  "); + if ($page != 1) + echo ("<="); + else + echo ("<="); + echo (" "); + + if ($page < ($user_count / $max_pageentrys)) + echo ("=>"); + else + echo ("=>"); + for ($i = 0; $i < ($user_count / $max_pageentrys); $i++) { + if ($i == $page - 1) + echo (" " . ($i + 1)); + else + echo (" " . ($i + 1) . ""); + } + echo ("
"); +} + + // compare function used for usort-method // rows are sorted with the first attribute entry of the sort column // if objects have attributes with multiple values the others are ignored