Creating actions.ini (table_tab) to show only my own records

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

Creating actions.ini (table_tab) to show only my own records

Postby rleyba » Wed Nov 16, 2011 1:49 am

Hi Steve and forum members,

I was wondering if somebody already has a code snippet that represents an action (expressed as one of the action tab options) that can list records based on the user's login ID.

Example when I log on to my application I see the usual "Details", "List", Find and "Calendar" actions. I want another tab "Show my Records" which makes the application display only the records of the current logged in user. This avoids the user having to go to the find tab, looking up the Username field and typing his own login name, then clicking"Submit"

I tried looking here --> http://xataface.com/wiki/actions.ini_file but am a little at a loss of how to implement the PHP permissions code to make it work.

Thanks for any suggestions.
rleyba
 
Posts: 53
Joined: Sat Dec 04, 2010 3:50 pm

Re: Creating actions.ini (table_tab) to show only my own rec

Postby shannah » Tue Nov 22, 2011 11:02 am

There are a few ways to achieve this. Here is one way using a tab as you mentioned.

Step One: Create an application delegate class method to get the logged in username:
Code: Select all
function username(){
    return Dataface_AuthenticationTool::getInstance()->getLoggedInUserName();
}


Step Two: Create Your action in the actions.ini file:

Code: Select all
[my_records]
    category=table_tabs
    url="{$site_href}?-table=my_table&-action=list&-mode=my_records&owner=={$app->getDelegate()->username()}"
    condition="$query['-table'] == 'my_table'"
    permission=list
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Creating actions.ini (table_tab) to show only my own rec

Postby rleyba » Wed Nov 23, 2011 4:15 am

Works perfectly! Thanks very much Steve!
rleyba
 
Posts: 53
Joined: Sat Dec 04, 2010 3:50 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 8 guests

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