function flag_flag::fetch_roles in Flag 7.3
Load this flag's role data from permissions.
Loads an array of roles into the flag, where each key is an action ('flag' and 'unflag'), and each value is a flat array of role ids which may perform that action.
This should only be used when a complete overview of a flag's permissions is needed. Use $flag->access or $flag->user_access() instead.
File
- includes/
flag/ flag_flag.inc, line 237 - Contains the flag_flag class. Flag type classes use an object oriented style inspired by that of Views 2.
Class
- flag_flag
- This abstract class represents a flag, or, in Views 2 terminology, "a handler".
Code
function fetch_roles() {
$actions = array(
'flag',
'unflag',
);
foreach ($actions as $action) {
// Build the permission string.
$permission = "{$action} {$this->name}";
// We want a flat array of rids rather than $rid => $role_name.
$this->roles[$action] = array_keys(user_roles(FALSE, $permission));
}
}