File:  [LON-CAPA] / loncom / auth / blockedaccess.pm
Revision 1.4: download - view: text, annotated - select for diffs
Sat Mar 31 23:10:47 2012 UTC (12 years ago) by raeburn
Branches: MAIN
CVS tags: version_2_11_2_uiuc, version_2_11_2_educog, version_2_11_2, version_2_11_1, version_2_11_0_RC3, version_2_11_0_RC2, version_2_11_0_RC1, version_2_11_0, HEAD
- Bug 6518
  - Exam blocks can also block access to specified folders and/or resources
    for the duration of an exam.
  - Start time for blocking can be based on activation of the timer for
    a specific timed quiz item (map or resource-specific). End time for
    blocking is then start time plus the duration of the timed interval.

lonnet.pm:
  - &rolesinit() now returns an array containing references to hashes
    for the following: userroles, firstaccenv, timerintenv.
  - New db file: timerinterval.db contains interval which applied when
    user activated timer for a map or resource for which time limit applied.
    - needed to determine end time for exam blocks which are triggered by
      timer activation.
   - New routine &get_comm_blocks() used to get communication/collaboration
     blocks from a course.  Now cached for 10 minutes in memcached.
   - New routine: &has_comm_blocking() used to determine if exam block
     applies to display of requested content item in a course. Used by
     &allowed().
   - new routine: &check_docs_block() used by &has_comm_blocking().

loncommon.pm:
   - new items added to user's environment by &init_user_environment()
      - $env{'course.courseid.firstaccess.symb'} and
        $env{'course.courseid.timerinterval.symb'} where symb is the symb
        of the resource or map which provides the activation-based block
        for access to specific content.

blockedaccess.pm:
  - now called when access to content is blocked by an exam block.
    duration, and setter of block now available in pop-up from:
    &loncommon::blocking_status() for this type of access control.

# The LearningOnline Network
# Information about blocking status for Portfolio files
#
# $Id: blockedaccess.pm,v 1.4 2012/03/31 23:10:47 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA 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 the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#

package Apache::blockedaccess;

use strict;
use Apache::Constants qw(:common :http REDIRECT);
use Apache::lonnet;
use Apache::loncommon();
use Apache::lonlocal;

sub handler {
    my $r = shift;
    &Apache::loncommon::content_type($r,'text/html');
    $r->send_http_header;
    return OK if $r->header_only;

    &Apache::lonlocal::get_language_handle($r);
    my $origurl = $r->uri;
    my ($blocked,$blocktext);

    if (&Apache::lonnet::is_portfolio_url($origurl)) {
        my ($type,$udom,$uname,$file_name,$group) = 
	    &Apache::lonnet::parse_portfolio_url($origurl);
        ($blocked,$blocktext) = 
            &Apache::loncommon::blocking_status('port',$uname,$udom);
    } else {
        if ($env{'request.course.id'}) {
            my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
            my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
            ($blocked,$blocktext) =
                &Apache::loncommon::blocking_status('docs',$cnum,$cdom,$origurl);
        }
    }
    if ($blocked) {
        $r->print(&Apache::loncommon::start_page('Access Temporarily Blocked'));
        $r->print($blocktext);
    } else {
        my $server = &Apache::lonnet::absolute_url();
        $r->header_out(Location => $server.$origurl);
        return REDIRECT;
    }
    $r->print(&Apache::loncommon::end_page());
    return OK;
}

sub setup_handler {
    my ($r) = @_;
    $r->set_handlers('PerlHandler'=>
                     [\&Apache::blockedaccess::handler]);
    $r->handler('perl-script');
}

1;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>