From 6cb3b671fc4bdb3174182f6368e57efea53c5093 Mon Sep 17 00:00:00 2001 From: yusuf amer Date: Tue, 5 Mar 2013 15:31:39 +0100 Subject: [PATCH 1/3] Added alma setting under "/admin/config/ding/provider/alma" to enable/disable "ready for pickup" remote loan deletion. --- alma.module | 7 +++++++ includes/alma.reservation.inc | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/alma.module b/alma.module index a837e89..a48720b 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_disable_remoteloan_deletion'] = array( + '#type' => 'checkbox', + '#title' => t('Disable "ready for pickup" remote loan deletion'), + '#default_value' => variable_get('alma_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..d396a67 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_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.')); + return FALSE; + } + } alma_reservation_clear_cache(); if( isset($reservations[$id]) ) { return alma_client_invoke('remove_reservation', $creds['name'], $creds['pass'], $reservations[$id]); From 44e7d91633183b7f605d9331cecded74ed124c2b Mon Sep 17 00:00:00 2001 From: yusuf amer Date: Wed, 6 Mar 2013 15:38:36 +0100 Subject: [PATCH 2/3] Added better drupal_set_message type. --- includes/alma.reservation.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/alma.reservation.inc b/includes/alma.reservation.inc index d396a67..4dc9a51 100644 --- a/includes/alma.reservation.inc +++ b/includes/alma.reservation.inc @@ -195,7 +195,7 @@ function alma_reservation_delete($account, $id) { // Reject "ready for pickup" remote loan deletion. if (variable_get('alma_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.')); + drupal_set_message(t('Deletion of "ready for pickup" remote loans are not allowed.'), 'warning'); return FALSE; } } From 4156f4a3f02b1910f82b1e3ed294f3048a9d0bb5 Mon Sep 17 00:00:00 2001 From: Rune Schjellerup Philosof Date: Mon, 11 Mar 2013 15:44:49 +0100 Subject: [PATCH 3/3] keep the alma variables properly namespaced --- alma.module | 4 ++-- includes/alma.reservation.inc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/alma.module b/alma.module index a48720b..bbef4c4 100644 --- a/alma.module +++ b/alma.module @@ -109,10 +109,10 @@ 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_disable_remoteloan_deletion'] = array( + $form['alma']['alma_reservation_disable_remoteloan_deletion'] = array( '#type' => 'checkbox', '#title' => t('Disable "ready for pickup" remote loan deletion'), - '#default_value' => variable_get('alma_disable_remoteloan_deletion', FALSE), + '#default_value' => variable_get('alma_reservation_disable_remoteloan_deletion', FALSE), '#description' => t('Reject "ready for pickup" remote loan deletion.'), ); diff --git a/includes/alma.reservation.inc b/includes/alma.reservation.inc index 4dc9a51..afd215e 100644 --- a/includes/alma.reservation.inc +++ b/includes/alma.reservation.inc @@ -193,7 +193,7 @@ 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_disable_remoteloan_deletion', TRUE)) { + 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;