You are here

function bat_unit_add_access in Booking and Availability Management Tools for Drupal 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.

1 string reference to 'bat_unit_add_access'
BatUnitUIController::hook_menu in modules/bat_unit/bat_unit.admin.inc
Overrides hook_menu() defaults.

File

modules/bat_unit/bat_unit.module, line 708

Code

function bat_unit_add_access() {
  if (user_access('administer bat_unit_bundle entities')) {

    // There are no unit bundles 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;
  }
  $bundles = bat_unit_get_bundles();
  foreach ($bundles as $bundle) {
    if (bat_unit_access('create', bat_unit_create(array(
      'type' => $bundle->type,
      'uid' => 0,
    )))) {
      return TRUE;
    }
  }
  return FALSE;
}