Twitter Feed

Xataface Maillist

Sign up to receive the Xataface news letter with weekly updates and development tips.

Found 1 of 138 records in table Wiki
Now Showing 1 of 1

Current Record: fieldname__permissions



fieldname__permissions() method

The fieldname__permissions() methods will allow you to define custom permissions on a particular field in the delegate class?. For example to specify permissions on a field named foo you would define the foo__permissions() method, and to define permissions on a field named role you would define the role__permissions() method.

Example #1

(Note this example needs to be refined to be more clear)

function approval_level__permissions(&$record){
    return array('edit'=>0); //this is will merge with what the permissions for the normal record

Here we are targeting the approval_level field of the delegate class?. The permissions method takes a return value an array of permissions. So for example:

$permissions['new'] = 0;
$permissions['edit'] = 0;

Would be an example of an array of permissions which the key being the permission name and the value being a boolean to specify whether they have (1) or don't (0) have permissions to that field. We don't have to specify a complete array of permissions (ie. permission of edit, new, readonly, etc, etc), but rather only the ones we want specifically. The reason being that the permissions array in the return value gets merged with the permissions that this record normally gets from the record permissions.

So if the record normally gives the permissions new=0, edit=1. Then the return value from approval_level will merge with the original permissions to produce an array like this:

$permissions['new'] = 0;
$permissions['edit'] = 1;

Also See:

blog comments powered by Disqus
Powered by Xataface
(c) 2005-2018 All rights reserved