From c74404ec29ff4508a854662fe0090bc7015be855 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 1 Jun 2004 11:32:00 +0000 Subject: [PATCH] moved draw_navigation_bar to lists.inc --- lam/lib/lists.inc | 53 ++++++++++++++++++- lam/style/500_layout.css | 8 +-- lam/templates/lists/listdomains.php | 58 ++++---------------- lam/templates/lists/listgroups.php | 69 +++++------------------- lam/templates/lists/listhosts.php | 67 +++++------------------ lam/templates/lists/listusers.php | 82 +++++++---------------------- 6 files changed, 112 insertions(+), 225 deletions(-) diff --git a/lam/lib/lists.inc b/lam/lib/lists.inc index 38761a15..1150b7da 100644 --- a/lam/lib/lists.inc +++ b/lam/lib/lists.inc @@ -72,7 +72,58 @@ function listSort($sort, $attr_array, $info) { // sort and return account list usort($info, "cmp_array"); return $info; - } + +/** +* @brief draws a navigation bar to switch between pages +* +* @param integer $count number of account entries +* @param integer $max_page_entries maximum number of account per page +* @param integer $page current page number +* @param string $sort sort attribute +* @param string $searchFilter LDAP search filter +* @param string $scope account type (user/group/host/domain) +* @param string $text string including the number of accounts +*/ +function listDrawNavigationBar($count, $max_page_entries, $page, $sort, $searchFilter, $scope, $text) { + + echo("\n"); + echo("\n"); + echo(""); + } + + echo(""); + + echo("
  "); + if ($page != 1) { + echo("<=\n"); + } + else { + echo("<="); + } + echo(" "); + + if ($page < ($count / $max_page_entries)) { + echo("=>\n"); + } + else { + echo("=>"); + //echo" " . $count . " " . _("Group(s) found"); + echo" "; + printf($text, $count); + echo(""); + for ($i = 0; $i < ($count / $max_page_entries); $i++) { + if ($i == $page - 1) { + echo(" " . ($i + 1)); + } + else { + echo(" " . ($i + 1) . "\n"); + } + } + echo("
\n"); +} + + + ?> \ No newline at end of file diff --git a/lam/style/500_layout.css b/lam/style/500_layout.css index be76102f..00f9f52d 100644 --- a/lam/style/500_layout.css +++ b/lam/style/500_layout.css @@ -106,23 +106,23 @@ tr.userlist-checked { } /* color for active page digit */ -td.userlist-activepage { +td.usernav-activepage { color:red; } /* style of navigation bar */ -td.userlist-navbar { +td.usernav { color:#AAAAAA; } -table.userlist-navbar { +table.usernav { background-color:#fff2a3; border-width:1px; border-style:solid; border-color:#9b8523; } -td.userlist-navbartext { +td.usernav-text { color:green; font-family:Verdana,sans-serif; font-size:12px; diff --git a/lam/templates/lists/listdomains.php b/lam/templates/lists/listdomains.php index ed010d0b..1290803e 100644 --- a/lam/templates/lists/listdomains.php +++ b/lam/templates/lists/listdomains.php @@ -72,9 +72,9 @@ $page = $_GET["page"]; if (!$page) $page = 1; // take maximum count of domain entries shown on one page out of session if ($_SESSION["config"]->get_MaxListEntries() <= 0) - $max_pageentrys = 10; // default setting, if not yet set + $max_page_entries = 10; // default setting, if not yet set else - $max_pageentrys = $_SESSION["config"]->get_MaxListEntries(); + $max_page_entries = $_SESSION["config"]->get_MaxListEntries(); // generate attribute and description tables @@ -106,7 +106,7 @@ if (! $_GET['norefresh']) { ldap_free_result($sr); if ($dom_info["count"] == 0) StatusMessage("WARN", "", _("No Samba Domains found!")); // delete first array entry which is "count" - array_shift($dom_info); + unset($dom_info['count']); // sort rows by sort column ($sort) $dom_info = listSort($sort, $attr_array, $dom_info); } @@ -123,7 +123,7 @@ echo ("
\n"); // draw navigation bar if domain accounts were found if (sizeof($dom_info) > 0) { -draw_navigation_bar(sizeof($dom_info)); +listDrawNavigationBar(sizeof($dom_info), $max_page_entries, $page, $sort, $searchFilter, "domain", _("%s Samba domain(s) found")); echo ("
\n"); } @@ -142,9 +142,9 @@ for ($k = 0; $k < sizeof($desc_array); $k++) { echo "\n"; // calculate which rows to show -$table_begin = ($page - 1) * $max_pageentrys; -if (($page * $max_pageentrys) > sizeof($dom_info)) $table_end = sizeof($dom_info); -else $table_end = ($page * $max_pageentrys); +$table_begin = ($page - 1) * $max_page_entries; +if (($page * $max_page_entries) > sizeof($dom_info)) $table_end = sizeof($dom_info); +else $table_end = ($page * $max_page_entries); // print domain list for ($i = $table_begin; $i < $table_end; $i++) { @@ -159,7 +159,7 @@ for ($i = $table_begin; $i < $table_end; $i++) { // print all attribute entries seperated by "; " if (sizeof($dom_info[$i][strtolower($attr_array[$k])]) > 0) { // delete first array entry which is "count" - if ((! $_GET['norefresh']) && (is_array($dom_info[$i][strtolower($attr_array[$k])]))) array_shift($dom_info[$i][strtolower($attr_array[$k])]); + if (is_array($dom_info[$i][strtolower($attr_array[$k])])) unset($dom_info[$i][strtolower($attr_array[$k])]['count']); if (is_array($dom_info[$i][strtolower($attr_array[$k])])) echo implode("; ", $dom_info[$i][strtolower($attr_array[$k])]); else echo $dom_info[$i][strtolower($attr_array[$k])]; } @@ -173,7 +173,7 @@ echo ("
"); // draw navigation bar if domain accounts were found if (sizeof($dom_info) > 0) { -draw_navigation_bar(sizeof($dom_info)); +listDrawNavigationBar(sizeof($dom_info), $max_page_entries, $page, $sort, $searchFilter, "domain", _("%s Samba domain(s) found")); echo ("
\n"); } @@ -205,46 +205,6 @@ echo ("

\n"); echo ("
\n"); echo "\n"; -/** - * @brief draws a navigation bar to switch between pages - * - * - * @return void - */ -function draw_navigation_bar ($count) { - global $max_pageentrys; - global $page; - global $sort; - - echo ("\n"); - echo ("\n"); - echo (""); - - echo (""); - - echo ("
  "); - if ($page != 1) - echo ("<=\n"); - else - echo ("<="); - echo (" "); - - if ($page < ($count / $max_pageentrys)) - echo ("=>\n"); - else - echo ("=>"); - echo " " . $count . " " . _("Samba Domain(s) found"); - echo (""); - for ($i = 0; $i < ($count / $max_pageentrys); $i++) { - if ($i == $page - 1) - echo (" " . ($i + 1)); - else - echo (" " . ($i + 1) . "\n"); - } - echo ("
\n"); -} - // save variables to session diff --git a/lam/templates/lists/listgroups.php b/lam/templates/lists/listgroups.php index 38d50c2b..87654281 100644 --- a/lam/templates/lists/listgroups.php +++ b/lam/templates/lists/listgroups.php @@ -111,9 +111,9 @@ $page = $_GET["page"]; if (!$page) $page = 1; // take maximum count of group entries shown on one page out of session if ($_SESSION["config"]->get_MaxListEntries() <= 0) - $max_pageentrys = 10; // default setting, if not yet set + $max_page_entries = 10; // default setting, if not yet set else - $max_pageentrys = $_SESSION["config"]->get_MaxListEntries(); + $max_page_entries = $_SESSION["config"]->get_MaxListEntries(); // generate column attributes and descriptions for ($i = 0; $i < sizeof($temp_array); $i++) { @@ -139,10 +139,10 @@ elseif ($_SESSION['grp_suffix']) $grp_suffix = $_SESSION['grp_suffix']; // old else $grp_suffix = $_SESSION["config"]->get_GroupSuffix(); // default suffix // generate search filter for sort links -$searchfilter = ""; +$searchFilter = ""; for ($k = 0; $k < sizeof($desc_array); $k++) { if (eregi("^([0-9a-z_\\*\\+\\-])+$", $_POST["filter" . strtolower($attr_array[$k])])) { - $searchfilter = $searchfilter . "&filter" . strtolower($attr_array[$k]) . "=". + $searchFilter = $searchFilter . "&filter" . strtolower($attr_array[$k]) . "=". $_POST["filter" . strtolower($attr_array[$k])]; } } @@ -169,7 +169,7 @@ if (! $_GET['norefresh']) { ldap_free_result($sr); if ($grp_info["count"] == 0) StatusMessage("WARN", "", _("No Groups found!")); // delete first array entry which is "count" - array_shift($grp_info); + unset($grp_info['count']); // sort rows by sort column ($sort) $grp_info = listSort($sort, $attr_array, $grp_info); } @@ -189,7 +189,7 @@ echo ("
\n"); // draw navigation bar if group accounts were found if (sizeof($grp_info) > 0) { -draw_navigation_bar(sizeof($grp_info)); +listDrawNavigationBar(sizeof($grp_info), $max_page_entries, $page, $sort, $searchFilter, "group", _("%s group(s) found")); echo ("
"); } @@ -200,10 +200,10 @@ echo ""; for ($k = 0; $k < sizeof($desc_array); $k++) { if (strtolower($attr_array[$k]) == $sort) { echo "" . $desc_array[$k] . ""; + "sort=" . strtolower($attr_array[$k]) . $searchFilter . "&norefresh=y" . "\">" . $desc_array[$k] . ""; } else echo "" . $desc_array[$k] . ""; + "sort=" . strtolower($attr_array[$k]) . $searchFilter . "&norefresh=y" . "\">" . $desc_array[$k] . ""; } echo "\n"; @@ -221,9 +221,9 @@ for ($k = 0; $k < sizeof ($desc_array); $k++) { echo "\n"; // calculate which rows to show -$table_begin = ($page - 1) * $max_pageentrys; -if (($page * $max_pageentrys) > sizeof($grp_info)) $table_end = sizeof($grp_info); -else $table_end = ($page * $max_pageentrys); +$table_begin = ($page - 1) * $max_page_entries; +if (($page * $max_page_entries) > sizeof($grp_info)) $table_end = sizeof($grp_info); +else $table_end = ($page * $max_page_entries); if (sizeof($grp_info) > 0) { // print group list @@ -246,7 +246,7 @@ if (sizeof($grp_info) > 0) { // print all attribute entries seperated by "; " if (sizeof($grp_info[$i][strtolower($attr_array[$k])]) > 0) { // delete first array entry which is "count" - if ((! $_GET['norefresh']) && (is_array($grp_info[$i][strtolower($attr_array[$k])]))) array_shift($grp_info[$i][strtolower($attr_array[$k])]); + if (is_array($grp_info[$i][strtolower($attr_array[$k])])) unset($grp_info[$i][strtolower($attr_array[$k])]['count']); // generate links for group members if (strtolower($attr_array[$k]) == "memberuid") { // sort array @@ -280,7 +280,7 @@ if (sizeof($grp_info) > 0) { echo "\n"; echo "\"select\n"; echo " " . + $searchFilter . "&selectall=yes\">" . "" . _("Select all") . "\n"; echo "\n"; } @@ -289,7 +289,7 @@ echo ("
"); // draw navigation bar if group accounts were found if (sizeof($grp_info) > 0) { -draw_navigation_bar(sizeof($grp_info)); +listDrawNavigationBar(sizeof($grp_info), $max_page_entries, $page, $sort, $searchFilter, "group", _("%s group(s) found")); echo ("
\n"); } @@ -327,47 +327,6 @@ if (sizeof($grp_info) > 0) { echo ("
\n"); echo "\n"; -/** - * @brief draws a navigation bar to switch between pages - * - * - * @return void - */ -function draw_navigation_bar ($count) { - global $max_pageentrys; - global $page; - global $sort; - global $searchfilter; - - echo ("\n"); - echo ("\n"); - echo (""); - - echo (""); - - echo ("
  "); - if ($page != 1) - echo ("<=\n"); - else - echo ("<="); - echo (" "); - - if ($page < ($count / $max_pageentrys)) - echo ("=>\n"); - else - echo ("=>"); - echo " " . $count . " " . _("Group(s) found"); - echo (""); - for ($i = 0; $i < ($count / $max_pageentrys); $i++) { - if ($i == $page - 1) - echo (" " . ($i + 1)); - else - echo (" " . ($i + 1) . "\n"); - } - echo ("
\n"); -} - // save variables to session $_SESSION['grp_info'] = $grp_info; $_SESSION['grp_units'] = $grp_units; diff --git a/lam/templates/lists/listhosts.php b/lam/templates/lists/listhosts.php index 7131bd15..5556264d 100644 --- a/lam/templates/lists/listhosts.php +++ b/lam/templates/lists/listhosts.php @@ -107,9 +107,9 @@ $page = $_GET["page"]; if (!$page) $page = 1; // take maximum count of host entries shown on one page out of session if ($_SESSION["config"]->get_MaxListEntries() <= 0) - $max_pageentrys = 10; // default setting, if not yet set + $max_page_entries = 10; // default setting, if not yet set else - $max_pageentrys = $_SESSION["config"]->get_MaxListEntries(); + $max_page_entries = $_SESSION["config"]->get_MaxListEntries(); // generate column attributes and descriptions for ($i = 0; $i < sizeof($temp_array); $i++) { @@ -135,10 +135,10 @@ elseif ($_SESSION['hst_suffix']) $hst_suffix = $_SESSION['hst_suffix']; // old else $hst_suffix = $_SESSION["config"]->get_HostSuffix(); // default suffix // generate search filter for sort links -$searchfilter = ""; +$searchFilter = ""; for ($k = 0; $k < sizeof($desc_array); $k++) { if (eregi("^([0-9a-z_\\*\\+\\-])+$", $_POST["filter" . strtolower($attr_array[$k])])) { - $searchfilter = $searchfilter . "&filter" . strtolower($attr_array[$k]) . "=". + $searchFilter = $searchFilter . "&filter" . strtolower($attr_array[$k]) . "=". $_POST["filter" . strtolower($attr_array[$k])]; } } @@ -165,7 +165,7 @@ if (! $_GET['norefresh']) { ldap_free_result($sr); if ($hst_info["count"] == 0) StatusMessage("WARN", "", _("No Samba Hosts found!")); // delete first array entry which is "count" - array_shift($hst_info); + unset($hst_info['count']); // sort rows by sort column ($sort) $hst_info = listSort($sort, $attr_array, $hst_info); } @@ -185,7 +185,7 @@ echo ("
\n"); // draw navigation bar if host accounts were found if (sizeof($hst_info) > 0) { -draw_navigation_bar(sizeof($hst_info)); +listDrawNavigationBar(sizeof($hst_info), $max_page_entries, $page, $sort, $searchFilter, "host", _("%s host(s) found")); echo ("
\n"); } @@ -196,10 +196,10 @@ echo ""; for ($k = 0; $k < sizeof($desc_array); $k++) { if (strtolower($attr_array[$k]) == $sort) { echo "" . $desc_array[$k] . ""; + "sort=" . strtolower($attr_array[$k]) . $searchFilter . "&norefresh=y" . "\">" . $desc_array[$k] . ""; } else echo "" . $desc_array[$k] . ""; + "sort=" . strtolower($attr_array[$k]) . $searchFilter . "&norefresh=y" . "\">" . $desc_array[$k] . ""; } echo "\n"; @@ -217,9 +217,9 @@ for ($k = 0; $k < sizeof ($desc_array); $k++) { echo "\n"; // calculate which rows to show -$table_begin = ($page - 1) * $max_pageentrys; -if (($page * $max_pageentrys) > sizeof($hst_info)) $table_end = sizeof($hst_info); -else $table_end = ($page * $max_pageentrys); +$table_begin = ($page - 1) * $max_page_entries; +if (($page * $max_page_entries) > sizeof($hst_info)) $table_end = sizeof($hst_info); +else $table_end = ($page * $max_page_entries); if (sizeof($hst_info) > 0) { // print host list @@ -259,7 +259,7 @@ if (sizeof($hst_info) > 0) { echo "\n"; echo "\"select\n"; echo " " . + $searchFilter . "&selectall=yes\">" . "" . _("Select all") . "\n"; echo "\n"; } @@ -269,7 +269,7 @@ echo ("
"); // draw navigation bar if host accounts were found if (sizeof($hst_info) > 0) { -draw_navigation_bar(sizeof($hst_info)); +listDrawNavigationBar(sizeof($hst_info), $max_page_entries, $page, $sort, $searchFilter, "host", _("%s host(s) found")); echo ("
\n"); } @@ -308,47 +308,6 @@ if (sizeof($hst_info) > 0) { echo ("
\n"); echo "\n"; -/** - * @brief draws a navigation bar to switch between pages - * - * - * @return void - */ -function draw_navigation_bar ($count) { - global $max_pageentrys; - global $page; - global $sort; - global $searchfilter; - - echo ("\n"); - echo ("\n"); - echo (""); - - echo (""); - - echo ("
  "); - if ($page != 1) - echo ("<=\n"); - else - echo ("<="); - echo (" "); - - if ($page < ($count / $max_pageentrys)) - echo ("=>\n"); - else - echo ("=>"); - echo " " . $count . " " . _("Samba Host(s) found"); - echo (""); - for ($i = 0; $i < ($count / $max_pageentrys); $i++) { - if ($i == $page - 1) - echo (" " . ($i + 1)); - else - echo (" " . ($i + 1) . "\n"); - } - echo ("
\n"); -} - // save variables to session $_SESSION['hst_info'] = $hst_info; $_SESSION['hst_units'] = $hst_units; diff --git a/lam/templates/lists/listusers.php b/lam/templates/lists/listusers.php index 75b6792f..12617ba5 100644 --- a/lam/templates/lists/listusers.php +++ b/lam/templates/lists/listusers.php @@ -54,7 +54,7 @@ if ($trans_primary == "on" && !$_GET["norefresh"]) { $sr = @ldap_search($_SESSION["ldap"]->server(), $suffix, $filter, $attrs); if ($sr) { $info = @ldap_get_entries($_SESSION["ldap"]->server(), $sr); - array_shift($info); // delete count entry + unset($info['count']); // delete count entry for ($i = 0; $i < sizeof($info); $i++) { $trans_primary_hash[$info[$i]['gidnumber'][0]] = $info[$i]['cn'][0]; } @@ -129,9 +129,9 @@ if (!$page) $page = 1; // take maximum count of user entries shown on one page out of session if ($_SESSION["config"]->get_MaxListEntries() <= 0) { - $max_pageentrys = 10; // default setting, if not yet set + $max_page_entries = 10; // default setting, if not yet set } -else $max_pageentrys = $_SESSION["config"]->get_MaxListEntries(); +else $max_page_entries = $_SESSION["config"]->get_MaxListEntries(); // generate attribute-description table $attr_array = array(); // list of LDAP attributes to show @@ -158,7 +158,7 @@ for ($i = 0; $i < sizeof($temp_array); $i++) { } } -$sort = $_GET["sortattrib"]; +$sort = $_GET["sort"]; if (!$sort) $sort = strtolower($attr_array[0]); @@ -169,10 +169,10 @@ else $usr_suffix = $_SESSION["config"]->get_UserSuffix(); // default suffix // generate search filter for sort links -$searchfilter = ""; +$searchFilter = ""; for ($k = 0; $k < sizeof($desc_array); $k++) { if (eregi("^([0-9a-z_\\*\\+\\-])+$", $_POST["filter" . strtolower($attr_array[$k])])) { - $searchfilter = $searchfilter . "&filter" . + $searchFilter = $searchFilter . "&filter" . strtolower($attr_array[$k]) . "=". $_POST["filter" . strtolower($attr_array[$k])]; } @@ -207,7 +207,7 @@ else { ldap_free_result ($sr); if ($userinfo["count"] == 0) StatusMessage("WARN", "", _("No Users found!")); // delete first array entry which is "count" - array_shift($userinfo); + unset($userinfo['count']); $userinfo = listSort($sort, $attr_array, $userinfo); $_SESSION["userlist"] = $userinfo; } @@ -226,11 +226,10 @@ echo ("
\n"); // display table only if users exist in LDAP if ($user_count != 0) { - - // create navigation bar on top of user table - draw_navigation_bar ($user_count); - - echo ("
"); + // create navigation bar on top of user table + listDrawNavigationBar($user_count, $max_page_entries, $page, $sort, + $searchFilter . "&trans_primary=" . $trans_primary, "user", _("%s user(s) found")); + echo ("
"); } // print user table header @@ -244,8 +243,8 @@ if ($user_count != 0) { echo "\n"; else echo "\n"; - echo "" . + echo "" . $desc_array[$k] . "\n"; } echo "\n"; @@ -278,7 +277,7 @@ if ($user_count != 0) { } } // print user list - $userinfo = array_slice ($userinfo, ($page - 1) * $max_pageentrys, $max_pageentrys); + $userinfo = array_slice ($userinfo, ($page - 1) * $max_page_entries, $max_page_entries); for ($i = 0; $i < sizeof ($userinfo); $i++) { // ignore last entry in array which is "count" echo(" 0) { if (is_array($userinfo[$i][strtolower($attr_array[$k])])) { // delete first array entry which is "count" - array_shift($userinfo[$i][strtolower($attr_array[$k])]); + unset($userinfo[$i][strtolower($attr_array[$k])]['count']); // sort array sort($userinfo[$i][strtolower($attr_array[$k])]); // print all attribute entries seperated by "; " @@ -317,8 +316,8 @@ if ($user_count != 0) { $colspan = sizeof($attr_array) + 1; echo "\n"; echo "\"select\n"; - echo " " . + echo " " . "" . _("Select all") . "\n"; echo "\n"; } @@ -326,8 +325,9 @@ echo ("\n"); echo ("
"); if ($user_count != 0) { - draw_navigation_bar ($user_count); - echo ("
"); + listDrawNavigationBar($user_count, $max_page_entries, $page, $sort, + $searchFilter . "&trans_primary=" . $trans_primary, "user", _("%s user(s) found")); + echo ("
"); } if (! $_GET['norefresh']) { @@ -380,48 +380,6 @@ 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; - global $sort; - global $searchfilter; - global $trans_primary; - - echo ("\n"); - echo ("\n"); - echo ("\n"); - - - echo ("\n
\n\n  "); - if ($page != 1) - echo ("<=\n"); - else echo ("<="); - echo (" "); - - if ($page < ($user_count / $max_pageentrys)) - echo ("=>\n"); - else echo ("=>"); - echo ("\n"); - echo " " . $user_count . " " . _("User(s) found") . "\n"; - echo (""); - for ($i = 0; $i < ($user_count / $max_pageentrys); $i++) { - if ($i == $page - 1) echo (" " . ($i + 1)); - else echo (" " . ($i + 1) . "\n"); - } - echo ("
\n"); -} - // save variables to session $_SESSION['usr_units'] = $usr_units;