[LON-CAPA-cvs] cvs: loncom / loncapa_apache.conf /auth blockedaccess.pm lonacc.pm publiccheck.pm /lonnet/perl lonnet.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Mon, 11 Dec 2006 14:06:09 -0000
raeburn Mon Dec 11 09:06:09 2006 EDT
Added files:
/loncom/auth blockedaccess.pm
Modified files:
/loncom/auth lonacc.pm publiccheck.pm
/loncom/lonnet/perl lonnet.pm
/loncom loncapa_apache.conf
Log:
Add response code of 'B' to lonnet::allowed() to indicate access to a file is currently subject to a block, because the file owner is part of a course with active communications blocking, and file viewer does not have 'evb' privilege in the course to nullify the block.
Used to block access to portfolio files. Response of 'B' triggers blockedaccess.pm which displays information about blocking conditions.
Index: loncom/auth/lonacc.pm
diff -u loncom/auth/lonacc.pm:1.102 loncom/auth/lonacc.pm:1.103
--- loncom/auth/lonacc.pm:1.102 Wed Nov 22 20:49:41 2006
+++ loncom/auth/lonacc.pm Mon Dec 11 09:06:04 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Cookie Based Access Handler
#
-# $Id: lonacc.pm,v 1.102 2006/11/23 01:49:41 albertel Exp $
+# $Id: lonacc.pm,v 1.103 2006/12/11 14:06:04 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,6 +36,7 @@
use Apache::loncommon();
use Apache::lonlocal;
use Apache::restrictedaccess();
+use Apache::blockedaccess();
use CGI::Cookie();
use Fcntl qw(:flock);
use LONCAPA;
@@ -256,6 +257,10 @@
&Apache::restrictedaccess::setup_handler($r);
return OK;
}
+ if ($access eq 'B') {
+ &Apache::blockedaccess::setup_handler($r);
+ return OK;
+ }
if (($access ne '2') && ($access ne 'F')) {
$env{'user.error.msg'}="$requrl:bre:1:1:Access Denied";
return HTTP_NOT_ACCEPTABLE;
Index: loncom/auth/publiccheck.pm
diff -u loncom/auth/publiccheck.pm:1.11 loncom/auth/publiccheck.pm:1.12
--- loncom/auth/publiccheck.pm:1.11 Wed Nov 22 20:49:41 2006
+++ loncom/auth/publiccheck.pm Mon Dec 11 09:06:04 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Cookie Based Access Handler
#
-# $Id: publiccheck.pm,v 1.11 2006/11/23 01:49:41 albertel Exp $
+# $Id: publiccheck.pm,v 1.12 2006/12/11 14:06:04 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -72,6 +72,9 @@
} elsif ($requrl eq '/adm/restrictedaccess') {
&process_public($r,$requrl);
return OK;
+ } elsif ($requrl eq '/adm/blockedaccess') {
+ &process_public($r,$requrl);
+ return OK;
}
return DECLINED;
}
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.813 loncom/lonnet/perl/lonnet.pm:1.814
--- loncom/lonnet/perl/lonnet.pm:1.813 Sat Dec 9 18:33:56 2006
+++ loncom/lonnet/perl/lonnet.pm Mon Dec 11 09:06:05 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.813 2006/12/09 23:33:56 albertel Exp $
+# $Id: lonnet.pm,v 1.814 2006/12/11 14:06:05 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3303,6 +3303,22 @@
my ($requrl) = @_;
my (undef,$udom,$unum,$file_name,$group) = &parse_portfolio_url($requrl);
my $result = &get_portfolio_access($udom,$unum,$file_name,$group);
+ if ($result) {
+ my %setters;
+ if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') {
+ my ($startblock,$endblock) =
+ &Apache::loncommon::blockcheck(\%setters,'port',$unum,$udom);
+ if ($startblock && $endblock) {
+ return 'B';
+ }
+ } else {
+ my ($startblock,$endblock) =
+ &Apache::loncommon::blockcheck(\%setters,'port');
+ if ($startblock && $endblock) {
+ return 'B';
+ }
+ }
+ }
if ($result eq 'ok') {
return 'F';
} elsif ($result =~ /^[^:]+:guest_/) {
@@ -3583,7 +3599,14 @@
my ($space,$domain,$name,@dir)=split('/',$uri);
if (($space=~/^(uploaded|editupload)$/) && ($env{'user.name'} eq $name) &&
($env{'user.domain'} eq $domain) && ('portfolio' eq $dir[0])) {
- return 'F';
+ my %setters;
+ my ($startblock,$endblock) =
+ &Apache::loncommon::blockcheck(\%setters,'port');
+ if ($startblock && $endblock) {
+ return 'B';
+ } else {
+ return 'F';
+ }
}
# bre access to group portfolio for rgf priv in group, or mdg or vcg in course.
@@ -3859,6 +3882,8 @@
unless ($env{'request.course.id'}) {
if ($thisallowed eq 'A') {
return 'A';
+ } elsif ($thisallowed eq 'B') {
+ return 'B';
} else {
return '1';
}
@@ -3926,6 +3951,8 @@
if ($thisallowed eq 'A') {
return 'A';
+ } elsif ($thisallowed eq 'B') {
+ return 'B';
}
return 'F';
}
Index: loncom/loncapa_apache.conf
diff -u loncom/loncapa_apache.conf:1.161 loncom/loncapa_apache.conf:1.162
--- loncom/loncapa_apache.conf:1.161 Thu Nov 9 21:06:54 2006
+++ loncom/loncapa_apache.conf Mon Dec 11 09:06:06 2006
@@ -1,7 +1,7 @@
##
## loncapa_apache.conf -- Apache HTTP LON-CAPA configuration file
##
-## $Id: loncapa_apache.conf,v 1.161 2006/11/10 02:06:54 raeburn Exp $
+## $Id: loncapa_apache.conf,v 1.162 2006/12/11 14:06:06 raeburn Exp $
##
#
@@ -516,6 +516,16 @@
ErrorDocument 500 /adm/errorhandler
</Location>
+<Location /adm/blockedaccess>
+PerlAccessHandler Apache::publiccheck
+AuthType LONCAPA
+Require valid-user
+SetHandler perl-script
+PerlAuthzHandler Apache::lonacc
+PerlHandler Apache::blockedaccess
+ErrorDocument 500 /adm/errorhandler
+</Location>
+
<Location /adm/logout>
AuthType LONCAPA
Require valid-user
Index: loncom/auth/blockedaccess.pm
+++ loncom/auth/blockedaccess.pm
# The LearningOnline Network
# Information about blocking status for Portfolio files
#
# 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 lib '/home/httpd/lib/perl/';
use Apache::Constants qw(:common :http REDIRECT);
use Apache::lonnet;
use Apache::loncommon();
use Apache::lonlocal;
sub handler {
my $r = shift;
my $origurl = $r->uri;
my ($type,$udom,$uname,$file_name,$group) =
&Apache::lonnet::parse_portfolio_url($origurl);
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
return OK if $r->header_only;
&Apache::lonlocal::get_language_handle($r);
my ($blocked,$blocktext) =
&Apache::loncommon::blocking_status('port',$uname,$udom);
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;