|
|
@ -28,6 +28,22 @@ function reserve_form_reserve_reservation_form_alter(array &$form, FormStateInte |
|
|
|
$path_args = explode('/', $_GET['path'] ); |
|
|
|
$path_args = explode('/', $_GET['path'] ); |
|
|
|
$length = 30 * $_GET['count']; |
|
|
|
$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') { |
|
|
|
//if (user_access('administer site configuration') && isset($_GET['edit']) && $_GET['edit'] == 'standard') { |
|
|
|
// return; |
|
|
|
// return; |
|
|
@ -62,7 +78,7 @@ function reserve_form_reserve_reservation_form_alter(array &$form, FormStateInte |
|
|
|
$yyyymmdd = date('Y-m-d', strtotime($year . '-' . $month . '-' . $day)); |
|
|
|
$yyyymmdd = date('Y-m-d', strtotime($year . '-' . $month . '-' . $day)); |
|
|
|
$d = $yyyymmdd . ' 00:00:00'; |
|
|
|
$d = $yyyymmdd . ' 00:00:00'; |
|
|
|
|
|
|
|
|
|
|
|
if (reserve_daily_max_exceeded($yyyymmdd)) { |
|
|
|
if (reserve_daily_max_exceeded($yyyymmdd) && !$book_extended) { |
|
|
|
$form = array(); |
|
|
|
$form = array(); |
|
|
|
$form['message'] = [ |
|
|
|
$form['message'] = [ |
|
|
|
'#type' => 'markup', |
|
|
|
'#type' => 'markup', |
|
|
@ -77,7 +93,8 @@ function reserve_form_reserve_reservation_form_alter(array &$form, FormStateInte |
|
|
|
} |
|
|
|
} |
|
|
|
$config = \Drupal::config('reserve.settings'); |
|
|
|
$config = \Drupal::config('reserve.settings'); |
|
|
|
$max_per_user = $config->get('reservations_per_user'); |
|
|
|
$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 = array(); |
|
|
|
$form['message'] = [ |
|
|
|
$form['message'] = [ |
|
|
|
'#type' => 'markup', |
|
|
|
'#type' => 'markup', |
|
|
@ -131,9 +148,7 @@ function reserve_form_reserve_reservation_form_alter(array &$form, FormStateInte |
|
|
|
$form['user_id']['#access'] = false; |
|
|
|
$form['user_id']['#access'] = false; |
|
|
|
$form['reservation_series_id']['#access'] = false; |
|
|
|
$form['reservation_series_id']['#access'] = false; |
|
|
|
$form['reservation_ebundle']['#access'] = false; |
|
|
|
$form['reservation_ebundle']['#access'] = false; |
|
|
|
//UPEI doesn't want repeat except of admins |
|
|
|
if(!$book_extended){ |
|
|
|
$user = \Drupal::currentUser(); |
|
|
|
|
|
|
|
if(!in_array('administrator', array_values($user->getRoles()))){ |
|
|
|
|
|
|
|
$form['reservation_repeat_type']['#access'] = FALSE; |
|
|
|
$form['reservation_repeat_type']['#access'] = FALSE; |
|
|
|
$form['reservation_repeat_until']['#access'] = FALSE; |
|
|
|
$form['reservation_repeat_until']['#access'] = FALSE; |
|
|
|
} |
|
|
|
} |
|
|
|