Annotation of loncom/auth/londatecheck.pm, revision 1.2
1.2 ! albertel 1: # Checks contentopen/close settings disable subsequent PerlHandlers if not open
! 2: # $Id: gplheader.pl,v 1.1 2001/11/29 18:19:27 www Exp $
! 3: #
! 4: # Copyright Michigan State University Board of Trustees
! 5: #
! 6: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
! 7: #
! 8: # LON-CAPA is free software; you can redistribute it and/or modify
! 9: # it under the terms of the GNU General Public License as published by
! 10: # the Free Software Foundation; either version 2 of the License, or
! 11: # (at your option) any later version.
! 12: #
! 13: # LON-CAPA is distributed in the hope that it will be useful,
! 14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
! 15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! 16: # GNU General Public License for more details.
! 17: #
! 18: # You should have received a copy of the GNU General Public License
! 19: # along with LON-CAPA; if not, write to the Free Software
! 20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! 21: #
! 22: # /home/httpd/html/adm/gpl.txt
! 23: #
! 24: # http://www.lon-capa.org/
! 25: #
! 26:
1.1 albertel 27: use strict;
28: package Apache::londatecheck;
29: use Apache::lonnet();
30: use Apache::Constants qw(:common :http :methods);
31:
32: sub content_date_check {
33: my $symb=$ENV{'request.symb'};
34: my $open=&Apache::lonnet::EXT('resource.0.contentopen',$symb);
35: &Apache::lonnet::logthis("Hrrm got an open of $open");
36: my $close=&Apache::lonnet::EXT('resource.0.contentclose',$symb);
1.2 ! albertel 37: if ( (defined($open) && $open ne '' && time < $open) ||
! 38: (defined($close) && $close ne '' && time > $close)) {
! 39: &Apache::lonnet::logthis(" returning CLOSED ");
1.1 albertel 40: return ('CLOSED',$open,$close);
41: }
42: return ('OPEN',$open,$close);
43: }
44:
45: sub handler {
46: my ($r)=@_;
47: my ($status)=&content_date_check();
48: if ($status ne 'OPEN') {
49: $r->set_handlers('PerlHandler'=>undef);
50: &Apache::loncommon::content_type($r,'text/html');
51: $r->send_http_header;
52: return OK if $r->header_only;
53: $r->print('<html><head><title>Go Away!</title>');
54: my $addentries=' onLoad="'.&Apache::lonmenu::loadevents().
55: '" onUnload="'.&Apache::lonmenu::unloadevents().'"';
56: $r->print(&Apache::lonmenu::registerurl(1));
57: $r->print('</head>'.
58: &Apache::loncommon::bodytag('Go Away!','',$addentries,'','',
59: undef));
60: $r->print('</body></html>');
61: $r->print("Go Away!");
62: }
63: return OK;
64: }
65: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>