You are here

function bat_unit_permission in Booking and Availability Management Tools for Drupal 7

Implements hook_permission().

File

modules/bat_unit/bat_unit.module, line 284

Code

function bat_unit_permission() {

  // Permission for Bat Units.
  $permissions = array(
    'administer bat_unit_bundle entities' => array(
      'title' => t('Administer unit bundles'),
      'description' => t('Allows users to add unit bundles and configure their fields.'),
      'restrict access' => TRUE,
    ),
    'view any bat_unit unpublished entity' => array(
      'title' => t('View any unpublished unit'),
      'description' => t('Allows users to view any unpublished unit.'),
      'restrict access' => TRUE,
    ),
    'view own bat_unit unpublished entities' => array(
      'title' => t('View own unpublished units'),
      'description' => t('Allows users to view own unpublished units.'),
    ),
  );
  $permissions += bat_entity_access_permissions('bat_unit');

  // Override view permissions.
  $entity_info = entity_get_info('bat_unit');
  foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
    $permissions['view own bat_unit entities of bundle ' . $bundle_name] = array(
      'title' => t('View own published %bundle @entity_bundle', array(
        '@entity_bundle' => 'units',
        '%bundle' => $bundle_info['label'],
      )),
    );
    $permissions['view any bat_unit entity of bundle ' . $bundle_name] = array(
      'title' => t('View any published %bundle @entity_bundle', array(
        '@entity_bundle' => 'unit',
        '%bundle' => $bundle_info['label'],
      )),
    );
  }

  // Permission for Bat Types.
  $permissions += array(
    'administer bat_type_bundle entities' => array(
      'title' => t('Administer type bundles'),
      'description' => t('Allows users to add type bundles and configure their fields.'),
      'restrict access' => TRUE,
    ),
    'view any bat_type unpublished entity' => array(
      'title' => t('View any unpublished type'),
      'description' => t('Allows users to view any unpublished type.'),
      'restrict access' => TRUE,
    ),
    'view own bat_type unpublished entities' => array(
      'title' => t('View own unpublished types'),
      'description' => t('Allows users to view own unpublished types.'),
    ),
    'view bat_type revisions' => array(
      'title' => t('View type revisions'),
      'description' => t('Allows users to view type revisions.'),
    ),
    'revert bat_type revisions' => array(
      'title' => t('Revert type revisions'),
      'description' => t('Allows users to revert type revisions.'),
    ),
    'delete bat_type revisions' => array(
      'title' => t('Delete type revisions'),
      'description' => t('Allows users to delete type revisions.'),
    ),
  );
  $permissions += bat_entity_access_permissions('bat_type');

  // Override view permissions.
  $entity_info = entity_get_info('bat_type');
  foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
    $permissions['view own bat_type entities of bundle ' . $bundle_name] = array(
      'title' => t('View own published %bundle @entity_bundle', array(
        '@entity_bundle' => 'types',
        '%bundle' => $bundle_info['label'],
      )),
    );
    $permissions['view any bat_type entity of bundle ' . $bundle_name] = array(
      'title' => t('View any published %bundle @entity_bundle', array(
        '@entity_bundle' => 'type',
        '%bundle' => $bundle_info['label'],
      )),
    );
  }
  return $permissions;
}