From 86807dde43d16c78f3e03dd7caba8acedd8a3e13 Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Tue, 20 Jun 2017 15:12:29 -0300 Subject: [PATCH] updated code to work better with books and not send reduntant titles and authors in some cases --- includes/form.inc | 7 ++++--- includes/relais.inc | 10 +++++++--- includes/utilities.inc | 16 ++++++++++++++-- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/includes/form.inc b/includes/form.inc index 9e07d29..62c08e4 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -299,7 +299,6 @@ function upei_roblib_ill_request_form($form, &$form_state) { $form['#prefix'] = '
'; $form['#suffix'] = '
'; $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( diff --git a/includes/relais.inc b/includes/relais.inc index 592d13a..b6a136d 100644 --- a/includes/relais.inc +++ b/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; } diff --git a/includes/utilities.inc b/includes/utilities.inc index 25d36c6..19a07e5 100644 --- a/includes/utilities.inc +++ b/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";