[Solved]Permissions in function block__* in a delegate class

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

[Solved]Permissions in function block__* in a delegate class

Postby silma » Wed Jun 08, 2011 3:21 am

Hello Steve, hello Xataface devs & users out there,

First one thing : I'm using the new xataface release for a few weeks now, and i really enjoy it : Thanks for your work, Steve.

I've got a "general" question about permissions in delegate class :

In my delegates classes, i'm using a getPermissions function to set the permissions for each user, depending on a role.
Its work well on the table that display the records.

In each delegate class, i also have a block__after_main_section function : is there a simple way to "inherit" the permissions of the getPermissions function to show/hide the content of this block?

Please excuse my english..

Thanks very much.
Last edited by silma on Thu Jun 09, 2011 12:43 am, edited 1 time in total.
silma
 
Posts: 87
Joined: Tue Apr 28, 2009 11:47 pm

Re: Permissions in function block__* in a delegate class

Postby shannah » Wed Jun 08, 2011 10:16 am

Inside the block function (or anywhere else) you can use permissions by calling getPermissions() on the current table or record.

e.g.

Code: Select all
function block__myblock(){
    $app = Dataface_Application::getInstance();
    $record = $app->getRecord();
    if ( $record and $record->checkPermission('my permission') ){
        echo 'Only print this if the user is granted the permission "my permission" on the current record';
    }

}


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

Re: Permissions in function block__* in a delegate class

Postby silma » Thu Jun 09, 2011 12:42 am

Thanks a lot, Steve, it's exactly what i needed.
silma
 
Posts: 87
Joined: Tue Apr 28, 2009 11:47 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 25 guests

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