/**
  * Process cancel request.
  *
  * @param \VuFind\ILS\Connection $catalog ILS connection object
  * @param array                  $patron  Current logged in patron
  *
  * @return array                          The result of the cancellation, an
  * associative array keyed by item ID (empty if no cancellations performed)
  */
 public function cancelStorageRetrievalRequests($catalog, $patron)
 {
     // Retrieve the flashMessenger helper:
     $flashMsg = $this->getController()->flashMessenger();
     $params = $this->getController()->params();
     // Pick IDs to cancel based on which button was pressed:
     $all = $params->fromPost('cancelAll');
     $selected = $params->fromPost('cancelSelected');
     if (!empty($all)) {
         $details = $params->fromPost('cancelAllIDS');
     } else {
         if (!empty($selected)) {
             $details = $params->fromPost('cancelSelectedIDS');
         } else {
             // No button pushed -- no action needed
             return [];
         }
     }
     if (!empty($details)) {
         // Confirm?
         if ($params->fromPost('confirm') === "0") {
             $url = $this->getController()->url()->fromRoute('myresearch-storageretrievalrequests');
             if ($params->fromPost('cancelAll') !== null) {
                 return $this->getController()->confirm('storage_retrieval_request_cancel_all', $url, $url, 'confirm_storage_retrieval_request_cancel_all_text', ['cancelAll' => 1, 'cancelAllIDS' => $params->fromPost('cancelAllIDS')]);
             } else {
                 return $this->getController()->confirm('storage_retrieval_request_cancel_selected', $url, $url, 'confirm_storage_retrieval_request_cancel_selected_text', ['cancelSelected' => 1, 'cancelSelectedIDS' => $params->fromPost('cancelSelectedIDS')]);
             }
         }
         foreach ($details as $info) {
             // If the user input contains a value not found in the session
             // whitelist, something has been tampered with -- abort the process.
             if (!in_array($info, $this->getSession()->validIds)) {
                 $flashMsg->addMessage('error_inconsistent_parameters', 'error');
                 return [];
             }
         }
         // Add Patron Data to Submitted Data
         $cancelResults = $catalog->cancelStorageRetrievalRequests(['details' => $details, 'patron' => $patron]);
         if ($cancelResults == false) {
             $flashMsg->addMessage('storage_retrieval_request_cancel_fail', 'error');
         } else {
             if ($cancelResults['count'] > 0) {
                 // TODO : add a mechanism for inserting tokens into translated
                 // messages so we can avoid a double translation here.
                 $msg = $this->getController()->translate('storage_retrieval_request_cancel_success_items');
                 $flashMsg->addMessage($cancelResults['count'] . ' ' . $msg, 'success');
             }
             return $cancelResults;
         }
     } else {
         $flashMsg->addMessage('storage_retrieval_request_empty_selection', 'error');
     }
     return [];
 }