You are here

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

Access callback: Checks whether the user has permission to add a unit.

Return value

bool TRUE if the user has add permission, otherwise FALSE.

See also

node_menu()

1 string reference to '_rooms_unit_add_access'
RoomsUnitUIController::hook_menu in modules/rooms_unit/rooms_unit.admin.inc
Overrides hook_menu() defaults. Main reason for doing this is that parent class hook_menu() is optimized for entity type administration.

File

modules/rooms_unit/rooms_unit.module, line 299
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_add_access() {
  if (user_access('administer rooms_unit_type entities')) {

    // There are no bookable unit types defined that the user has permission to
    // create, but the user does have the permission to administer the content
    // types, so grant them access to the page anyway.
    return TRUE;
  }
  $types = rooms_unit_get_types();
  foreach ($types as $type) {
    if (rooms_unit_access('create', rooms_unit_create(array(
      'type' => $type->type,
      'uid' => 0,
    )))) {
      return TRUE;
    }
  }
  return FALSE;
}