From 50503852e305957d137e99be98baaaee728152cf 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 --- catalogue/detail.pl | 29 ++++++++++++--- .../prog/en/xslt/MARC21slim2intranetDetail.xsl | 42 +++++++++++++++------- 2 files changed, 54 insertions(+), 17 deletions(-) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index f865ddb28d..baab67bf62 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(); @@ -144,12 +145,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 31c094de00..9ac1cbd1b8 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.11.0