You are here

function tca_permission in Token Content Access 7

Implements hook_permission().

File

./tca.module, line 115
The Token Content Access module file.

Code

function tca_permission() {
  $permissions = array();

  // Load information from any module that implements hook_tca().
  $modules = module_invoke_all('tca');
  foreach ($modules as $module => $info) {

    // Get information about the entity.
    $entity_info = entity_get_info($info['entity type']);
    $entity_label = strtolower(isset($entity_info['plural label']) ? $entity_info['plural label'] : $entity_info['label']);

    // Add an administer permission.
    $permissions['administer ' . $module] = array(
      'title' => t('Administer Token Content Access settings for @entity_type', array(
        '@entity_type' => $entity_label,
      )),
    );

    // Add a bypass permission.
    $permissions['bypass ' . $module] = array(
      'title' => t('Bypass Token Content Access action for @entity_type', array(
        '@entity_type' => $entity_label,
      )),
      'description' => t('Allows user to bypass the action that has been configured for @entity_type.', array(
        '@entity_type' => $entity_label,
      )),
      'restrict access' => TRUE,
    );
  }
  return $permissions;
}