You are here

function ctools_plugin_example_example_role_ctools_access_check in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 ctools_plugin_example/plugins/access/example_role.inc \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
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.

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);
}