function ctools_plugin_example_example_role_ctools_access_summary

Provide a summary description based upon the checked roles.

1 string reference to 'ctools_plugin_example_example_role_ctools_access_summary'
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 62

Code

function ctools_plugin_example_example_role_ctools_access_summary($conf, $context) {
  if (!isset($conf['rids'])) {
    $conf['rids'] = array();
  }
  $roles = ctools_get_roles();
  $names = array();
  foreach (array_filter($conf['rids']) as $rid) {
    $names[] = check_plain($roles[$rid]);
  }
  if (empty($names)) {
    return t('@identifier can have any role', array(
      '@identifier' => $context->identifier,
    ));
  }
  return format_plural(count($names), '@identifier must have role "@roles"', '@identifier can be one of "@roles"', array(
    '@roles' => implode(', ', $names),
    '@identifier' => $context->identifier,
  ));
}