This topic is locked
[SOLVED]

 Show records depending on user

8/11/2010 7:30:49 AM
PHPRunner General questions
P
Pkas author

Hi

It's my first post in here, untill now i did all the work just by reading your answers.

I'm working with phprunner 5.2.

Now the problem.
I've to display diferent record depending on the user logged in. 2 tables one with the information to show and a 2nd table with the users.

Table A (id, name, address, tel) and Table B (id, name, A_fk)
So i want to show records 1,4,6,7 to user 'xpto' and 2,3,5 to user 'ptox' and so on.

if the username (B.name) was in main table (A) i could use the $strWhereClause but is in a different table and my only solution was a view.
i'm sure there are another solution but at this time i'm out of fresh ideas...
Thanks

A
ann 8/11/2010

Hi,
you can access logged in user using session variable $_SESSION["UserID"].
Also you can set up permissions settings on the Security tab. Open Advanced security settings dialog and choose Users can see and edit their own data only or Users can see other users data, can edit their own data only. Then select the field which is responsible for dividing records according to the user logged in as OwnerID field.

P
Pkas author 8/11/2010

Tks for your fast answer, but i must exemplify a little better.
The table A as a dropdown list based on table B named as a 'GroupMember' and the only users that can see the data are the group members.
Ex:

A

-------

1 Jonh Cleese 1st street 555999000 [Maia][Morrisson] (can be more)

2 Ian Beorn 2nd street 555999111 [Shepard]

3 Leon Marras 3th street 555999222 [Maia]
*in brakets are the dropdown list
B

-------

1 Maia 1

2 Shepard 2

3 Maia 3

4 Morrisson 1

5 Sting null
So when [Maia] log's the record showed to her are 1 and 3;

When [Shepard] log's the record showed to him are 2;

When [Morrisson] log's the record showed to him are 1;

When the [Sting] log's no record are shown.
The record's are inserted by someone else, this are only the manager's so the dificulty to use the advanced security settings.

The filter is by record depending on user logged.

by the way the Database is a MSSql.

A
ann 8/12/2010

Hi,
I'm afraid the only solution is to create a view and use it as a source table in the dropdown as you did it.

P
Pkas author 8/26/2010

Hi,
Modified the $strSQl in event Before SQL query using the query "SELECT * from tableA INNER JOIN table B ON tableA.id = tableB.id AND tableB.name = '$user'".
It's like a view on the fly <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=52177&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />