Bugzilla – Attachment 126439 Details for
Bug 29020
Missing Background jobs link in admin-home
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29020: Add link on the mainpage for users without admin access
Bug-29020-Add-link-on-the-mainpage-for-users-witho.patch (text/plain), 6.40 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-10-18 15:06:33 UTC
(
hide
)
Description:
Bug 29020: Add link on the mainpage for users without admin access
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-10-18 15:06:33 UTC
Size:
6.40 KB
patch
obsolete
>From d6cb8ab7e0e859bebdca7e82c48d503deda6c4fd Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 8 Oct 2021 15:53:02 +0200 >Subject: [PATCH] Bug 29020: Add link on the mainpage for users without admin > access > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > admin/background_jobs.pl | 28 ++++++++++++++----- > .../prog/en/modules/intranet-main.tt | 8 +++++- > mainpage.pl | 9 ++++++ > 3 files changed, 37 insertions(+), 8 deletions(-) > >diff --git a/admin/background_jobs.pl b/admin/background_jobs.pl >index 4dadcc1784..8a27c00a27 100755 >--- a/admin/background_jobs.pl >+++ b/admin/background_jobs.pl >@@ -29,23 +29,24 @@ my $input = CGI->new; > 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", >- flagsrequired => $flags_required, >+ flagsrequired => { catalogue => 1 }, > } > ); > >+my $logged_in_user = Koha::Patrons->find($loggedinuser); >+my $can_manage_background_jobs = >+ $logged_in_user->has_permission( { parameters => 'manage_background_jobs' } ); >+ > if ( $op eq 'view' ) { > my $id = $input->param('id'); > if ( my $job = Koha::BackgroundJobs->find($id) ) { > if ( $job->borrowernumber ne $loggedinuser >- && !Koha::Patrons->find($loggedinuser)->has_permission( { parameters => 'manage_background_jobs' } ) ) >+ && !$can_manage_background_jobs ) > { > push @messages, { code => 'cannot_view_job' }; > } >@@ -61,15 +62,28 @@ if ( $op eq 'view' ) { > > if ( $op eq 'cancel' ) { > my $id = $input->param('id'); >- if ( my $job = Koha::BackgroundJobs->find($id) ) { # FIXME Make sure logged in user can cancel this job >+ my $job = Koha::BackgroundJobs->find($id); >+ if ( $can_manage_background_jobs >+ || $job->borrowernumber eq $logged_in_user->borrowernumber ) >+ { > $job->cancel; > } >+ else { >+ push @messages, { code => 'cannot_cancel_job' }; >+ } > $op = 'list'; > } > > > if ( $op eq 'list' ) { >- my $jobs = Koha::BackgroundJobs->search({}, { order_by => { -desc => 'enqueued_on' }}); >+ my $jobs = >+ $can_manage_background_jobs >+ ? Koha::BackgroundJobs->search( {}, >+ { order_by => { -desc => 'enqueued_on' } } ) >+ : Koha::BackgroundJobs->search( >+ { borrowernumber => $logged_in_user->borrowernumber }, >+ { order_by => { -desc => 'enqueued_on' } } >+ ); > $template->param( jobs => $jobs ); > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt >index b97e4d4801..cf7f0300e3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt >@@ -165,7 +165,7 @@ > <div class="row"> > <div class="col-sm-12"> > [%# Following statement must be in one line for translatability %] >- [% IF ( CAN_user_tools_moderate_comments && pendingcomments ) || ( CAN_user_tools_moderate_tags && pendingtags ) || ( CAN_user_borrowers_edit_borrowers && pending_borrower_modifications ) || ( CAN_user_suggestions_suggestions_manage && pendingsuggestions ) || ( CAN_user_borrowers_edit_borrowers && pending_discharge_requests ) || pending_article_requests || ( Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes && pending_checkout_notes.count ) || ( Koha.Preference('OPACReportProblem') && CAN_user_problem_reports && pending_problem_reports.count ) %] >+ [% IF ( CAN_user_tools_moderate_comments && pendingcomments ) || ( CAN_user_tools_moderate_tags && pendingtags ) || ( CAN_user_borrowers_edit_borrowers && pending_borrower_modifications ) || ( CAN_user_suggestions_suggestions_manage && pendingsuggestions ) || ( CAN_user_borrowers_edit_borrowers && pending_discharge_requests ) || pending_article_requests || ( Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes && pending_checkout_notes.count ) || ( Koha.Preference('OPACReportProblem') && CAN_user_problem_reports && pending_problem_reports.count ) || already_ran_jobs %] > <div id="area-pending"> > [% IF pending_article_requests %] > <div class="pending-info" id="article_requests_pending"> >@@ -234,6 +234,12 @@ > </div> > [% END %] > >+ [% IF already_ran_jobs %] >+ <div class="pending-info" id="background_jobs"> >+ <a href="/cgi-bin/koha/admin/background_jobs.pl">Access your background jobs</a> >+ </div> >+ [% END %] >+ > </div> > > [% END %] >diff --git a/mainpage.pl b/mainpage.pl >index ab7089c8f3..6972d39871 100755 >--- a/mainpage.pl >+++ b/mainpage.pl >@@ -33,6 +33,7 @@ use Koha::ArticleRequests; > use Koha::ProblemReports; > use Koha::Quotes; > use Koha::Suggestions; >+use Koha::BackgroundJobs; > > my $query = CGI->new; > >@@ -45,6 +46,8 @@ my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( > } > ); > >+my $logged_in_user = Koha::Patrons->find($loggedinuser); >+ > my $homebranch; > if (C4::Context->userenv) { > $homebranch = C4::Context->userenv->{'branch'}; >@@ -99,6 +102,12 @@ my $pending_article_requests = Koha::ArticleRequests->search_limited( > )->count; > my $pending_problem_reports = Koha::ProblemReports->search({ status => 'New' }); > >+unless ( $logged_in_user->has_permission( { parameters => 'manage_background_jobs' } ) ) { >+ my $already_ran_jobs = Koha::BackgroundJobs->search( >+ { borrowernumber => $logged_in_user->borrowernumber } )->count ? 1 : 0; >+ $template->param( already_ran_jobs => $already_ran_jobs ); >+} >+ > $template->param( > pendingcomments => $pendingcomments, > pendingtags => $pendingtags, >-- >2.32.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29020
:
125964
|
125965
|
125980
|
125981
|
125982
| 126439 |
126440