This topic is locked

Private and public lists

7/26/2006 4:47:21 PM
PHPRunner General questions
G
giles author

Hi,

I'm creating a mailing application where we need private lists accessible only by the user who created them and public lists accessible by all users.
The standard phprunner access control and security works fine for the private lists.But it automatically prevents access to the public lists.
For simplicity of the user interface and for the application doing the mailing I do not want to create a separate table for public lists. What I have in mind is a flag in the list table that can be set to indicate that a list is public. The SELECT statement would then be something like:
SELECT * FROM lists WHERE userID=thisuserID OR publiclistflag=True
Where do I need to modify phprunner generated code to achieve this. Or is there a better way?
Giles

Alexey admin 7/27/2006

Giles,
the line you need to edit is in generated include\..._variables.php file.

It starts with:

$gstrSQL="select ....

G
giles author 7/28/2006

Alexey,

I must admit I'm over my head here.
I've found the spot in the _variable.php file you've indicated.
But what to put there....???
If I do not define a master table for lists what do I put in the SELECT statement to get the lists for the current user?
SELECT FROM lists WHERE publiclistflag=True OR userID = ?????
Alternately if I do define a master table for lists how do I get the OR condition to add the public lists? At the location you indicated in _variables.php I can only set SELECT
FROM lists WHERE publiclistflag=True. The userId condition is further hidden in the code.
As background, I have:

  1. User table with the field UserID as bigint
  2. Lists table with the fields UserID and publiclistflag (as tinyint)
    For any given user (as defined by UserID) I want to show:
  3. Their own lists AND 2. all public lists.
    Thanks in advance,
    Giles.

Alexey admin 7/31/2006

Hi,
At first you need to save a value of UserID field in a session variable.

To do this insert this code into After successful login event:

global $data;

$_SESSION["user_id"] = $data["UserID"];


Build the pages and modify the line in ..._variables.php file this way:

$gstrSQL = "SELECT * FROM lists WHERE publiclistflag=True OR userID = ".$_SESSION["user_id"];

G
giles author 7/31/2006

Hi Alexey,
Thanks, that worked perfectly. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=10119&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />
Giles