Page 1 of 1

Multiple Users, one site [SOLVED]

PostPosted: Tue Aug 31, 2010 6:50 am
by cantlep
Hi All,

Wondering if anyone has done this before. I'm going to start a second Xataface site. This one will contain gym workout details for various users. Now, Obviously, I don't want UserA to be able to edit UserB's workout details (or even see them for that matter).

If I have a table called "Chest" (for example - to indicate body part worked on), how do I allow UserA to add in his details and only see his details...and the same for UserB, UserC, etc, etc. I guess in SQl some sort of WHERE USER = UserA needs to be in place but I'm not sure how to do it from the SQl side or the Xataface side.

I think this might work - http://xataface.com/documentation/how-t ... ty_filters but not sure if that just applies to tables "owned" by each user or if it applies to tables that need to be written to by all users.

Any thoughts?

PS: Steve - the link to the filters section needs updating as it's currently broken. Cheers

Paul

Re: Multiple Users, one site

PostPosted: Tue Aug 31, 2010 10:45 am
by jhenry
Paul,

Could you set it up so that each person only has access to their table for say 'Users' and then make the workouts a datagrid within that users record. If you set up the user_id for the workouts to be tied to the users the permissions should follow and only allow access to those records that belong to that person. It should follow as well that if the workouts are tied to a specific user then they should only be able to see those records assigned to them. Hope this helps.

Jason

Re: Multiple Users, one site

PostPosted: Wed Sep 01, 2010 7:43 am
by cantlep
Cheers Jason,

i'm almost there with what I want. I've added this (as per the wiki) into ApplicationDelegate.php
Code: Select all
function getPreferences(){
    $mytable =& Dataface_Table::loadTable('WorkoutLog') ; // load the table named 'WorkoutLog'
    $auth =& Dataface_AuthenticationTool::getInstance();
    $user =& $auth->getLoggedInUser();
    if ( $user and  $user->val('role') != 'ADMIN' ){
    $mytable->setSecurityFilter(array('UserName'=>$user->val('UserName')));
    }
    return array();  // Mandatory!! getPreferences() must return array.
}


I just need to tweak some permissions now :-)

Thanks

Re: Multiple Users, one site

PostPosted: Wed Sep 01, 2010 8:10 am
by cantlep
All sorted now :-)

Thanks