This topic is locked

Hide Control based on User group

8/2/2011 11:52:40 AM
PHPRunner General questions
I
imthebest author

I am using Dynamic Security for the project.

I wanted to hide some controls on the List page if user logged in does not belong to Admin group.
I used the below codes as given in help file -
$xt->assign("orgid_fieldheadercolumn",$_SESSION["AccessLevel"]== ACCESS_LEVEL_ADMINGROUP);

$xt->assign("orgid_fieldcolumn",$_SESSION["AccessLevel"]== ACCESS_LEVEL_ADMINGROUP);
But above codes are hiding the field from all users including user fro Admin group.
Please advice, if above codes are not applicable to Dynamic Security?
Another query is that Help file states that session variable $_SESSION["GroupID"] is populated only for static security. In that case, what is the option for Dynamic Security?
Thanks in advance?

C
cgphp 8/2/2011
global $conn;
$strSQL = "SELECT GroupID FROM ugmembers WHERE UserName ='".$_SESSION["UserID"]."' LIMIT 1";

$rs = db_query($strSQL,$conn);

$record=db_fetch_array($rs);
$xt->assign("orgid_fieldheadercolumn",$record['GroupID'] == -1);

$xt->assign("orgid_fieldcolumn",$record['GroupID'] == -1);
I
imthebest author 8/3/2011

Thanks Cristian. This is working.
But when I try to use Session variable for then the same does not work. I populated $_SESSION["GroupID"] during "After Successful login" event. Then used the same in list page for "Before Display" event -
$xt->assign("orgid_fieldheadercolumn", $_SESSION["GroupID"] == -1);

$xt->assign("orgid_fieldcolumn",$_SESSION["GroupID"] == -1);
The above is hiding the field from all users including Admin user.
I also tried to use userid (populated during "After successful login" event), but that is also hiding the blick from all users including admin.
$xt->assign("orgid_fieldheadercolumn", $_SESSION["UserID"] == "admin");

$xt->assign("orgid_fieldcolumn",$_SESSION["UserID"] == "admin");
Do session variables not work here? Or I am missing something. Please advice.
Thanks in advance.

Sergey Kornilov admin 8/3/2011

Session variables should work exactly the same way here. If you need more help contact support directly providing a copy of your files and databases for investigation.

T
techster 8/26/2011



Thanks Cristian. This is working.
But when I try to use Session variable for then the same does not work. I populated $_SESSION["GroupID"] during "After Successful login" event. Then used the same in list page for "Before Display" event -
$xt->assign("orgid_fieldheadercolumn", $_SESSION["GroupID"] == -1);

$xt->assign("orgid_fieldcolumn",$_SESSION["GroupID"] == -1);
The above is hiding the field from all users including Admin user.
I also tried to use userid (populated during "After successful login" event), but that is also hiding the blick from all users including admin.
$xt->assign("orgid_fieldheadercolumn", $_SESSION["UserID"] == "admin");

$xt->assign("orgid_fieldcolumn",$_SESSION["UserID"] == "admin");
Do session variables not work here? Or I am missing something. Please advice.
Thanks in advance.


Were you able to find a solution?

C
cgphp 8/26/2011

Please, provide the code of the "After successful login" event.