Browse Source

on form submission patrons are now redirected to a landing page

9.x-1.0
Paul Pound 8 years ago
parent
commit
b181fb5374
  1. 27
      includes/form.inc
  2. 16
      includes/relais.inc
  3. 8
      upei_roblib_ill.module

27
includes/form.inc

@ -65,14 +65,35 @@ function upei_roblib_ill_form_submit($form, &$form_state) {
break;
case 'upei_roblib_ill_auth_form':
//process the form
drupal_set_message('completed form');
$aid = upei_roblib_ill_authenticate($form_state['values']['campus_id']);
upei_roblib_ill_add_request($form_state, $aid);
break;
$response = upei_roblib_ill_add_request($form_state, $aid);
$form_state['redirect'] = array(
'upei/roblib/ill/finished',
array(
'query' => array(
'message' => $response['ConfirmMessage'],
),
),
);
}
}
/**
* After submitting an ILL request patrons will be redirected to the content returned from this function.
* @return string
* a string of HTML to display including the results of the ILL request and some boilerplate text.
*/
function upei_roblib_ill_form_redirect() {
//TODO turn this into a drupal render array
//TODO phone number, email etc. could be variables read from the database.
$std_message = "<div class='upei-roblib-ill-message'>To contact the department about this request, you can send a message to <a href='mailto:ill@upei.ca'>ill@upei.ca</a> or
call 902-566-0445</div>";
return "<div class='upei-roblib-ill-relais-message'>" . $_GET['message'] . '</div>'. $std_message;
}
/**
* The patron portion of the ILL form.

16
includes/relais.inc

@ -45,23 +45,17 @@ function upei_roblib_ill_add_request($form_state, $aid) {
if(!isset($aid) || is_array($aid)) {
upei_roblib_ill_log_request($relais_arr, $aid);
drupal_set_message(t('Error retrieving authentication token, @message', array('@message' => $aid['Problem']['Message'])), 'error');
return;
return array('ConfirmMessage' => $aid['Problem']['Message'] . ' You may have entered an incorrect Campus ID');
}
$result = drupal_http_request($url . '?aid=' . $aid, $options);
module_load_include('inc', 'upei_roblib_ill', 'includes/db');
if(!isset($result->data)) {
return array('ConfirmMessage' => 'Error Communicating with Relais, no data returned.');
}
$response_json = $result->data;
$response_arr = json_decode($response_json, TRUE);
if ($result->code == '200') {
//TODO remove or improve the line below after testing
drupal_set_message('submitted request to relais' . $response_json);
}
else {
drupal_set_message(t('Error submitting request to relais, @code, @message', array(
'@code' => $result->code,
'@message' => $result->message
)), 'error');
}
upei_roblib_ill_log_request($relais_arr, $response_arr);
return $response_arr;
}
/**

8
upei_roblib_ill.module

@ -25,6 +25,14 @@ function upei_roblib_ill_menu() {
'file' => 'includes/form.inc',
'type' => MENU_NORMAL_ITEM,
);
$items['upei/roblib/ill/finished'] = array(
'title' => 'UPEI ILL Request',
'description' => 'Redirect to this page after form is submitted',
'page callback' => 'upei_roblib_ill_form_redirect',
'access arguments' => array('access content'),
'file' => 'includes/form.inc',
'type' => MENU_NORMAL_ITEM,
);
return $items;
}

Loading…
Cancel
Save