[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [1173] trunk/LedgerSMB.pm



Revision: 1173
          http://svn.sourceforge.net/ledger-smb/?rev=1173&view=rev
Author:   einhverfr
Date:     2007-05-08 09:28:28 -0700 (Tue, 08 May 2007)

Log Message:
-----------
Adding role checking function for UI use

Modified Paths:
--------------
    trunk/LedgerSMB.pm

Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm	2007-05-08 16:06:22 UTC (rev 1172)
+++ trunk/LedgerSMB.pm	2007-05-08 16:28:28 UTC (rev 1173)
@@ -48,6 +48,11 @@
 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
..hidden..  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 @@
     @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 {
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.