Page 1 of 1

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

PostPosted: Wed Jun 08, 2011 3:21 am
by silma
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.

Re: Permissions in function block__* in a delegate class

PostPosted: Wed Jun 08, 2011 10:16 am
by shannah
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

Re: Permissions in function block__* in a delegate class

PostPosted: Thu Jun 09, 2011 12:42 am
by silma
Thanks a lot, Steve, it's exactly what i needed.