Bugzilla – Attachment 43233 Details for
Bug 14544
Move the list related code to Koha::Virtualshelves
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14544: Get rid of GetShelves
Bug-14544-Get-rid-of-GetShelves.patch (text/plain), 9.93 KB, created by
Jonathan Druart
on 2015-10-08 09:10:39 UTC
(
hide
)
Description:
Bug 14544: Get rid of GetShelves
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-10-08 09:10:39 UTC
Size:
9.93 KB
patch
obsolete
>From 515913573fad327c0d85bfdd19b60560b7693ad1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 16 Jul 2015 17:42:03 +0100 >Subject: [PATCH] Bug 14544: Get rid of GetShelves > >This does not work for now, see later. > >Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com> >--- > C4/VirtualShelves.pm | 70 +--------------------- > C4/VirtualShelves/Page.pm | 17 +++++- > Koha/Virtualshelves.pm | 43 +++++++++++++ > .../opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 6 +- > 4 files changed, 62 insertions(+), 74 deletions(-) > >diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm >index 252ca2e..73786d1 100644 >--- a/C4/VirtualShelves.pm >+++ b/C4/VirtualShelves.pm >@@ -40,7 +40,7 @@ BEGIN { > require Exporter; > @ISA = qw(Exporter); > @EXPORT = qw( >- &GetShelves &GetShelfContents >+ &GetShelfContents > &ShelfPossibleAction > ); > @EXPORT_OK = qw( >@@ -65,74 +65,6 @@ bibs to and from virtual shelves. > > =head1 FUNCTIONS > >-=head2 GetShelves >- >- $shelflist = &GetShelves($category, $row_count, $offset, $owner); >- ($shelfnumber, $shelfhash) = each %{$shelflist}; >- >-Returns the number of shelves specified by C<$row_count> and C<$offset> as well as the total >-number of shelves that meet the C<$owner> and C<$category> criteria. C<$category>, >-C<$row_count>, and C<$offset> are required. C<$owner> must be supplied when C<$category> == 1. >-When C<$category> is 2, supply undef as argument for C<$owner>. >- >-This function is used by shelfpage in VirtualShelves/Page.pm when listing all shelves for lists management in opac or staff client. Order is by shelfname. >- >-C<$shelflist>is a reference-to-hash. The keys are the virtualshelves numbers (C<$shelfnumber>, above), >-and the values (C<$shelfhash>, above) are themselves references-to-hash, with the following keys: >- >-=over >- >-=item C<$shelfhash-E<gt>{shelfname}> >- >-A string. The name of the shelf. >- >-=back >- >-=cut >- >-sub GetShelves { >- my ($category, $row_count, $offset, $owner) = @_; >- $offset ||= 0; >- my @params = ( $offset, $row_count ); >- my $dbh = C4::Context->dbh; >- my $query = qq{ >- SELECT vs.shelfnumber, vs.shelfname,vs.owner, >- bo.surname,bo.firstname,vs.category,vs.sortfield, >- count(vc.biblionumber) as count >- FROM virtualshelves vs >- LEFT JOIN borrowers bo ON vs.owner=bo.borrowernumber >- LEFT JOIN virtualshelfcontents vc USING (shelfnumber) }; >- if($category==1) { >- $query.= qq{ >- LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber >- AND sh.borrowernumber=? >- WHERE category=1 AND (vs.owner=? OR sh.borrowernumber=?) }; >- unshift @params, ($owner) x 3; >- } >- else { >- $query.= 'WHERE category=2 '; >- } >- $query.= qq{ >- GROUP BY vs.shelfnumber >- ORDER BY vs.shelfname >- LIMIT ?, ?}; >- >- my $sth2 = $dbh->prepare($query); >- $sth2->execute(@params); >- my %shelflist; >- while( my ($shelfnumber, $shelfname, $owner, $surname, $firstname, $category, $sortfield, $count)= $sth2->fetchrow) { >- $shelflist{$shelfnumber}->{'shelfname'} = $shelfname; >- $shelflist{$shelfnumber}->{'count'} = $count; >- $shelflist{$shelfnumber}->{'single'} = $count==1; >- $shelflist{$shelfnumber}->{'sortfield'} = $sortfield; >- $shelflist{$shelfnumber}->{'category'} = $category; >- $shelflist{$shelfnumber}->{'owner'} = $owner; >- $shelflist{$shelfnumber}->{'surname'} = $surname; >- $shelflist{$shelfnumber}->{'firstname'} = $firstname; >- } >- return \%shelflist; >-} >- > =head2 GetSomeShelfNames > > Returns shelf names and numbers for Add to combo of search results and Lists button of OPAC header. >diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm >index 69a85c1..47efb14 100644 >--- a/C4/VirtualShelves/Page.pm >+++ b/C4/VirtualShelves/Page.pm >@@ -89,7 +89,13 @@ sub shelfpage { > > # getting the Shelves list > my $category = ( ( $displaymode eq 'privateshelves' ) ? 1 : 2 ); >- my $shelflist = GetShelves( $category, $shelveslimit, $shelvesoffset, $loggedinuser ); >+ >+ my $shelflist; >+ if ( $category == 2 ) { >+ $shelflist = Koha::Virtualshelves->get_public_shelves({ limit => $shelveslimit, offset => $shelvesoffset }); >+ } else { >+ $shelflist = Koha::Virtualshelves->get_private_shelves({ limit => $shelveslimit, offset => $shelvesoffset, borrowernumber => $loggedinuser }); >+ } > my $totshelves = C4::VirtualShelves::GetShelfCount( $loggedinuser, $category ); > > my $op = $query->param('op'); >@@ -438,7 +444,14 @@ sub shelfpage { > my $numberCanManage = 0; > > # rebuild shelflist in case a shelf has been added >- $shelflist = GetShelves( $category, $shelveslimit, $shelvesoffset, $loggedinuser ) unless $delflag; >+ unless ( $delflag ) { >+ if ( $category == 2 ) { >+ $shelflist = Koha::Virtualshelves->get_public_shelves({ limit => $shelveslimit, offset => $shelvesoffset }); >+ } else { >+ $shelflist = Koha::Virtualshelves->get_private_shelves({ limit => $shelveslimit, offset => $shelvesoffset, borrowernumber => $loggedinuser }); >+ } >+ } >+ > $totshelves = C4::VirtualShelves::GetShelfCount( $loggedinuser, $category ) unless $delflag; > foreach my $element ( sort { lc( $shelflist->{$a}->{'shelfname'} ) cmp lc( $shelflist->{$b}->{'shelfname'} ) } keys %$shelflist ) { > my %line; >diff --git a/Koha/Virtualshelves.pm b/Koha/Virtualshelves.pm >index 5627afa..98f9d40 100644 >--- a/Koha/Virtualshelves.pm >+++ b/Koha/Virtualshelves.pm >@@ -39,6 +39,49 @@ Koha::Virtualshelf - Koha Virtualshelf Object class > > =cut > >+sub get_private_shelves { >+ my ( $self, $params ) = @_; >+ my $limit = $params->{limit}; >+ my $offset = $params->{offset} || 0; >+ my $borrowernumber = $params->{borrowernumber}; >+ >+ $self->search( >+ { >+ 'virtualshelfshares.borrowernumber' => $borrowernumber, >+ category => 1, >+ -or => { >+ 'virtualshelfshares.owner' => $borrowernumber, >+ 'virtualshelves.borrowernumber' => $borrowernumber, >+ } >+ }, >+ { >+ join => ['borrowers', 'virtualshelfcontents', 'virtualshelfshares' ], >+ group_by => 'shelfnumber', >+ order_by => 'shelfname', >+ limit => "$limit,$offset", >+ } >+ ); >+} >+ >+ >+sub get_public_shelves { >+ my ( $self, $params ) = @_; >+ my $limit = $params->{limit}; >+ my $offset = $params->{offset} || 0; >+ >+ $self->search( >+ { >+ category => 1, >+ }, >+ { >+ join => [ 'virtualshelfcontents' ], >+ group_by => 'shelfnumber', >+ order_by => 'shelfname', >+ limit => "$limit,$offset", >+ } >+ ); >+} >+ > sub type { > return 'Virtualshelve'; > } >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt >index 24000db..e2e1541 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt >@@ -115,7 +115,7 @@ > [% IF ( paramsloo.need_confirm ) %] > <div class="alert"> > The list <i>[% paramsloo.need_confirm %]</i> is not empty. >- <br />It has <b>[% paramsloo.count %]</b> [% IF ( paramsloo.single ) %]entry[% ELSE %]entries[% END %]. >+ <br />It has <b>[% paramsloo.count %]</b> [% IF paramsloo.count == 1 %]entry[% ELSE %]entries[% END %]. > <br />Use the "Confirm" button below to confirm deletion. > </div> > [% END %] >@@ -643,7 +643,7 @@ > [% FOREACH shelveslooppri IN shelveslooppriv %] > <tr> > <td><a href="/cgi-bin/koha/opac-shelves.pl?display=privateshelves&viewshelf=[% shelveslooppri.shelf %]&sortfield=[% shelveslooppri.sortfield %]">[% shelveslooppri.shelfname |html %]</a></td> >- <td>[% IF ( shelveslooppri.count ) %][% shelveslooppri.count %] [% IF ( shelveslooppri.single ) %]item[% ELSE %]items[% END %][% ELSE %]Empty[% END %]</td> >+ <td>[% IF ( shelveslooppri.count ) %][% shelveslooppri.count %] [% IF shelveslooppri.count == 1 %]item[% ELSE %]items[% END %][% ELSE %]Empty[% END %]</td> > <td> > [% IF ( shelveslooppri.viewcategory1 ) %][% IF !shelveslooppri.shares %]Private[% ELSE %]Shared[% END %][% END %] > </td> >@@ -717,7 +717,7 @@ > [% FOREACH shelvesloo IN shelvesloop %] > <tr> > <td><a class="title" href="/cgi-bin/koha/opac-shelves.pl?viewshelf=[% shelvesloo.shelf %]&sortfield=[% shelvesloo.sortfield %]">[% shelvesloo.shelfname |html %]</a></td> >- <td>[% shelvesloo.count %] [% IF ( shelvesloo.single ) %]item[% ELSE %]item(s)[% END %]</td> >+ <td>[% shelvesloo.count %] [% IF shelvesloo.count == 1 %]item[% ELSE %]item(s)[% END %]</td> > <td> > [% IF ( shelvesloo.viewcategory2 ) %]Public[% END %] > </td> >-- >2.1.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 14544
:
41034
|
41035
|
41036
|
41037
|
41038
|
41039
|
41040
|
41041
|
41042
|
41403
|
41404
|
41405
|
41406
|
41407
|
41408
|
41409
|
41410
|
41411
|
41412
|
41584
|
41585
|
41586
|
41587
|
41588
|
41589
|
41590
|
41591
|
41592
|
41593
|
41594
|
41595
|
41596
|
41597
|
41598
|
41599
|
41600
|
41601
|
41716
|
41717
|
41718
|
41719
|
41720
|
41721
|
41722
|
41723
|
41724
|
41725
|
41726
|
41727
|
41728
|
41729
|
41730
|
41731
|
41732
|
41733
|
41766
|
41909
|
41910
|
41913
|
41914
|
41915
|
41917
|
41918
|
41919
|
41924
|
41927
|
41931
|
41932
|
41953
|
41954
|
41955
|
41956
|
41957
|
41958
|
41959
|
41960
|
41961
|
41962
|
41963
|
41964
|
41965
|
41966
|
41967
|
41968
|
41969
|
41970
|
41973
|
41974
|
41975
|
41976
|
41977
|
41978
|
41979
|
41980
|
41981
|
41982
|
41983
|
41986
|
41988
|
42192
|
42199
|
42200
|
42201
|
42202
|
42203
|
42204
|
42205
|
42206
|
42207
|
42208
|
42209
|
42210
|
42211
|
42212
|
42213
|
42214
|
42215
|
42216
|
42217
|
42218
|
42219
|
42638
|
43223
|
43224
|
43225
|
43226
|
43227
|
43228
|
43229
|
43230
|
43231
|
43232
|
43233
|
43234
|
43235
|
43236
|
43237
|
43238
|
43239
|
43240
|
43241
|
43242
|
43243
|
43296
|
43334
|
43335
|
43403
|
43456
|
43457
|
43458
|
43459
|
43460
|
43461
|
43462
|
43463
|
43464
|
43465
|
43466
|
43467
|
43469
|
43470
|
43471
|
43472
|
43473
|
43474
|
43475
|
43476
|
43477
|
43478
|
43479
|
43480
|
43481
|
43482
|
43485
|
43486
|
43487
|
44467
|
44468
|
44469
|
44470
|
44471
|
44472
|
44473
|
44474
|
44475
|
44476
|
44477
|
44478
|
44479
|
44480
|
44481
|
44482
|
44483
|
44484
|
44485
|
44486
|
44487
|
44758
|
44845
|
44852
|
44863
|
44872