Browse Source

updated code to work better with books and not send reduntant titles and authors in some cases

9.x-1.0
Paul Pound 8 years ago
parent
commit
86807dde43
  1. 7
      includes/form.inc
  2. 10
      includes/relais.inc
  3. 16
      includes/utilities.inc

7
includes/form.inc

@ -299,7 +299,6 @@ function upei_roblib_ill_request_form($form, &$form_state) {
$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'),
@ -376,10 +375,11 @@ function upei_roblib_ill_request_form($form, &$form_state) {
),
'#required' => FALSE,
);
$article_author = ($genre == 'book') ? '' : upei_roblib_ill_get_request_variable('author');
$form['ArticleAuthor'] = array(
'#type' => 'textfield',
'#title' => t('Author'),
'#default_value' => upei_roblib_ill_get_request_variable('author'),
'#default_value' => $article_author,
'#size' => 50,
'#required' => FALSE,
'#description' => 'Article or Chapter Author',
@ -389,10 +389,11 @@ function upei_roblib_ill_request_form($form, &$form_state) {
),
),
);
$author = ($genre == 'book') ? upei_roblib_ill_get_request_variable('author') : '';
$form['Author'] = array(
'#type' => 'textfield',
'#title' => t('Book Author'),
'#default_value' => upei_roblib_ill_get_request_variable('author'),
'#default_value' => $author,
'#size' => 50,
'#required' => FALSE,
'#states' => array(

10
includes/relais.inc

@ -62,15 +62,19 @@ function upei_roblib_ill_build_relais_arr($form_state) {
$relais_arr = array(
"SupplyingLibrarySymbol" => variable_get('upei_roblib_ill_library_symbol','PCU'),
);
$pub_type = upei_roblib_ill_get_pub_type($form_state['storage']['upei_roblib_ill_request_form']['Genre']);
$relais_arr['BibliographicInfo'] = upei_roblib_ill_clean_array($form_state['storage']['upei_roblib_ill_request_form']);
$relais_arr['DeliveryAddress'] = upei_roblib_ill_clean_array($form_state['storage']['upei_roblib_ill_auth_form']);
$relais_arr['ElectronicDelivery']['DeliveryAddress'] = $relais_arr['ElectronicDelivery']['MessagingAddress'] =
$relais_arr['DeliveryAddress']['DeliveryAddress'];
if($pub_type != 'B') {
// this is not a book but is a journal or chapter we will send electronically and as copy
$relais_arr['ElectronicDelivery']['DeliveryAddress'] = $relais_arr['ElectronicDelivery']['MessagingAddress'] =
$relais_arr['DeliveryAddress']['DeliveryAddress'];
}
$request_info = upei_roblib_ill_request_info_array($relais_arr['BibliographicInfo'], $form_state['values']['notes']);
$relais_arr['RequestInfo'] = $request_info;
$relais_arr['PublisherInfo']['PublicationDate'] = isset($form_state['storage']['upei_roblib_ill_request_form']['Date']) ?
$form_state['storage']['upei_roblib_ill_request_form']['Date'] : '';
$relais_arr['PublisherInfo']['PublicationType'] = upei_roblib_ill_get_pub_type($form_state['storage']['upei_roblib_ill_request_form']['Genre']);
$relais_arr['PublisherInfo']['PublicationType'] = $pub_type;
return $relais_arr;
}

16
includes/utilities.inc

@ -21,10 +21,18 @@ function upei_roblib_ill_clean_array($values) {
if (isset($arr['ISBN'])) {
$arr['ISBN'] = array($arr['ISBN']);
}
if (isset($arr['Genre']) && $arr['Genre'] == 'article' && isset($arr['Author'])) {
if (isset($arr['Genre']) && ($arr['Genre'] == 'article' || $arr['Genre'] == 'chapter') && isset($arr['Author'])) {
// We want ArticleAuthor
unset($arr['Author']);
}
if (isset($arr['Genre']) && $arr['Genre'] == 'book' && isset($arr['ArticleAuthor'])) {
// We want Author
unset($arr['ArticleAuthor']);
}
if (isset($arr['Genre']) && $arr['Genre'] == 'book' && isset($arr['ArticleTitle'])) {
// We want Title only
unset($arr['ArticleTitle']);
}
if (isset($arr['doi'])) {
$arr['AdditionalNumbers'] = $arr['doi'];
}
@ -60,6 +68,10 @@ function upei_roblib_ill_get_request_variable($variable) {
// ebsco sometimes sends garbage as issns verify this is a valid issn before displaying the value in the form.
return preg_match('/^\d{4}-?\d{3}[\dxX]$/', $_REQUEST[$variable]) ? $_REQUEST[$variable] : '';
}
// ebsco sometimes returns bookitem we only understand chapter
if(($variable == 'genre' && !empty($_REQUEST[$variable])) && $_REQUEST[$variable] == 'bookitem') {
return 'chapter';
}
return isset($_REQUEST[$variable]) ? $_REQUEST[$variable] : '';
}
@ -75,7 +87,7 @@ function upei_roblib_ill_request_info_array($values, $notes) {
$genre = $values['Genre'];
$requestInfo['DateSubmitted'] = date('Y-m-d H:i:s');
$requestInfo['Notes'] = $notes;
if ($genre == 'book' || $genre == 'chapter') {
if ($genre == 'book') {
$requestInfo['ServiceType'] = 'L';
$requestInfo['ServiceLabel'] = "R";
//$requestInfo['RequestSource'] = "C";

Loading…
Cancel
Save