Browse Source

added regex for issn also some code cleanup

9.x-1.0
Paul Pound 7 years ago
parent
commit
bc89b5adc8
  1. 4
      includes/form.inc
  2. 14
      includes/utilities.inc

4
includes/form.inc

@ -115,7 +115,7 @@ function upei_roblib_ill_form_redirect() {
$standard_message = t("To contact the department about this request, you can send a message to ill@upei.ca or
call 902-566-0445.");
if (isset($_GET['error']) && $_GET['error'] === 'FALSE') {
$standard_message = t("A message including the Request ID has been sent to @email.", array(
$standard_message = t("A message including the Request ID has been sent to @email. ", array(
'@email' => $_GET['email'],
)) . $standard_message;
}
@ -344,7 +344,7 @@ function upei_roblib_ill_request_form($form, &$form_state) {
'#rows' => 2,
'#title' => t('Source Title'),
'#default_value' => upei_roblib_ill_get_request_variable('title'),
'#description' => 'Journal or Book Title',
'#description' => 'Journal or Book Title (Required)',
'#size' => 50,
'#required' => FALSE,
);

14
includes/utilities.inc

@ -21,11 +21,11 @@ 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' && isset($arr['Author'])) {
// We want ArticleAuthor
unset($arr['Author']);
}
if(isset($arr['doi'])) {
if (isset($arr['doi'])) {
$arr['AdditionalNumbers'] = $arr['doi'];
}
unset($arr['form_build_id']);
@ -55,6 +55,10 @@ function upei_roblib_ill_get_request_variable($variable) {
$last_name = isset($_REQUEST['aulast']) ? $_REQUEST['aulast'] : NULL;
return !empty($last_name) ? $last_name . ',' . $initial : '';
}
if ($variable == 'issn' && !empty($_REQUEST[$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] : '';
}
return isset($_REQUEST[$variable]) ? $_REQUEST[$variable] : '';
}
@ -89,10 +93,10 @@ function upei_roblib_ill_request_info_array($values, $notes) {
* @return string
*/
function upei_roblib_format_biblio_info($form_state) {
$data = upei_roblib_ill_clean_array($form_state['storage']['upei_roblib_ill_request_form']);
$data = upei_roblib_ill_clean_array($form_state['storage']['upei_roblib_ill_request_form']);
$rows = array();
foreach($data as $key => $value) {
if($key == 'ISSN' || $key == 'ISBN') {
foreach ($data as $key => $value) {
if ($key == 'ISSN' || $key == 'ISBN') {
$value = reset($value);
}
array_push($rows, array($key, $value));

Loading…
Cancel
Save