Bug 25498: Add transfer button on intranet

Note: Adjusting shelves_results template too for not allowing delete
when you do not have delete_public_lists (or higher). If you are the
owner, you are allowed to edit or delete. But transfer specifically
needs edit_public_lists (or higher).

Note: Removed a few useless POD lines to make qa tools happy.

Test plan:
Check if you see the transfer button on public lists only when having
permission edit_public_lists (or higher). And never on private lists.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Marcel de Rooy 2022-06-09 12:59:43 +00:00 committed by Tomas Cohen Arazi
parent 7d65cd5db4
commit ad83180fb0
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
4 changed files with 24 additions and 8 deletions

View file

@ -531,6 +531,9 @@
},{
'name': 'template_path',
'value': 'virtualshelves/tables/shelves_results.tt',
},{
'name': 'allow_transfer',
'value': '[% allow_transfer | html %]',
},{
'name': 'shelfname_sorton',
'value': 'vs.shelfname',

View file

@ -46,7 +46,7 @@
[%~ action_block = action_block _ '<button class="editshelf btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</button>' ~%]
[%~ action_block = action_block _ '</form> ' ~%]
[%~ END ~%]
[%~ IF can_manage_shelf OR can_delete_shelf ~%]
[%~ IF can_delete_shelf ~%]
[%~ action_block = action_block _ ' <form action="shelves.pl" method="post">' ~%]
[%~ action_block = action_block _ '<input type="hidden" name="shelves" value="1" />' ~%]
[%~ action_block = action_block _ '<input type="hidden" name="op" value="delete" />' ~%]
@ -56,6 +56,16 @@
[%~ action_block = action_block _ '<button type="submit" class="deleteshelf btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</button>' ~%]
[%~ action_block = action_block _ '</form>' ~%]
[%~ END ~%]
[%~ IF public AND allow_transfer ~%]
[%~ action_block = action_block _ ' <form action="shelves.pl" method="post">' ~%]
[%~ action_block = action_block _ '<input type="hidden" name="shelves" value="1" />' ~%]
[%~ action_block = action_block _ '<input type="hidden" name="op" value="transfer" />' ~%]
[%~ action_block = action_block _ '<input type="hidden" name="shelfnumber" value="' _ shelfnumber _ '" />' ~%]
[%~ action_block = action_block _ '<input type="hidden" name="public" value="1" />' ~%]
[%~ action_block = action_block _ '<input type="hidden" name="referer" value="list" />' ~%]
[%~ action_block = action_block _ '<button type="submit" class="btn btn-default btn-xs"><i class="fa"></i> Transfer</button>' ~%]
[%~ action_block = action_block _ '</form>' ~%]
[%~ END ~%]
[%~ ELSE ~%]
[%~ SET action_block = 'None' ~%]
[%~ END ~%]

View file

@ -24,6 +24,7 @@ my $count = $input->param('count');
my $owner = $input->param('owner');
my $public = $input->param('public');
my $sortby = $input->param('sortby');
my $allow_transfer = $input->param('allow_transfer');
# variable information for DataTables (id)
my $sEcho = $input->param('sEcho');
@ -48,7 +49,9 @@ $template->param(
sEcho => $sEcho,
iTotalRecords => $results->{iTotalRecords},
iTotalDisplayRecords => $results->{iTotalDisplayRecords},
aaData => $results->{shelves}
aaData => $results->{shelves},
public => $public,
allow_transfer => $allow_transfer,
);
output_with_http_headers $input, $cookie, $template->output, 'json';
@ -63,10 +66,6 @@ search - a search script for finding virtual shelves
This script provides a service for template for virtual shelves search using DataTables
=cut
=back
=head1 LICENSE
Copyright 2014 BibLibre

View file

@ -19,9 +19,10 @@
use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Auth qw( get_template_and_user );
use C4::Auth qw( get_template_and_user haspermission );
use C4::Biblio qw( GetMarcBiblio );
use C4::Circulation qw( barcodedecode );
use C4::Context;
use C4::Koha qw(
GetNormalizedEAN
GetNormalizedISBN
@ -57,7 +58,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
my $op = $query->param('op') || 'list';
my $referer = $query->param('referer') || $op;
my $public = $query->param('public') ? 1 : 0;
my ( $shelf, $shelfnumber, @messages );
my ( $shelf, $shelfnumber, @messages, $allow_transfer );
if ( $op eq 'add_form' ) {
# Only pass default
@ -353,6 +354,8 @@ if ( $op eq 'view' ) {
} else {
push @messages, { type => 'alert', code => 'does_not_exist' };
}
} elsif( $op eq 'list' ) {
$allow_transfer = haspermission( C4::Context->userenv->{id}, { lists => 'edit_public_lists' } ) ? 1 : 0;
}
$template->param(
@ -363,6 +366,7 @@ $template->param(
public => $public,
print => scalar $query->param('print') || 0,
csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' })->as_list ],
allow_transfer => $allow_transfer,
);
output_html_with_http_headers $query, $cookie, $template->output;