Lines 63-100
unless ($atomicUpdater->find('Bug14540')) {
Link Here
|
63 |
$dbh->do("INSERT INTO permissions (module, code, description) VALUES ('staffaccess', 'staff_access_permissions', 'Allow staff members to modify permissions for other staff members.');"); |
63 |
$dbh->do("INSERT INTO permissions (module, code, description) VALUES ('staffaccess', 'staff_access_permissions', 'Allow staff members to modify permissions for other staff members.');"); |
64 |
|
64 |
|
65 |
##Create borrower_permissions to replace singular userflags from borrowers.flags. |
65 |
##Create borrower_permissions to replace singular userflags from borrowers.flags. |
|
|
66 |
my $sthSelectSubPermissions = $dbh->prepare("SELECT * FROM permissions p LEFT JOIN permission_modules pm ON p.module = pm.module WHERE pm.permission_module_id = ?"); |
67 |
my $sthSelectBorrowerPermission = $dbh->prepare("SELECT * FROM borrower_permissions WHERE permission_id = ? AND borrowernumber = ?"); |
68 |
my $sthInsertBorrowerPermission = $dbh->prepare("INSERT INTO borrower_permissions (borrowernumber, permission_module_id, permission_id) VALUES (?,?,?)"); |
69 |
sub grantAllSubpermissions { |
70 |
my ($borrowernumber, $module_id, $dbh) = @_; |
71 |
|
72 |
$sthSelectSubPermissions->execute($module_id); |
73 |
my $subPermissions = $sthSelectSubPermissions->fetchall_arrayref({}); |
74 |
foreach my $sp (@$subPermissions) { |
75 |
$sthSelectBorrowerPermission->execute($sp->{permission_id}, $borrowernumber); |
76 |
my $alreadyPermission = $sthSelectBorrowerPermission->fetchrow_hashref(); |
77 |
unless ($alreadyPermission) { |
78 |
$sthInsertBorrowerPermission->execute($borrowernumber, $sp->{permission_module_id}, $sp->{permission_id}); |
79 |
} |
80 |
} |
81 |
} |
82 |
|
66 |
my $sthSelectAllBorrowers = $dbh->prepare("SELECT * FROM borrowers;"); |
83 |
my $sthSelectAllBorrowers = $dbh->prepare("SELECT * FROM borrowers;"); |
67 |
my $sth = $dbh->prepare(" |
|
|
68 |
INSERT INTO borrower_permissions (borrowernumber, permission_module_id, permission_id) |
69 |
VALUES (?, |
70 |
(SELECT permission_module_id FROM permission_modules WHERE module = ?), |
71 |
(SELECT permission_id FROM permissions WHERE code = ?) |
72 |
); |
73 |
"); |
74 |
$sthSelectAllBorrowers->execute(); |
84 |
$sthSelectAllBorrowers->execute(); |
75 |
my $borrowers = $sthSelectAllBorrowers->fetchall_arrayref({}); |
85 |
my $borrowers = $sthSelectAllBorrowers->fetchall_arrayref({}); |
76 |
foreach my $b (@$borrowers) { |
86 |
foreach my $b (@$borrowers) { |
77 |
next unless $b->{flags}; |
87 |
next unless $b->{flags}; |
78 |
if ( ( $b->{flags} & ( 2**0 ) ) ) { |
88 |
if ( ( $b->{flags} & ( 2**0 ) ) ) { |
79 |
$sth->execute($b->{borrowernumber}, 'superlibrarian', 'superlibrarian'); |
89 |
grantAllSubpermissions($b->{borrowernumber}, 21, $dbh); #superlibrarian |
|
|
90 |
} |
91 |
if ( ( $b->{flags} & ( 2**1 ) ) ) { |
92 |
grantAllSubpermissions($b->{borrowernumber}, 1, $dbh); #circulate |
80 |
} |
93 |
} |
81 |
if ( ( $b->{flags} & ( 2**2 ) ) ) { |
94 |
if ( ( $b->{flags} & ( 2**2 ) ) ) { |
82 |
$sth->execute($b->{borrowernumber}, 'catalogue', 'staff_login'); |
95 |
grantAllSubpermissions($b->{borrowernumber}, 2, $dbh); #catalogue |
|
|
96 |
} |
97 |
if ( ( $b->{flags} & ( 2**3 ) ) ) { |
98 |
grantAllSubpermissions($b->{borrowernumber}, 3, $dbh); #parameters, should be deprecated already |
83 |
} |
99 |
} |
84 |
if ( ( $b->{flags} & ( 2**4 ) ) ) { |
100 |
if ( ( $b->{flags} & ( 2**4 ) ) ) { |
85 |
$sth->execute($b->{borrowernumber}, 'borrowers', 'view_borrowers'); |
101 |
grantAllSubpermissions($b->{borrowernumber}, 4, $dbh); #borrowers |
86 |
} |
102 |
} |
87 |
if ( ( $b->{flags} & ( 2**5 ) ) ) { |
103 |
if ( ( $b->{flags} & ( 2**5 ) ) ) { |
88 |
$sth->execute($b->{borrowernumber}, 'permissions', 'set_permissions'); |
104 |
grantAllSubpermissions($b->{borrowernumber}, 5, $dbh); #permissions |
|
|
105 |
} |
106 |
if ( ( $b->{flags} & ( 2**6 ) ) ) { |
107 |
grantAllSubpermissions($b->{borrowernumber}, 6, $dbh); #reserveforothers |
108 |
} |
109 |
# if ( ( $b->{flags} & ( 2**7 ) ) ) { |
110 |
# grantAllSubpermissions($b->{borrowernumber}, 7, $dbh); #borrow, should be deprecated already |
111 |
# } |
112 |
if ( ( $b->{flags} & ( 2**9 ) ) ) { |
113 |
grantAllSubpermissions($b->{borrowernumber}, 9, $dbh); #editcatalogue |
114 |
} |
115 |
if ( ( $b->{flags} & ( 2**10 ) ) ) { |
116 |
grantAllSubpermissions($b->{borrowernumber}, 10, $dbh); #updatecharges |
117 |
} |
118 |
if ( ( $b->{flags} & ( 2**11 ) ) ) { |
119 |
grantAllSubpermissions($b->{borrowernumber}, 11, $dbh); #acquisition |
89 |
} |
120 |
} |
90 |
if ( ( $b->{flags} & ( 2**12 ) ) ) { |
121 |
if ( ( $b->{flags} & ( 2**12 ) ) ) { |
91 |
$sth->execute($b->{borrowernumber}, 'management', 'management'); |
122 |
grantAllSubpermissions($b->{borrowernumber}, 12, $dbh); #management |
|
|
123 |
} |
124 |
if ( ( $b->{flags} & ( 2**13 ) ) ) { |
125 |
grantAllSubpermissions($b->{borrowernumber}, 13, $dbh); #tools |
92 |
} |
126 |
} |
93 |
if ( ( $b->{flags} & ( 2**14 ) ) ) { |
127 |
if ( ( $b->{flags} & ( 2**14 ) ) ) { |
94 |
$sth->execute($b->{borrowernumber}, 'editauthorities', 'edit_authorities'); |
128 |
grantAllSubpermissions($b->{borrowernumber}, 14, $dbh); #editauthorities |
|
|
129 |
} |
130 |
if ( ( $b->{flags} & ( 2**15 ) ) ) { |
131 |
grantAllSubpermissions($b->{borrowernumber}, 15, $dbh); #serials |
132 |
} |
133 |
if ( ( $b->{flags} & ( 2**16 ) ) ) { |
134 |
grantAllSubpermissions($b->{borrowernumber}, 16, $dbh); #reports |
95 |
} |
135 |
} |
96 |
if ( ( $b->{flags} & ( 2**17 ) ) ) { |
136 |
if ( ( $b->{flags} & ( 2**17 ) ) ) { |
97 |
$sth->execute($b->{borrowernumber}, 'staffaccess', 'staff_access_permissions'); |
137 |
grantAllSubpermissions($b->{borrowernumber}, 17, $dbh); #staffaccess |
|
|
138 |
} |
139 |
if ( ( $b->{flags} & ( 2**18 ) ) ) { |
140 |
grantAllSubpermissions($b->{borrowernumber}, 18, $dbh); #coursereserves |
141 |
} |
142 |
if ( ( $b->{flags} & ( 2**19 ) ) ) { |
143 |
grantAllSubpermissions($b->{borrowernumber}, 19, $dbh); #plugins |
98 |
} |
144 |
} |
99 |
} |
145 |
} |
100 |
|
146 |
|
101 |
- |
|
|