<?php

	$menuString = ".|Import||||
..|Table Config|../tableconfig2.php|||content
..|Table Log|../tablelog.php|||content
.|Report||||content
..|Report Designer|../report_designer.php|||content
..|Report|../report2.php|||content
.|User||||
..|User|../user.php|||content
..|User Group|../user_group.php|||content
..|User Rights|../user_right.php|||content
..|User Report|../user_report.php|||content
..|Right|../right.php|||content
..|Group|../group.php|||content
..|Group Rights|../group_right.php|||content
.|Language||||
..|Language|../language2.php|||content
..|Dictionary|../dictionary2.php|||content
.|Change Password|../chpass.php|||content
.|Log History|../qb_changelog.php|||content
.|Online User|../online_user.php|||content
.|Setting|../qb_setting.php|||content
.|Logout|../logout.php|||content";

	// SET m = array ( User.User => ..|User|../user.php|||content );
	$p = explode("\n", $menuString);
	foreach ($p as $k => $v) {
		$p2 = explode("|", $v);
		$l[strlen($p2[0])-1] = $p2[1];
		$p3 = '';
		for ($i=0;$i<strlen($p2[0]);$i++) {
			$p3 .= $l[$i].'.';
		}
		$p3 = substr($p3,0,-1);
		$firstPipe = strpos($v, '|');
		$secondPipe = strpos($v, '|', $firstPipe+1);
		#echo $firstPipe." ".$secondPipe."<br>\n";
		$a = substr($v, 0, $firstPipe+1);
		$b = substr($v, $firstPipe+1, ($secondPipe-$firstPipe)-1);
		$c = substr($v, $secondPipe);
		$m[$p3] = $a.__($p3,$b,__FILE__).$c;
		#$m[$p3] = $v;
	}
	#print_r($m);
	#exit;

	$userId = $_SESSION['userid'];
	if (!$isSupervisor) {
		$userMenu = getUserMenu($userId);
		$where = str_replace(",", "','", $userMenu);
		$rs = $adodb->Execute("SELECT DISTINCT(module) as module FROM qb_right ".
		" WHERE id IN ('".$where."')");
		if (!$rs->EOF) {
			$arrModule = array();
			while (!$rs->EOF) {
				$mod = $rs->fields['module'];
				$p = explode(".", $mod);
				$p2 = '';
				for ($i=0,$j=count($p);$i<$j;$i++) {
					$p2 .= $p[$i].'.';
					$arrModule[trim(substr($p2,0,-1))] = 1;
				}
				$rs->MoveNext();
			}
		}
		$arrModule['Logout'] = 1;
	} else {
		$arrModule =& $m;
	}

	$menuString = '';
	foreach ($m as $k => $v) {
		$k = trim($k);
		if (isset($arrModule[$k])) $menuString .= $v."\n";
	}
	#$menuString .= $m['Logout']."\n";

?>
