Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added alma setting under "/admin/config/ding/provider/alma" to enable/di... #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions alma.module
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
8 changes: 7 additions & 1 deletion includes/alma.reservation.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down