This topic is locked
[SOLVED]

 $_SESSION["GroupID"] for dynamic permissio

8/23/2010 3:35:44 AM
PHPRunner General questions
romaldus author

How i use $_SESSION["GroupID"] for dynamic permission?

A
ann 8/23/2010

Romaldus,
I'm not sure that I understand your question.

Please re-phrase it.

woodey2002 8/24/2010
romaldus author 8/24/2010



Romaldus,
I'm not sure that I understand your question.

Please re-phrase it.


Thanks Ann. The problem is really simple.
I have a table with the name MASTER_PARTS
FIELD1...FIELD2...FIELD3...FIELD4...FILED5
on phprunner visual editor (MASTER_PARTS add page):

i made FIELD5 as readonly and then set the default value to $_SESSION["GroupID"]


on phprunner generated application, login with username : scott (scott is a member of INVENTORY group)

i try to add new record to MASTER_PARTS table.

Something's wrong in this step, FIELD5 auto-filled with current logged UserID (Scott), not the GroupID (INVENTORY GroupID).
In PHPRUNNER manual i found that $_SESSION["GroupID"] can only used for static permissions only.
$_SESSION["GroupID"]:GroupID that user belongs to. Populated if User Group Security turned on (used for static permissions only).

A
ann 8/25/2010

Romaldus,
you need to select user group manually from database in this case.

Set up custom session variable as default value, then fill it in the Before Process event.

Here is a sample:

$rstmp = CustomQuery("select GroupID from ugmembers where UserName='".$_SESSION["UserID"]."'");

$datatmp = db_fetch_array($rstmp);

$_SESSION["CustomGroupID"] = $datatmp["GroupID"];
romaldus author 8/25/2010



Romaldus,
you need to select user group manually from database in this case.

Set up custom session variable as default value, then fill it in the Before Process event.

Here is a sample:

$rstmp = CustomQuery("select GroupID from ugmembers where UserName='".$_SESSION["UserID"]."'");

$datatmp = db_fetch_array($rstmp);

$_SESSION["CustomGroupID"] = $datatmp["GroupID"];"



Thanks Ann but the code not work. Please take at the screenshot :


I tried another solution using After Record Added event :

$sql = "UPDATE mst_parts SET Field5 = (SELECT GroupID FROM ugmembers WHERE username = '".$_SESSION["UserID"]."')";


it works but something's wrong now... in Field5 on entire table (MST_PARTS table) updated with current logged GroupID..

A
ann 8/26/2010

Romaldus,
remove the quotes from the following line in the code:

$_SESSION["CustomGroupID"] = $datatmp["GroupID"];



In the code you've posted there is no where statement in the update query.

romaldus author 8/26/2010



Romaldus,
remove the quotes from the following line in the code:

$_SESSION["CustomGroupID"] = $datatmp["GroupID"];



In the code you've posted there is no where statement in the update query.


Thank you very much Ann.. it works now....
it was a mistake <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=52159&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />