diff --git a/alma.module b/alma.module index a837e89..bbef4c4 100644 --- a/alma.module +++ b/alma.module @@ -109,6 +109,13 @@ function alma_settings_form() { '#description' => t('Logs requests to the Alma webservice. Sensitive information such as CPR number and PIN code is stripped from the requests.'), ); + $form['alma']['alma_reservation_disable_remoteloan_deletion'] = array( + '#type' => 'checkbox', + '#title' => t('Disable "ready for pickup" remote loan deletion'), + '#default_value' => variable_get('alma_reservation_disable_remoteloan_deletion', FALSE), + '#description' => t('Reject "ready for pickup" remote loan deletion.'), + ); + return system_settings_form($form); } diff --git a/includes/alma.reservation.inc b/includes/alma.reservation.inc index 98192ce..afd215e 100644 --- a/includes/alma.reservation.inc +++ b/includes/alma.reservation.inc @@ -192,7 +192,13 @@ function alma_reservation_update_order($account, $id, $pickup_branch, $expiry_da function alma_reservation_delete($account, $id) { $creds = ding_user_get_creds($account); $reservations = alma_reservation_get_reservations($account); - + // Reject "ready for pickup" remote loan deletion. + if (variable_get('alma_reservation_disable_remoteloan_deletion', TRUE)) { + if ($id < 0 && isset($reservations[$id]['pickup_number'])) { + drupal_set_message(t('Deletion of "ready for pickup" remote loans are not allowed.'), 'warning'); + return FALSE; + } + } alma_reservation_clear_cache(); if( isset($reservations[$id]) ) { return alma_client_invoke('remove_reservation', $creds['name'], $creds['pass'], $reservations[$id]);