This topic is locked

Flxible access to records

9/5/2006 9:38:01 PM
PHPRunner General questions
G
giles author

Hi,

I have a table with two fields, CreatedByID and OwnerID, that respectively define who created a record and who is the assigned owner of the record.
I am using master-detail relationship combined with advanced security settings to so that users can see and edit their own data only. And an Admin user has been configured to be able to see all records. However this approach can be applied only to one of the above fields and I need to let users view both the records they created and the records, created by others, for which they are the assigned owner.
I have tried doing this by:

  1. Defining a $_SESSION["usersIDNumber"] in a global event at login
  2. Removing the master-detail relationship
  3. Editing the "where" part of the SQL query in the _variables.php file

    ....where `CreatedByID` = ".$_SESSION["usersIDNumber"]." or `OwnerID` = ".$_SESSION["usersIDNumber"];
    That works perfectly for the users but does not work for the Admin user who can then only see/edit their own records and not all records.
    I do not want to create another view of the records just for the Admin user.
    So, is there a way of getting the normal users to see/edit both the created and assigned records AND allow the Admin user to see/edit all?
    Giles

G
giles author 9/11/2006

Hi,

I didn't get an answer to this question so I'll try simplifying the question....
In which file does the SQL query reside that selects only the records defined in the master-detail relationship?
Thanx in advance.
Giles

J
Jane 9/12/2006

Giles,
you can edit where clause of detail table SQL in the ..._list.php file.

Here is a snippet where masterkey is added to SQL:

if($masterkey)

{

$mastertableurl="TableName";

$mastertablename="TableName";
$where = GetFullFieldName("`OrderID`")."=".make_db_value(RemoveFieldWrappers("`FieldName`"),$masterkey);

$strSQL = AddWhere($strSQL,$where);

}



where TableName and FieldName are your actial table and field names correspondingly.