Hi,
I need some advice how to manage the problem below.
I have 3 tables:
Desktop - master table, fields: siteid and few others
Sites - dictionary table (data for dropdown box on desktop page), fields: SiteID, SiteName
Administrator - contains fields: UserLogin, SiteID, RoleID
I'm filtering records in Desktop table based on detected NT login and relation between tables.
Login page -> Before process (check the NT user name)
if ($_SERVER["REMOTE_USER"])
{
$_SESSION["UserID"] = $_SERVER["REMOTE_USER"];
$_SESSION["AccessLevel"] = ACCESS_LEVEL_USER;
header("Location: menu.php");
exit();
}
List page (Desktop) -> Before SQL Query
global $conn;
$rs = CustomQuery("SELECT RoleID FROM Administrator WHERE UserLogin='".$_SERVER["REMOTE_USER"]."'",$conn);
$data = db_fetch_array($rs);
if($data['RoleID'] == 'LOCALADMIN')
{
$rs = CustomQuery("SELECT SiteID FROM Administrator WHERE UserLogin='".$_SERVER["REMOTE_USER"]."'",$conn);
$sites = "(";
while($record = db_fetch_array($rs))
{
$sites .= "'".$record['SiteID']."',";
}
$sites .= "'')";
$strWhereClause = whereAdd($strWhereClause,"SiteID in ".$sites);
}
Summary:
- if user has MASTERADMIN role - can see ALL records
- if user has LOCALADMIN role - can see only records related to SiteID assigned to his NT login in Administrator table
For now everything is working fine.
Now I have dropdown box Site on page Desktop - it is connected to table Sites, linked field is SiteID, display field is SiteName. For now I see here all sites.
How to set any relation on this dropdown box (Site) to show only sites match relations between NT login and records in Administrator table? Simple example:
- if UserLogin AAA has assigned SiteID S1, S2 and has RoleID "localadmin", he should see only sites S1, S2 in dropdown box
- if UserLogin AAA has assigned RoleID "masteradmin", he should see ALL sites in dropdown box
Brgds
Mariusz