[system] / trunk / webwork-modperl / lib / WeBWorK / Authz.pm Repository:
ViewVC logotype

View of /trunk/webwork-modperl/lib/WeBWorK/Authz.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 817 - (download) (as text) (annotate)
Wed Apr 23 06:39:03 2003 UTC (10 years, 1 month ago) by sh002i
File size: 1084 byte(s)
rewrote these modules to use the WWDBv2 library. rewrote the Authen.pm
verify function to (hopefully) be more readable.
-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 
   17 sub new($$$$) {
   18   my $invocant = shift;
   19   my $class = ref($invocant) || $invocant;
   20   my $self = {};
   21   ($self->{r}, $self->{ce}, $self->{db}) = @_;
   22   bless $self, $class;
   23   return $self;
   24 }
   25 
   26 # This currently only uses two of it's arguments, but it accepts any number, in
   27 # case in the future calculating certain permissions requires more information.
   28 sub hasPermissions {
   29   my ($self, $user, $activity) = @_;
   30   my $r = $self->{r};
   31   my $courseEnvironment = $self->{ce};
   32   my $permissionLevels = $courseEnvironment->{permissionLevels};
   33 
   34   my $permissionLevel = $self->{db}->getPermissionLevel($user)->permission();
   35   if (defined $permissionLevels->{$activity}
   36       and $permissionLevel >= $permissionLevels->{$activity}) {
   37     return 1;
   38   } else {
   39     return 0;
   40   }
   41 }
   42 
   43 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9