This topic is locked
[SOLVED]

 List Filter

12/4/2012 7:47:37 AM
PHPRunner General questions
W
Wynus Marais author

I am a newbie to both PHP & PHPrunner. I have been struggling with something, which I know for a fact must be as easy as pie, but for some reason I just can't get it to work in PHPrunner. I have read and tried just about everything in the manual as well as in the forum for over two days and I am still missing a vital ingredient.
To Simplify:
I have a users table, with among the normal columns (User_ID & Password etc) there is also one for Area. I have a main table, also with an Area column.
I need to filter the main table list after login so that a user from a certain Area can only see records that is from the same Area. (Obviously there are many users from the same area.)
PLEASE steer me in the right direction...

mikue from germany 12/4/2012

Hi Marais,
please read following article carefully, thats what you will need to solve your probem easily.
Advanced security settings

W
Wynus Marais author 12/4/2012



Hi Marais,
please read following article carefully, thats what you will need to solve your probem easily.
Advanced security settings


Hi Mikue
Thanks for your speedy response.
This was one of the solutions I have investigated already. This won't solve my problem however, because all users will still be able to see all records and will only be limited in whether they can edit or not. I need them not to be able to see any records outside of their designated "Area". (I must add that the users are not linked in any way to a particular record. Not even in a many to many relationship.
Some of the hundreds of Solutions if have already tried was to use:
function AfterSuccessfulLogin($username, $password, $data)

{

$SESSION["Area"] = $data["Area"];

}
and the following code in the "after table initialized" event:_
$query->addWhere("Area='".$_SESSION["Area"]."'");
Sorry for bothering you all with this, but I must miss something essential and can't figure it out. All I need is a good pointer in the right direction.

Sergey Kornilov admin 12/4/2012

Marais,
you need to use 'Users can see and edit their own data only' security mode. No code to add.

W
Wynus Marais author 12/4/2012



Marais,
you need to use 'Users can see and edit their own data only' security mode. No code to add.


Hi Sergey,
That particular option won't work, because the users don't add any records. The records (main table) are added separately, actually imported.
When users register (Users table) they choose an Area and should then only be able to see records (Ads) from the main tabe where Area corresponds. Users.Area = Main.Area e.g. a user that lives in New York will only see records (ads) for New York.
The administrator group on the other hand can see everything, add, edit & delete etc. (I have already finished admin and guest access. Works fine!) The only stumbleblock now is to limit normal registered users to only see a filtered portion of the main database, if there are any records (Ads) for that particular Area.

W
Wynus Marais author 12/5/2012

I am really stuck here and I am running in circles.
It appears the coding as I have used it is correct:
function AfterSuccessfulLogin($username, $password, $data)

{

$_SESSION["Area"] = $data["Area"];

}
Adding this code in the After Successful Login Event should give me access to the value of column Area across all other events and I should be able to use it in my sql query string as this:
$strWhereClause = whereAdd($strWhereClause, "Area= '".$_SESSION["Area"]."'");
Why is the value of $_SESSION["Area"] empty and ending up in this: "select count(*) FROM Main where Area = ''

mikue from germany 12/6/2012

Hi Marais,
you are writing down your own solution but you don't see it


no need to use session variables in that case.
Its a good idea to ensure that maintable area and usertable area have same content

usertable.area = New York and maintable.area = Newyork will not work.
you should work in usertable.area field with dropdown option to get the entries from main table (unique)
now you should stop running in circles ;-)
Greetings Michael

Sergey Kornilov admin 12/6/2012

I'm completely lost.
If you need more help post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.

W
Wynus Marais author 12/10/2012



I'm completely lost.
If you need more help post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.


Problem was solved by myself. It had (as I explained twice) nothing to do with security settings as the user don't add any records themselves. It only took two lines of code to solve and the solution was that for some strange reason the code must be before any other code, even though none of the variables are referenced again in the additional functions. One of those strange unexplainable glitches...
Thanks for trying to help Micheal, I still appreciate it.