From 4adfb2df7ad148f47eea30d61617aee3736873bc Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sun, 2 Dec 2007 00:02:16 +0000 Subject: Backport display_top_tabs() from HEAD. --- etc/inc/pfsense-utils.inc | 68 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 13 deletions(-) diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index e890395..fff1d3d 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -2138,16 +2138,58 @@ function get_disk_info() { * NAME * display_top_tabs - display tabs with rounded edges * INPUTS - * $text - array of tabs + * $text - array of tabs * RESULT * null ******/ -function display_top_tabs($tab_array) { +function display_top_tabs(& $tab_array) { + global $HTTP_SERVER_VARS; + global $config; + + $groupindex = index_groups(); + $userindex = index_users(); + + $allowed = array (); + + $allowed[] = ''; + if (!isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER']) && isset ($config['system']['group'][$groupindex[$config['system']['user'][$userindex[$HTTP_SERVER_VARS['AUTH_USER']]]['groupname']]]['pages'][0]['page'])) { + $allowed = & $config['system']['group'][$groupindex[$config['system']['user'][$userindex[$HTTP_SERVER_VARS['AUTH_USER']]]['groupname']]]['pages'][0]['page']; + } + + /* does the user have access to this tab? + * master user has access to everything. + * if the user does not have access, simply + * unset the tab item. + */ + + if (!isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER'])) { + $authorized = & $allowed; + $tab_temp = array (); + foreach ($tab_array as $ta) { + $link = $ta[2]; + // TODO: humm what shall we do with pkg_edit.php and pkg.php? + if ((strpos($link, "pkg.php")) !== false || (strpos($link, "pkg_edit.php")) !== false) { + $pos_equal = strpos($link, "="); + $pos_xmlsuffix = strpos($link, ".xml"); + $link = substr($link, $pos_equal +1, ($pos_xmlsuffix - $pos_equal +3)); + } + // next check - what if the basename contains a query string? + if ((strpos($link, "?")) !== false) { + $pos_qmark = strpos($link, "?"); + $link = substr($link, 0, $pos_qmark); + } + if (in_array(basename($link), $authorized)) + $tab_temp[] = $ta; + } + unset ($tab_array); + $tab_array = & $tab_temp; + } + echo "\n"; - echo " \n"; + echo " \n"; $tabscounter = 0; foreach ($tab_array as $ta) { - if($ta[1] == true) { + if ($ta[1] == true) { echo " \n"; } else { echo " \n"; @@ -2156,19 +2198,19 @@ function display_top_tabs($tab_array) { } echo "\n\n"; foreach ($tab_array as $ta) { - if($ta[1] == true) { - echo " \n"; + echo " \n"; } else { - echo " \n"; + echo " \n"; } } - echo "\n\n"; + echo "\n\n"; foreach ($tab_array as $ta) { - if($ta[1] == true) { + if ($ta[1] == true) { echo " \n"; } else { echo " \n"; @@ -2181,7 +2223,7 @@ function display_top_tabs($tab_array) { echo ""; } -- cgit v1.1
   {$ta[0]}"; + if ($ta[1] == true) { + echo "    {$ta[0]}"; echo "   "; - echo "    "; - echo "{$ta[0]}   "; - echo "    "; + echo "{$ta[0]}   "; + echo "