[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 924 - (download) (as text) (annotate)
Wed May 28 01:38:55 2003 UTC (9 years, 11 months ago) by malsyned
File size: 1120 byte(s)
Added a helpful comment to Authz
Fixed bug #15 in hardcopy
Gave ProblemSetList the proper db calls, now that SQL databases are
working.
-Dennis

    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 # WeBWorK::Authz->new($r, $ce, $db)
   18 sub new($$$$) {
   19   my $invocant = shift;
   20   my $class = ref($invocant) || $invocant;
   21   my $self = {};
   22   ($self->{r}, $self->{ce}, $self->{db}) = @_;
   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 
   35   my $permissionLevel = $self->{db}->getPermissionLevel($user)->permission();
   36   if (defined $permissionLevels->{$activity}
   37       and $permissionLevel >= $permissionLevels->{$activity}) {
   38     return 1;
   39   } else {
   40     return 0;
   41   }
   42 }
   43 
   44 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9