This topic is locked
[SOLVED]

 Filter edit query based on group user is in (Dynamic Permissions)

6/28/2018 2:20:24 AM
PHPRunner General questions
J
jwehner author

I'm using phprunner 9.8 and want to filter a table based on the groups the user is in. So a table has a column of group assigned I want the user to only be able to edit rows that the user is in.
So if the table has groups: 1,2,3,4,5 and user is in 2 and 5 he would only be able to edit those rows.
Scratching my head....
Any help is appreciated.

J
jwehner author 6/28/2018

Ok I figured it out myself for anyone else that may need to know.
I did an inner join on groups than a left outer join on users. Then in events before SQL query added this:
$usercheck = $_SESSION["UserID"];

$strWhereClause = whereAdd($strWhereClause,"alert_ugmembers.UserName='".$usercheck."'");
Query on table:
SELECT

idBridge,

BridgeName,

SendWordNowUserID,

UserAssigned,

BridgeSecurityGroup,

GroupAssigned

FROM oncallbridgenames

INNER JOIN acualerts_uggroups ON oncallbridgenames.GroupAssigned = acualerts_uggroups .GroupID

LEFT OUTER JOIN alert_ugmembers ON alert_uggroups.GroupID = alert_ugmembers.GroupID

J
jwehner author 6/30/2018

Well I spoke a little two soon.. My query may be bad but I think i'm in the right direction.

J
jwehner author 7/1/2018



Well I spoke a little two soon.. My query may be bad but I think i'm in the right direction.


Nope query was good <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=85290&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' /> I was looking at something wrong. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=85290&image=2&table=forumreplies' class='bbc_emoticon' alt=':)' />

lefty 7/1/2018



Well I spoke a little two soon.. My query may be bad but I think i'm in the right direction.


I thought I saw this same question recently . dejavu.

Try

After Successful login event put $_SESSION["Examplefldgroup"] = $data["Examplefldgroup"]; // you need to assign groups in dynamic permission to each user.

Then in dynamic security phprunner . Make user can see but only edit their own data or they can only see their own data.

Then in default field on the tablefield your are using for group put in default value: $_SESSIon["Examplefldgroup"];
That's it . When a user logs in he will be only able to edit his own records but see others or you can make it he only sees his records, that groups 2 and 5.

If he belongs to 2 or 5 he will only see records 2 and 5 . same for 1 or 2 or etc......; no need for all those inner joins.
The only thing I see is you are using the name filter . Are you using the filter panel to do this? Instead of an event when entering edit page?

J
jwehner author 7/1/2018

Yes I'm using filtering panel along with the the custom query. It's working.
I think your way won't allow someone else to edit the list if they are in the same group. I want everyon in a group to edit the list they are in.