Lines 31-58
my $input = new CGI;
Link Here
|
31 |
my $op = $input->param('op') || 'list'; |
31 |
my $op = $input->param('op') || 'list'; |
32 |
my @messages; |
32 |
my @messages; |
33 |
|
33 |
|
|
|
34 |
# The "view" view should be accessible for the user who create this job. |
35 |
my $flags_required = $op ne 'view' ? { parameters => 'manage_background_jobs' } : undef; |
36 |
|
34 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
37 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
35 |
{ |
38 |
{ |
36 |
template_name => "admin/background_jobs.tt", |
39 |
template_name => "admin/background_jobs.tt", |
37 |
query => $input, |
40 |
query => $input, |
38 |
type => "intranet", |
41 |
type => "intranet", |
39 |
authnotrequired => 0, |
42 |
authnotrequired => 0, |
40 |
flagsrequired => { parameters => 'manage_background_jobs' }, # Maybe the "view" view should be accessible for the user who create this job. |
43 |
flagsrequired => $flags_required, |
41 |
# But in that case what could the permission to check here? tools => '*' ? |
|
|
42 |
debug => 1, |
44 |
debug => 1, |
43 |
} |
45 |
} |
44 |
); |
46 |
); |
45 |
|
47 |
|
46 |
my $dbh = C4::Context->dbh; |
|
|
47 |
|
48 |
if ( $op eq 'view' ) { |
48 |
if ( $op eq 'view' ) { |
49 |
my $id = $input->param('id'); |
49 |
my $id = $input->param('id'); |
50 |
if ( my $job = Koha::BackgroundJobs->find($id) ) { |
50 |
if ( my $job = Koha::BackgroundJobs->find($id) ) { |
51 |
$template->param( |
51 |
if ( $job->borrowernumber ne $loggedinuser |
52 |
job => $job, |
52 |
&& !Koha::Patrons->find($loggedinuser)->has_permission( { parameters => 'manage_background_jobs' } ) ) |
53 |
); |
53 |
{ |
54 |
$template->param( lists => scalar Koha::Virtualshelves->search([{ category => 1, owner => $loggedinuser }, { category => 2 }]) ) |
54 |
push @messages, { code => 'cannot_view_job' }; |
55 |
if $job->type eq 'batch_biblio_record_modification'; |
55 |
} |
|
|
56 |
else { |
57 |
$template->param( job => $job, ); |
58 |
$template->param( |
59 |
lists => scalar Koha::Virtualshelves->search( |
60 |
[ |
61 |
{ category => 1, owner => $loggedinuser }, |
62 |
{ category => 2 } |
63 |
] |
64 |
) |
65 |
) if $job->type eq 'batch_biblio_record_modification'; |
66 |
} |
56 |
} else { |
67 |
} else { |
57 |
$op = 'list'; |
68 |
$op = 'list'; |
58 |
} |
69 |
} |