Filtering related records based no logged in user

A place for users and developers of the Xataface to discuss and receive support.

Filtering related records based no logged in user

Postby yokaiface » Mon Aug 03, 2009 12:35 pm

Hi Steve,

Yet another challenge! Is there a way to filter related records based on logged in user? I want the related records to display on those records owned by the one logged in.

Regards
yokaiface
 
Posts: 7
Joined: Mon Jul 27, 2009 9:50 am

Postby shannah » Wed Aug 05, 2009 12:24 pm

OK.. haven't tested this but it should work..

2 steps:

1. Create a calculated field in the delegate class for the source table that simply returns the logged in user.

2. Include this calculated field as part of the relationship definition.

E.g.

Your calculated field might look like:

Code: Select all
function field__current_user(&$record){
    $auth =& Dataface_AuthenticationTool::getInstance();
    return $auth->getLoggedInUserName();
}


Then in your relationship you might have:
Code: Select all
[books]
books.category_id="$category_id"
books.owner_id="$current_user"


This all assumes that your relationship is going from a "category" table to a "books" table and includes only books that match the current category's category_id AND the book's owner_id field matches the username of the currently logged in user.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 24 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved