Browse Source

users with the Create new Reservations extended perm can now book unlimited number of reservations

d9
ppound 3 years ago
parent
commit
7270b635e8
  1. 25
      reservation.inc
  2. 1
      reserve.inc

25
reservation.inc

@ -28,6 +28,22 @@ function reserve_form_reserve_reservation_form_alter(array &$form, FormStateInte
$path_args = explode('/', $_GET['path'] );
$length = 30 * $_GET['count'];
};
$user = \Drupal::currentUser();
$user_roles = $user->getRoles();
//Allow users with the 'add reservation extended' to book unlimited number
//of reservations.'
$book_extended = FALSE;
//Allow administrators to create as many reservations as needed.
if (in_array('administrator', $user_roles)) {
$book_extended = TRUE;
}
//Allow perm 'add reservations extended' to add as many as needed.
$roles_permissions = user_role_permissions($user_roles);
foreach ($roles_permissions as $role_key => $permissions) {
if (in_array('add reservations extended', $permissions)) {
$book_extended = TRUE;
}
}
//if (user_access('administer site configuration') && isset($_GET['edit']) && $_GET['edit'] == 'standard') {
// return;
@ -62,7 +78,7 @@ function reserve_form_reserve_reservation_form_alter(array &$form, FormStateInte
$yyyymmdd = date('Y-m-d', strtotime($year . '-' . $month . '-' . $day));
$d = $yyyymmdd . ' 00:00:00';
if (reserve_daily_max_exceeded($yyyymmdd)) {
if (reserve_daily_max_exceeded($yyyymmdd) && !$book_extended) {
$form = array();
$form['message'] = [
'#type' => 'markup',
@ -77,7 +93,8 @@ function reserve_form_reserve_reservation_form_alter(array &$form, FormStateInte
}
$config = \Drupal::config('reserve.settings');
$max_per_user = $config->get('reservations_per_user');
if (count(reserve_user_reservations()) > $max_per_user) {
if (count(reserve_user_reservations()) > $max_per_user
&& !$book_extended) {
$form = array();
$form['message'] = [
'#type' => 'markup',
@ -131,9 +148,7 @@ function reserve_form_reserve_reservation_form_alter(array &$form, FormStateInte
$form['user_id']['#access'] = false;
$form['reservation_series_id']['#access'] = false;
$form['reservation_ebundle']['#access'] = false;
//UPEI doesn't want repeat except of admins
$user = \Drupal::currentUser();
if(!in_array('administrator', array_values($user->getRoles()))){
if(!$book_extended){
$form['reservation_repeat_type']['#access'] = FALSE;
$form['reservation_repeat_until']['#access'] = FALSE;
}

1
reserve.inc

@ -938,7 +938,6 @@ function reserve_daily_max_exceeded($yyyy_mmdd) {
->execute();
$record_count = count($ids);
}
debug($record_count, 'pp-record-count', TRUE);
if ($record_count < $max) {
return FALSE;
}

Loading…
Cancel
Save