function ctools_plugin_example_example_role_ctools_access_check
Check for access.
1 string reference to 'ctools_plugin_example_example_role_ctools_access_check'
- example_role.inc in ctools_plugin_example/
plugins/ access/ example_role.inc - Plugin to provide access control based upon role membership. This is directly from the ctools module, but serves as a good example of an access plugin.
File
-
ctools_plugin_example/
plugins/ access/ example_role.inc, line 47
Code
function ctools_plugin_example_example_role_ctools_access_check($conf, $context) {
// As far as I know there should always be a context at this point, but this
// is safe.
if (empty($context) || empty($context->data) || !isset($context->data->roles)) {
return FALSE;
}
$roles = array_keys($context->data->roles);
$roles[] = $context->data->uid ? DRUPAL_AUTHENTICATED_RID : DRUPAL_ANONYMOUS_RID;
return (bool) array_intersect($conf['rids'], $roles);
}