Bug 14544: Make the OPAC side independent of Page.pm

Bug 14544: Fix redirect on editing a list

If you edit a list from the list view, after saving the form, you are
not redirected to the list view (but on the edit form).

Bug 14544: Cosmetic: › should be a class divider

Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2015-08-10 16:53:06 +01:00 committed by Tomas Cohen Arazi
parent b9f92a0125
commit f510627842
15 changed files with 719 additions and 434 deletions

View file

@ -126,6 +126,17 @@ sub count {
return $self->_resultset()->count($params);
}
=head3 Koha::Objects->pager();
my $pager = Koha::Objects->pager;
=cut
sub pager {
my ( $self ) = @_;
return $self->_resultset->pager;
}
=head3 Koha::Objects->next();
my $object = Koha::Objects->next();

View file

@ -101,12 +101,14 @@ sub is_shelfname_valid {
sub get_shares {
my ( $self ) = @_;
return $self->{_result}->virtualshelfshares;
my $shares = $self->{_result}->virtualshelfshares;
return $shares;
}
sub get_contents {
my ( $self ) = @_;
return $self->{_result}->virtualshelfcontents;
my $contents = $self->{_result}->virtualshelfcontents;
return $contents;
}
sub share {
@ -132,6 +134,16 @@ sub is_shared {
)->count;
}
sub is_shared_with {
my ( $self, $borrowernumber ) = @_;
return unless $borrowernumber;
return $self->get_shares->search(
{
borrowernumber => $borrowernumber,
}
)->count;
}
sub remove_share {
my ( $self, $borrowernumber ) = @_;
my $shelves = Koha::Virtualshelfshares->search(

View file

@ -41,24 +41,23 @@ Koha::Virtualshelf - Koha Virtualshelf Object class
sub get_private_shelves {
my ( $self, $params ) = @_;
my $limit = $params->{limit};
my $offset = $params->{offset} || 0;
my $borrowernumber = $params->{borrowernumber};
my $page = $params->{page};
my $rows = $params->{rows};
my $borrowernumber = $params->{borrowernumber} || 0;
$self->search(
{
'virtualshelfshares.borrowernumber' => $borrowernumber,
category => 1,
-or => {
'virtualshelfshares.owner' => $borrowernumber,
'virtualshelves.borrowernumber' => $borrowernumber,
'virtualshelfshares.borrowernumber' => $borrowernumber,
'me.owner' => $borrowernumber,
}
},
{
join => ['borrowers', 'virtualshelfcontents', 'virtualshelfshares' ],
join => [ 'virtualshelfshares' ],
group_by => 'shelfnumber',
order_by => 'shelfname',
limit => "$limit,$offset",
( ( $page and $rows ) ? ( page => $page, rows => $rows ) : () ),
}
);
}
@ -66,18 +65,17 @@ sub get_private_shelves {
sub get_public_shelves {
my ( $self, $params ) = @_;
my $limit = $params->{limit};
my $offset = $params->{offset} || 0;
my $page = $params->{page};
my $rows = $params->{rows};
$self->search(
{
category => 1,
category => 2,
},
{
join => [ 'virtualshelfcontents' ],
group_by => 'shelfnumber',
order_by => 'shelfname',
limit => "$limit,$offset",
( ( $page and $rows ) ? ( page => $page, rows => $rows ) : () ),
}
);
}

View file

@ -36,6 +36,7 @@
[%~ action_block = action_block _ '<input type="hidden" name="shelfnumber" value="' _ shelfnumber _ '" />' ~%]
[%~ action_block = action_block _ '<input type="hidden" name="op" value="edit_form" />' ~%]
[%~ action_block = action_block _ '<input type="hidden" name="category" value="' _ type _ '" />' ~%]
[%~ action_block = action_block _ '<input type="hidden" name="referer" value="list" />' ~%]
[%~ action_block = action_block _ '<input type="submit" class="editshelf" value="Edit" />' ~%]
[%~ action_block = action_block _ '</form>' ~%]
[%~ END ~%]
@ -46,6 +47,7 @@
[%~ action_block = action_block _ '<input type="hidden" name="op" value="delete" />' ~%]
[%~ action_block = action_block _ '<input type="hidden" name="shelfnumber" value="' _ shelfnumber _ '" />' ~%]
[%~ action_block = action_block _ '<input type="hidden" name="category" value="' _ type _ '" />' ~%]
[%~ action_block = action_block _ '<input type="hidden" name="referer" value="list" />' ~%]
[%~ action_block = action_block _ '<input type="submit" class="deleteshelf" onclick="return confirmDelete(MSG_CONFIRM_DELETE_LIST)" value="Delete" />' ~%]
[%~ action_block = action_block _ '</form>' ~%]
[%~ END ~%]

View file

@ -38,26 +38,26 @@
<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?display=publicshelves" tabindex="-1" role="menuitem"><strong>Public lists</strong></a></li>
<li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;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?viewshelf=[% pubshelvesloo.shelfnumber %]&amp;sortfield=[% pubshelvesloo.sortfield %]" tabindex="-1" role="menuitem">[% pubshelvesloo.shelfname |html %]</a></li>
<li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% pubshelvesloo.shelfnumber %]&amp;sortfield=[% pubshelvesloo.sortfield %]" tabindex="-1" role="menuitem">[% pubshelvesloo.shelfname |html %]</a></li>
[% END %]
<li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?display=publicshelves" tabindex="-1" role="menuitem" class="listmenulink">View All</a></li>
<li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;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>
[% END %]
<li class="divider" role="presentation"></li>
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
<li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?display=privateshelves" tabindex="-1" role="menuitem"><strong>Your lists</strong></a></li>
<li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;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?viewshelf=[% barshelvesloo.shelfnumber %]&amp;sortfield=[% barshelvesloo.sortfield %]" tabindex="-1" role="menuitem">[% barshelvesloo.shelfname |html %]</a></li>
<li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% barshelvesloo.shelfnumber %]&amp;sortfield=[% barshelvesloo.sortfield %]" tabindex="-1" role="menuitem">[% barshelvesloo.shelfname |html %]</a></li>
[% END %]
<li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?display=privateshelves" tabindex="-1" role="menuitem" class="listmenulink">View all</a></li>
<li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;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?display=privateshelves" tabindex="-1" role="menuitem" class="listmenulink">New list</a></li>
<li role="presentation"><a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;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>

View file

@ -91,7 +91,7 @@
[% ELSE %]
<li>
[% END %]
<a href="/cgi-bin/koha/opac-shelves.pl?display=privateshelves">your lists</a></li>
<a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=1">your lists</a></li>
[% END %]
[% IF Koha.Preference( 'useDischarge' ) == 1 %]

View file

@ -392,8 +392,8 @@
<!--This grabs all of the lists a bib record appears in -->
[% IF shelves %]
<span class="results_summary lists"><span class="label">List(s) this item appears in: </span>
[% FOREACH shelf IN shelves %]
<a href="/cgi-bin/koha/opac-shelves.pl?viewshelf=[% shelf.shelfnumber %]">[% shelf.shelfname %]</a>
[% FOREACH s IN shelves %]
<a href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% s.shelfnumber %]">[% s.shelfname %]</a>
[% IF ( loop.last ) %][% ELSE %]|[% END %]
[% END %]
</span>

View file

@ -1,7 +1,7 @@
[% USE Koha %]
[% IF ( fullpage ) %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Download list [% shelfname %]</title>[% INCLUDE 'doc-head-close.inc' %]
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Download list [% shelf.shelfname %]</title>[% INCLUDE 'doc-head-close.inc' %]
[% BLOCK cssinclude %][% END %]
</head>
[% INCLUDE 'bodytag.inc' bodyid='opac-downloadlist' %]
@ -13,14 +13,14 @@
<li><a href="/cgi-bin/koha/opac-user.pl">[% FOREACH USER_INF IN USER_INFO %][% USER_INF.title %] [% USER_INF.firstname %] [% USER_INF.surname %][% END %]</a> <span class="divider">&rsaquo;</span></li>
[% END %]
<li>
[% IF ( showprivateshelves ) %]
<a href="/cgi-bin/koha/opac-shelves.pl">Your lists</a>
[% IF shelf.category == 1 %]
<a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=1">Your lists</a>
[% ELSE %]
<a href="/cgi-bin/koha/opac-shelves.pl?display=publicshelves">Public lists</a>
<a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=2">Public lists</a>
[% END %]
<span class="divider">&rsaquo;</span>
</li>
<li>Download list <i>[% shelfname %]</i></li>
<li>Download list <i>[% shelf.shelfname %]</i></li>
</ul>
<div class="container-fluid">
<div class="row-fluid">
@ -47,7 +47,7 @@
<p>Your download should begin automatically.</p>
</div>
[% ELSE %]
<h1>Download list <i>[% shelfname %]</i></h1>
<h1>Download list <i>[% shelf.shelfname %]</i></h1>
<form method="post" action="/cgi-bin/koha/opac-downloadshelf.pl">
<fieldset>
<select name="format" id="dlformat" required="required">
@ -64,9 +64,9 @@
</fieldset>
<fieldset class="action">
<input type="hidden" name="shelfid" value="[% shelfid | html %]" />
<input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
<input type="submit" name="save" class="btn" value="Go" />
<a href="/cgi-bin/koha/opac-shelves.pl?viewshelf=[% shelfid | html %]" class="cancel close" data-dismiss="modal">Cancel</a>
<a href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | html %]" class="cancel close" data-dismiss="modal">Cancel</a>
</fieldset>
</form>
[% IF ( modal ) %]

View file

@ -15,7 +15,7 @@
<div class="alert alert-success">
<p>The list was sent to: [% email %]</p>
</div>
<p><a class="focus close" href="/cgi-bin/koha/opac-shelves.pl?viewshelf=[% shelfid %]">Back to lists</a></p>
<p><a class="focus close" href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% shelfid %]">Back to lists</a></p>
[% END %]
[% IF ( error ) %]
<div class="alert">
@ -27,7 +27,7 @@
<div class="alert">
<p>You do not have permission to send this list.</p>
</div>
<p><a class="button close" href="/cgi-bin/koha/opac-shelves.pl?viewshelf=[% shelfid %]">Back to lists</a></p>
<p><a class="button close" href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% shelfid %]">Back to lists</a></p>
[% ELSE %]
<h1>Sending your list</h1>
<form action="/cgi-bin/koha/opac-sendshelf.pl" method="post" id="sendshelfform">
@ -42,7 +42,7 @@
</fieldset>
<fieldset class="action">
<input type="submit" value="Send" class="btn" />
<a class="cancel close" href="/cgi-bin/koha/opac-shelves.pl?viewshelf=[% shelfid %]">Cancel</a>
<a class="cancel close" href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% shelfid %]">Cancel</a>
</fieldset>
</form>

