Browse Source

first commit

9.x-1.0
Paul Pound 8 years ago
commit
a72955caa3
  1. 13
      README.md
  2. 56
      includes/admin.form.inc
  3. 117
      includes/doi.inc
  4. 421
      includes/form.inc
  5. 80
      includes/relais.inc
  6. 76
      includes/utilities.inc
  7. 3
      upei_roblib_ill.info
  8. 19
      upei_roblib_ill.install
  9. 38
      upei_roblib_ill.module

13
README.md

@ -0,0 +1,13 @@
# Robertson Library ILL Forms module
## Introduction
Standalone module to submit ILL requests to Relais. Can read openurl parameters or lookup data based on a DOI
## Requirements
* Drupal 7
## Maintainers/Sponsors
* UPEI Robertson Library

56
includes/admin.form.inc

@ -0,0 +1,56 @@
<?php
/**
* @file
* the administrative form for upei_roblib_ill
*/
function upei_roblib_ill_admin_form($form, &$form_state) {
$form = array();
$form['upei_roblib_ill_add_url'] = array(
'#required' => TRUE,
'#type' => 'textfield',
'#size' => 200,
'#title' => t('The Relais AddRequest URL'),
'#description' => t('The URL for the Relais ILL server AddRequest service, the default is
https://caul-cbua.relais-host.com/portal-service/request/add'),
'#default_value' => variable_get('upei_roblib_ill_add_url', 'https://caul-cbua.relais-host.com/portal-service/request/add'),
);
$form['upei_roblib_ill_auth_url'] = array(
'#required' => TRUE,
'#type' => 'textfield',
'#size' => 200,
'#title' => t('The Relais Auth URL'),
'#description' => t('The URL for the Relais ILL server Auth service (retrieve the aid), the default is
https://caul-cbua.relais-host.com/portal-service/user/authentication'),
'#default_value' => variable_get('upei_roblib_ill_auth_url', 'https://caul-cbua.relais-host.com/portal-service/user/authentication'),
);
$form['upei_roblib_ill_library_symbol'] = array(
'#required' => TRUE,
'#type' => 'textfield',
'#size' => 200,
'#title' => t('Your Relais Library Symbol'),
'#description' => t('Your Relais Library Symbol'),
'#default_value' => variable_get('upei_roblib_ill_library_symbol'),
);
$form['upei_roblib_ill_relais_key'] = array(
'#required' => TRUE,
'#type' => 'textfield',
'#size' => 200,
'#title' => t('The Relais API key'),
'#description' => t('The API key used to communicate with the Relais API, Contact Relais International to get your key'),
'#default_value' => variable_get('upei_roblib_ill_relais_key'),
);
$form['upei_roblib_ill_doi_openurl_pid'] = array(
'#required' => TRUE,
'#type' => 'textfield',
'#size' => 200,
'#title' => t('OpenURL PID'),
'#description' => t('An identifier to call yourself, for the OpenURL endpoint. To use this service you first need to register for an account here: http://www.crossref.org/requestaccount/'),
'#default_value' => variable_get('upei_roblib_ill_doi_openurl_pid'),
);
return system_settings_form($form);
}

117
includes/doi.inc

@ -0,0 +1,117 @@
<?php
/**
* @file
* Contains functions for working with doi requests
* Borrowed code from the islandora_doi module as we don't want
* all the dependancies it would require.
*/
function upei_roblib_ill_doi_get_data($form, $doi) {
if (empty($doi)) {
$doi = 'Empty DOI';
}
$response = upei_roblib_ill_doi_load($doi);
$headers = array_change_key_case($response->headers);
if ($response->data &&
strpos($headers['content-type'], 'text/html') === FALSE &&
strpos($response->data, "Malformed DOI") === FALSE
) {
$crossref_xml = new DOMDocument('1.0');
if (!$crossref_xml->loadXML($response->data)) {
drupal_set_message(t('Error parseing DOI response, @msg'));
$form['doi']['#value'] = '';
return $form;
}
else {
return upei_roblib_ill_populate_form_doi($crossref_xml, $form);
}
}
else {
drupal_set_message(t('Error retrieve data using DOI of @doi', array('@doi' => $doi)), 'error');
$form['doi']['#value'] = '';
return $form;
}
}
function upei_roblib_ill_populate_form_doi($crossref_xml, $form) {
$full_title = $crossref_xml->getElementsbyTagName('full_title')
->item(0)->nodeValue;
$form['Title']['#value'] = $full_title;
$form['ISSN']['#value'] = $crossref_xml->getElementsbyTagName('issn')
->item(0)->nodeValue;
$form['Date']['#value'] = $crossref_xml->getElementsbyTagName('year')
->item(0)->nodeValue;
$form['ArticleTitle']['#value'] = $crossref_xml->getElementsbyTagName('title')
->item(0)->nodeValue;
$form['ImageOrPageNumber']['#value'] = $crossref_xml->getElementsbyTagName('first_page')
->item(0)->nodeValue;
$form['PagesRequested']['#value'] = $crossref_xml->getElementsbyTagName('last_page')
->item(0)->nodeValue;
$form['Volume']['#value'] = $crossref_xml->getElementsbyTagName('volume')
->item(0)->nodeValue;
$form['Issue']['#value'] = $crossref_xml->getElementsbyTagName('issue')
->item(0)->nodeValue;
foreach ($crossref_xml->getElementsbyTagName('person_name') as $person) {
$role = $person->getAttribute('contributor_role');
$sequence = $person->getAttribute('sequence');
if ($person->getAttribute('contributor_role') == 'author' &&
$person->getAttribute('sequence') == 'first'
) {
$author = $person->getElementsbyTagName('surname')
->item(0)->nodeValue . ',' . $person->getElementsbyTagName('given_name')
->item(0)->nodeValue;
}
}
$form['ArticleAuthor']['#value'] = $author;
$form['doi']['#value'] = '';
return $form;
}
/**
* Get the DOI name for the given url.
*
* @param string $doi_url
* A DOI url, or a DOI name with or without the "doi:" prefix. If the $url
* is a CrossRef ID passed in as doi:10.1016/j.tiv.2011.10.017 or
* 10.1111/eve.12339 it will not get changed by running it through parse_url.
*
* @return string
* A string containing the DOI name.
*/
function upei_roblib_ill_doi_name_from_url($doi_url) {
// Allows for DOI to be entered in the following formats: 10.1111/eva.12339,
// http://dx.doi.org/10.1111/eva.12339, http://doi.org/10.1111/eva.12339,
// or doi:10.1111/eva.12339. Removing whitespace before parsing the url and
// then removing any trailing "/" from the returned path.
$doi_name = trim(parse_url(trim($doi_url), PHP_URL_PATH), '/');
return $doi_name;
}
/**
* Perform a request to CrossRef for the given ID.
*
* @param string $doi
* A DOI to lookop. May be provided with or without the "doi:" prefix. Can
* also pass a full DOI url (i.e, http://doi.org/10.1111/eva.12339 ).
*
* @return object
* An object as provided by drupal_http_request().
*/
function upei_roblib_ill_doi_load($doi) {
// Allows for $id to pass a DOI url string or the DOI name.
$id = upei_roblib_ill_doi_name_from_url($doi);
$openurl = variable_get('upei_roblib_ill_doi_openurl', 'http://www.crossref.org/openurl');
$openurl_pid = variable_get('upei_roblib_ill_doi_openurl_pid', 'user@example.com');
$url = url($openurl, array(
'query' => array(
'noredirect' => 'true',
'pid' => $openurl_pid,
'format' => 'unixref',
'id' => ((strpos($id, 'doi:') === 0) ? $id : 'doi:' . $id),
),
));
return drupal_http_request($url);
}

421
includes/form.inc

@ -0,0 +1,421 @@
<?php
/**
* @file
* Contains the ILL forms.
*/
/**
* A form to wrap the different steps of our multi step form.
*
* @param array $form
* An array representing a Drupal form.
* @param array $form_state
* An array containing the Drupal form state.
*
* @return array
* An array representing the bibliographic form.
*/
function upei_roblib_ill_form($form, &$form_state) {
if (!isset($form_state['values'])) {
$form_name = 'upei_roblib_ill_request_form';
}
else {
$form_name = 'upei_roblib_ill_auth_form';
}
$form_state['step'] = $form_name;
return $form_name === 'upei_roblib_ill_request_form' ? upei_roblib_ill_request_form($form, $form_state) :
upei_roblib_ill_auth_form($form, $form_state);
}
/**
* Validation for the upei_roblib_ill_form form.
*
* @param array $form
* An array representing a Drupal form.
* @param array $form_state
* An array containing the Drupal form state.
*/
function upei_roblib_ill_form_validate($form, &$form_state) {
if ($form_state['step'] == 'upei_roblib_ill_request_form' && empty($form_state['values']['doi']) && empty($form_state['values']['Title']) &&
empty($form_state['values']['ArtcleTitle'])
) {
form_set_error('Title', t('One of "DOI", "Title" or "Article Title" values must be provided'));
}
}
/**
* Submit handler for the upei_roblib_ill_form form.
*
* @param array $form
* An array representing a Drupal form.
* @param array $form_state
* An array containing the Drupal form state.
*/
function upei_roblib_ill_form_submit($form, &$form_state) {
module_load_include('inc', 'upei_roblib_ill', 'includes/relais');
$form_state['storage'][$form_state['step']] = $form_state['values'];
switch ($form_state['step']) {
case 'upei_roblib_ill_request_form':
if ($form_state['clicked_button']['#value'] != 'lookup DOI') {
$form_state['step'] = 'upei_roblib_ill_auth_form';
$form_state['rebuild'] = TRUE;
}
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']);
if (isset($aid)) {
upei_roblib_ill_add_request($form_state, $aid);
}
else {
drupal_set_message(t("Error authenticating with Relais"), 'error');
}
break;
}
}
/**
* The patron portion of the ILL form.
*
* The campus_id and email portion are also used in a request for an Relais aid.
*
* @param array $form
* An array representing a Drupal form.
* @param array $form_state
* An array containing the Drupal form state.
*
* @return array
* An array representing the bibliographic form.
*/
function upei_roblib_ill_auth_form($form, &$form_state) {
$_REQUEST;
$form['FirstName'] = array(
'#type' => 'textfield',
'#title' => t('Your First Name'),
'#size' => 50,
'#required' => TRUE,
);
$form['Surname'] = array(
'#type' => 'textfield',
'#title' => t('Your Last Name'),
'#size' => 50,
'#required' => TRUE,
);
$form['campus_id'] = array(
'#type' => 'textfield',
'#title' => t('Your Campus ID'),
'#size' => 50,
'#required' => TRUE,
);
$patron_types = array(
'None' => t('None'),
'UPEI Faculty/Staff' => t('UPEI Faculty/Staff'),
'UPEI Graduate Student' => t('UPEI Graduate Student'),
'UPEI Undergraduate Student' => t('UPEI Undergraduate Student'),
'UPEI Honours Undergraduate Student' => t('UPEI Honours Undergraduate Student'),
'UPEI Alumni Premiere member' => t('UPEI Alumni Premiere member'),
'UPEI Alumni member' => t('UPEI Alumni member'),
'Public Borrower' => t('Public Borrower'),
);
$departments = array(
'Applied Human Sciences' => t('Applied Human Sciences'),
'AVC - Biomedical Sciences' => t('AVC - Biomedical Sciences'),
'AVC - Companion Animals' => t('AVC - Companion Animals'),
'AVC - Health Management' => t('AVC - Health Management'),
'AVC - Pathology/Microbiology' => t('AVC - Pathology/Microbiology'),
'AVC - Lobster Science' => t('AVC - Lobster Science'),
'Biology' => t('Biology'),
'Business' => t('Business'),
'Chemistry' => t('Chemistry'),
'Classics' => t('Classics'),
'Diversity and Social Justice Studies' => t('Diversity and Social Justice Studies'),
'Economics' => t('Economics'),
'Education' => t('Education'),
'English' => t('English'),
'Engineering' => t('Engineering'),
'Environmental Studies' => t('Environmental Studies'),
'Fine Arts' => t('Fine Arts'),
'History' => t('History'),
'Island Studies' => t('Island Studies'),
'Island Studies (Masters)' => t('Island Studies (Masters)'),
'Robertson Library' => t('Robertson Library'),
'Robertson Library' => t('Robertson Library'),
'Mathematical and Computational Sciences' => t('Mathematical and Computational Sciences'),
'Modern Languages' => t('Modern Languages'),
'Music' => t('Music'),
'Nursing' => t('Nursing'),
'Philosophy' => t('Philosophy'),
'Physics' => t('Physics'),
'Political Science' => t('Political Science'),
'Psychology' => t('Psychology'),
'Religious Studies' => t('Religious Studies'),
'Sociology/Anthropology' => t('Sociology/Anthropology'),
'Other' => t('Other (Please add to the Notes field)'),
);
$form['patron_type'] = array(
'#type' => 'select',
'#title' => t('Your Patron Type'),
'#options' => $patron_types,
'#required' => TRUE,
);
$form['Department'] = array(
'#type' => 'select',
'#title' => t('Your Department'),
'#options' => $departments,
'#required' => TRUE,
);
$form['DeliveryAddress'] = array(
'#type' => 'textfield',
'#title' => t('Your Email'),
'#size' => 50,
'#required' => TRUE,
);
$form['InstitutionName'] = array(
'#type' => 'textfield',
'#title' => t('Name of Institution'),
'#size' => 50,
'#default_value' => 'University of Prince Edward Island',
'#required' => TRUE,
);
$form['LibraryName'] = array(
'#type' => 'textfield',
'#title' => t('Name of Institution'),
'#size' => 50,
'#default_value' => 'Robertson Library',
'#required' => TRUE,
);
$form['notes'] = array(
'#type' => 'textarea',
'#title' => t('Notes'),
'#size' => 50,
'#required' => FALSE,
);
$form['certify'] = array(
'#type' => 'checkbox',
'#description' => 'I hereby certify that this item is being sought for a fair dealing purpose and any copying will be in accordance with the Copyright Act. ',
'#size' => 50,
'#required' => TRUE,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
);
return $form;
}
/**
* The bibliographic portion of the ILL form.
*
* @param array $form
* An array representing a Drupal form.
* @param array $form_state
* An array containing the Drupal form state.
*
* @return array
* An array representing the bibliographic form.
*/
function upei_roblib_ill_request_form($form, &$form_state) {
module_load_include('inc', 'upei_roblib_ill', 'includes/utilities');
$form['#prefix'] = '<div id="upei-roblib-ill-request-form">';
$form['#suffix'] = '</div>';
$genre = empty(upei_roblib_ill_get_request_variable('genre')) ? 'article' : upei_roblib_ill_get_request_variable('genre');
//$values = isset($form_state['multistep_values']['upei_roblib_ill_request']) ? orm_state['multistep_values']['ra$fte_the_room'] : array();
$form['Genre'] = array(
'#type' => 'select',
'#title' => t('Genre'),
'#default_value' => $genre,
'#options' => array(
'article' => t('Journal Article'),
'book' => t('Book'),
'chapter' => t('Book Chapter'),
),
'#required' => TRUE,
);
$form['doi'] = array(
'#type' => 'textfield',
'#title' => t('DOI'),
'#default_value' => upei_roblib_ill_get_request_variable('doi'),
'#description' => 'DOI, if you provide a DOI we will attempt to lookup the record for you',
'#size' => 50,
'#states' => array(
'visible' => array(
':input[name="Genre"]' => array('value' => 'article'),
),
),
'#required' => FALSE,
);
$form['doi_button'] = array(
'#type' => 'submit',
'#value' => 'lookup DOI',
'#ajax' => array(
'callback' => 'upei_roblib_ill_doi_callback',
'method' => 'replace',
'wrapper' => 'upei-roblib-ill-request-form',
'effect' => 'fade',
),
'#states' => array(
'visible' => array(
':input[name="Genre"]' => array('value' => 'article'),
),
),
'#required' => FALSE,
);
$form['Title'] = array(
'#type' => 'textfield',
'#title' => t('Source Title'),
'#default_value' => upei_roblib_ill_get_request_variable('title'),
'#description' => 'Journal or Book Title',
'#size' => 50,
'#required' => FALSE,
);
$form['ArticleTitle'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => upei_roblib_ill_get_request_variable('atitle'),
'#description' => 'Article or Chapter Title',
'#size' => 50,
'#states' => array(
'visible' => array(
':input[name="Genre"]' => array('value' => 'article'),
),
),
'#required' => FALSE,
);
$form['ISSN'] = array(
'#type' => 'textfield',
'#title' => t('ISSN'),
'#default_value' => upei_roblib_ill_get_request_variable('issn'),
'#size' => 50,
'#states' => array(
'visible' => array(
':input[name="Genre"]' => array('value' => 'article'),
),
),
'#required' => FALSE,
);
$form['ArticleAuthor'] = array(
'#type' => 'textfield',
'#title' => t('Author'),
'#default_value' => upei_roblib_ill_get_request_variable('author'),
'#size' => 50,
'#required' => FALSE,
'#description' => 'Article or Chapter Author',
'#states' => array(
'invisible' => array(
':input[name="Genre"]' => array('value' => 'book'),
),
),
);
$form['Author'] = array(
'#type' => 'textfield',
'#title' => t('Book Author'),
'#default_value' => upei_roblib_ill_get_request_variable('author'),
'#size' => 50,
'#required' => FALSE,
'#states' => array(
'invisible' => array(
':input[name="Genre"]' => array('value' => t('article')),
),
),
);
$form['ISBN'] = array(
'#type' => 'textfield',
'#title' => t('ISBN'),
'#default_value' => upei_roblib_ill_get_request_variable('isbn'),
'#size' => 50,
'#states' => array(
'invisible' => array(
':input[name="Genre"]' => array('value' => 'article'),
),
),
'#required' => FALSE,
);
$form['SubTitle'] = array(
'#type' => 'hidden',
'#title' => t('Sub Title'),
'#default_value' => upei_roblib_ill_get_request_variable('ubtitle'),
'#size' => 50,
'#required' => FALSE,
);
$form['SeriesTitle'] = array(
'#type' => 'hidden',
'#title' => t('Series Title'),
'#default_value' => upei_roblib_ill_get_request_variable('stitle'),
'#size' => 50,
'#required' => FALSE,
);
$form['Volume'] = array(
'#type' => 'textfield',
'#title' => t('Volume'),
'#default_value' => upei_roblib_ill_get_request_variable('volume'),
'#size' => 50,
'#required' => FALSE,
'#states' => array(
'visible' => array(
':input[name="Genre"]' => array('value' => 'article'),
),
),
);
$form['Issue'] = array(
'#type' => 'textfield',
'#title' => t('Issue'),
'#default_value' => upei_roblib_ill_get_request_variable('issue'),
'#size' => 50,
'#required' => FALSE,
'#states' => array(
'visible' => array(
':input[name="Genre"]' => array('value' => 'article'),
),
),
);
$form['ImageOrPageNumber'] = array(
'#type' => 'textfield',
'#title' => t('Start Page'),
'#default_value' => upei_roblib_ill_get_request_variable('spage'),
'#size' => 50,
'#required' => FALSE,
'#states' => array(
'invisible' => array(
':input[name="Genre"]' => array('value' => 'book'),
),
),
);
$form['PagesRequested'] = array(
'#type' => 'textfield',
'#title' => t('End Page'),
'#default_value' => upei_roblib_ill_get_request_variable('epage'),
'#size' => 50,
'#required' => FALSE,
'#states' => array(
'invisible' => array(
':input[name="Genre"]' => array('value' => 'book'),
),
),
);
$form['Date'] = array(
'#type' => 'textfield',
'#title' => t('Date'),
'#default_value' => upei_roblib_ill_get_request_variable('date'),
'#size' => 50,
'#required' => FALSE,
);
$form['next'] = array(
'#type' => 'submit',
'#value' => t('Next')
);
$form_state['stage'] = 'upei_roblib_ill_auth';
return $form;
}

80
includes/relais.inc

@ -0,0 +1,80 @@
<?php
/**
* @file
* Contains the functions to send and receive data to/from Relais.
*/
/**
* Submit an ILL AddRequest to relais.
* @param array $form_state
* A drupal form_state array
* @param string $aid
* A relais authentication id (token)
*/
function upei_roblib_ill_add_request($form_state, $aid) {
module_load_include('inc', 'upei_roblib_ill', 'includes/utilities');
$url = variable_get('upei_roblib_ill_add_url', 'https://caul-cbua.relais-host.com/portal-service/request/add');
$relais_arr = array(
"SupplyingLibrarySymbol" => 'PCU',
);
$relais_arr['BibliographicInfo'] = upei_roblib_ill_clean_array($form_state['storage']['upei_roblib_ill_request_form']);
//$relais_arr['BibliographicInfo']
$relais_arr['DeliveryAddress'] = upei_roblib_ill_clean_array($form_state['storage']['upei_roblib_ill_auth_form']);
$request_info = upei_roblib_ill_request_info_array($relais_arr['BibliographicInfo'], $form_state['values']['notes']);
$relais_arr['RequestInfo'] = $request_info;
$relais_json = json_encode($relais_arr);
$options = array(
'method' => 'POST',
'data' => $relais_json,
'timeout' => 15,
'headers' => array('Content-Type' => 'application/json'),
);
$result = drupal_http_request($url . '?aid=' . $aid, $options);
if ($result->code == '200') {
$response_json = $result->data;
$response_arr = json_decode($response_json);
//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');
}
}
/**
* Request an aid from Relais.
* @param string $barcode
* A patron_id, campus_id or barcode to identify a user
* @return string/null
* Returns a Relais authentication id (token) or NULL on if authentication fails
*/
function upei_roblib_ill_authenticate($barcode) {
$url = variable_get('upei_roblib_ill_auth_url', 'https://caul-cbua.relais-host.com/portal-service/user/authentication');
$json_arr = array();
$json_arr['ApiKey'] = variable_get('upei_roblib_ill_relais_key');
$json_arr['UserGroup'] = 'patron';
$json_arr['LibrarySymbol'] = variable_get('upei_roblib_ill_library_symbol');
$json_arr['PatronId'] = $barcode;
$request_json = json_encode($json_arr);
$options = array(
'method' => 'POST',
'data' => $request_json,
'timeout' => 15,
'headers' => array('Content-Type' => 'application/json'),
);
$result = drupal_http_request($url, $options);
if ($result->code == '200') {
$response_data = json_decode($result->data, TRUE);
if (isset($response_data['Problem'])) {
drupal_set_message(t('Error retrieving authentication token, @message', array('@message' => $response_data['Problem']['Message'])), 'error');
return NULL;
}
$aid = $response_data['AuthorizationId'];
}
return isset($aid) ? $aid : NULL;
}

76
includes/utilities.inc

@ -0,0 +1,76 @@
<?php
/**
* @file
* Contains helper functions for working with Relais requests.
*/
/**
* Removes empty elements and drupal specific elements from an array
*
* @param $values
* A drupal form_state['values] array
* @return array
* An array where the keys in the array that have empty values are removed and
* drupal specific elements are removed.
*/
function upei_roblib_ill_clean_array($values) {
$arr = array_filter($values);
if (isset($arr['ISSN'])) {
$arr['ISSN'] = array($arr['ISSN']);
}
if (isset($arr['ISBN'])) {
$arr['ISBN'] = array($arr['ISBN']);
}
unset($arr['form_build_id']);
unset($arr['form_token']);
unset($arr['form_id']);
unset($arr['op']);
unset($arr['submit']);
unset($arr['next']);
unset($arr['certify']);
unset($arr['doi']);
return $arr;
}
/**
* Allows us to ask for _REQUEST variables that may or may not exist without generating a php warning.
* Also does some formating for certain variables.
* @param string $variable
* The name of the $_REQUEST variable to check
* @return string
* The value of the $_REQUEST variable or an empty string.
*/
function upei_roblib_ill_get_request_variable($variable) {
if ($variable == 'author' && empty($_REQUEST[$variable])) {
//google scholar usually sends auinit aulast instead of author
$initial = isset($_REQUEST['auinit']) ? $_REQUEST['auinit'] : NULL;
$last_name = isset($_REQUEST['aulast']) ? $_REQUEST['aulast'] : NULL;
return !empty($last_name) ? $last_name . ',' . $initial : '';
}
return isset($_REQUEST[$variable]) ? $_REQUEST[$variable] : '';
}
/**
* Populates the requestInfo portion of a Relais request
* @param array $values
* an array containing a 'Genre' element.
* @return array
* The requestInfo portion of a Relais request
*/
function upei_roblib_ill_request_info_array($values, $notes) {
$requestInfo = array();
$genre = $values['Genre'];
$requestInfo['DateSubmitted'] = date('Y-m-d');
$requestInfo['Notes'] = $notes;
if ($genre == 'book' || $genre == 'chapter') {
$requestInfo['ServiceType'] = 'L';
$requestInfo['ServiceLabel'] = "R";
$requestInfo['RequestSource'] = "C";
}
else {
$requestInfo['ServiceType'] = 'X';
$requestInfo['ServiceLabel'] = "R";
$requestInfo['RequestSource'] = "C";
}
return $requestInfo;
}

3
upei_roblib_ill.info

@ -0,0 +1,3 @@
name = UPEI Robertson Library ILL forms
description = UPEI Robertson Library ILL forms
core = 7.x

19
upei_roblib_ill.install

@ -0,0 +1,19 @@
<?php
/**
* @file
* Implementations of installation hooks.
*/
/**
* Implements hook_uninstall().
*/
function upei_roblib_ill_uninstall() {
$variables = array(
'upei_roblib_ill_add_url',
'upei_roblib_ill_auth_url',
'upei_roblib_ill_relais_key',
'upei_roblib_ill_library_symbol',
);
array_walk($variables, 'variable_del');
}

38
upei_roblib_ill.module

@ -0,0 +1,38 @@
<?php
/**
* @file
* The drupal module file for upei_roblib_ill module
*/
function upei_roblib_ill_menu() {
$items = array();
$items['admin/settings/roblibill'] = array(
'title' => 'UPEI Roblib ILL settings',
'description' => 'Conifiguration for the UPEI ILL forms',
'page callback' => 'drupal_get_form',
'page arguments' => array('upei_roblib_ill_admin_form'),
'access arguments' => array('access administration pages'),
'file' => 'includes/admin.form.inc',
'type' => MENU_NORMAL_ITEM,
);
$items['upei/roblib/ill'] = array(
'title' => 'UPEI ILL Form',
'description' => 'The entry point for the UPEI ILL forms',
'page callback' => 'drupal_get_form',
'page arguments' => array('upei_roblib_ill_form'),
'access arguments' => array('access content'),
'file' => 'includes/form.inc',
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
function upei_roblib_ill_doi_callback($form, &$form_state) {
module_load_include('inc', 'upei_roblib_ill', 'includes/doi');
$form = upei_roblib_ill_doi_get_data($form, $form_state['values']['doi']);
return $form;
}
Loading…
Cancel
Save