From b6813142ddedebf96bb6dfa50d5544d42c30e5e1 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 1 Mar 2018 15:38:48 +0100 Subject: [PATCH] Bug 17530: Use can_article_request to control sidebar link Before this patch, the 'Request article' link is displayed whenever the pref is enabled. In many cases this might be useless. Instead of a guess as in opac-search, we now call can_article_request to know for sure. Note: at least this is the case when a user has logged in. Update sidebar template with template variable artreqpossible. Add code in opac-detail, MARCdetail and ISBDdetail to fill it. Test plan: [1] Look for two biblios with items: one that should allow article requests and one that should not (respecting branch, patron, item type). [2] Verify on detail, ISBD and MARC that the link is displayed for the first biblio and hidden for the second biblio. Signed-off-by: Marcel de Rooy Signed-off-by: Brendan Gallagher Signed-off-by: Chris Cormack Signed-off-by: Nick Clemens --- .../bootstrap/en/includes/opac-detail-sidebar.inc | 2 +- opac/opac-ISBDdetail.pl | 7 +++++++ opac/opac-MARCdetail.pl | 7 +++++++ opac/opac-detail.pl | 8 ++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc index 4fa6f508ee..a8f6f4ec28 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc @@ -14,7 +14,7 @@
  • Print
  • [% IF Koha.Preference( 'opacuserlogin' ) == 1 %] - [% IF Koha.Preference('ArticleRequests') %] + [% IF artreqpossible %]
  • Request article
  • [% END %] [% END %] diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl index 40e9b71f4c..cdbd37bf37 100755 --- a/opac/opac-ISBDdetail.pl +++ b/opac/opac-ISBDdetail.pl @@ -217,4 +217,11 @@ if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){ $template->param('OPACSearchForTitleIn' => $search_for_title); } +if( C4::Context->preference('ArticleRequests') ) { + my $artreqpossible = $patron + ? $biblio->can_article_request( $patron ) + : $biblio->may_article_request; + $template->param( artreqpossible => $artreqpossible ); +} + output_html_with_http_headers $query, $cookie, $template->output; diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl index ebb78a2982..926b70be58 100755 --- a/opac/opac-MARCdetail.pl +++ b/opac/opac-MARCdetail.pl @@ -349,6 +349,13 @@ if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){ $template->param('OPACSearchForTitleIn' => $search_for_title); } +if( C4::Context->preference('ArticleRequests') ) { + my $artreqpossible = $patron + ? $biblio->can_article_request( $patron ) + : $biblio->may_article_request; + $template->param( artreqpossible => $artreqpossible ); +} + $template->param( item_loop => \@item_loop, item_header_loop => \@item_header_loop, diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 2ee3fd4318..e0fbb903bd 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -756,6 +756,14 @@ if (!C4::Context->preference("OPACXSLTDetailsDisplay") ) { my $marcnotesarray = GetMarcNotes ($record,$marcflavour); my $subtitle = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber)); +if( C4::Context->preference('ArticleRequests') ) { + my $patron = $borrowernumber ? Koha::Patrons->find($borrowernumber) : undef; + my $artreqpossible = $patron + ? $biblio->can_article_request( $patron ) + : $biblio->may_article_request; + $template->param( artreqpossible => $artreqpossible ); +} + $template->param( MARCNOTES => $marcnotesarray, norequests => $norequests, -- 2.39.5