Current Record: fieldname__permissions #53

fieldname__permissions() method Table of Contents fieldname__permissions() method Example #1 Also See: The fieldname__permissions() ...

Current Record: fieldname__permissions #53

fieldname__permissions() method Table of Contents fieldname__permissions() method Example #1 Also See: The fieldname__permissions() ...

fieldname__permissions

[Permalink]

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-2024 All rights reserved