This topic is locked

UserRights Variable / Lookup Filter

9/17/2009 1:35:18 PM
PHPRunner General questions
W
will author

variable is not up to date.
Let me give you the background to my situation first. I'm building a forecast tool, and I needed to give the Sales Manager access to all forecast records, but restrict the records the Account Managers has access to. Making sure every account manager can only see the relevant records is easy using advanced security settings. Bear in mind that I don't want to give the Sales Manager Admin User Rights (i.e. changing user / group settings), but he has Admin Permissions on the relevant table. The challenge came when I used a lookup on the customer field, and needed to filter the list of customers with only those customers relevant to each account manager.
I've been unable to trace my steps to where I came about the idea to enter the following in the WHERE field on the Lookup settings:
[font="Courier New"]"account_manager = " . $_SESSION["MyFilter"]
and then add the following to the Before Proccess event on the Add, Edit and List pages:
== "ACCESS_LEVEL_ADMINGROUP")

$_SESSION["MyFilter "] = "account_manager";

ELSE

$_SESSION["MyFilter "] = "'".$_SESSION["OwnerID"]."'";
In this situation I had to make another plan though because I didn't want to give the Sales Manager Admin User Rights. That's when looked at the $_SESSION["UserRights"]["<table name>"] variable, and literally stumbled upon the answer on how to use the variable through trail and error. My solution follows:
global $strTableName;
$My_Permissions = $_SESSION["UserRights"][$_SESSION["UserID"]][$strTableName];
IF ($My_Permissions[strlen($My_Permissions)-1] == "M")

$_SESSION["MyFilter "] = "account_manager";

ELSE

$_SESSION["MyFilter "] = "'".$_SESSION["OwnerID"]."'";
To come to my opening line, I did not get any result when using the variable as indicated in the manual. Is this a bug (PHPRunner 5.1 - Build 2370) or is the manual outdated.
Secondly I'm open for any suggestions on how to accomplish the same in another / easier way.

[/font]

J
Jane 9/18/2009

Hi,
thank you for pointing me to this bug in PHPRunner Help.

We'll update it.
Use following code in your event:

global $strTableName;
$My_Permissions = GetUserPermissions($strTableName);
if ($My_Permissions[strlen($My_Permissions)-1] == "M")

$_SESSION["MyFilter "] = "account_manager";

ELSE

$_SESSION["MyFilter "] = "'".$_SESSION["OwnerID"]."'";