From 8da73fe4283198ac93e2f15695f44e0cea7c490f Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 17 Jul 2020 09:44:46 -0300 Subject: [PATCH] Bug 15851: (follow-up) Only display the analytics link when required (staff) This patch replicates the introduced behaviour, for the admin interface. To test, follow the test plan from the OPAC, but on the intranet. Signed-off-by: Tomas Cohen Arazi Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- catalogue/detail.pl | 29 +++++++++++-- .../en/xslt/MARC21slim2intranetDetail.xsl | 42 +++++++++++++------ 2 files changed, 54 insertions(+), 17 deletions(-) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index fde981f65d..3a22b5db86 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -49,6 +49,7 @@ use Koha::ItemTypes; use Koha::Patrons; use Koha::Virtualshelves; use Koha::Plugins; +use Koha::SearchEngine::Search; my $query = CGI->new(); @@ -143,12 +144,32 @@ my $lang = $xslfile ? C4::Languages::getlanguage() : undef; my $sysxml = $xslfile ? C4::XSLT::get_xslt_sysprefs() : undef; if ( $xslfile ) { + + my $searcher = Koha::SearchEngine::Search->new( + { index => $Koha::SearchEngine::BIBLIOS_INDEX } + ); + my $cleaned_title = $biblio->title; + $cleaned_title =~ tr|/||; + my $query = + ( C4::Context->preference('UseControlNumber') and $record->field('001') ) + ? 'rcn:'. $record->field('001')->data . ' and (bib-level:a or bib-level:b)' + : "Host-item:$cleaned_title"; + my ( $err, $result, $count ) = $searcher->simple_search_compat( $query, 0, 0 ); + + warn "Warning from simple_search_compat: $err" + if $err; + + my $variables = { + show_analytics_link => $count > 0 ? 1 : 0 + }; + $template->param( XSLTDetailsDisplay => '1', - XSLTBloc => XSLTParse4Display( - $biblionumber, $record, "XSLTDetailsDisplay", - 1, undef, $sysxml, $xslfile, $lang - ) + XSLTBloc => XSLTParse4Display( + $biblionumber, $record, "XSLTDetailsDisplay", 1, + undef, $sysxml, $xslfile, $lang, + $variables + ) ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl index fc88cec6fd..16f727a0e1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl +++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl @@ -320,21 +320,37 @@ - - - Analytics: - + + - - /cgi-bin/koha/catalogue/search.pl?q=rcn:+AND+(bib-level:a+OR+bib-level:b) - - - /cgi-bin/koha/catalogue/search.pl?q=Host-item: - + + + analytic_collection + analytic_subunit + analytic_ires + analytic_monograph + analytic_serial + analytic_undefined - Show analytics - - + + + + + + results_summary analytics + Analytics: + + + + /cgi-bin/koha/catalogue/search.pl?q=rcn:+AND+(bib-level:a+OR+bib-level:b) + + + /cgi-bin/koha/catalogue/search.pl?q=Host-item: + + + Show analytics + + -- 2.39.5