From dec6ab96f0e1bc6981464a32cba7b31c7a0be99d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 6 Aug 2015 15:28:12 +0100 Subject: [PATCH] Bug 14544: Get rid of GetBibliosShelves Signed-off-by: Alex Arnaud --- C4/VirtualShelves.pm | 21 ------------------- catalogue/detail.pl | 13 +++++++++++- .../prog/en/modules/catalogue/detail.tt | 22 ++++++++++---------- .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 8 +++---- opac/opac-detail.pl | 15 ++++++++++--- 5 files changed, 39 insertions(+), 40 deletions(-) diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm index 5c072f9..252ca2e 100644 --- a/C4/VirtualShelves.pm +++ b/C4/VirtualShelves.pm @@ -42,7 +42,6 @@ BEGIN { @EXPORT = qw( &GetShelves &GetShelfContents &ShelfPossibleAction - &GetBibliosShelves ); @EXPORT_OK = qw( &ShelvesMax @@ -333,26 +332,6 @@ sub ShelfPossibleAction { return 0; } -=head2 GetBibliosShelves - -This finds all the public lists that this bib record is in. - -=cut - -sub GetBibliosShelves { - my ( $biblionumber ) = @_; - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare(' - SELECT vs.shelfname, vs.shelfnumber - FROM virtualshelves vs - JOIN virtualshelfcontents vc ON (vs.shelfnumber= vc.shelfnumber) - WHERE vs.category=2 - AND vc.biblionumber= ? - '); - $sth->execute( $biblionumber ); - return $sth->fetchall_arrayref({}); -} - =head2 ShelvesMax $howmany= ShelvesMax($context); diff --git a/catalogue/detail.pl b/catalogue/detail.pl index b7ba9a4..0a4342b 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -45,6 +45,8 @@ use C4::HTML5Media; use C4::CourseReserves qw(GetItemCourseReservesInfo); use C4::Acquisition qw(GetOrdersByBiblionumber); +use Koha::Virtualshelves; + my $query = CGI->new(); my $analyze = $query->param('analyze'); @@ -374,7 +376,16 @@ $template->param( # Lists if (C4::Context->preference("virtualshelves") ) { - $template->param( 'GetShelves' => GetBibliosShelves( $biblionumber ) ); + my $shelves = Koha::Virtualshelves->search( + { + biblionumber => $biblionumber, + category => 2, + }, + { + join => 'virtualshelfcontents', + } + ); + $template->param( 'shelves' => $shelves ); } # XISBN Stuff diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 0746ff6..20b6615 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -356,10 +356,10 @@ function verify_images() { [% IF ( XSLTDetailsDisplay ) %] [% XSLTBloc %] - [% IF ( GetShelves ) %] + [% IF shelves %] Lists that include this title: - [% FOREACH GetShelve IN GetShelves %] - [% GetShelve.shelfname %] + [% FOREACH s IN shelves %] + [% s.shelfname %] [% IF ( loop.last ) %][% ELSE %]|[% END %] [% END %] @@ -520,14 +520,14 @@ function verify_images() { [% END %] - [% IF ( GetShelves ) %] -
  • Lists that include this title: - -
  • + [% IF shelves %] +
  • Lists that include this title: + +
  • [% END %] [% IF ( TagsEnabled && TagsShowOnDetail && TagLoop ) %]
  • Tags: diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index 6799e23..97de226 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -389,14 +389,14 @@ [% END # / LibraryThingForLibrariesID %] - [% IF ( GetShelves ) %] + [% IF shelves %] List(s) this item appears in: - [% FOREACH GetShelve IN GetShelves %] - [% GetShelve.shelfname %] + [% FOREACH shelf IN shelves %] + [% shelf.shelfname %] [% IF ( loop.last ) %][% ELSE %]|[% END %] [% END %] - [% END # / GetShelves %] + [% END %] [% IF ( TagsShowEnabled ) %]
    diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 0fa588f..4e3d73e 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -53,6 +53,8 @@ use Koha::DateUtils; use C4::HTML5Media; use C4::CourseReserves qw(GetItemCourseReservesInfo); +use Koha::Virtualshelves; + BEGIN { if (C4::Context->preference('BakerTaylorEnabled')) { require C4::External::BakerTaylor; @@ -844,12 +846,19 @@ $template->param( ); # Lists - if (C4::Context->preference("virtualshelves") ) { - $template->param( 'GetShelves' => GetBibliosShelves( $biblionumber ) ); + my $shelves = Koha::Virtualshelves->search( + { + biblionumber => $biblionumber, + category => 2, + }, + { + join => 'virtualshelfcontents', + } + ); + $template->param( shelves => $shelves ); } - # XISBN Stuff if (C4::Context->preference("OPACFRBRizeEditions")==1) { eval { -- 1.7.10.4