You are here

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

Give the new permission 'create customer profiles on bookings' to all roles with 'bypass rooms_booking entities access' permission.

File

modules/rooms_booking/rooms_booking.install, line 402
Sets up the base table for our entity and a table to store information about the entity types.

Code

function rooms_booking_update_7007() {
  $roles = db_select('role_permission', 'r')
    ->fields('r', array(
    'rid',
    'permission',
  ))
    ->condition('permission', 'bypass rooms_booking entities access')
    ->execute()
    ->fetchAllKeyed();
  foreach (array_keys($roles) as $rid) {
    db_merge('role_permission')
      ->key(array(
      'rid' => $rid,
      'permission' => 'create customer profiles on bookings',
    ))
      ->fields(array(
      'rid' => $rid,
      'permission' => 'create customer profiles on bookings',
      'module' => 'rooms_booking',
    ))
      ->execute();
  }
}