From ad83180fb071bfb3f1c3d9c223e455a19ca81adb Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 9 Jun 2022 12:59:43 +0000 Subject: [PATCH] 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 Signed-off-by: Owen Leonard Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- .../prog/en/modules/virtualshelves/shelves.tt | 3 +++ .../modules/virtualshelves/tables/shelves_results.tt | 12 +++++++++++- svc/virtualshelves/search | 9 ++++----- virtualshelves/shelves.pl | 8 ++++++-- 4 files changed, 24 insertions(+), 8 deletions(-) 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 3fa48ea555..01879ae345 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt @@ -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', diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt index fa89225653..8e5a4c24d6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt @@ -46,7 +46,7 @@ [%~ action_block = action_block _ '' ~%] [%~ action_block = action_block _ ' ' ~%] [%~ END ~%] - [%~ IF can_manage_shelf OR can_delete_shelf ~%] + [%~ IF can_delete_shelf ~%] [%~ action_block = action_block _ '
' ~%] [%~ action_block = action_block _ '' ~%] [%~ action_block = action_block _ '' ~%] @@ -56,6 +56,16 @@ [%~ action_block = action_block _ '' ~%] [%~ action_block = action_block _ '
' ~%] [%~ END ~%] + [%~ IF public AND allow_transfer ~%] + [%~ action_block = action_block _ '
' ~%] + [%~ action_block = action_block _ '' ~%] + [%~ action_block = action_block _ '' ~%] + [%~ action_block = action_block _ '' ~%] + [%~ action_block = action_block _ '' ~%] + [%~ action_block = action_block _ '' ~%] + [%~ action_block = action_block _ '' ~%] + [%~ action_block = action_block _ '
' ~%] + [%~ END ~%] [%~ ELSE ~%] [%~ SET action_block = 'None' ~%] [%~ END ~%] diff --git a/svc/virtualshelves/search b/svc/virtualshelves/search index d2b0cb5a76..5d172562fe 100755 --- a/svc/virtualshelves/search +++ b/svc/virtualshelves/search @@ -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 diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl index 66947f925b..4ea540c507 100755 --- a/virtualshelves/shelves.pl +++ b/virtualshelves/shelves.pl @@ -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; -- 2.39.5