From 488fa77de2472e7fc83fa1c751668aa5b6eff436 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 --- 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 c968e33dc99..7940a9c559b 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -48,6 +48,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 31c094de001..9ac1cbd1b83 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.27.0