Lines 2031-2047
sub get_all_subpermissions {
Link Here
|
2031 |
|
2031 |
|
2032 |
=head2 haspermission |
2032 |
=head2 haspermission |
2033 |
|
2033 |
|
2034 |
$flags = ($userid, $flagsrequired); |
2034 |
$flags = ( $userid, $flagsrequired[, { no_inherit => 1 } ] ); |
2035 |
|
2035 |
|
2036 |
C<$userid> the userid of the member |
2036 |
C<$userid> the userid of the member |
2037 |
C<$flags> is a hashref of required flags like C<$borrower-<{authflags}> |
2037 |
C<$flags> is a hashref of required flags like C<$borrower-<{authflags}> |
|
|
2038 |
C<no_inherit>, if true, means that this function will not return true if |
2039 |
$flagsrequired is { module => 'sub_perm' } and the user only has { module => 1 }. |
2040 |
This is useful for *_restricted permissions. |
2038 |
|
2041 |
|
2039 |
Returns member's flags or 0 if a permission is not met. |
2042 |
Returns member's flags or 0 if a permission is not met. |
2040 |
|
2043 |
|
2041 |
=cut |
2044 |
=cut |
2042 |
|
2045 |
|
2043 |
sub haspermission { |
2046 |
sub haspermission { |
2044 |
my ( $userid, $flagsrequired ) = @_; |
2047 |
my ( $userid, $flagsrequired, $options ) = @_; |
2045 |
my $sth = C4::Context->dbh->prepare("SELECT flags FROM borrowers WHERE userid=?"); |
2048 |
my $sth = C4::Context->dbh->prepare("SELECT flags FROM borrowers WHERE userid=?"); |
2046 |
$sth->execute($userid); |
2049 |
$sth->execute($userid); |
2047 |
my $row = $sth->fetchrow(); |
2050 |
my $row = $sth->fetchrow(); |
Lines 2057-2063
sub haspermission {
Link Here
|
2057 |
$flags->{'superlibrarian'} = 1; |
2060 |
$flags->{'superlibrarian'} = 1; |
2058 |
} |
2061 |
} |
2059 |
|
2062 |
|
2060 |
return $flags if $flags->{superlibrarian}; |
2063 |
return $flags if $flags->{superlibrarian} && !$options->{no_inherit}; |
2061 |
|
2064 |
|
2062 |
foreach my $module ( keys %$flagsrequired ) { |
2065 |
foreach my $module ( keys %$flagsrequired ) { |
2063 |
my $subperm = $flagsrequired->{$module}; |
2066 |
my $subperm = $flagsrequired->{$module}; |
Lines 2066-2072
sub haspermission {
Link Here
|
2066 |
} else { |
2069 |
} else { |
2067 |
return 0 unless ( |
2070 |
return 0 unless ( |
2068 |
( defined $flags->{$module} and |
2071 |
( defined $flags->{$module} and |
2069 |
$flags->{$module} == 1 ) |
2072 |
$flags->{$module} == 1 and |
|
|
2073 |
!$options->{no_inherit} ) |
2070 |
or |
2074 |
or |
2071 |
( ref( $flags->{$module} ) and |
2075 |
( ref( $flags->{$module} ) and |
2072 |
exists $flags->{$module}->{$subperm} and |
2076 |
exists $flags->{$module}->{$subperm} and |