1 package Koha::Auth::Permissions;
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
24 Koha::Auth::Permissions - Class for setting up CAN_user_* permissions
30 =head3 get_authz_from_flags
34 sub get_authz_from_flags {
35 my ($class,$args) = @_;
36 my $flags = $args->{flags};
38 my $all_perms = C4::Auth::get_all_subpermissions();
39 if ($flags && $all_perms){
40 foreach my $module ( keys %$all_perms ) {
42 ( $flags->{superlibrarian} == 1 ) ||
43 ( defined($flags->{$module}) && $flags->{$module} == 1 )
45 foreach my $subperm ( keys %{ $all_perms->{$module} } ) {
46 $authz->{ "CAN_user_${module}_${subperm}" } = 1;
49 elsif ( ref( $flags->{$module} ) ){
50 foreach my $subperm ( keys %{ $flags->{$module} } ) {
51 $authz->{ "CAN_user_${module}_${subperm}" } = 1;
55 foreach my $module ( keys %$flags ) {
57 ( $flags->{superlibrarian} == 1 ) ||
58 ( $flags->{$module} == 1 ) ||
59 ( ref( $flags->{$module} ) )
61 $authz->{ "CAN_user_$module" } = 1;