Page 1 of 1

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

PostPosted: Wed Nov 16, 2011 1:49 am
by rleyba
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.

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

PostPosted: Tue Nov 22, 2011 11:02 am
by shannah
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

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

PostPosted: Wed Nov 23, 2011 4:15 am
by rleyba
Works perfectly! Thanks very much Steve!