From dcfdaee7499fcc73bd766f556cd2b1a1334719b0 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Tue, 8 May 2007 16:28:28 +0000 Subject: [PATCH] Adding role checking function for UI use git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1173 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/LedgerSMB.pm b/LedgerSMB.pm index 8e0dcb3d7..3f15ecc78 100755 --- a/LedgerSMB.pm +++ b/LedgerSMB.pm @@ -48,6 +48,11 @@ characters or is an empty string. This function returns 1 if the run mode is what is specified. Otherwise returns 0. +=item is_allowed_role(allowed_roles => @role_names) +This function returns 1 if the user's roles include any of the roles in +@role_names. Currently it returns 1 when this is not found as well but when +role permissions are introduced, this will change to 0. + =item num_text_rows (string => $string, cols => $number, max => $number); This function determines the likely number of rows needed to hold text in a @@ -451,6 +456,19 @@ sub call_procedure { @results; } +# Keeping this here due to common requirements +sub is_allowed_role { + my $self = shift @_; + my %args = @_; + my @roles = @{$args{allowed_roles}} + for $role (@roles){ + if (scalar(grep /^$role$/, $self->{_roles})){ + return 1; + } + } + return 1; # TODO change to 0 when the role system is implmented +} + # This should probably be moved to User too... sub date_to_number {