<?
/***********************************************************/
/* Get Action Security
/* Each action has a set of security levels available to it
/* 
/***********************************************************/
$actionName = '';
$actionSecy = array();

$query = <<<eod
SELECT a.ActionId, a.Action, a.ActionLabel, sl.SecyLvlId
FROM
	Actions a
INNER JOIN
	ActionSecys asec
		ON asec.ActionId = a.ActionId
INNER JOIN
	SecyLvls sl
		ON sl.SecyLvlId = asec.SecyLvlId
WHERE a.Action = '{$action}'
eod;

$result = mysql_query($query, $mydb) or die(mysql_error() . "<br>" . $query);
while($row = mysql_fetch_array($result)) {
	$actionId = $row['ActionId'];
	$actionName = $row['Action'];
	array_push($actionSecy, $row['SecyLvlId']);
	$actionLabel = $row['ActionLabel'];
}
if($actionName == '') {
	$actionId = 1;
	$actionSecy = array();
	array_push($actionSecy, 1);
}
/***********************************************************/
/* Get User Access for Action
 /***********************************************************/
$allowAccess = false;
for($i = 0; $i < count($actionSecy); $i++) {
	if($actionSecy[$i] == 1) {
		$allowAccess = true;
		break;
	}
	elseif(is_array($_SESSION['UserSecyLvl'])) {
		if(in_array($actionSecy[$i], $_SESSION['UserSecyLvl'])) {
			$allowAccess = true;
			break;
		}
	}
}
?>