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 7 years ago
parent
commit
86807dde43
  1. 7
      includes/form.inc
  2. 6
      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['#prefix'] = '<div id="upei-roblib-ill-request-form">';
$form['#suffix'] = '</div>'; $form['#suffix'] = '</div>';
$genre = empty(upei_roblib_ill_get_request_variable('genre')) ? 'article' : upei_roblib_ill_get_request_variable('genre'); $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( $form['Genre'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => t('Genre'), '#title' => t('Genre'),
@ -376,10 +375,11 @@ function upei_roblib_ill_request_form($form, &$form_state) {
), ),
'#required' => FALSE, '#required' => FALSE,
); );
$article_author = ($genre == 'book') ? '' : upei_roblib_ill_get_request_variable('author');
$form['ArticleAuthor'] = array( $form['ArticleAuthor'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Author'), '#title' => t('Author'),
'#default_value' => upei_roblib_ill_get_request_variable('author'), '#default_value' => $article_author,
'#size' => 50, '#size' => 50,
'#required' => FALSE, '#required' => FALSE,
'#description' => 'Article or Chapter Author', '#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( $form['Author'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Book Author'), '#title' => t('Book Author'),
'#default_value' => upei_roblib_ill_get_request_variable('author'), '#default_value' => $author,
'#size' => 50, '#size' => 50,
'#required' => FALSE, '#required' => FALSE,
'#states' => array( '#states' => array(

6
includes/relais.inc

@ -62,15 +62,19 @@ function upei_roblib_ill_build_relais_arr($form_state) {
$relais_arr = array( $relais_arr = array(
"SupplyingLibrarySymbol" => variable_get('upei_roblib_ill_library_symbol','PCU'), "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['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['DeliveryAddress'] = upei_roblib_ill_clean_array($form_state['storage']['upei_roblib_ill_auth_form']);
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['ElectronicDelivery']['DeliveryAddress'] = $relais_arr['ElectronicDelivery']['MessagingAddress'] =
$relais_arr['DeliveryAddress']['DeliveryAddress']; $relais_arr['DeliveryAddress']['DeliveryAddress'];
}
$request_info = upei_roblib_ill_request_info_array($relais_arr['BibliographicInfo'], $form_state['values']['notes']); $request_info = upei_roblib_ill_request_info_array($relais_arr['BibliographicInfo'], $form_state['values']['notes']);
$relais_arr['RequestInfo'] = $request_info; $relais_arr['RequestInfo'] = $request_info;
$relais_arr['PublisherInfo']['PublicationDate'] = isset($form_state['storage']['upei_roblib_ill_request_form']['Date']) ? $relais_arr['PublisherInfo']['PublicationDate'] = isset($form_state['storage']['upei_roblib_ill_request_form']['Date']) ?
$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; return $relais_arr;
} }

16
includes/utilities.inc

@ -21,10 +21,18 @@ function upei_roblib_ill_clean_array($values) {
if (isset($arr['ISBN'])) { if (isset($arr['ISBN'])) {
$arr['ISBN'] = array($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 // We want ArticleAuthor
unset($arr['Author']); 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'])) { if (isset($arr['doi'])) {
$arr['AdditionalNumbers'] = $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. // 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] : ''; 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] : ''; return isset($_REQUEST[$variable]) ? $_REQUEST[$variable] : '';
} }
@ -75,7 +87,7 @@ function upei_roblib_ill_request_info_array($values, $notes) {
$genre = $values['Genre']; $genre = $values['Genre'];
$requestInfo['DateSubmitted'] = date('Y-m-d H:i:s'); $requestInfo['DateSubmitted'] = date('Y-m-d H:i:s');
$requestInfo['Notes'] = $notes; $requestInfo['Notes'] = $notes;
if ($genre == 'book' || $genre == 'chapter') { if ($genre == 'book') {
$requestInfo['ServiceType'] = 'L'; $requestInfo['ServiceType'] = 'L';
$requestInfo['ServiceLabel'] = "R"; $requestInfo['ServiceLabel'] = "R";
//$requestInfo['RequestSource'] = "C"; //$requestInfo['RequestSource'] = "C";

Loading…
Cancel
Save