[system] / branches / rel-2-4-patches / webwork2 / lib / WeBWorK / Authz.pm Repository:
ViewVC logotype

Annotation of /branches/rel-2-4-patches/webwork2/lib/WeBWorK/Authz.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 682 - (view) (download) (as text)
Original Path: trunk/webwork2/lib/WeBWorK/Authz.pm

1 : sh002i 455 ################################################################################
2 : sh002i 494 # WeBWorK mod_perl (c) 2000-2002 WeBWorK Project
3 : sh002i 455 # $Id$
4 :     ################################################################################
5 :    
6 : malsyned 390 package WeBWorK::Authz;
7 :    
8 : sh002i 455 =head1 NAME
9 :    
10 :     WeBWorK::Authz - check user permissions.
11 :    
12 :     =cut
13 :    
14 : malsyned 441 use strict;
15 :     use warnings;
16 : malsyned 390 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->{courseEnvironment}) = @_;
23 :     bless $self, $class;
24 :     return $self;
25 :     }
26 :    
27 : malsyned 676 # 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 : malsyned 390 sub hasPermissions {
30 :     my ($self, $user, $activity) = @_;
31 :     my $r = $self->{r};
32 :     my $courseEnvironment = $self->{courseEnvironment};
33 : sh002i 682 my $permissionLevels = $courseEnvironment->{permissionLevels};
34 : malsyned 390 my $auth = WeBWorK::DB::Auth->new($courseEnvironment);
35 :    
36 :     my $permissionLevel = $auth->getPermissions($user);
37 : sh002i 682 if (defined $permissionLevels->{$activity}
38 :     and $permissionLevel >= $permissionLevels->{$activity}) {
39 : malsyned 390 return 1;
40 :     } else {return 0;}
41 :     }
42 :    
43 :     1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9