Bugzilla – Attachment 42550 Details for
Bug 14540
Move member-flags.pl to PermissionsManager to better manage permissions for testing.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14540 - PermissionManager - Hotfix check_api_auth, remove flags.
Bug-14540---PermissionManager---Hotfix-checkapiaut.patch (text/plain), 6.79 KB, created by
Olli-Antti Kivilahti
on 2015-09-15 09:14:47 UTC
(
hide
)
Description:
Bug 14540 - PermissionManager - Hotfix check_api_auth, remove flags.
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2015-09-15 09:14:47 UTC
Size:
6.79 KB
patch
obsolete
>From e83c5a186ee99ad8660e9cf196bd3f95593d1595 Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Tue, 15 Sep 2015 12:14:14 +0300 >Subject: [PATCH] Bug 14540 - PermissionManager - Hotfix check_api_auth, remove > flags. > >--- > C4/Auth.pm | 2 +- > .../atomicupdate/Bug14540-PermissionManager.pl | 74 ++++++++++++++++++---- > 2 files changed, 61 insertions(+), 15 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index b996ff1..54bc798 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -1565,7 +1565,7 @@ sub check_api_auth { > > unless ( $sth->rows ) { > my $sth = $dbh->prepare( >-"select borrowernumber, firstname, surname, flags, borrowers.branchcode, branches.branchname as branchname, branches.branchprinter as branchprinter, email from borrowers left join branches on borrowers.branchcode=branches.branchcode where cardnumber=?" >+"select borrowernumber, firstname, surname, borrowers.branchcode, branches.branchname as branchname, branches.branchprinter as branchprinter, email from borrowers left join branches on borrowers.branchcode=branches.branchcode where cardnumber=?" > ); > $sth->execute($cardnumber); > ( >diff --git a/installer/data/mysql/atomicupdate/Bug14540-PermissionManager.pl b/installer/data/mysql/atomicupdate/Bug14540-PermissionManager.pl >index 74b4c0a..17dd34a 100644 >--- a/installer/data/mysql/atomicupdate/Bug14540-PermissionManager.pl >+++ b/installer/data/mysql/atomicupdate/Bug14540-PermissionManager.pl >@@ -63,38 +63,84 @@ unless ($atomicUpdater->find('Bug14540')) { > $dbh->do("INSERT INTO permissions (module, code, description) VALUES ('staffaccess', 'staff_access_permissions', 'Allow staff members to modify permissions for other staff members.');"); > > ##Create borrower_permissions to replace singular userflags from borrowers.flags. >+ my $sthSelectSubPermissions = $dbh->prepare("SELECT * FROM permissions p LEFT JOIN permission_modules pm ON p.module = pm.module WHERE pm.permission_module_id = ?"); >+ my $sthSelectBorrowerPermission = $dbh->prepare("SELECT * FROM borrower_permissions WHERE permission_id = ? AND borrowernumber = ?"); >+ my $sthInsertBorrowerPermission = $dbh->prepare("INSERT INTO borrower_permissions (borrowernumber, permission_module_id, permission_id) VALUES (?,?,?)"); >+ sub grantAllSubpermissions { >+ my ($borrowernumber, $module_id, $dbh) = @_; >+ >+ $sthSelectSubPermissions->execute($module_id); >+ my $subPermissions = $sthSelectSubPermissions->fetchall_arrayref({}); >+ foreach my $sp (@$subPermissions) { >+ $sthSelectBorrowerPermission->execute($sp->{permission_id}, $borrowernumber); >+ my $alreadyPermission = $sthSelectBorrowerPermission->fetchrow_hashref(); >+ unless ($alreadyPermission) { >+ $sthInsertBorrowerPermission->execute($borrowernumber, $sp->{permission_module_id}, $sp->{permission_id}); >+ } >+ } >+ } >+ > my $sthSelectAllBorrowers = $dbh->prepare("SELECT * FROM borrowers;"); >- my $sth = $dbh->prepare(" >- INSERT INTO borrower_permissions (borrowernumber, permission_module_id, permission_id) >- VALUES (?, >- (SELECT permission_module_id FROM permission_modules WHERE module = ?), >- (SELECT permission_id FROM permissions WHERE code = ?) >- ); >- "); > $sthSelectAllBorrowers->execute(); > my $borrowers = $sthSelectAllBorrowers->fetchall_arrayref({}); > foreach my $b (@$borrowers) { > next unless $b->{flags}; > if ( ( $b->{flags} & ( 2**0 ) ) ) { >- $sth->execute($b->{borrowernumber}, 'superlibrarian', 'superlibrarian'); >+ grantAllSubpermissions($b->{borrowernumber}, 21, $dbh); #superlibrarian >+ } >+ if ( ( $b->{flags} & ( 2**1 ) ) ) { >+ grantAllSubpermissions($b->{borrowernumber}, 1, $dbh); #circulate > } > if ( ( $b->{flags} & ( 2**2 ) ) ) { >- $sth->execute($b->{borrowernumber}, 'catalogue', 'staff_login'); >+ grantAllSubpermissions($b->{borrowernumber}, 2, $dbh); #catalogue >+ } >+ if ( ( $b->{flags} & ( 2**3 ) ) ) { >+ grantAllSubpermissions($b->{borrowernumber}, 3, $dbh); #parameters, should be deprecated already > } > if ( ( $b->{flags} & ( 2**4 ) ) ) { >- $sth->execute($b->{borrowernumber}, 'borrowers', 'view_borrowers'); >+ grantAllSubpermissions($b->{borrowernumber}, 4, $dbh); #borrowers > } > if ( ( $b->{flags} & ( 2**5 ) ) ) { >- $sth->execute($b->{borrowernumber}, 'permissions', 'set_permissions'); >+ grantAllSubpermissions($b->{borrowernumber}, 5, $dbh); #permissions >+ } >+ if ( ( $b->{flags} & ( 2**6 ) ) ) { >+ grantAllSubpermissions($b->{borrowernumber}, 6, $dbh); #reserveforothers >+ } >+# if ( ( $b->{flags} & ( 2**7 ) ) ) { >+# grantAllSubpermissions($b->{borrowernumber}, 7, $dbh); #borrow, should be deprecated already >+# } >+ if ( ( $b->{flags} & ( 2**9 ) ) ) { >+ grantAllSubpermissions($b->{borrowernumber}, 9, $dbh); #editcatalogue >+ } >+ if ( ( $b->{flags} & ( 2**10 ) ) ) { >+ grantAllSubpermissions($b->{borrowernumber}, 10, $dbh); #updatecharges >+ } >+ if ( ( $b->{flags} & ( 2**11 ) ) ) { >+ grantAllSubpermissions($b->{borrowernumber}, 11, $dbh); #acquisition > } > if ( ( $b->{flags} & ( 2**12 ) ) ) { >- $sth->execute($b->{borrowernumber}, 'management', 'management'); >+ grantAllSubpermissions($b->{borrowernumber}, 12, $dbh); #management >+ } >+ if ( ( $b->{flags} & ( 2**13 ) ) ) { >+ grantAllSubpermissions($b->{borrowernumber}, 13, $dbh); #tools > } > if ( ( $b->{flags} & ( 2**14 ) ) ) { >- $sth->execute($b->{borrowernumber}, 'editauthorities', 'edit_authorities'); >+ grantAllSubpermissions($b->{borrowernumber}, 14, $dbh); #editauthorities >+ } >+ if ( ( $b->{flags} & ( 2**15 ) ) ) { >+ grantAllSubpermissions($b->{borrowernumber}, 15, $dbh); #serials >+ } >+ if ( ( $b->{flags} & ( 2**16 ) ) ) { >+ grantAllSubpermissions($b->{borrowernumber}, 16, $dbh); #reports > } > if ( ( $b->{flags} & ( 2**17 ) ) ) { >- $sth->execute($b->{borrowernumber}, 'staffaccess', 'staff_access_permissions'); >+ grantAllSubpermissions($b->{borrowernumber}, 17, $dbh); #staffaccess >+ } >+ if ( ( $b->{flags} & ( 2**18 ) ) ) { >+ grantAllSubpermissions($b->{borrowernumber}, 18, $dbh); #coursereserves >+ } >+ if ( ( $b->{flags} & ( 2**19 ) ) ) { >+ grantAllSubpermissions($b->{borrowernumber}, 19, $dbh); #plugins > } > } > >-- >1.9.1
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 14540
:
41030
|
41051
|
41055
|
41056
|
41059
|
41062
|
41071
|
41123
|
41158
|
41255
|
41258
|
41310
|
41402
|
41535
|
42390
|
42410
|
42432
|
42434
|
42550
|
44490
|
63252
|
63253
|
63254