View file

@ -41,7 +41,7 @@
[% IF errcode==6 %]<div class="alert">Sorry, but you did not enter a valid email address.</div>[% END %]
[% IF errcode==7 %]<div class="alert">Sorry, but we could not accept this key. The invitation may have expired. Contact the patron who sent you the invitation.</div>[% END %]
[% IF errcode==8 %]<div class="alert">As owner of a list you cannot accept an invitation for sharing it.</div>[% END %]
<p><a href="/cgi-bin/koha/opac-shelves.pl?display=privateshelves">Return to your lists</a></p>
<p><a href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;category=1">Return to your lists</a></p>
[% ELSIF op=='invite' %]
<div id="invite">
@ -59,7 +59,7 @@
</fieldset>
<fieldset class="action">
<input type="submit" value="Send" class="btn" />
<a href="/cgi-bin/koha/opac-shelves.pl?display=privateshelves" class="cancel">Cancel</a>
<a href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;category=1" class="cancel">Cancel</a>
</fieldset>
</form>
</div>
@ -75,7 +75,7 @@
[% IF approvedaddress %]
<p>You will receive an email notification if someone accepts your share within two weeks.</p>
[% END %]
<p><a href="/cgi-bin/koha/opac-shelves.pl?display=privateshelves">Return to your lists</a></p>
<p><a href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;category=1">Return to your lists</a></p>
</div>
[% ELSIF op=='accept' %]

View file

@ -3,9 +3,9 @@
<rss version="2.0">
<channel>
<title>[% shelfname %]</title>
<link>[% OPACBaseURL %]/cgi-bin/koha/opac-shelves.pl?rss=1&amp;viewshelf=[% shelfnumber %]</link>
<description>RSS feed for public list [% shelfname | html %]</description>
<title>[% shelf.shelfname %]</title>
<link>[% OPACBaseURL %]/cgi-bin/koha/opac-shelves.pl?rss=1&amp;viewshelf=[% shelf.shelfnumber %]</link>
<description>RSS feed for public list [% shelf.shelfname | html %]</description>
[% FOREACH i IN itemsloop %]
<item>

View file

