From c40eb1ca41cd33388960544ce8e2ed492b875de9 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 3 Aug 2020 10:12:40 +0200 Subject: [PATCH] Bug 22417: Let owner of a job see the progress A owner of a job should be able to see the progress of this job. Signed-off-by: David Cook Signed-off-by: Marcel de Rooy --- admin/background_jobs.pl | 29 +++++++++++++------ .../prog/en/modules/admin/background_jobs.tt | 8 +++-- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/admin/background_jobs.pl b/admin/background_jobs.pl index 9e08c70605..e97f908151 100755 --- a/admin/background_jobs.pl +++ b/admin/background_jobs.pl @@ -31,28 +31,39 @@ my $input = new CGI; my $op = $input->param('op') || 'list'; my @messages; +# The "view" view should be accessible for the user who create this job. +my $flags_required = $op ne 'view' ? { parameters => 'manage_background_jobs' } : undef; + my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { template_name => "admin/background_jobs.tt", query => $input, type => "intranet", authnotrequired => 0, - flagsrequired => { parameters => 'manage_background_jobs' }, # Maybe the "view" view should be accessible for the user who create this job. - # But in that case what could the permission to check here? tools => '*' ? + flagsrequired => $flags_required, debug => 1, } ); -my $dbh = C4::Context->dbh; - if ( $op eq 'view' ) { my $id = $input->param('id'); if ( my $job = Koha::BackgroundJobs->find($id) ) { - $template->param( - job => $job, - ); - $template->param( lists => scalar Koha::Virtualshelves->search([{ category => 1, owner => $loggedinuser }, { category => 2 }]) ) - if $job->type eq 'batch_biblio_record_modification'; + if ( $job->borrowernumber ne $loggedinuser + && !Koha::Patrons->find($loggedinuser)->has_permission( { parameters => 'manage_background_jobs' } ) ) + { + push @messages, { code => 'cannot_view_job' }; + } + else { + $template->param( job => $job, ); + $template->param( + lists => scalar Koha::Virtualshelves->search( + [ + { category => 1, owner => $loggedinuser }, + { category => 2 } + ] + ) + ) if $job->type eq 'batch_biblio_record_modification'; + } } else { $op = 'list'; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt index 4949d958f1..920e33f159 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt @@ -12,7 +12,7 @@
@@ -25,6 +25,8 @@ [% SWITCH m.code %] [% CASE 'cannot_retrieve_jobs' %]
Cannot retrieve pending jobs ([% m.error %])
+ [% CASE 'cannot_view_job' %] +
Insufficient permission to see this job.
[% CASE %] [% m.code | html %] [% END %] @@ -132,7 +134,9 @@ - Return to the job list + [% IF CAN_user_parameters_manage_background_jobs %] + Return to the job list + [% END %] [% END %] [% IF op == 'list' %] -- 2.20.1