Bugzilla – Attachment 43471 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 GetSomeShelfNames
Bug-14544-Get-rid-of-GetSomeShelfNames.patch (text/plain), 37.15 KB, created by
Marcel de Rooy
on 2015-10-16 08:53:34 UTC
(
hide
)
Description:
Bug 14544: Get rid of GetSomeShelfNames
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2015-10-16 08:53:34 UTC
Size:
37.15 KB
patch
obsolete
>From 3129cc8de8da54d31eb82e5ee70d06d82bf50b08 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 17 Aug 2015 20:45:34 +0100 >Subject: [PATCH] Bug 14544: Get rid of GetSomeShelfNames >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Auth.pm | 44 +++++++++----- > C4/VirtualShelves.pm | 39 ------------- > Koha/Virtualshelves.pm | 39 +++++++++++++ > catalogue/search.pl | 29 +++++++--- > installer/data/mysql/kohastructure.sql | 6 +- > .../prog/en/modules/catalogue/results.tt | 41 +++++++++---- > .../prog/en/modules/virtualshelves/shelves.tt | 26 +++++---- > .../opac-tmpl/bootstrap/en/includes/masthead.inc | 56 ++++++++++-------- > .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 60 +++++++++++--------- > members/deletemem.pl | 3 +- > misc/cronjobs/delete_patrons.pl | 3 +- > opac/opac-search.pl | 27 ++++++--- > opac/opac-shelves.pl | 6 -- > tools/cleanborrowers.pl | 3 +- > virtualshelves/shelves.pl | 25 +++++--- > 15 files changed, 245 insertions(+), 162 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index ef0c585..b32e397 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -203,13 +203,21 @@ sub get_template_and_user { > $template->param( sessionID => $sessionID ); > > if ( $in->{'type'} eq 'opac' ) { >- require C4::VirtualShelves; >- my ( $total, $pubshelves, $barshelves ) = C4::VirtualShelves::GetSomeShelfNames( $borrowernumber, 'MASTHEAD' ); >+ require Koha::Virtualshelves; >+ my $some_private_shelves = Koha::Virtualshelves->get_some_shelves( >+ { >+ borrowernumber => $borrowernumber, >+ category => 1, >+ } >+ ); >+ my $some_public_shelves = Koha::Virtualshelves->get_some_shelves( >+ { >+ category => 2, >+ } >+ ); > $template->param( >- pubshelves => $total->{pubtotal}, >- pubshelvesloop => $pubshelves, >- barshelves => $total->{bartotal}, >- barshelvesloop => $barshelves, >+ some_private_shelves => $some_private_shelves, >+ some_public_shelves => $some_public_shelves, > ); > } > >@@ -340,11 +348,14 @@ sub get_template_and_user { > $template->param( sessionID => $sessionID ); > > if ( $in->{'type'} eq 'opac' ){ >- require C4::VirtualShelves; >- my ( $total, $pubshelves ) = C4::VirtualShelves::GetSomeShelfNames( undef, 'MASTHEAD' ); >+ require Koha::Virtualshelves; >+ my $some_public_shelves = Koha::Virtualshelves->get_some_shelves( >+ { >+ category => 2, >+ } >+ ); > $template->param( >- pubshelves => $total->{pubtotal}, >- pubshelvesloop => $pubshelves, >+ some_public_shelves => $some_public_shelves, > ); > } > } >@@ -714,7 +725,7 @@ sub checkauth { > # state variables > my $loggedin = 0; > my %info; >- my ( $userid, $cookie, $sessionID, $flags, $barshelves, $pubshelves ); >+ my ( $userid, $cookie, $sessionID, $flags ); > my $logout = $query->param('logout.x'); > > my $anon_search_history; >@@ -1207,11 +1218,14 @@ sub checkauth { > $template->param( loginprompt => 1 ) unless $info{'nopermission'}; > > if ( $type eq 'opac' ) { >- require C4::VirtualShelves; >- my ( $total, $pubshelves ) = C4::VirtualShelves::GetSomeShelfNames( undef, 'MASTHEAD' ); >+ require Koha::Virtualshelves; >+ my $some_public_shelves = Koha::Virtualshelves->get_some_shelves( >+ { >+ category => 2, >+ } >+ ); > $template->param( >- pubshelves => $total->{pubtotal}, >- pubshelvesloop => $pubshelves, >+ some_public_shelves => $some_public_shelves, > ); > } > >diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm >index e85f920..29126cc 100644 >--- a/C4/VirtualShelves.pm >+++ b/C4/VirtualShelves.pm >@@ -63,45 +63,6 @@ bibs to and from virtual shelves. > > =head1 FUNCTIONS > >-=head2 GetSomeShelfNames >- >-Returns shelf names and numbers for Add to combo of search results and Lists button of OPAC header. >- >-=cut >- >-sub GetSomeShelfNames { >- my ($owner, $purpose, $adding_allowed)= @_; >- my ($bar, $pub, @params); >- my $dbh = C4::Context->dbh; >- >- my $bquery = 'SELECT vs.shelfnumber, vs.shelfname FROM virtualshelves vs '; >- my $limit= ShelvesMax($purpose); >- >- my $qry1= $bquery."WHERE vs.category=2 "; >- $qry1.= "AND (allow_add=1 OR owner=?) " if $adding_allowed; >- push @params, $owner||0 if $adding_allowed; >- $qry1.= "ORDER BY vs.lastmodified DESC LIMIT $limit"; >- >- unless($adding_allowed && (!defined($owner) || $owner<=0)) { >- #if adding items, user should be known >- $pub= $dbh->selectall_arrayref($qry1,{Slice=>{}},@params); >- } >- >- if($owner) { >- my $qry2= $bquery. qq{ >- LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber AND sh.borrowernumber=? >- WHERE vs.category=1 AND (vs.owner=? OR sh.borrowernumber=?) }; >- @params=($owner,$owner,$owner); >- $qry2.= "AND (allow_add=1 OR owner=?) " if $adding_allowed; >- push @params, $owner if $adding_allowed; >- $qry2.= "ORDER BY vs.lastmodified DESC "; >- $qry2.= "LIMIT $limit"; >- $bar= $dbh->selectall_arrayref($qry2,{Slice=>{}},@params); >- } >- >- return ( { bartotal => $bar? scalar @$bar: 0, pubtotal => $pub? scalar @$pub: 0}, $pub, $bar); >-} >- > =head2 ShelvesMax > > $howmany= ShelvesMax($context); >diff --git a/Koha/Virtualshelves.pm b/Koha/Virtualshelves.pm >index 65b0680..34b1003 100644 >--- a/Koha/Virtualshelves.pm >+++ b/Koha/Virtualshelves.pm >@@ -80,6 +80,45 @@ sub get_public_shelves { > ); > } > >+sub get_some_shelves { >+ my ( $self, $params ) = @_; >+ my $borrowernumber = $params->{borrowernumber} || 0; >+ my $category = $params->{category} || 1; >+ my $add_allowed = $params->{add_allowed}; >+ >+ my @conditions; >+ if ( $add_allowed ) { >+ push @conditions, { >+ -or => >+ { >+ "me.allow_add" => 1, >+ "me.owner" => $borrowernumber, >+ } >+ }; >+ } >+ if ( $category == 1 ) { >+ push @conditions, { >+ -or => >+ { >+ "virtualshelfshares.borrowernumber" => $borrowernumber, >+ "me.owner" => $borrowernumber, >+ } >+ }; >+ } >+ >+ $self->search( >+ { >+ category => $category, >+ ( @conditions ? ( -and => \@conditions ) : () ), >+ }, >+ { >+ join => [ 'virtualshelfshares' ], >+ group_by => 'shelfnumber', >+ order_by => 'lastmodified desc', >+ } >+ ); >+} >+ > sub type { > return 'Virtualshelve'; > } >diff --git a/catalogue/search.pl b/catalogue/search.pl >index 43d7f29..e57c9ae 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -153,6 +153,8 @@ use POSIX qw(ceil floor); > use C4::Branch; # GetBranches > use C4::Search::History; > >+use Koha::Virtualshelves; >+ > use URI::Escape; > > my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold"); >@@ -746,14 +748,25 @@ if ($query_desc || $limit_desc) { > > # VI. BUILD THE TEMPLATE > >-# Build drop-down list for 'Add To:' menu... >-my ($totalref, $pubshelves, $barshelves)= >- C4::VirtualShelves::GetSomeShelfNames($borrowernumber,'COMBO',1); >+my $some_private_shelves = Koha::Virtualshelves->get_some_shelves( >+ { >+ borrowernumber => $borrowernumber, >+ add_allowed => 1, >+ category => 1, >+ } >+); >+my $some_public_shelves = Koha::Virtualshelves->get_some_shelves( >+ { >+ borrowernumber => $borrowernumber, >+ add_allowed => 1, >+ category => 2, >+ } >+); >+ >+ > $template->param( >- addbarshelves => $totalref->{bartotal}, >- addbarshelvesloop => $barshelves, >- addpubshelves => $totalref->{pubtotal}, >- addpubshelvesloop => $pubshelves, >- ); >+ add_to_some_private_shelves => $some_private_shelves, >+ add_to_some_public_shelves => $some_public_shelves, >+); > > output_html_with_http_headers $cgi, $cookie, $template->output; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index c36a792..9efa8ad 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -2297,7 +2297,7 @@ CREATE TABLE `virtualshelves` ( -- information about lists (or virtual shelves) > `allow_delete_own` tinyint(1) default 1, -- permission for deleting entries frm list that you added yourself > `allow_delete_other` tinyint(1) default 0, -- permission for deleting entries from list that another person added > PRIMARY KEY (`shelfnumber`), >- CONSTRAINT `virtualshelves_ibfk_1` FOREIGN KEY (`owner`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in VirtualShelves.pm >+ CONSTRAINT `virtualshelves_ibfk_1` FOREIGN KEY (`owner`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in Members.pm > ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; > > -- >@@ -2315,7 +2315,7 @@ CREATE TABLE `virtualshelfcontents` ( -- information about the titles in a list > KEY `biblionumber` (`biblionumber`), > CONSTRAINT `virtualshelfcontents_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE, > CONSTRAINT `shelfcontents_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE, >- CONSTRAINT `shelfcontents_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in VirtualShelves.pm >+ CONSTRAINT `shelfcontents_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in Members.pm > ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; > > -- >@@ -2330,7 +2330,7 @@ CREATE TABLE `virtualshelfshares` ( -- shared private lists > `invitekey` varchar(10), -- temporary string used in accepting the invitation to access thist list; not-empty means that the invitation has not been accepted yet > `sharedate` datetime, -- date of invitation or acceptance of invitation > CONSTRAINT `virtualshelfshares_ibfk_1` FOREIGN KEY (`shelfnumber`) REFERENCES `virtualshelves` (`shelfnumber`) ON DELETE CASCADE ON UPDATE CASCADE, >- CONSTRAINT `virtualshelfshares_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in VirtualShelves.pm >+ CONSTRAINT `virtualshelfshares_ibfk_2` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE SET NULL -- no cascaded delete, please see HandleDelBorrower in Members.pm > ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; > > -- >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >index 4b1c94b..091c633 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >@@ -91,17 +91,38 @@ $('#sort_by').change(function() { > }); > var param1 = "<label for=\"addto\">"+_("Add to:")+"<\/label><select name=\"addto\" id=\"addto\"><option value=\"\"><\/option>"; > [% IF ( intranetbookbag ) %] param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>"; [% END %] >- [% IF ( virtualshelves ) %][% IF ( addbarshelves ) %] >- param1 += "<optgroup label=\""+_("Your lists:")+"\">";[% FOREACH addbarshelvesloo IN addbarshelvesloop %] >- param1 += "<option id=\"s[% addbarshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addbarshelvesloo.shelfname |html %]<\/option>";[% END %] >- param1 += "<\/optgroup>";[% END %] >- [% IF ( addpubshelves ) %]param1 += "<optgroup label=\""+_("Public lists:")+"\">"[% FOREACH addpubshelvesloo IN addpubshelvesloop %]+"<option id=\"s[% addpubshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addpubshelvesloo.shelfname |html %]<\/option>"[% END %] >- param1 += "<\/optgroup>";[% END %] >- [% IF ( ( addbarshelvesloop && addbarshelvesloop.size>9 ) || (addpubshelvesloop && addpubshelvesloop.size>9 )) %] >- param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>"; >- [% END %] >- param1 +="<option value=\"newlist\">"+_("[ New list ]")+"<\/option>" >+ >+ [% IF Koha.Preference('virtualshelves') %] >+ [% IF add_to_some_private_shelves.count %] >+ param1 += "<optgroup label=\""+_("Your lists:")+"\">"; >+ [% SET number_of_private_shelves = 0 %] >+ [% FOREACH s IN add_to_some_private_shelves %] >+ [% IF shelfnumber != s.shelfnumber %] >+ param1 += "<option id=\"s[% s.shelfnumber %]\" value=\"addtolist\">[% s.shelfname |html %]<\/option>"; >+ [% SET number_of_private_shelves = number_of_private_shelves + 1 %] >+ [% IF number_of_private_shelves == 10 %][% LAST %][% END %] >+ [% END %] >+ [% END %] >+ param1 += "<\/optgroup>"; >+ [% END %] >+ [% IF add_to_some_public_shelves.count %] >+ param1 += "<optgroup label=\""+_("Public lists:")+"\">"; >+ [% SET number_of_public_shelves = 0 %] >+ [% FOREACH s IN add_to_some_public_shelves %] >+ [% IF shelfnumber != s.shelfnumber %] >+ param1 += "<option id=\"s[% s.shelfnumber %]\" value=\"addtolist\">[% s.shelfname |html %]<\/option>"; >+ [% SET number_of_public_shelves = number_of_public_shelves + 1 %] >+ [% IF number_of_public_shelves == 10 %][% LAST %][% END %] >+ [% END %] >+ [% END %] >+ param1 += "<\/optgroup>"; >+ [% END %] >+ [% IF add_to_some_private_shelves.count > 10 or add_to_some_public_shelves.count > 10 %] >+ param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>"; >+ [% END %] >+ param1 +="<option value=\"newlist\">"+_("[ New list ]")+"<\/option>" > [% END %] >+ > param1 += "<\/select> <input id=\"cartsubmit\" type=\"submit\" class=\"submit\" value=\""+_("Save")+"\" />"; > $('#sortsubmit').hide(); > $("span.clearall").html("<a id=\"CheckNone\" href=\"#\">"+_("Clear all")+"<\/a>"); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >index 704f884..23b147c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >@@ -130,26 +130,32 @@ $(document).ready(function(){ > [% IF ( intranetbookbag ) %] > param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>"; > [% END %] >- [% IF ( virtualshelves ) %] >- [% IF ( addbarshelves ) %] >+ [% IF Koha.Preference('virtualshelves') %] >+ [% IF add_to_some_private_shelves.count %] > param1 += "<optgroup label=\""+_("Your lists:")+"\">"; >- [% FOREACH addbarshelvesloo IN addbarshelvesloop %] >- [% IF ( shelfnumber != addbarshelvesloo.shelfnumber ) %] >- param1 += "<option id=\"s[% addbarshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addbarshelvesloo.shelfname |html %]<\/option>"; >+ [% SET number_of_private_shelves = 0 %] >+ [% FOREACH s IN add_to_some_private_shelves %] >+ [% IF shelfnumber != s.shelfnumber %] >+ param1 += "<option id=\"s[% s.shelfnumber %]\" value=\"addtolist\">[% s.shelfname |html %]<\/option>"; >+ [% SET number_of_private_shelves = number_of_private_shelves + 1 %] >+ [% IF number_of_private_shelves == 10 %][% LAST %][% END %] > [% END %] > [% END %] > param1 += "<\/optgroup>"; > [% END %] >- [% IF ( addpubshelves ) %] >+ [% IF add_to_some_public_shelves.count %] > param1 += "<optgroup label=\""+_("Public lists:")+"\">"; >- [% FOREACH addpubshelvesloo IN addpubshelvesloop %] >- [% IF ( shelfnumber != addpubshelvesloo.shelfnumber ) %] >- param1 += "<option id=\"s[% addpubshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addpubshelvesloo.shelfname |html %]<\/option>"; >+ [% SET number_of_public_shelves = 0 %] >+ [% FOREACH s IN add_to_some_public_shelves %] >+ [% IF shelfnumber != s.shelfnumber %] >+ param1 += "<option id=\"s[% s.shelfnumber %]\" value=\"addtolist\">[% s.shelfname |html %]<\/option>"; >+ [% SET number_of_public_shelves = number_of_public_shelves + 1 %] >+ [% IF number_of_public_shelves == 10 %][% LAST %][% END %] > [% END %] > [% END %] > param1 += "<\/optgroup>"; > [% END %] >- [% IF ( ( addbarshelvesloop && addbarshelvesloop.size > 9 ) || (addpubshelvesloop && addpubshelvesloop.size > 9 )) %] >+ [% IF add_to_some_private_shelves.count > 10 or add_to_some_public_shelves.count > 10 %] > param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>"; > [% END %] > param1 +="<option value=\"newlist\">"+_("[ New list ]")+"<\/option>" >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >index a2b5cd7..28dfa60 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >@@ -37,32 +37,42 @@ > <li class="dropdown"> > <a href="#" title="Show lists" class="dropdown-toggle" id="listsmenu" data-toggle="dropdown" role="button"><i class="icon-list icon-white"></i> <span class="listslabel">Lists</span> <b class="caret"></b></a> > <ul aria-labelledby="listsmenu" role="menu" class="dropdown-menu"> >- [% IF ( pubshelves ) %] >- <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=2" tabindex="-1" role="menuitem"><strong>Public lists</strong></a></li> >- [% FOREACH pubshelvesloo IN pubshelvesloop %] >- <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=view&shelfnumber=[% pubshelvesloo.shelfnumber %]&sortfield=[% pubshelvesloo.sortfield %]" tabindex="-1" role="menuitem">[% pubshelvesloo.shelfname |html %]</a></li> >- [% END %] >- <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=2" tabindex="-1" role="menuitem" class="listmenulink">View All</a></li> >- [% ELSE %] >- <li role="presentation"><a href="#" tabindex="-1" class="menu-inactive" role="menuitem">No public lists</a></li> >+ [% IF some_public_shelves.count %] >+ <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=2" tabindex="-1" role="menuitem"><strong>Public lists</strong></a></li> >+ [% SET number_of_public_shelves = 0 %] >+ [% FOREACH s IN some_public_shelves %] >+ <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=view&shelfnumber=[% s.shelfnumber %]&sortfield=[% s.sortfield %]" tabindex="-1" role="menuitem">[% s.shelfname |html %]</a></li> >+ [% SET number_of_public_shelves = number_of_public_shelves + 1 %] >+ [% IF number_of_public_shelves >= 10 %][% LAST %][% END %] > [% END %] >- <li class="divider" role="presentation"></li> >- [% IF Koha.Preference( 'opacuserlogin' ) == 1 %] >- <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=1" tabindex="-1" role="menuitem"><strong>Your lists</strong></a></li> >- [% IF ( loggedinusername ) %] >- [% IF ( barshelves ) %] >- [% FOREACH barshelvesloo IN barshelvesloop %] >- <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=view&shelfnumber=[% barshelvesloo.shelfnumber %]&sortfield=[% barshelvesloo.sortfield %]" tabindex="-1" role="menuitem">[% barshelvesloo.shelfname |html %]</a></li> >- [% END %] >- <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=1" tabindex="-1" role="menuitem" class="listmenulink">View all</a></li> >- [% ELSE %] >- <li role="presentation"><a href="#" tabindex="-1" class="menu-inactive" role="menuitem">No private lists</a></li> >- <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=1" tabindex="-1" role="menuitem" class="listmenulink">New list</a></li> >+ [% IF some_public_shelves > 10 %] >+ <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=2" tabindex="-1" role="menuitem" class="listmenulink">View All</a></li> >+ [% END %] >+ [% ELSE %] >+ <li role="presentation"><a href="#" tabindex="-1" class="menu-inactive" role="menuitem">No public lists</a></li> >+ [% END %] >+ <li class="divider" role="presentation"></li> >+ [% IF Koha.Preference( 'opacuserlogin' ) == 1 %] >+ <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=1" tabindex="-1" role="menuitem"><strong>Your lists</strong></a></li> >+ [% IF loggedinusername %] >+ [% IF some_private_shelves.count %] >+ [% SET number_of_private_shelves = 0 %] >+ [% FOREACH s IN some_private_shelves %] >+ <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=view&shelfnumber=[% s.shelfnumber %]&sortfield=[% s.sortfield %]" tabindex="-1" role="menuitem">[% s.shelfname |html %]</a></li> >+ [% SET number_of_private_shelves = number_of_private_shelves + 1 %] >+ [% IF number_of_private_shelves >= 10 %][% LAST %][% END %] >+ [% END %] >+ [% IF some_private_shelves > 10 %] >+ <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=1" tabindex="-1" role="menuitem" class="listmenulink">View All</a></li> > [% END %] > [% ELSE %] >- <li role="presentation"><a href="/cgi-bin/koha/opac-user.pl" tabindex="-1" class="menu-inactive loginModal-trigger" role="menuitem">Log in to create your own lists</a></li> >- [% END # / IF loggedinusername %] >- [% END # / IF opacuserlogin %] >+ <li role="presentation"><a href="#" tabindex="-1" class="menu-inactive" role="menuitem">No private lists</a></li> >+ <li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&category=1" tabindex="-1" role="menuitem" class="listmenulink">New list</a></li> >+ [% END %] >+ [% ELSE %] >+ <li role="presentation"><a href="/cgi-bin/koha/opac-user.pl" tabindex="-1" class="menu-inactive loginModal-trigger" role="menuitem">Log in to create your own lists</a></li> >+ [% END # / IF loggedinusername %] >+ [% END # / IF opacuserlogin %] > </ul> <!-- / .dropdown-menu --> > </li> <!-- / .dropdown --> > [% END # / IF virtualshelves %] >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 60ecab1..8a0ec89 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >@@ -743,37 +743,43 @@ $(document).ready(function(){ > param1 += "<span id=\"selections\">"+_("Select titles to: ")+"</span>"; > [% END %] > >-[% IF Koha.Preference( 'opacbookbag' ) == 1 %] >- [% IF Koha.Preference( 'virtualshelves' ) == 1 %] >+[% IF Koha.Preference( 'opacbookbag' ) == 1 OR Koha.Preference('virtualshelves') %] > param1 += "<select class=\"disabled\" name=\"addto\" id=\"addto\"><option>"+_("Add to...")+"</option>"; >- [% IF Koha.Preference( 'opacbookbag' ) == 1 %] param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>"; >- [% END %][% IF Koha.Preference( 'virtualshelves' ) == 1 %][% IF ( loggedinusername ) %][% IF ( addbarshelves ) %] >- param1 += "<optgroup label=\""+_("Your lists:")+"\">";[% FOREACH addbarshelvesloo IN addbarshelvesloop %] >- param1 += "<option id=\"s[% addbarshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addbarshelvesloo.shelfname |html %]<\/option>";[% END %] >- param1 += "<\/optgroup>";[% END %] >- [% IF ( addpubshelves ) %]param1 += "<optgroup label=\""+_("Public lists:")+"\">"[% FOREACH addpubshelvesloo IN addpubshelvesloop %]+"<option id=\"s[% addpubshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addpubshelvesloo.shelfname |html %]<\/option>"[% END %]; >- param1 += "<\/optgroup>";[% END %] >- [% IF (( addbarshelvesloop && addbarshelvesloop.size>9) || (addpubshelvesloop && addpubshelvesloop.size>9 )) %] >- param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>"; >- [% END %] >- param1 += "<option value=\"newlist\">[ "+_("New list")+" ]<\/option>"; >+ >+ [% IF Koha.Preference( 'opacbookbag' ) == 1 %] >+ param1 += "<option value=\"addtocart\">"+_("Cart")+"<\/option>"; > [% END %] >+ [% IF Koha.Preference('virtualshelves') %] >+ [% IF loggedinusername AND add_to_some_private_shelves.count %] >+ param1 += "<optgroup label=\""+_("Your lists:")+"\">"; >+ [% SET number_of_private_shelves = 0 %] >+ [% FOREACH s IN add_to_some_private_shelves %] >+ [% IF shelfnumber != s.shelfnumber %] >+ param1 += "<option id=\"s[% s.shelfnumber %]\" value=\"addtolist\">[% s.shelfname |html %]<\/option>"; >+ [% SET number_of_private_shelves = number_of_private_shelves + 1 %] >+ [% IF number_of_private_shelves == 10 %][% LAST %][% END %] >+ [% END %] >+ [% END %] >+ param1 += "<\/optgroup>"; >+ [% END %] >+ [% IF add_to_some_public_shelves.count %] >+ param1 += "<optgroup label=\""+_("Public lists:")+"\">"; >+ [% SET number_of_public_shelves = 0 %] >+ [% FOREACH s IN add_to_some_public_shelves %] >+ [% IF shelfnumber != s.shelfnumber %] >+ param1 += "<option id=\"s[% s.shelfnumber %]\" value=\"addtolist\">[% s.shelfname |html %]<\/option>"; >+ [% SET number_of_public_shelves = number_of_public_shelves + 1 %] >+ [% IF number_of_public_shelves == 10 %][% LAST %][% END %] >+ [% END %] >+ [% END %] >+ param1 += "<\/optgroup>"; >+ [% END %] >+ [% IF add_to_some_private_shelves.count > 10 or add_to_some_public_shelves.count > 10 %] >+ param1 += "<option value=\"morelists\">[ "+_("More lists")+" ]<\/option>"; >+ [% END %] >+ param1 +="<option value=\"newlist\">"+_("[ New list ]")+"<\/option>" > [% END %] > param1 += "<\/select> <input type=\"submit\" class=\"btn btn-small\" value=\""+_("Save")+"\" />"; >- [% ELSE %] >- param1 += "<a id=\"addto\" class=\"addtocart\" href=\"#\">" + _("Add to cart") + "<\/a>"; >- [% END %] >-[% ELSE %] >- param1 += "<select name=\"addto\" id=\"addto\"><option value=\"\">"+_("Add to list: ")+"<\/option>"; >-[% IF Koha.Preference( 'virtualshelves' ) == 1 %][% IF ( loggedinusername ) %][% IF ( addbarshelves ) %] >- param1 += "<optgroup label=\""+_("Your lists:")+"\">";[% FOREACH addbarshelvesloo IN addbarshelvesloop %] >- param1 += "<option id=\"s[% addbarshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addbarshelvesloo.shelfname |html %]<\/option>";[% END %] >- param1 += "<\/optgroup>";[% END %] >- [% IF ( addpubshelves ) %]param1 += "<optgroup label=\""+_("Public lists:")+"\">"[% FOREACH addpubshelvesloo IN addpubshelvesloop %]+"<option id=\"s[% addpubshelvesloo.shelfnumber %]\" value=\"addtolist\">[% addpubshelvesloo.shelfname |html %]<\/option>"[% END %][% END %] >- param1 +="<\/optgroup><option value=\"newlist\">[ "+_("New list")+" ]<\/option>" >- [% END %] >- [% END %] >- param1 += "<\/select> <input type=\"submit\" class=\"btn btn-small disabled\" value=\""+_("Save")+"\" />"; > [% END %] > > $('#sortsubmit').hide(); >diff --git a/members/deletemem.pl b/members/deletemem.pl >index 972a898..869ebf3 100755 >--- a/members/deletemem.pl >+++ b/members/deletemem.pl >@@ -30,7 +30,6 @@ use C4::Output; > use C4::Auth; > use C4::Members; > use C4::Branch; # GetBranches >-use C4::VirtualShelves (); #no import > use Module::Load; > if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) { > load Koha::NorwegianPatronDB, qw( NLMarkForDeletion NLSync ); >@@ -147,7 +146,7 @@ output_html_with_http_headers $input, $cookie, $template->output; > > } else { > MoveMemberToDeleted($member); >- C4::VirtualShelves::HandleDelBorrower($member); >+ C4::Members::HandleDelBorrower($member); > DelMember($member); > print $input->redirect("/cgi-bin/koha/members/members-home.pl"); > } >diff --git a/misc/cronjobs/delete_patrons.pl b/misc/cronjobs/delete_patrons.pl >index 6c1a489..c05126f 100755 >--- a/misc/cronjobs/delete_patrons.pl >+++ b/misc/cronjobs/delete_patrons.pl >@@ -6,7 +6,6 @@ use Pod::Usage; > use Getopt::Long; > > use C4::Members; >-use C4::VirtualShelves; > use Koha::DateUtils; > use C4::Log; > >@@ -82,7 +81,7 @@ for my $member (@$members) { > next; > } > eval { >- C4::VirtualShelves::HandleDelBorrower( $borrowernumber ) >+ C4::Members::HandleDelBorrower( $borrowernumber ) > if $confirm; > }; > if ($@) { >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 81f2bbb..a7d02ca 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -920,15 +920,26 @@ if ($query_desc || $limit_desc) { > } > > # VI. BUILD THE TEMPLATE >-# Build drop-down list for 'Add To:' menu... >-my ($totalref, $pubshelves, $barshelves)= >- C4::VirtualShelves::GetSomeShelfNames($borrowernumber,'COMBO',1); >+my $some_private_shelves = Koha::Virtualshelves->get_some_shelves( >+ { >+ borrowernumber => $borrowernumber, >+ add_allowed => 1, >+ category => 1, >+ } >+); >+my $some_public_shelves = Koha::Virtualshelves->get_some_shelves( >+ { >+ borrowernumber => $borrowernumber, >+ add_allowed => 1, >+ category => 2, >+ } >+); >+while(my$s = $some_public_shelves->next){warn $s->shelfnumber;}; >+ > $template->param( >- addbarshelves => $totalref->{bartotal}, >- addbarshelvesloop => $barshelves, >- addpubshelves => $totalref->{pubtotal}, >- addpubshelvesloop => $pubshelves, >- ); >+ add_to_some_private_shelves => $some_private_shelves, >+ add_to_some_public_shelves => $some_public_shelves, >+); > > my $content_type = ($format eq 'rss' or $format eq 'atom') ? $format : 'html'; > >diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl >index c5f0a35..f7bd52a 100755 >--- a/opac/opac-shelves.pl >+++ b/opac/opac-shelves.pl >@@ -283,13 +283,7 @@ if ( $op eq 'view' ) { > push @items, $this_item; > } > >- # Build drop-down list for 'Add To:' menu... >- my ( $totalref, $pubshelves, $barshelves ) = C4::VirtualShelves::GetSomeShelfNames( $loggedinuser, 'COMBO', 1 ); > $template->param( >- addbarshelves => $totalref->{bartotal}, >- addbarshelvesloop => $barshelves, >- addpubshelves => $totalref->{pubtotal}, >- addpubshelvesloop => $pubshelves, > can_manage_shelf => $shelf->can_be_managed($loggedinuser), > can_delete_shelf => $shelf->can_be_deleted($loggedinuser), > can_remove_biblios => $shelf->can_biblios_be_removed($loggedinuser), >diff --git a/tools/cleanborrowers.pl b/tools/cleanborrowers.pl >index d1fc01c..7888b99 100755 >--- a/tools/cleanborrowers.pl >+++ b/tools/cleanborrowers.pl >@@ -39,7 +39,6 @@ use C4::Auth; > use C4::Output; > use C4::Members; # GetBorrowersWhoHavexxxBorrowed. > use C4::Circulation; # AnonymiseIssueHistory. >-use C4::VirtualShelves (); #no import > use Koha::DateUtils qw( dt_from_string output_pref ); > use Date::Calc qw/Today Add_Delta_YM/; > >@@ -124,7 +123,7 @@ elsif ( $step == 3 ) { > $radio eq 'testrun' && last; > my $borrowernumber = $membersToDelete->[$i]->{'borrowernumber'}; > $radio eq 'trash' && MoveMemberToDeleted( $borrowernumber ); >- C4::VirtualShelves::HandleDelBorrower( $borrowernumber ); >+ C4::Members::HandleDelBorrower( $borrowernumber ); > DelMember( $borrowernumber ); > } > $template->param( >diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl >index 53f9c24..2af2015 100755 >--- a/virtualshelves/shelves.pl >+++ b/virtualshelves/shelves.pl >@@ -194,7 +194,7 @@ if ( $op eq 'view' ) { > $shelf = Koha::Virtualshelves->find($shelfnumber); > if ( $shelf ) { > if ( $shelf->can_be_viewed( $loggedinuser ) ) { >- my $sortfield = $query->param('sortfield') || $shelf->sortfield; # Passed in sorting overrides default sorting >+ my $sortfield = $query->param('sortfield') || $shelf->sortfield || 'title'; # Passed in sorting overrides default sorting > my $direction = $query->param('direction') || 'asc'; > my ( $rows, $page ); > unless ( $query->param('print') ) { >@@ -241,13 +241,24 @@ if ( $op eq 'view' ) { > push @items, $this_item; > } > >- # Build drop-down list for 'Add To:' menu... >- my ( $totalref, $pubshelves, $barshelves ) = C4::VirtualShelves::GetSomeShelfNames( $loggedinuser, 'COMBO', 1 ); >+ my $some_private_shelves = Koha::Virtualshelves->get_some_shelves( >+ { >+ borrowernumber => $loggedinuser, >+ add_allowed => 1, >+ category => 1, >+ } >+ ); >+ my $some_public_shelves = Koha::Virtualshelves->get_some_shelves( >+ { >+ borrowernumber => $loggedinuser, >+ add_allowed => 1, >+ category => 2, >+ } >+ ); >+ > $template->param( >- addbarshelves => $totalref->{bartotal}, >- addbarshelvesloop => $barshelves, >- addpubshelves => $totalref->{pubtotal}, >- addpubshelvesloop => $pubshelves, >+ add_to_some_private_shelves => $some_private_shelves, >+ add_to_some_public_shelves => $some_public_shelves, > can_manage_shelf => $shelf->can_be_managed($loggedinuser), > can_remove_shelf => $shelf->can_be_deleted($loggedinuser), > can_remove_biblios => $shelf->can_biblios_be_removed($loggedinuser), >-- >1.7.10.4
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