Parent Directory
|
Revision Log
changed the name of the "courseEnvironment" field in the ContentGenerator object to "ce", to match the style and conciesness of the existing "r" and new "db" fields. -sam
1 ################################################################################ 2 # WeBWorK mod_perl (c) 2000-2002 WeBWorK Project 3 # $Id$ 4 ################################################################################ 5 6 package WeBWorK::Authz; 7 8 =head1 NAME 9 10 WeBWorK::Authz - check user permissions. 11 12 =cut 13 14 use strict; 15 use warnings; 16 use WeBWorK::DB::Auth; 17 18 sub new($$$) { 19 my $invocant = shift; 20 my $class = ref($invocant) || $invocant; 21 my $self = {}; 22 ($self->{r}, $self->{ce}) = @_; 23 bless $self, $class; 24 return $self; 25 } 26 27 # This currently only uses two of it's arguments, but it accepts any number, in 28 # case in the future calculating certain permissions requires more information. 29 sub hasPermissions { 30 my ($self, $user, $activity) = @_; 31 my $r = $self->{r}; 32 my $courseEnvironment = $self->{ce}; 33 my $permissionLevels = $courseEnvironment->{permissionLevels}; 34 my $auth = WeBWorK::DB::Auth->new($courseEnvironment); 35 36 my $permissionLevel = $auth->getPermissions($user); 37 if (defined $permissionLevels->{$activity} 38 and $permissionLevel >= $permissionLevels->{$activity}) { 39 return 1; 40 } else {return 0;} 41 } 42 43 1;
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |