You are here

function rooms_unit_permission in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

Implements hook_permission().

File

modules/rooms_unit/rooms_unit.module, line 160
Manage units - Units are things that can be booked on a nightly basis (e.g. rooms - but also villas bungalows, etc).

Code

function rooms_unit_permission() {
  $permissions = array(
    'administer rooms_unit_type entities' => array(
      'title' => t('Administer bookable unit types'),
      'description' => t('Allows users to add bookable unit types and configure their fields.'),
      'restrict access' => TRUE,
    ),
    'view any rooms_unit unpublished entity' => array(
      'title' => t('View any unpublished bookable unit'),
      'description' => t('Allows users to view any unpublished bookable unit.'),
      'restrict access' => TRUE,
    ),
    'view own rooms_unit unpublished entities' => array(
      'title' => t('View own unpublished bookable units'),
      'description' => t('Allows users to view own unpublished bookable units.'),
    ),
    'manage room units' => array(
      'title' => t('Manage Room Units'),
      'description' => t('Allows access to the Rooms Unit Admin'),
      'restrict access' => TRUE,
    ),
  );
  $permissions += rooms_entity_access_permissions('rooms_unit');

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