[system] / trunk / webwork2 / lib / WeBWorK / Authz.pm Repository:
ViewVC logotype

View of /trunk/webwork2/lib/WeBWorK/Authz.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1663 - (download) (as text) (annotate)
Tue Dec 9 01:12:32 2003 UTC (9 years, 5 months ago) by sh002i
File size: 1856 byte(s)
Normalized headers. All files now contain the text below as a header.
This is important since all files now (a) use the full name of the
package, (b) assign copyright to "The WeBWorK Project", (c) give the
full path of the file (relative to CVSROOT) instead of simply the file
name, and (d) include license and warranty information.

Here is the new header:

################################################################################
# WeBWorK Online Homework Delivery System
# Copyright © 2000-2003 The WeBWorK Projcct, http://openwebwork.sf.net/
# $CVSHeader$
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of either: (a) the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any later
# version, or (b) the "Artistic License" which comes with this package.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See either the GNU General Public License or the
# Artistic License for more details.
################################################################################

    1 ################################################################################
    2 # WeBWorK Online Homework Delivery System
    3 # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/
    4 # $CVSHeader$
    5 #
    6 # This program is free software; you can redistribute it and/or modify it under
    7 # the terms of either: (a) the GNU General Public License as published by the
    8 # Free Software Foundation; either version 2, or (at your option) any later
    9 # version, or (b) the "Artistic License" which comes with this package.
   10 #
   11 # This program is distributed in the hope that it will be useful, but WITHOUT
   12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   13 # FOR A PARTICULAR PURPOSE.  See either the GNU General Public License or the
   14 # Artistic License for more details.
   15 ################################################################################
   16 
   17 package WeBWorK::Authz;
   18 
   19 =head1 NAME
   20 
   21 WeBWorK::Authz - check user permissions.
   22 
   23 =cut
   24 
   25 use strict;
   26 use warnings;
   27 
   28 # WeBWorK::Authz->new($r, $ce, $db)
   29 sub new($$$$) {
   30   my $invocant = shift;
   31   my $class = ref($invocant) || $invocant;
   32   my $self = {};
   33   ($self->{r}, $self->{ce}, $self->{db}) = @_;
   34   bless $self, $class;
   35   return $self;
   36 }
   37 
   38 # This currently only uses two of it's arguments, but it accepts any number, in
   39 # case in the future calculating certain permissions requires more information.
   40 sub hasPermissions {
   41   my ($self, $user, $activity) = @_;
   42   my $r = $self->{r};
   43   my $courseEnvironment = $self->{ce};
   44   my $permissionLevels = $courseEnvironment->{permissionLevels};
   45 
   46   my $Permission = $self->{db}->getPermissionLevel($user); # checked
   47   return 0 unless defined $Permission;
   48   my $permissionLevel = $Permission->permission();
   49   if (defined $permissionLevels->{$activity}
   50       and $permissionLevel >= $permissionLevels->{$activity}) {
   51     return 1;
   52   } else {
   53     return 0;
   54   }
   55 }
   56 
   57 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9