From df7d11432f94b506e98302f0b66a10961e0c0e93 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sun, 4 Aug 2019 21:28:24 -0500 Subject: [PATCH] Bug 15522: Fix permission name manage_circ_rules_from_any_libraries On 15520 followups have been provided to not use a negative permission. Note that two api tests are failing (get 400). I would like some help to investigate here why 400 is returned instead of 403. --- Koha/REST/V1/CirculationRules.pm | 2 +- admin/policy.pl | 2 +- t/db_dependent/api/v1/circ_rules.t | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Koha/REST/V1/CirculationRules.pm b/Koha/REST/V1/CirculationRules.pm index f0ad6c41cd..b38ee1196d 100644 --- a/Koha/REST/V1/CirculationRules.pm +++ b/Koha/REST/V1/CirculationRules.pm @@ -52,7 +52,7 @@ sub save_rules { my $schema = Koha::Database->new->schema; my $uid = $c->stash( 'koha.user' )->userid; - my $restricted_to_library = $uid && haspermission( $uid, { parameters => 'manage_circ_rules_restricted' }, { no_inherit => 1 } ) ? $c->stash( 'koha.user' )->branchcode : ""; + my $restricted_to_library = $uid && haspermission( $uid, { parameters => 'manage_circ_rules_from_any_libraries' } ) ? "" : $c->stash( 'koha.user' )->branchcode; return try { my $rules = $c->req->json; diff --git a/admin/policy.pl b/admin/policy.pl index c6c771460b..f10a12296d 100755 --- a/admin/policy.pl +++ b/admin/policy.pl @@ -41,7 +41,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( ); my $uid = Koha::Patrons->find( $borrowernumber )->userid; -my $restricted_to_own_library = $uid && haspermission( $uid, { parameters => 'manage_circ_rules_restricted' }, { no_inherit => 1 } ); +my $restricted_to_own_library = !( $uid && haspermission( $uid, { parameters => 'manage_circ_rules_from_any_libraries' } ) ); $template->param( restricted_to_library => $restricted_to_own_library ? C4::Context::mybranch() : "" ); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/t/db_dependent/api/v1/circ_rules.t b/t/db_dependent/api/v1/circ_rules.t index 688395644e..47b5317f44 100644 --- a/t/db_dependent/api/v1/circ_rules.t +++ b/t/db_dependent/api/v1/circ_rules.t @@ -253,11 +253,11 @@ sub create_user_and_session { $session->param( 'lasttime', time() ); $session->flush; - if ( $args->{permissions} eq 'authorized_restricted' ) { + if ( $args->{permissions} ne 'authorized_restricted' ) { $dbh->do( q{ INSERT INTO user_permissions (borrowernumber,module_bit,code) - VALUES (?,3,'manage_circ_rules_restricted'), (?,3,'manage_circ_rules')}, + VALUES (?,3,'manage_circ_rules_from_any_libraries'), (?,3,'manage_circ_rules')}, undef, $user->{borrowernumber}, $user->{borrowernumber} ); } -- 2.11.0