Project

General

Profile

« Previous | Next » 

Revision 4adfb2df

Added by Scott Ullrich over 17 years ago

Backport display_top_tabs() from HEAD.

View differences:

etc/inc/pfsense-utils.inc
2138 2138
 * NAME
2139 2139
 *   display_top_tabs - display tabs with rounded edges
2140 2140
 * INPUTS
2141
 *   $text	- array of tabs
2141
 *   $text      - array of tabs
2142 2142
 * RESULT
2143 2143
 *   null
2144 2144
 ******/
2145
function display_top_tabs($tab_array) {
2145
function display_top_tabs(& $tab_array) {
2146
	global $HTTP_SERVER_VARS;
2147
	global $config;
2148

  
2149
	$groupindex = index_groups();
2150
	$userindex = index_users();
2151

  
2152
	$allowed = array ();
2153

  
2154
	$allowed[] = '';
2155
	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'])) {
2156
		$allowed = & $config['system']['group'][$groupindex[$config['system']['user'][$userindex[$HTTP_SERVER_VARS['AUTH_USER']]]['groupname']]]['pages'][0]['page'];
2157
	}
2158

  
2159
	/*   does the user have access to this tab?
2160
	 *   master user has access to everything.
2161
	*   if the user does not have access, simply
2162
	*   unset the tab item.
2163
	*/
2164

  
2165
	if (!isSystemAdmin($HTTP_SERVER_VARS['AUTH_USER'])) {
2166
		$authorized = & $allowed;
2167
		$tab_temp = array ();
2168
		foreach ($tab_array as $ta) {
2169
			$link = $ta[2];
2170
			// TODO: humm what shall we do with pkg_edit.php and pkg.php?
2171
			if ((strpos($link, "pkg.php")) !== false || (strpos($link, "pkg_edit.php")) !== false) {
2172
				$pos_equal = strpos($link, "=");
2173
				$pos_xmlsuffix = strpos($link, ".xml");
2174
				$link = substr($link, $pos_equal +1, ($pos_xmlsuffix - $pos_equal +3));
2175
			}
2176
			// next check - what if the basename contains a query string?
2177
			if ((strpos($link, "?")) !== false) {
2178
				$pos_qmark = strpos($link, "?");
2179
				$link = substr($link, 0, $pos_qmark);
2180
			}
2181
			if (in_array(basename($link), $authorized))
2182
				$tab_temp[] = $ta;
2183
		}
2184
		unset ($tab_array);
2185
		$tab_array = & $tab_temp;
2186
	}
2187

  
2146 2188
	echo "<table cellpadding='0' cellspacing='0'>\n";
2147
	echo " <tr height='1'>\n";
2189
	echo " <tr>\n";
2148 2190
	$tabscounter = 0;
2149 2191
	foreach ($tab_array as $ta) {
2150
		if($ta[1] == true) {
2192
		if ($ta[1] == true) {
2151 2193
			echo "  <td bgcolor='#EEEEEE' onClick=\"document.location='{$ta[2]}'\" style=\"cursor: pointer;\"><div id='tabactive'></div></td>\n";
2152 2194
		} else {
2153 2195
			echo "  <td bgcolor='#777777' onClick=\"document.location='{$ta[2]}'\" style=\"cursor: pointer;\"><div id='tabdeactive{$tabscounter}'></div></td>\n";
......
2156 2198
	}
2157 2199
	echo "</tr>\n<tr>\n";
2158 2200
	foreach ($tab_array as $ta) {
2159
		if($ta[1] == true) {
2160
			echo "  <td bgcolor='#EEEEEE' onClick=\"document.location='{$ta[2]}'\" style=\"cursor: pointer;\"><B>&nbsp;&nbsp;&nbsp;{$ta[0]}";
2201
		if ($ta[1] == true) {
2202
			echo "  <td height=\"15\" valign=\"middle\" bgcolor='#EEEEEE' onClick=\"document.location='{$ta[2]}'\" style=\"cursor: pointer;\"><B>&nbsp;&nbsp;&nbsp;{$ta[0]}";
2161 2203
			echo "&nbsp;&nbsp;&nbsp;";
2162
			echo "<font size='-12'>&nbsp;</td>\n";
2204
			echo "<font size='-12'>&nbsp;</font></B></td>\n";
2163 2205
		} else {
2164
			echo "  <td bgcolor='#777777' onClick=\"document.location='{$ta[2]}'\" style=\"cursor: pointer;\"><B>&nbsp;&nbsp;&nbsp;<a href='{$ta[2]}'>";
2165
			echo "<font color='white'>{$ta[0]}</a>&nbsp;&nbsp;&nbsp;";
2166
			echo "<font size='-12'>&nbsp;</td>\n";
2206
			echo "  <td height=\"15\" valign=\"middle\" bgcolor='#777777' onClick=\"document.location='{$ta[2]}'\" style=\"cursor: pointer;\"><B>&nbsp;&nbsp;&nbsp;<a href='{$ta[2]}'>";
2207
			echo "<font color='white'>{$ta[0]}</font></a>&nbsp;&nbsp;&nbsp;";
2208
			echo "<font size='-12'>&nbsp;</font></B></td>\n";
2167 2209
		}
2168 2210
	}
2169
	echo "</tr>\n<tr height='5px'>\n";
2211
	echo "</tr>\n<tr>\n";
2170 2212
	foreach ($tab_array as $ta) {
2171
		if($ta[1] == true) {
2213
		if ($ta[1] == true) {
2172 2214
			echo "  <td bgcolor='#EEEEEE' onClick=\"document.location='{$ta[2]}'\" style=\"cursor: pointer;\"></td>\n";
2173 2215
		} else {
2174 2216
			echo "  <td bgcolor='#777777' onClick=\"document.location='{$ta[2]}'\" style=\"cursor: pointer;\"></td>\n";
......
2181 2223
	echo "<script type=\"text/javascript\">";
2182 2224
	echo "NiftyCheck();\n";
2183 2225
	echo "Rounded(\"div#tabactive\",\"top\",\"#FFF\",\"#EEEEEE\",\"smooth\");\n";
2184
	for($x=0; $x<$tabscounter; $x++)
2226
	for ($x = 0; $x < $tabscounter; $x++)
2185 2227
		echo "Rounded(\"div#tabdeactive{$x}\",\"top\",\"#FFF\",\"#777777\",\"smooth\");\n";
2186 2228
	echo "</script>";
2187 2229
}

Also available in: Unified diff