Bugzilla – Attachment 51614 Details for
Bug 16551
Display the name of lists to the search results at the OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16551: Display the name of lists to the search results at the OPAC
Bug-16551-Display-the-name-of-lists-to-the-search-.patch (text/plain), 10.30 KB, created by
Jonathan Druart
on 2016-05-19 08:35:35 UTC
(
hide
)
Description:
Bug 16551: Display the name of lists to the search results at the OPAC
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-05-19 08:35:35 UTC
Size:
10.30 KB
patch
obsolete
>From c62d8ac012c69795e064f7b2dfae873a2655e9ca Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 17 May 2016 16:31:11 +0100 >Subject: [PATCH] Bug 16551: Display the name of lists to the search results at > the OPAC > >This new enhancement will allow to add the name of lists containing a >biblio to the search results at the OPAC. > >Test plan: >0/ Regenerate the css file to get the style change: > % lessc --clean-css="--s0 --advanced --compatibility=ie7" > koha-tmpl/opac-tmpl/bootstrap/less/opac.less > > koha-tmpl/opac-tmpl/bootstrap/css/opac.css >1/ Create some lists and add items to them >2/ On the search results you should see the name of the lists which >contains the record. > >Note that we could add a syspref to make this new behavior optional. > >Sponsored-by: University of the Arts London >--- > Koha/Virtualshelves.pm | 39 ++++++++++ > .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 13 ++++ > koha-tmpl/opac-tmpl/bootstrap/less/opac.less | 2 +- > opac/opac-search.pl | 8 ++ > t/db_dependent/Virtualshelves.t | 90 +++++++++++++++++++++- > 5 files changed, 150 insertions(+), 2 deletions(-) > >diff --git a/Koha/Virtualshelves.pm b/Koha/Virtualshelves.pm >index 75ccfa8..a8d1b20 100644 >--- a/Koha/Virtualshelves.pm >+++ b/Koha/Virtualshelves.pm >@@ -119,6 +119,45 @@ sub get_some_shelves { > ); > } > >+sub get_shelves_containing_record { >+ my ( $self, $params ) = @_; >+ my $borrowernumber = $params->{borrowernumber}; >+ my $biblionumber = $params->{biblionumber}; >+ >+ my @conditions = ( 'virtualshelfcontents.biblionumber' => $biblionumber ); >+ if ($borrowernumber) { >+ push @conditions, >+ { >+ -or => [ >+ { >+ category => 1, >+ -or => { >+ 'me.owner' => $borrowernumber, >+ -or => { >+ 'virtualshelfshares.borrowernumber' => $borrowernumber, >+ "me.allow_add" => 1, >+ }, >+ } >+ }, >+ { category => 2 }, >+ ] >+ }; >+ } else { >+ push @conditions, { category => 2 }; >+ } >+ >+ return Koha::Virtualshelves->search( >+ { >+ -and => \@conditions >+ }, >+ { >+ join => [ 'virtualshelfcontents', 'virtualshelfshares' ], >+ group_by => 'shelfnumber', >+ order_by => { -asc => 'shelfname' }, >+ } >+ ); >+} >+ > sub _type { > return 'Virtualshelve'; > } >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >index 7021638..1954407 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >@@ -459,6 +459,19 @@ > </div> > [% END %] > >+ [% IF Koha.Preference('virtualshelves') AND SEARCH_RESULT.shelves.count %] >+ <div class="results_summary shelves"> >+ <span class="label">Lists:</span> >+ <ul> >+ [% FOREACH shelf IN SEARCH_RESULT.shelves %] >+ <li><a href="/cgi-bin/koha/opac-shelves.pl?op=view&shelfnumber=[% shelf.shelfnumber %]">[% shelf.shelfname %]</a></li> >+ [%~ UNLESS loop.last %], [% ELSE %].[% END ~%] >+ [% END %] >+ </ul> >+ </span> >+ </div> >+ [% END %] >+ > [% IF ( SEARCH_RESULT.searchhighlightblob ) %] > <span class="results_summary"> > <span class="label">Match:</span> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/less/opac.less b/koha-tmpl/opac-tmpl/bootstrap/less/opac.less >index 6d20cd0..d027ef1 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/less/opac.less >+++ b/koha-tmpl/opac-tmpl/bootstrap/less/opac.less >@@ -2212,7 +2212,7 @@ td img { > line-height: 135%; > } > } >-.tags { >+.tags, .shelves { > ul { > display: inline; > list-style: none; >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 64b8800..9b1c92b 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -55,6 +55,7 @@ use C4::Ratings; > use C4::External::OverDrive; > > use Koha::LibraryCategories; >+use Koha::Virtualshelves; > > use POSIX qw(ceil floor strftime); > use URI::Escape; >@@ -694,6 +695,13 @@ for (my $i=0;$i<@servers;$i++) { > } > } > >+ $res->{shelves} = Koha::Virtualshelves->get_shelves_containing_record( >+ { >+ biblionumber => $res->{biblionumber}, >+ borrowernumber => $borrowernumber >+ } >+ ); >+ > if ( C4::Context->preference('OpacStarRatings') eq 'all' ) { > my $rating = GetRating( $res->{'biblionumber'}, $borrowernumber ); > $res->{'rating_value'} = $rating->{'rating_value'}; >diff --git a/t/db_dependent/Virtualshelves.t b/t/db_dependent/Virtualshelves.t >index 58d3fec..c867056 100644 >--- a/t/db_dependent/Virtualshelves.t >+++ b/t/db_dependent/Virtualshelves.t >@@ -1,7 +1,7 @@ > #!/usr/bin/perl > > use Modern::Perl; >-use Test::More tests => 5; >+use Test::More tests => 6; > use DateTime::Duration; > > use C4::Context; >@@ -404,6 +404,94 @@ subtest 'Get shelves' => sub { > teardown(); > }; > >+subtest 'Get shelves containing biblios' => sub { >+ >+ plan tests => 9; >+ my $patron1 = $builder->build( { source => 'Borrower', } ); >+ my $patron2 = $builder->build( { source => 'Borrower', } ); >+ my $biblio1 = $builder->build( { source => 'Biblio', } ); >+ my $biblio2 = $builder->build( { source => 'Biblio', } ); >+ my $biblio3 = $builder->build( { source => 'Biblio', } ); >+ my $biblio4 = $builder->build( { source => 'Biblio', } ); >+ >+ my $shelf1 = Koha::Virtualshelf->new( >+ { shelfname => "my first shelf", >+ owner => $patron1->{borrowernumber}, >+ category => 1, >+ } >+ )->store; >+ my $shelf2 = Koha::Virtualshelf->new( >+ { shelfname => "my x second shelf", # 'x' to make it sorted after 'third' >+ owner => $patron2->{borrowernumber}, >+ category => 1, >+ } >+ )->store; >+ my $shelf3 = Koha::Virtualshelf->new( >+ { shelfname => "my third shelf", >+ owner => $patron1->{borrowernumber}, >+ category => 2, >+ } >+ )->store; >+ >+ my $content1 = $shelf1->add_biblio( $biblio1->{biblionumber}, $patron1->{borrowernumber} ); >+ my $content2 = $shelf1->add_biblio( $biblio2->{biblionumber}, $patron1->{borrowernumber} ); >+ my $content3 = $shelf2->add_biblio( $biblio2->{biblionumber}, $patron2->{borrowernumber} ); >+ my $content4 = $shelf2->add_biblio( $biblio3->{biblionumber}, $patron2->{borrowernumber} ); >+ my $content5 = $shelf2->add_biblio( $biblio4->{biblionumber}, $patron2->{borrowernumber} ); >+ my $content6 = $shelf3->add_biblio( $biblio4->{biblionumber}, $patron2->{borrowernumber} ); >+ >+ my $shelves_with_biblio1_for_any_patrons = Koha::Virtualshelves->get_shelves_containing_record( >+ { >+ biblionumber => $biblio1->{biblionumber}, >+ } >+ ); >+ is ( $shelves_with_biblio1_for_any_patrons->count, 0, 'shelf1 is private and should not be displayed if patron is not logged in' ); >+ >+ my $shelves_with_biblio4_for_any_patrons = Koha::Virtualshelves->get_shelves_containing_record( >+ { >+ biblionumber => $biblio4->{biblionumber}, >+ } >+ ); >+ is ( $shelves_with_biblio4_for_any_patrons->count, 1, 'shelf3 is public and should be displayed for any patrons' ); >+ is ( $shelves_with_biblio4_for_any_patrons->next->shelfname, $shelf3->shelfname, 'The correct shelf (3) should be displayed' ); >+ >+ my $shelves_with_biblio1_for_other_patrons = Koha::Virtualshelves->get_shelves_containing_record( >+ { >+ biblionumber => $biblio1->{biblionumber}, >+ borrowernumber => $patron2->{borrowernumber}, >+ } >+ ); >+ is ( $shelves_with_biblio1_for_other_patrons->count, 0, 'shelf1 is private and should not be displayed for other patrons' ); >+ >+ my $shelves_with_biblio1_for_owner = Koha::Virtualshelves->get_shelves_containing_record( >+ { >+ biblionumber => $biblio1->{biblionumber}, >+ borrowernumber => $patron1->{borrowernumber}, >+ } >+ ); >+ is ( $shelves_with_biblio1_for_owner->count, 1, 'shelf1 is private and should be displayed for the owner' ); >+ >+ my $shelves_with_biblio2_for_patron1 = Koha::Virtualshelves->get_shelves_containing_record( >+ { >+ biblionumber => $biblio2->{biblionumber}, >+ borrowernumber => $patron1->{borrowernumber}, >+ } >+ ); >+ is ( $shelves_with_biblio2_for_patron1->count, 1, 'Only shelf1 should be displayed for patron 1 and biblio 1' ); >+ is ( $shelves_with_biblio2_for_patron1->next->shelfname, $shelf1->shelfname, 'The correct shelf (1) should be displayed for patron 1' ); >+ >+ my $shelves_with_biblio4_for_patron2 = Koha::Virtualshelves->get_shelves_containing_record( >+ { >+ biblionumber => $biblio4->{biblionumber}, >+ borrowernumber => $patron2->{borrowernumber}, >+ } >+ ); >+ is ( $shelves_with_biblio4_for_patron2->count, 2, 'Patron should shown private and public lists for a given biblio' ); >+ is ( $shelves_with_biblio4_for_patron2->next->shelfname, $shelf3->shelfname, 'The shelves should be sorted by shelfname' ); >+ >+ teardown(); >+}; >+ > sub teardown { > $dbh->do(q|DELETE FROM virtualshelfshares|); > $dbh->do(q|DELETE FROM virtualshelfcontents|); >-- >2.7.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16551
:
51614
|
51616
|
51942
|
55669
|
55670