summaryrefslogtreecommitdiff
path: root/LedgerSMB.pm
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-05-08 16:28:28 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-05-08 16:28:28 +0000
commitdcfdaee7499fcc73bd766f556cd2b1a1334719b0 (patch)
treeff3dd4f72ffa9acebb443262d64b5ab1e957c327 /LedgerSMB.pm
parent2aa92462c19709880a4dc629aa5e7c3a59ed89f6 (diff)
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
Diffstat (limited to 'LedgerSMB.pm')
-rwxr-xr-xLedgerSMB.pm18
1 files changed, 18 insertions, 0 deletions
diff --git a/LedgerSMB.pm b/LedgerSMB.pm
index 8e0dcb3d..3f15ecc7 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 {