@ -1,9 +1,11 @@
[% USE Koha %]
[% SET TagsShowEnabled = ( ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsShowOnList ) %]
[% SET TagsInputEnabled = ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsInputOnList ) %]
[% SET PRIVATE = 1 %]
[% SET PUBLIC = 2 %]
[% SET TagsShowEnabled = ( ( Koha.Preference( 'TagsEnabled' ) == 1 ) && Koha.Preference('TagsShowOnList') ) %]
[% SET TagsInputEnabled = ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( Koha.Preference( 'TagsEnabled' ) == 1 ) && Koha.Preference('TagsInputOnList') ) %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; [% IF ( viewshelf ) %]Contents of [% shelfname |html %][% ELSE %]Your lists[% END %]</title>[% INCLUDE 'doc-head-close.inc' %]
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; [% IF op == 'view' %]Contents of [% shelf.shelfname |html %][% ELSE %]Your lists[% END %]</title>[% INCLUDE 'doc-head-close.inc' %]
[% BLOCK cssinclude %][% END %]
</head>
[% IF ( loggedinusername ) %][% INCLUDE 'bodytag.inc' bodyid='opac-userlists' bodyclass='scrollto' %][% ELSE %][% INCLUDE 'bodytag.inc' bodyid='opac-lists' bodyclass='scrollto' %][% END %]
@ -12,35 +14,28 @@
<li>
<label for="allow_add">Permissions: </label>
<select name="allow_add" id="allow_add">
[% IF allow_add %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
[% IF allow_add %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
[% IF shelf.allow_add %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
[% IF shelf.allow_add %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
</select>
&nbsp;<span>anyone else to add entries. (The owner of a list is always allowed to add entries, but needs permission to remove.)</span>
</li>
<li>
<label>&nbsp;</label>
<select name="allow_delete_own" id="allow_delete_own">
[% IF allow_delete_own %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
[% IF allow_delete_own %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
[% IF shelf.allow_delete_own %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
[% IF shelf.allow_delete_own %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
</select>
&nbsp;<span>anyone to remove his own contributed entries.</span>
</li>
<li>
<label>&nbsp;</label>
<select name="allow_delete_other" id="allow_delete_other">
[% IF allow_delete_other %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
[% IF allow_delete_other %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
[% IF shelf.allow_delete_other %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
[% IF shelf.allow_delete_other %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
</select>
&nbsp;<span>anyone to remove other contributed entries.</span>
</li>
[% END %]
[% BLOCK remove_share %]
[%# Use: add parameter shelfnumber and add end form tag %]
<form action="opac-shelves.pl" method="post" class="form-inline">
<input type="hidden" name="shelves" value="1" />
<input type="hidden" name="display" value="privateshelves" />
<input type="submit" class="deleteshelf" onclick="return confirmDelete(MSG_CONFIRM_REMOVE_SHARE);" value="Remove share" />
[% END %]
[% INCLUDE 'masthead.inc' %]
<div class="main">
@ -50,42 +45,36 @@
<li><a href="/cgi-bin/koha/opac-user.pl">[% FOREACH USER_INF IN USER_INFO %][% USER_INF.title %] [% USER_INF.firstname %] [% USER_INF.surname %][% END %]</a> <span class="divider">&rsaquo;</span></li>
[% END %]
[% IF ( category1 ) %]
[% IF ( viewshelf || edit ) %]
<li><a href="/cgi-bin/koha/opac-shelves.pl?display=privateshelves">Your lists</a></li>
[% IF op != 'list' %]
<li><a href="/cgi-bin/koha/opac-shelves.pl">Lists</a></li>
[% ELSE %]
<li>Lists</li>
[% END %]
[% IF shelf and shelf.category == PRIVATE %]
[% IF op == 'view' OR op == 'edit_form' %]
<li><span class="divider">&rsaquo;</span> <a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=[% PRIVATE %]">Your lists</a></li>
[% ELSE %]
<li>Your lists</li>
<li><span class="divider">&rsaquo;</span> Your lists</li>
[% END %]
[% ELSIF ( category2 ) %]
[% IF ( viewshelf || edit ) %]
<li><a href="/cgi-bin/koha/opac-shelves.pl?display=publicshelves">Public lists</a></li>
[% ELSIF shelf AND shelf.category == PUBLIC %]
[% IF op == 'view' %]
<li><span class="divider">&rsaquo;</span> <a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=[% PUBLIC %]">Public lists</a></li>
[% ELSE %]
<li>Public lists</li>
[% END %]
[% ELSIF ( showprivateshelves ) %]
[% IF ( viewshelf || edit ) %]
<li><a href="/cgi-bin/koha/opac-shelves.pl?display=privateshelves">Your lists</a></li>
[% ELSE %]
<li>Your lists</li>
[% END %]
[% ELSIF ( showpublicshelves ) %]
[% IF ( viewshelf || edit || shelves ) %]
<li><a href="/cgi-bin/koha/opac-shelves.pl?display=publicshelves">Public lists</a></li>
[% ELSE %]
<li>Public lists</li>
<li><span class="divider">&rsaquo;</span> Public lists</li>
[% END %]
[% END %]
[% IF ( viewshelf ) %]
<li><span class="divider">&rsaquo;</span> Contents of <i>[% shelfname | html %]</i></li>
[% IF op == 'view' %]
<li><span class="divider">&rsaquo;</span> Contents of <i>[% shelf.shelfname | html %]</i></li>
[% END %]
[% IF ( shelves ) %]
[% IF op == 'add_form' %]
<li><span class="divider">&rsaquo;</span> Create new list</li>
[% END %]
[% IF ( edit ) %]
<li><span class="divider">&rsaquo;</span> Edit list <i>[% shelfname | html %]</i></li>
[% IF op == 'edit_form' %]
<li><span class="divider">&rsaquo;</span> Edit list <i>[% shelf.shelfname | html %]</i></li>
[% END %]
</ul> <!-- / .breadcrumb -->
@ -107,52 +96,65 @@
[% END %]
<div id="usershelves" class="maincontent">
[% IF ( paramsloop ) %]
[% FOREACH paramsloo IN paramsloop %]
[% IF ( paramsloo.status ) %]<div class="alert">[% paramsloo.string %]</div>[% END %]
[% IF ( paramsloo.nobarcode ) %]<div class="alert">ERROR: No barcode given.</div>[% END %]
[% IF ( paramsloo.noshelfnumber ) %]<div class="alert">ERROR: No shelfnumber given.</div>[% END %]
[% 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.count == 1 %]entry[% ELSE %]entries[% END %].
<br />Use the "Confirm" button below to confirm deletion.
</div>
[% END %]
[% IF ( paramsloo.nopermission ) %]
<div class="alert">ERROR: You do not have adequate permission for that action on list [% paramsloo.nopermission |html%].</div>
[% END %]
[% IF ( paramsloo.failgetitem ) %]
<div class="alert">ERROR: No item found with barcode [% paramsloo.failgetitem %].</div>
[% END %]
[% IF ( paramsloo.duplicatebiblio ) %]
<div class="alert">A record matching barcode <b>[% paramsloo.duplicatebiblio %]</b> has already been added.</div>
[% END %]
[% IF ( paramsloo.delete_ok ) %]
<div class="alert alert-info">List [% paramsloo.delete_ok |html %] Deleted.</div>
[% END %]
[% IF ( paramsloo.delete_fail ) %]
<div class="alert alert-info">ERROR: Database error. Delete (list number [% paramsloo.delete_fail |html %]) failed.</div>
[% END %]
[% IF ( paramsloo.unrecognized ) %]
<div class="alert alert-info">ERROR: List number [% paramsloo.unrecognized %] unrecognized.</div>
[% END %]
[% IF ( paramsloo.modifyfailure) %]
<div class="alert alert-info">ERROR: Shelf could not be renamed to [% paramsloo.modifyfailure %]. This name may not be unique for this type of list. Please check.</div>
[% END %]
[% IF ( paramsloo.nothingdeleted) %]
<div class="alert alert-info">Warning: You could not delete any selected items from this shelf.</div>
[% END %]
[% IF ( paramsloo.somedeleted) %]
<div class="alert alert-info">Warning: You could not delete all selected items from this shelf.</div>
[% END %]
[% END # / FOREACH paramsloop %]
[% END # / IF paramsloop %]
[% FOR m IN messages %]
[% SWITCH m.type %]
[% CASE 'message' %]
<div class="alert alert-success" role="alert">
[% CASE 'error' %]
<div class="alert alert-danger" role="alert">
[% END %]
[% SWITCH m.code %]
[% CASE 'error_on_update' %]
An error occurred when updating this list. Perhaps the value already exists.
[% CASE 'error_on_insert' %]
An error occurred when inserting this list. Perhaps the name already exists.
[% CASE 'error_on_delete' %]
An error occurred when deleteing this list. Check the logs.
[% CASE 'error_on_add_biblio' %]
The item has not been added to the list. Please check it's not in this list yet.
[% CASE 'error_on_remove_share' %]
The share has not been removed.
[% CASE 'success_on_update' %]
List updated with success.
[% CASE 'success_on_insert' %]
List inserted with success.
[% CASE 'success_on_delete' %]
List deleted with success.
[% CASE 'success_on_add_biblio' %]
The item has been added to the list.
[% CASE 'success_on_remove_biblios' %]
The item has been removed from the list.
[% CASE 'success_on_remove_share' %]
The share has been removed.
[% CASE 'does_not_exist' %]
This list does not exist.
[% CASE 'item_does_not_exist' %]
This item does not exist.
[% CASE 'unauthorized_on_view' %]
You do not have permission to view this list.
[% CASE 'unauthorized_on_update' %]
You do not have permission to update this list.
[% CASE 'unauthorized_on_delete' %]
You do not have permission to delete this list.
[% CASE 'unauthorized_on_add_biblio' %]
You do not have permission to add a biblio to this list.
[% CASE 'no_biblio_removed' %]
No biblio has been removed.
[% CASE 'Koha::Exceptions::Virtualshelves::DuplicateObject' %]
An error occurred when inserting this list. The name already [% shelfname %] exists.
[% CASE 'DBIx::Class::Exception' %]
[% m.msg %]
[% CASE %]
[% m.code %]
[% m.msg %]
[% END %]
</div>
[% END %]
[% IF ( viewshelf ) %]<!-- Viewing a particular shelf -->
[% IF op == 'view' %]
<h3>
[% shelfname |html %]
<a href="[% OPACBaseURL %]/cgi-bin/koha/opac-shelves.pl?rss=1&amp;viewshelf=[% shelfnumber %]" class="rss-list-link noprint">
[% shelf.shelfname |html %]
<a href="[% OPACBaseURL %]/cgi-bin/koha/opac-shelves.pl?rss=1&amp;op=view&amp;shelfnumber=[% shelf.shelfnumber %]" class="rss-list-link noprint">
<img src="[% interface %]/[% theme %]/images/feed-icon-16x16.png" alt="Subscribe to this list" title="Subscribe to this list" border="0" class="rsssearchicon"/>
</a>
</h3>
@ -160,68 +162,70 @@
[% IF ( itemsloop ) %]
<div id="toolbar" class="toolbar clearfix">
<div class="list-actions">
<a class="newshelf" href="/cgi-bin/koha/opac-shelves.pl?shelves=1">New list</a> <span class="sep">|</span>
<a href="/cgi-bin/koha/opac-downloadshelf.pl?shelfid=[% shelfnumber | html %]&amp;showprivateshelves=[% showprivateshelves | html %]" class="download" data-toggle="modal" data-target="#modalWin">Download list</a>
<a class="newshelf" href="/cgi-bin/koha/opac-shelves.pl?op=add_form">New list</a> <span class="sep">|</span>
<a href="/cgi-bin/koha/opac-downloadshelf.pl?shelfnumber=[% shelf.shelfnumber | html %]" class="download" data-toggle="modal" data-target="#modalWin">Download list</a>
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
<span class="sendlist"><a href="/cgi-bin/koha/opac-sendshelf.pl?shelfid=[% shelfnumber | html %]" class="send" onclick="open('/cgi-bin/koha/opac-sendshelf.pl?shelfid=[% shelfnumber | html %]','win_form','scrollbars=no,resizable=no,height=300,width=450,top=50,left=100'); return false; ">Send list</a></span>
[% END %]
<a class="print-small" target="_blank" href="/cgi-bin/koha/opac-shelves.pl?viewshelf=[% shelfnumber %]&sort=[% sort %]&direction=[% direction |uri %]&print=1">Print list</a>
<a class="print-small" target="_blank" href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber %]&sortfield=[% sortfield %]&direction=[% direction |uri %]&print=1">Print list</a>
[% IF ( manageshelf ) %]
[% IF can_manage_shelf %]
<span class="sep">|</span>
<form method="get" action="/cgi-bin/koha/opac-shelves.pl" class="form-inline">
<input type="hidden" name="op" value="modif" />
<input type="hidden" name="display" value="viewshelf" />
<input type="hidden" name="shelfnumber" value="[% shelfnumber | html %]" />
<input type="hidden" name="op" value="edit_form" />
<input type='hidden' name='category' value='[% category %]' />
<input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
<input type="submit" class="editshelf" value="Edit list" />
</form>
<form method="post" action="/cgi-bin/koha/opac-shelves.pl" class="form-inline">
<input type="hidden" value="1" name="shelves"/>
<input type="hidden" value="1" name="DEL-[% shelfnumber | html %]"/>
[% IF ( showprivateshelves ) %]
<input type="hidden" name="display" value="privateshelves"/>
[% END %]
<input type="hidden" name="op" value="delete" />
<input type='hidden' name='category' value='[% category %]' />
<input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
<input type="submit" class="deleteshelf" value="Delete list" onclick="return confirmDelete(MSG_CONFIRM_DELETE_LIST);"/>
</form>
[% IF showprivateshelves && Koha.Preference('OpacAllowSharingPrivateLists') %]
<a href="/cgi-bin/koha/opac-shareshelf.pl?op=invite&shelfnumber=[% shelfnumber | html %]" class="">Share list</a>
[% IF category == PRIVATE && Koha.Preference('OpacAllowSharingPrivateLists') %]
<a href="/cgi-bin/koha/opac-shareshelf.pl?op=invite&shelfnumber=[% shelf.shelfnumber | html %]" class="">Share list</a>
[% END %]
[% ELSIF showprivateshelves # not manageshelf and private means shared %]
[% INCLUDE remove_share %]
<input type="hidden" name="REMSHR-[% shelfnumber | html %]" value="1" />
[% ELSIF category == PRIVATE # not manageshelf and private means shared %]
<form action="/cgi-bin/koha/opac-shelves.pl" method="post" class="form-inline">
<input type="hidden" name="op" value="remove_share" />
<input type='hidden' name='category' value='[% category %]' />
<input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
<input type="submit" class="deleteshelf" onclick="return confirmDelete(MSG_CONFIRM_REMOVE_SHARE);" value="Remove share" />
</form>
[% END # / IF manageshelf %]
[% END %]
</div>
<form action="/cgi-bin/koha/opac-shelves.pl" id="sorting-form" class="form-inline sort_by pull-right">
<input type="hidden" name="viewshelf" value="[% shelfnumber | html %]" />
<input type="hidden" name="op" value="view" />
<input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
<label for="sort">Sort by: </label>
<select name="sort" id="sort" class="resort" onchange="$('#sorting-form').submit()">
<label for="sortfield">Sort by: </label>
<select name="sortfield" id="sortfield" class="resort" onchange="$('#sorting-form').submit()">
<option value="">Default sorting</option>
[% IF sort == 'author' %]
[% IF sortfield == 'author' %]
<option value="author" selected="selected">Author</option>
[% ELSE %]
<option value="author">Author</option>
[% END %]
[% IF sort == 'title' %]
[% IF sortfield == 'title' %]
<option value="title" selected="selected">Title</option>
[% ELSE %]
<option value="title">Title</option>
[% END %]
[% IF sort == 'itemcallnumber' %]
[% IF sortfield == 'itemcallnumber' %]
<option value="itemcallnumber" selected="selected">Call number</option>
[% ELSE %]
<option value="itemcallnumber">Call number</option>
[% END %]
[% IF sort == 'copyrightdate' %]
[% IF sortfield == 'copyrightdate' %]
<option value="copyrightdate" selected="selected">Copyright date</option>
[% ELSE %]
<option value="copyrightdate">Copyright date</option>
@ -265,23 +269,23 @@
<a href="#" id="tagsel_cancel">Cancel</a>
</span>
[% END %]
[% IF ( loggedinusername && allowremovingitems ) %]
[% IF loggedinusername && can_remove_biblios %]
<span id="removeitems"></span>
[% END %]
</span> <!-- / .links -->
</div> <!-- / #selections-toolbar -->
<form action="/cgi-bin/koha/opac-shelves.pl" method="post" id="myform" name="myform" class="checkboxed">
[% IF ( manageshelf ) %]
<input type="hidden" name="viewshelf" value="[% shelfnumber | html %]" />
<input type="hidden" name="modifyshelfcontents" value="1" />
[% IF can_manage_shelf %]
<input type="hidden" name="op" value="remove_biblios" />
<input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
[% END %]
<div class="searchresults">
<table id="listcontents" class="table">
<tbody>
[% FOREACH itemsloo IN itemsloop %]
<tr>
<td class="select selectcol"><input type="checkbox" class="cb" name="REM-[% itemsloo.biblionumber %]" value="[% itemsloo.biblionumber %]" /></td>
<td class="select selectcol"><input type="checkbox" class="cb" name="biblionumber" value="[% itemsloo.biblionumber %]" /></td>
[% UNLESS ( item_level_itypes ) %]
<td>
[% UNLESS ( noItemTypeImages ) %]
@ -456,8 +460,8 @@
<span class="actions"><a class="addtoshelf" href="/cgi-bin/koha/opac-addbybiblionumber.pl?biblionumber=[% itemsloo.biblionumber %]" onclick="Dopop('opac-addbybiblionumber.pl?biblionumber=[% itemsloo.biblionumber %]'); return false;">Save to another list</a></span>
[% END %]
[% IF ( allowremovingitems ) %]
<span class="actions"><a class="removefromlist hidden" id="REM-[% itemsloo.biblionumber %]" href="#">Remove from this list</a></span>
[% IF can_remove_biblios %]
<span class="actions"><a class="removefromlist" href="/cgi-bin/koha/opac-shelves.pl?op=remove_biblios&amp;shelfnumber=[% shelf.shelfnumber %]&amp;biblionumber=[% itemsloo.biblionumber %]">Remove from this list</a></span>
[% END %]
[% IF Koha.Preference( 'opacbookbag' ) == 1 %]
@ -485,25 +489,23 @@
[% ELSE %]
<div id="toolbar" class="toolbar clearfix">
<div class="list-actions">
<a class="newshelf" href="/cgi-bin/koha/opac-shelves.pl?shelves=1">New list</a> <span class="sep"></span>
[% IF ( manageshelf ) %]
<a class="newshelf" href="/cgi-bin/koha/opac-shelves.pl?op=add_form">New list</a> <span class="sep"></span>
[% IF can_manage_shelf %]
<span class="sep">|</span>
<form method="get" action="/cgi-bin/koha/opac-shelves.pl" class="form-inline">
<input type="hidden" name="op" value="modif" />
<input type="hidden" name="display" value="viewshelf" />
<input type="hidden" name="shelfnumber" value="[% shelfnumber | html %]" />
<input type="hidden" name="op" value="edit_form" />
<input type="hidden" name="category" value="category" />
<input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
<input type="submit" class="editshelf" value="Edit list" />
</form>
<form method="post" action="/cgi-bin/koha/opac-shelves.pl" class="form-inline">
<input type="hidden" value="1" name="shelves"/>
<input type="hidden" value="1" name="DEL-[% shelfnumber | html %]"/>
[% IF ( showprivateshelves ) %]
<input type="hidden" name="display" value="privateshelves"/>
[% END %]
<input type="hidden" name="op" value="delete" />
<input type="hidden" name="shelfnumber" value="[% shelfnumber | html %]"/>
<input type="hidden" name="category" value="category" />
<input type="submit" class="deleteshelf" value="Delete list" onclick="return confirmDelete(MSG_CONFIRM_DELETE_LIST);"/>
</form>
[% END # / IF manageshelf %]
[% END %]
</div> <!-- / .list-actions -->
</div> <!-- / #toolbar -->
@ -514,297 +516,203 @@
[% END %]
</div>
[% END # / IF itemsloop %]
[% END # / IF viewshelf %]
[% END %]
[% IF ( itemsloop && allowremovingitems ) %]
<input type="hidden" name="shelfnumber" value="[% shelfnumber | html %]" />
[% IF itemsloop && can_remove_biblios %]
<input type="hidden" name="op" value="view" />
<input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
<input type="hidden" name="modifyshelfcontents" value="1" />
<input type="hidden" name="viewshelf" value="[% shelfnumber | html %]" /><input type="submit" value="Remove selected items" id="remove-selected" class="btn btn-danger"/>
<input type="submit" value="Remove selected items" id="remove-selected" class="btn btn-danger"/>
</form>
[% ELSIF ( !itemsloop && manageshelf ) %]
[% ELSIF !itemsloop && can_manage_shelf %]
<form method="post" action="opac-shelves.pl">
<input type="hidden" name="DEL-[% shelfnumber | html %]" value="1" />
<input type="hidden" name="shelves" value="1" />
<input type="hidden" name="shelfoff" value="[% shelfoff %]" />
<input type="hidden" name="op" value="delete" />
<input type="hidden" name="referer" value="list" />
<input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]"/>
<input type="submit" class="btn btn-danger" value="Delete this list" onclick="return confirmDelete(MSG_CONFIRM_DELETE_LIST)" />
</form>
[% END %]
[% IF ( edit ) %]
[% IF op == 'add_form' OR op == 'edit_form' %]
<form method="post" action="/cgi-bin/koha/opac-shelves.pl">
<input type="hidden" name="op" value="modifsave" />
<input type="hidden" name="display" value="[% display |html %]" />
<input type="hidden" name="shelfnumber" value="[% shelfnumber | html %]" />
<fieldset class="rows">
<legend>Editing <em>[% shelfname |html %]</em></legend>
[% IF op == 'add_form' %]
<div id="addshelf">
<legend>Create a new list</legend>
<input type="hidden" name="op" value="add" />
[% ELSE %]
<legend>Editing <em>[% shelf.shelfname |html %]</em></legend>
<input type="hidden" name="op" value="edit" />
<input type="hidden" name="referer" value="view" />
<input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
[% END %]
<input type="hidden" name="owner" id="owner" value="[% loggedinusernumber %]" />
<ol>
<li><label for="shelfname">List name: </label><input type="text" id="shelfname" name="shelfname" maxlength="255" value="[% shelfname |html %]" /></li>
<li>
<label class="required" for="shelfname">List name: </label>
<input type="text" id="shelfname" name="shelfname" maxlength="255" value="[% shelf.shelfname |html %]" /></li>
<li>
<label for="sortfield" >Sort this list by: </label>
<select name="sortfield" id="sortfield">
[% IF ( sortfield == "title" ) %]
[% IF shelf.sortfield == "title" %]
<option value="title" selected="selected">Title</option>
[% ELSE %]
<option value="title">Title</option>
[% END %]
[% IF ( sortfield == "author" ) %]
[% IF shelf.sortfield == "author" %]
<option value="author" selected="selected">Author</option>
[% ELSE %]
<option value="author">Author</option>
[% END %]
[% IF ( sortfield == "copyrightdate" ) %]
[% IF shelf.sortfield == "copyrightdate" %]
<option value="copyrightdate" selected="selected">Year</option>
[% ELSE %]
<option value="copyrightdate">Year</option>
[% END %]
[% IF ( sortfield == "itemcallnumber" ) %]
[% IF shelf.sortfield == "itemcallnumber" %]
<option value="itemcallnumber" selected="selected">Call number</option>
[% ELSE %]
<option value="itemcallnumber">Call number</option>
[% END %]
</select>
</li>
[% IF ( OpacAllowPublicListCreation || category2 ) %]
[% IF Koha.Preference('OpacAllowPublicListCreation') OR category == PUBLIC %]
<li>
<label for="category">Category:</label>
<select name="category" id="category">
[% IF ( category1 ) %]
[% IF shelf.category == PRIVATE %]
<option value="1" selected="selected">Private</option>
[% ELSE %]
<option value="1">Private</option>
[% END %]
[% IF ( category2 ) %]
[% IF shelf.category == PUBLIC %]
<option value="2" selected="selected">Public</option>
[% ELSE %]
<option value="2">Public</option>
[% END %]
</select>
[% IF ( category2 && !OpacAllowPublicListCreation ) %]
[% IF shelf.category == PUBLIC AND NOT Koha.Preference('OpacAllowPublicListCreation') %]
<span class="hint alert alert-info">The library has disabled the ability for patrons to create new public lists. If you make your list private, you will not be able to make it public again.</span>
[% END %]
</li>
[% INCLUDE list_permissions %]
[% END %]
</ol>
[% UNLESS ( OpacAllowPublicListCreation || category2 ) %]
<input type="hidden" name="category" value="1" />
[% UNLESS Koha.Preference('OpacAllowPublicListCreation') OR category == PUBLIC %]
<input type="hidden" name="category" value="[% PRIVATE %]" />
[% END %]
</fieldset>
<fieldset class="action">
<input type="submit" value="Save" class="btn" />
[% IF ( showprivateshelves ) %]
<a class="cancel" href="/cgi-bin/koha/opac-shelves.pl?shelfnumber=[% shelfnumber | html %]&amp;display=privateshelves">Cancel</a>
<input type="submit" onclick="Check(this.form); return false;" value="Save" class="btn" />
[% IF referer == 'view' %]
<a href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber %]" class="cancel">Cancel</a>
[% ELSE %]
<a class="cancel" href="/cgi-bin/koha/opac-shelves.pl?shelfnumber=[% shelfnumber | html %]">Cancel</a>
[% END %]
<a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=[% PRIVATE %]" class="cancel">Cancel</a>
[% END %]
</fieldset>
</form>
[% END # / IF edit %]
[% ELSIF op == 'list' %]
<h2>Lists</h2>
<div class="toptabs ui-tabs ui-widget ui-widget-content ui-corner-all">
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
[% IF category == PRIVATE %]
<li id="privateshelves_tab" class="ui-state-default ui-corner-top ui-tabs-active ui-state-active"><a class="ui-tabs-anchor" href="/cgi-bin/koha/opac-shelves.pl?op=listamp;category=[% PRIVATE %]">Your lists</a></li>
[% ELSE %]
<li id="privateshelves_tab" class="ui-state-default ui-corner-top"><a class="ui-tabs-anchor" href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=[% PRIVATE %]">Your lists</a></li>
[% END %]
[% END %]
[% IF category == PUBLIC %]
<li id="publicshelves_tab" class="ui-state-default ui-corner-top ui-tabs-active ui-state-active"><a class="ui-tabs-anchor" href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=[% PUBLIC %]">Public lists</a></li>
[% ELSE %]
<li id="publicshelves_tab" class="ui-state-default ui-corner-top"><a class="ui-tabs-anchor" href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=[% PUBLIC %]">Public lists</a></li>
[% END %]
</ul>
[% UNLESS ( edit ) %]
[% UNLESS ( viewshelf ) %]
[% UNLESS ( shelves ) %]
<h2>Lists</h2>
<div class="toptabs ui-tabs ui-widget ui-widget-content ui-corner-all">
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
[% IF ( showprivateshelves ) %]
<li id="privateshelves_tab" class="ui-state-default ui-corner-top ui-tabs-active ui-state-active"><a class="ui-tabs-anchor" href="/cgi-bin/koha/opac-shelves.pl?display=privateshelves">Your lists</a></li>
[% ELSE %]
<li id="privateshelves_tab" class="ui-state-default ui-corner-top"><a class="ui-tabs-anchor" href="/cgi-bin/koha/opac-shelves.pl?display=privateshelves">Your lists</a></li>
[% IF category == PRIVATE %]
<div id="privateshelves" class="ui-tabs-panel ui-widget-content ui-corner-bottom" style="display:block;">
[% ELSE %]
<div id="publicshelves" class="ui-tabs-panel ui-widget-content ui-corner-bottom" style="display:block;">
[% END %]
<div id="toolbar" class="toolbar"><a class="newshelf" href="/cgi-bin/koha/opac-shelves.pl?op=add_form">New list</a></div>
[% IF shelves %]
<table class="table">
<thead>
<tr>
<th>List name</th>
<th>Contents</th>
<th>Type</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
[% FOREACH s IN shelves %]
[% SET contents = s.get_contents %]
<tr>
<td><a href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% s.shelfnumber %]">[% s.shelfname |html %]</a></td>
<td>[% IF contents.count %][% contents.count %] [% IF contents.count == 1 %]item[% ELSE %]items[% END %][% ELSE %]Empty[% END %]</td>
<td>
[% IF s.category == PRIVATE %]
[% IF s.is_shared %]Shared[% ELSE %]Private[% END %]
[% ELSE %]
Public
[% END %]
</td>
<td>
[% IF s.can_be_managed( loggedinusernumber ) %]
<form action="/cgi-bin/koha/opac-shelves.pl" method="get" class="form-inline">
<input type="hidden" name="shelfnumber" value="[% s.shelfnumber |html %]" />
<input type="hidden" name="category" value="[% s.category %]" />
<input type="hidden" name="op" value="edit_form" />
<input type="hidden" name="referer" value="list" />
<input type="submit" class="editshelf" value="Edit" />
</form>
[% END %]
[% IF s.can_be_deleted( loggedinusernumber ) %]
<form action="/cgi-bin/koha/opac-shelves.pl" method="post" class="form-inline">
<input type="hidden" name="op" value="delete" />
<input type="hidden" name="referer" value="list" />
<input type='hidden' name='category' value='[% category %]' />
<input type="hidden" name="shelfnumber" value="[% s.shelfnumber | html %]" />
<input type="submit" class="deleteshelf" onclick="return confirmDelete(MSG_CONFIRM_DELETE_LIST);" value="Delete" />
</form>
[% END %]
[% IF s.category == PRIVATE AND s.can_be_managed( loggedinusernumber ) AND Koha.Preference('OpacAllowSharingPrivateLists') %]
<a href="/cgi-bin/koha/opac-shareshelf.pl?op=invite&shelfnumber=[% s.shelfnumber |html %]" class="">Share</a>
[% END %]
[% IF s.is_shared_with( loggedinusernumber ) %]
<form action="opac-shelves.pl" method="post" class="form-inline">
<input type="hidden" name="op" value="remove_share" />
<input type="hidden" name="referer" value="list" />
<input type='hidden' name='category' value='[% category %]' />
<input type="hidden" name="shelfnumber" value="[% s.shelfnumber | html %]" />
<input type="submit" class="deleteshelf" onclick="return confirmDelete(MSG_CONFIRM_REMOVE_SHARE);" value="Remove share" />
</form>
[% END %]&nbsp;
</td>
</tr>
[% END %]
[% END %]
[% IF ( showpublicshelves ) %]
<li id="publicshelves_tab" class="ui-state-default ui-corner-top ui-tabs-active ui-state-active"><a class="ui-tabs-anchor" href="/cgi-bin/koha/opac-shelves.pl?display=publicshelves">Public lists</a></li>
[% ELSE %]
<li id="publicshelves_tab" class="ui-state-default ui-corner-top"><a class="ui-tabs-anchor" href="/cgi-bin/koha/opac-shelves.pl?display=publicshelves">Public lists</a></li>
[% END %]
</ul>
[% IF ( showprivateshelves ) %]
<div id="privateshelves" class="ui-tabs-panel ui-widget-content ui-corner-bottom" style="display:block;">
[% IF ( loggedinusername ) %]
<div id="toolbar" class="toolbar"><a class="newshelf" href="/cgi-bin/koha/opac-shelves.pl?shelves=1">New list</a></div>
[% IF ( showprivateshelves ) %]
[% IF ( shelveslooppriv ) %]
<table class="table">
<thead>
<tr>
<th>List name</th>
<th>Contents</th>
<th>Type</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
[% FOREACH shelveslooppri IN shelveslooppriv %]
<tr>
<td><a href="/cgi-bin/koha/opac-shelves.pl?display=privateshelves&amp;viewshelf=[% shelveslooppri.shelf %]&amp;sortfield=[% shelveslooppri.sortfield %]">[% shelveslooppri.shelfname |html %]</a></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>
<td>
[% IF ( shelveslooppri.mine ) %]
<form action="/cgi-bin/koha/opac-shelves.pl" method="get" class="form-inline">
<input type="hidden" name="shelfnumber" value="[% shelveslooppri.shelf |html %]" />
<input type="hidden" name="display" value="privateshelves" />
<input type="hidden" name="op" value="modif" />
<input type="submit" class="editshelf" value="Edit" />
</form>
<form action="opac-shelves.pl" method="post" class="form-inline">
<input type="hidden" name="shelves" value="1" />
<input type="hidden" name="display" value="privateshelves" />
<input type="hidden" name="DEL-[% shelveslooppri.shelf |html %]" value="1" />
<input type="hidden" name="shelfoff" value="[% shelfoff |html %]" />
[% IF ( shelveslooppri.confirm ) %]
<input type="hidden" name="CONFIRM-[% shelveslooppri.confirm |html %]" value="1" />
<input type="submit" class="btn btn-danger confirm" value="Confirm" />
[% ELSE %]
<input type="submit" class="deleteshelf" onclick="return confirmDelete(MSG_CONFIRM_DELETE_LIST);" value="Delete" />
[% END %]
</form>
[% IF Koha.Preference('OpacAllowSharingPrivateLists') %]
<a href="/cgi-bin/koha/opac-shareshelf.pl?op=invite&shelfnumber=[% shelveslooppri.shelf |html %]" class="">Share</a>
[% END %]
[% ELSE # not shelveslooppri.mine, so shared %]
[% INCLUDE remove_share # if pref is off, you should still be able to remove shares %]
<input type="hidden" name="shelfoff" value="[% shelfoff |html %]" />
<input type="hidden" name="REMSHR-[% shelveslooppri.shelf |html %]" value="1" />
</form>
[% END %]&nbsp;
</td>
</tr>
[% END # / FOREACH shelveslooppri %]
</tbody>
</table>
<div class="pages">[% pagination_bar %]</div>
[% ELSE %]
<p>No private lists.</p>
[% END # / IF shelveslooppriv %]
[% END # / IF showprivateshelves %]
[% ELSE %]
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
<div class="alert alert-info"><a href="/cgi-bin/koha/opac-user.pl">Log in</a> to create new lists.</div>
[% END %]
[% END # IF loggedinusername %]
</div><!-- / #privateshelves -->
[% END # / IF showprivateshelves %]
[% IF ( showpublicshelves ) %]
<div id="publicshelves" class="ui-tabs-panel ui-widget-content ui-corner-bottom" style="display:block;">
[% IF ( loggedinusername ) %]
<div id="toolbar" class="toolbar"> <a class="newshelf" href="/cgi-bin/koha/opac-shelves.pl?shelves=1">New list</a></div>
[% ELSE %]
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
<div class="alert alert-info"><a href="/cgi-bin/koha/opac-user.pl">Log in</a> to create new lists.</div>
[% END %]
[% END # / IF loggedinusername %]
[% IF ( shelvesloop ) %]
<table class="table">
<thead>
<tr>
<th>List name</th>
<th>Contents</th>
<th>Type</th><th>&nbsp;</th>
</tr>
</thead>
<tbody>
[% FOREACH shelvesloo IN shelvesloop %]
<tr>
<td><a class="title" href="/cgi-bin/koha/opac-shelves.pl?viewshelf=[% shelvesloo.shelf %]&amp;sortfield=[% shelvesloo.sortfield %]">[% shelvesloo.shelfname |html %]</a></td>
<td>[% shelvesloo.count %] [% IF shelvesloo.count == 1 %]item[% ELSE %]item(s)[% END %]</td>
<td>
[% IF ( shelvesloo.viewcategory2 ) %]Public[% END %]
</td>
<td>
[% IF ( shelvesloo.mine ) %]
<form action="/cgi-bin/koha/opac-shelves.pl" method="get" class="form-inline">
<input type="hidden" name="shelfnumber" value="[% shelvesloo.shelf %]" />
<input type="hidden" name="op" value="modif" />
<input type="hidden" name="display" value="publicshelves" />
<input type="submit" class="editshelf" value="Edit" />
</form>
<form action="opac-shelves.pl" method="post" class="form-inline">
<input type="hidden" name="shelves" value="1" />
<input type="hidden" name="DEL-[% shelvesloo.shelf %]" value="1" />
[% IF ( shelvesloo.confirm ) %]
<input type="hidden" name="CONFIRM-[% shelvesloo.confirm %]" value="1" />
<input type="submit" class="btn btn-danger confirm" value="Confirm" />
[% ELSE %]
<input type="submit" class="deleteshelf" onclick="return confirmDelete(MSG_CONFIRM_DELETE_LIST);" value="Delete" />
[% END %]
</form>
[% END %]&nbsp;
</td>
</tr>
[% END # / FOREACH shelvesloop %]
</tbody>
</table>
[% IF ( pagination_bar ) %]<div class="pages">[% pagination_bar %]</div>[% END %]
[% ELSE %]
[% IF ( showpublicshelves ) %]<p>No public lists.</p>[% END %]
[% END # / IF shelvesloop %]
</div><!-- / # publicshelves -->
[% END # / IF showprivateshelves %]
</div> <!-- / .ui-tabs-panel -->
[% END # / UNLESS shelves %]
[% END # / UNLESS viewshelf %]
[% END # / UNLESS edit %]
[% IF ( shelves ) %]
<div id="addshelf">
<form method="post" action="/cgi-bin/koha/opac-shelves.pl">
<fieldset class="rows">
<legend>Create a new list</legend>
<input type="hidden" name="shelves" value="1" />
<ol>
<li>
<label class="required" for="addshelf">List name:</label>
[% IF shelfname %]
<input id="addshelf" type="text" name="addshelf" value="[% shelfname %]" maxlength="255" class="input-fluid" />
[% ELSE %]
<input id="addshelf" type="text" name="addshelf" maxlength="255" class="input-fluid" />
[% END %]
<input type="hidden" name="owner" id="owner" value="[% loggedinuser %]" />
</li>
<li>
<label for="sortfield" >Sort this list by: </label>
<select name="sortfield" id="sortfield">
<option value="title">Title</option>
<option value="author">Author</option>
<option value="copyrightdate">Year</option>
<option value="itemcallnumber">Call number</option>
</select>
</li>
[% IF (OpacAllowPublicListCreation) %]
<li>
<label for="category">Category:</label>
<select name="category" id="category">
<option value="1">Private</option>
<option value="2">Public</option>
</select>
</li>
[% INCLUDE list_permissions %]
[% END %]
</ol>
[% UNLESS (OpacAllowPublicListCreation) %]
<input type="hidden" name="category" value="1" />
[% END %]
</fieldset>
<fieldset class="action">
<input type="submit" onclick="Check(this.form); return false;" value="Save" class="btn" />
<a class="cancel" href="/cgi-bin/koha/opac-shelves.pl">Cancel</a>
</fieldset>
</form>
</div> <!-- / #addshelf -->
[% END # / IF shelves %]
</tbody>
</table>
<div class="pages">[% pagination_bar %]</div>
[% ELSE %]
[% IF category == PUBLIC %]
<p>No public lists.</p>
[% ELSE %]
<p>No private lists.</p>
[% END %]
[% END %]
<div> [%# privateshelves or publicshelves %]
</div> [%# <div class="toptabs ui-tabs ui-widget ui-widget-content ui-corner-all"> %]
[% ELSIF NOT loggedinusernumber %]
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
<div class="alert alert-info"><a href="/cgi-bin/koha/opac-user.pl">Log in</a> to create new lists.</div>
[% END %]
[% END # IF loggedinusername %]
</div> <!-- / #usershelves -->
</div> <!-- / .span10/12 -->
</div> <!-- / .row-fluid -->
@ -988,15 +896,9 @@ $(function() {
});
[% END %]
[% IF ( loggedinusername && allowremovingitems ) %]
var removeFromListLinks = $(".removefromlist");
removeFromListLinks.removeClass("hidden");
// "remove from list" appearing on each line of the list output
removeFromListLinks.on("click",function(){
$(".checkboxed").unCheckCheckboxes();
var listitem = $("input[name="+this.id+"]");
listitem.prop("checked",true);
$("#myform").submit();
[% IF loggedinusername && can_remove_biblios %]
$(".removefromlist").on("click", function(e){
return confirmDelete(MSG_REMOVE_ONE_FROM_LIST);
});
$("#myform").submit(function(){

View file

@ -46,17 +46,17 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
}
);
my $shelfid = $query->param('shelfid');
my $shelfnumber = $query->param('shelfnumber');
my $format = $query->param('format');
my $context = $query->param('context');
my $showprivateshelves = $query->param('showprivateshelves');
my $dbh = C4::Context->dbh;
if ( ShelfPossibleAction( (defined($borrowernumber) ? $borrowernumber : -1), $shelfid, 'view' ) ) {
my $shelf = Koha::Virtualshelves->find( $shelfnumber );
if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) {
if ($shelfid && $format) {
if ($shelfnumber && $format) {
my ($items, $totitems) = GetShelfContents($shelfid);
my ($items, $totitems) = GetShelfContents($shelfnumber);
my $marcflavour = C4::Context->preference('marcflavour');
my $output;
my $extension;
@ -116,13 +116,7 @@ if ( ShelfPossibleAction( (defined($borrowernumber) ? $borrowernumber : -1), $sh
$template->param(fullpage => 1);
}
$template->param(csv_profiles => GetCsvProfilesLoop('marc'));
$template->param(
showprivateshelves => $showprivateshelves,
shelfid => $shelf->shelfnumber,
shelfnumber => $shelf->shelfnumber,
viewshelf => $shelf->shelfnumber,
shelfname => $shelf->shelfname,
);
$template->param( shelf => $shelf );
output_html_with_http_headers $query, $cookie, $template->output;
}

View file

@ -1,6 +1,6 @@
#!/usr/bin/perl
# Copyright 2000-2002 Katipo Communications
# Copyright 2015 Koha Team
#
# This file is part of Koha.
#
@ -17,13 +17,20 @@
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use strict;
use warnings;
use Modern::Perl;
use CGI qw ( -utf8 );
use C4::VirtualShelves::Page;
use C4::VirtualShelves;
use C4::Auth;
use C4::Biblio;
use C4::Koha;
use C4::Items;
use C4::Members;
use C4::Output;
use C4::Tags qw( get_tags );
use C4::XSLT;
use Koha::Virtualshelves;
my $query = CGI->new();
my $query = new CGI;
my $template_name = $query->param('rss') ? "opac-shelves-rss.tt" : "opac-shelves.tt";
@ -34,9 +41,302 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
});
my $op = $query->param('op') || 'list';
my $referer = $query->param('referer') || $op;
my $category = $query->param('category') || 1;
my ( $shelf, $shelfnumber, @messages );
if ( $op eq 'add_form' ) {
# Nothing to do
} elsif ( $op eq 'edit_form' ) {
$shelfnumber = $query->param('shelfnumber');
$shelf = Koha::Virtualshelves->find($shelfnumber);
if ( $shelf ) {
$category = $shelf->category;
my $patron = GetMember( 'borrowernumber' => $shelf->owner );
$template->param( owner => $patron, );
unless ( $shelf->can_be_managed( $loggedinuser ) ) {
push @messages, { type => 'error', code => 'unauthorized_on_update' };
$op = 'list';
}
} else {
push @messages, { type => 'error', code => 'does_not_exist' };
}
} elsif ( $op eq 'add' ) {
eval {
$shelf = Koha::Virtualshelf->new(
{ shelfname => $query->param('shelfname'),
sortfield => $query->param('sortfield'),
category => $query->param('category') || 1,
allow_add => $query->param('allow_add'),
allow_delete_own => $query->param('allow_delete_own'),
allow_delete_other => $query->param('allow_delete_other'),
owner => $query->param('owner'),
}
);
$shelf->store;
$shelfnumber = $shelf->shelfnumber;
};
if ($@) {
push @messages, { type => 'error', code => ref($@), msg => $@ };
} elsif ( not $shelf ) {
push @messages, { type => 'error', code => 'error_on_insert' };
} else {
push @messages, { type => 'message', code => 'success_on_insert' };
$op = 'view';
}
} elsif ( $op eq 'edit' ) {
$shelfnumber = $query->param('shelfnumber');
$shelf = Koha::Virtualshelves->find($shelfnumber);
if ( $shelf ) {
$op = $referer;
if ( $shelf->can_be_managed( $loggedinuser ) ) {
$shelf->shelfname( $query->param('shelfname') );
$shelf->sortfield( $query->param('sortfield') );
$shelf->allow_add( $query->param('allow_add') );
$shelf->allow_delete_own( $query->param('allow_delete_own') );
$shelf->allow_delete_other( $query->param('allow_delete_other') );
$shelf->category( $query->param('category') );
eval { $shelf->store };
if ($@) {
push @messages, { type => 'error', code => 'error_on_update' };
$op = 'edit_form';
} else {
push @messages, { type => 'message', code => 'success_on_update' };
}
} else {
push @messages, { type => 'error', code => 'unauthorized_on_update' };
}
} else {
push @messages, { type => 'error', code => 'does_not_exist' };
}
} elsif ( $op eq 'delete' ) {
$shelfnumber = $query->param('shelfnumber');
$shelf = Koha::Virtualshelves->find($shelfnumber);
if ($shelf) {
if ( $shelf->can_be_deleted( $loggedinuser ) ) {
eval { $shelf->delete; };
if ($@) {
push @messages, { type => 'error', code => ref($@), msg => $@ };
} else {
push @messages, { type => 'message', code => 'success_on_delete' };
}
} else {
push @messages, { type => 'error', code => 'unauthorized_on_delete' };
}
} else {
push @messages, { type => 'error', code => 'does_not_exist' };
}
$op = $referer;
} elsif ( $op eq 'remove_share' ) {
$shelfnumber = $query->param('shelfnumber');
$shelf = Koha::Virtualshelves->find($shelfnumber);
if ($shelf) {
my $removed = eval { $shelf->remove_share( $loggedinuser ); };
if ($@) {
push @messages, { type => 'error', code => ref($@), msg => $@ };
} elsif ( $removed ) {
push @messages, { type => 'message', code => 'success_on_remove_share' };
} else {
push @messages, { type => 'error', code => 'error_on_remove_share' };
}
} else {
push @messages, { type => 'error', code => 'does_not_exist' };
}
$op = $referer;
} elsif ( $op eq 'add_biblio' ) {
$shelfnumber = $query->param('shelfnumber');
$shelf = Koha::Virtualshelves->find($shelfnumber);
if ($shelf) {
if( my $barcode = $query->param('barcode') ) {
my $item = GetItem( 0, $barcode);
if (defined $item && $item->{itemnumber}) {
my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} );
if ( $shelf->can_biblios_be_added( $loggedinuser ) ) {
my $added = eval { $shelf->add_biblio( $biblio->{biblionumber}, $loggedinuser ); };
if ($@) {
push @messages, { type => 'error', code => ref($@), msg => $@ };
} elsif ( $added ) {
push @messages, { type => 'message', code => 'success_on_add_biblio' };
} else {
push @messages, { type => 'message', code => 'error_on_add_biblio' };
}
} else {
push @messages, { type => 'error', code => 'unauthorized_on_add_biblio' };
}
} else {
push @messages, { type => 'error', code => 'item_does_not_exist' };
}
}
} else {
push @messages, { type => 'error', code => 'does_not_exist' };
}
$op = $referer;
} elsif ( $op eq 'remove_biblios' ) {
$shelfnumber = $query->param('shelfnumber');
$shelf = Koha::Virtualshelves->find($shelfnumber);
my @biblionumber = $query->param('biblionumber');
if ($shelf) {
if ( $shelf->can_biblios_be_removed( $loggedinuser ) ) {
my $number_of_biblios_removed = eval {
$shelf->remove_biblios(
{
biblionumbers => \@biblionumber,
borrowernumber => $loggedinuser,
}
);
};
if ($@) {
push @messages, { type => 'error', code => ref($@), msg => $@ };
} elsif ( $number_of_biblios_removed ) {
push @messages, { type => 'message', code => 'success_on_remove_biblios' };
} else {
push @messages, { type => 'error', code => 'no_biblio_removed' };
}
} else {
push @messages, { type => 'error', code => 'unauthorized_on_remove_biblios' };
}
} else {
push @messages, { type => 'error', code => 'does_not_exist' };
}
$op = 'view';
}
if ( $op eq 'view' ) {
$shelfnumber ||= $query->param('shelfnumber');
$shelf = Koha::Virtualshelves->find($shelfnumber);
if ( $shelf ) {
if ( $shelf->can_be_viewed( $loggedinuser ) ) {
$category = $shelf->category;
my $sortfield = $query->param('sortfield') || $shelf->sortfield; # Passed in sorting overrides default sorting
my $direction = $query->param('direction') || 'asc';
my ( $shelflimit, $shelfoffset, $itemoff );
unless ( $query->param('print') or $query->param('rss') ) {
$shelflimit = C4::Context->preference('OPACnumSearchResults') || 20;
$itemoff = ( $query->param('itemoff') ? $query->param('itemoff') : 1 );
$shelfoffset = ( $itemoff - 1 ) * $shelflimit; # Sets the offset to begin retrieving items at
}
my ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield, $direction );
# get biblionumbers stored in the cart
my @cart_list;
if(my $cart_list = $query->cookie('bib_list')){
@cart_list = split(/\//, $cart_list);
}
my $borrower = GetMember( borrowernumber => $loggedinuser );
for my $this_item (@$items) {
my $biblionumber = $this_item->{biblionumber};
my $record = GetMarcBiblio($biblionumber);
if ( C4::Context->preference("OPACXSLTResultsDisplay") ) {
$this_item->{XSLTBloc} = XSLTParse4Display( $biblionumber, $record, "OPACXSLTResultsDisplay" );
}
my $marcflavour = C4::Context->preference("marcflavour");
$this_item->{'imageurl'} = getitemtypeinfo( $this_item->{'itemtype'}, 'intranet' )->{'imageurl'};
$this_item->{'coins'} = GetCOinSBiblio($record);
$this_item->{'subtitle'} = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $this_item->{'biblionumber'} ) );
$this_item->{'normalized_upc'} = GetNormalizedUPC( $record, $marcflavour );
$this_item->{'normalized_ean'} = GetNormalizedEAN( $record, $marcflavour );
$this_item->{'normalized_oclc'} = GetNormalizedOCLCNumber( $record, $marcflavour );
$this_item->{'normalized_isbn'} = GetNormalizedISBN( undef, $record, $marcflavour );
unless ( defined $this_item->{size} ) {
#TT has problems with size
$this_item->{size} = q||;
}
# Getting items infos for location display
my @items_infos = &GetItemsLocationInfo( $this_item->{'biblionumber'} );
$this_item->{'ITEM_RESULTS'} = \@items_infos;
if (C4::Context->preference('TagsEnabled') and C4::Context->preference('TagsShowOnList')) {
$this_item->{TagLoop} = get_tags({
biblionumber=>$this_item->{'biblionumber'}, approved=>1, 'sort'=>'-weight',
limit => C4::Context->preference('TagsShowOnList'),
});
}
$this_item->{allow_onshelf_holds} = C4::Reserves::OnShelfHoldsAllowed($this_item, $borrower);
if ( grep {$_ eq $biblionumber} @cart_list) {
$this_item->{incart} = 1;
}
if ( $query->param('rss') ) {
$this_item->{title} = $content->biblionumber->title;
$this_item->{author} = $content->biblionumber->author;
$this_item->{biblionumber} = $biblionumber;
}
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),
can_add_biblios => $shelf->can_biblios_be_added($loggedinuser),
sortfield => $sortfield,
itemsloop => $items,
sortfield => $sortfield,
direction => $direction,
);
if ($shelflimit) {
$template->param(
pagination_bar => pagination_bar(
q||, ( int( $totitems / $shelflimit ) ) + ( ( $totitems % $shelflimit ) > 0 ? 1 : 0 ),
$itemoff, "itemoff", { op => 'view', shelfnumber => $shelf->shelfnumber, sortfield => $sortfield, direction => $direction, }
),
);
}
} else {
push @messages, { type => 'error', code => 'unauthorized_on_view' };
}
} else {
push @messages, { type => 'error', code => 'does_not_exist' };
}
}
if ( $op eq 'list' ) {
my $shelves;
my ( $page, $rows ) = ( $query->param('page') || 1, 20 );
if ( $category == 1 ) {
$shelves = Koha::Virtualshelves->get_private_shelves({ page => $page, rows => $rows, borrowernumber => $loggedinuser, });
} else {
$shelves = Koha::Virtualshelves->get_public_shelves({ page => $page, rows => $rows, });
}
my $pager = $shelves->pager;
$template->param(
shelves => $shelves,
pagination_bar => pagination_bar(
q||, $pager->last_page - $pager->first_page + 1,
$page, "page", { op => 'list', category => $category, }
),
);
}
$template->param(
op => $op,
referer => $referer,
shelf => $shelf,
messages => \@messages,
category => $category,
print => $query->param('print') || 0,
listsview => 1,
print => $query->param('print')
);
shelfpage('opac', $query, $template, $loggedinuser, $cookie);
output_html_with_http_headers $query, $cookie, $template->output;

View file

@ -1,7 +1,7 @@
#!/usr/bin/perl
use Modern::Perl;
use Test::More tests => 4;
use Test::More tests => 5;
use DateTime::Duration;
use C4::Context;
@ -14,10 +14,7 @@ use t::lib::TestBuilder;
my $dbh = C4::Context->dbh;
$dbh->{AutoCommit} = 0;
$dbh->do(q|DELETE FROM virtualshelfshares|);
$dbh->do(q|DELETE FROM virtualshelfcontents|);
$dbh->do(q|DELETE FROM virtualshelves|);
teardown();
my $builder = t::lib::TestBuilder->new;
@ -81,6 +78,8 @@ subtest 'CRUD' => sub {
is( $is_deleted, 1, 'The shelf has been deleted correctly' );
$number_of_shelves = Koha::Virtualshelves->search->count;
is( $number_of_shelves, 1, 'To be sure the shelf has been deleted' );
teardown();
};
subtest 'Sharing' => sub {
@ -149,6 +148,8 @@ subtest 'Sharing' => sub {
is( $shelf_to_share->remove_share( $share_with_me->{borrowernumber} ), 1, '1 share should have been removed if the shelf was shared with this patron' );
$number_of_shelves_shared = Koha::Virtualshelfshares->search->count;
is( $number_of_shelves_shared, 1, 'To be sure the share has been removed' );
teardown();
};
subtest 'Shelf content' => sub {
@ -235,6 +236,8 @@ subtest 'Shelf content' => sub {
is( $number_of_deleted_biblios, 1, );
$number_of_contents = Koha::Virtualshelfcontents->search->count;
is( $number_of_contents, 1, 'The biblio should have been deleted to the shelf by the patron 2, even if it is not his own content (allow_delete_other=1)' );
teardown();
};
subtest 'Shelf permissions' => sub {
@ -340,4 +343,67 @@ subtest 'Shelf permissions' => sub {
is( $private_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 1, 'The owner should be able to remove biblios to his list' );
is( $private_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 1, 'Private list could be modified (remove) by someone else # individual check done later' );
teardown();
};
subtest 'Get shelves' => sub {
plan tests => 4;
my $patron1 = $builder->build({
source => 'Borrower',
});
my $patron2 = $builder->build({
source => 'Borrower',
});
my $private_shelf1_1 = Koha::Virtualshelf->new({
shelfname => "private shelf 1 for patron 1",
owner => $patron1->{borrowernumber},
category => 1,
}
)->store;
my $private_shelf1_2 = Koha::Virtualshelf->new({
shelfname => "private shelf 2 for patron 1",
owner => $patron1->{borrowernumber},
category => 1,
}
)->store;
my $private_shelf2_1 = Koha::Virtualshelf->new({
shelfname => "private shelf 1 for patron 2",
owner => $patron2->{borrowernumber},
category => 1,
}
)->store;
my $public_shelf1_1 = Koha::Virtualshelf->new({
shelfname => "public shelf 1 for patron 1",
owner => $patron1->{borrowernumber},
category => 2,
}
)->store;
my $public_shelf1_2 = Koha::Virtualshelf->new({
shelfname => "public shelf 2 for patron 1",
owner => $patron1->{borrowernumber},
category => 2,
}
)->store;
my $private_shelves = Koha::Virtualshelves->get_private_shelves;
is( $private_shelves->count, 0, 'Without borrowernumber given, get_private_shelves should not return any shelf' );
$private_shelves = Koha::Virtualshelves->get_private_shelves({ borrowernumber => $patron1->{borrowernumber} });
is( $private_shelves->count, 2, 'get_private_shelves should return all shelves for a given patron' );
$private_shelf2_1->share('a key')->accept('a key', $patron1->{borrowernumber});
$private_shelves = Koha::Virtualshelves->get_private_shelves({ borrowernumber => $patron1->{borrowernumber} });
is( $private_shelves->count, 3, 'get_private_shelves should return all shelves for a given patron, even the shared ones' );
my $public_shelves = Koha::Virtualshelves->get_public_shelves;
is( $public_shelves->count, 2, 'get_public_shelves should return all public shelves, no matter who is the owner' );
teardown();
};
sub teardown {
$dbh->do(q|DELETE FROM virtualshelfshares|);
$dbh->do(q|DELETE FROM virtualshelfcontents|);
$dbh->do(q|DELETE FROM virtualshelves|);
}