Bugzilla – Attachment 83415 Details for
Bug 22031
C4::Auth->haspermission should allow checking for more than one subpermission
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22031: Adjust haspermission to take an array
Bug-22031-Adjust-haspermission-to-take-an-array.patch (text/plain), 2.05 KB, created by
Nick Clemens (kidclamp)
on 2018-12-20 13:43:27 UTC
(
hide
)
Description:
Bug 22031: Adjust haspermission to take an array
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2018-12-20 13:43:27 UTC
Size:
2.05 KB
patch
obsolete
>From 7365aa2b131a236aade6b3149343e82f2c38ebf7 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 20 Dec 2018 13:42:08 +0000 >Subject: [PATCH] Bug 22031: Adjust haspermission to take an array > >To test: >1 - Apply this patch on top of unit tests >2 - Unit tests now pass >3 - Ensure you can use Koha as before with no regressions >--- > C4/Auth.pm | 31 +++++++++++++++++++------------ > 1 file changed, 19 insertions(+), 12 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index b19197b35b..6dbe7eed1d 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -2039,20 +2039,27 @@ sub haspermission { > my $flags = getuserflags( $row, $userid ); > > return $flags if $flags->{superlibrarian}; >- > foreach my $module ( keys %$flagsrequired ) { >- my $subperm = $flagsrequired->{$module}; >- if ( $subperm eq '*' ) { >- return 0 unless ( $flags->{$module} == 1 or ref( $flags->{$module} ) ); >+ my $subperms = $flagsrequired->{$module}; >+ my @sub_loop; >+ if ( ref($subperms) eq 'ARRAY' ) { >+ @sub_loop = @$subperms; > } else { >- return 0 unless ( >- ( defined $flags->{$module} and >- $flags->{$module} == 1 ) >- or >- ( ref( $flags->{$module} ) and >- exists $flags->{$module}->{$subperm} and >- $flags->{$module}->{$subperm} == 1 ) >- ); >+ push @sub_loop, $subperms; >+ } >+ foreach my $subperm (@sub_loop){ >+ if ( $subperm eq '*' ) { >+ return 0 unless ( $flags->{$module} == 1 or ref( $flags->{$module} ) ); >+ } else { >+ return 0 unless ( >+ ( defined $flags->{$module} and >+ $flags->{$module} == 1 ) >+ or >+ ( ref( $flags->{$module} ) and >+ exists $flags->{$module}->{$subperm} and >+ $flags->{$module}->{$subperm} == 1 ) >+ ); >+ } > } > } > return $flags; >-- >2.11.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 22031
:
83414
|
83415
|
83474
|
86197
|
86204