[Solved]Permissions in function block__* in a delegate class
Archived from the Xataface Users forum.
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.
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
silma — Thu Jun 09, 2011 12:42 am
Thanks a lot, Steve, it’s exactly what i needed.