File:  [LON-CAPA] / loncom / auth / londatecheck.pm
Revision 1.3: download - view: text, annotated - select for diffs
Mon Jun 28 16:26:55 2004 UTC (19 years, 10 months ago) by albertel
Branches: MAIN
CVS tags: version_1_1_99_5, version_1_1_99_4, version_1_1_99_3, version_1_1_99_2, version_1_1_99_1, HEAD
- BUG#3133

    1: # Checks contentopen/close settings disable subsequent PerlHandlers if not open
    2: # $Id: londatecheck.pm,v 1.3 2004/06/28 16:26:55 albertel 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: 
   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:     my $close=&Apache::lonnet::EXT('resource.0.contentclose',$symb);
   36:     if ( (defined($open)  && $open  ne '' && time < $open) ||
   37: 	 (defined($close) && $close ne '' && time > $close)) {
   38: 	return ('CLOSED',$open,$close);
   39:     }
   40:     return ('OPEN',$open,$close);
   41: }
   42: 
   43: sub handler {
   44:     my ($r)=@_;
   45:     my ($status)=&content_date_check();
   46:     if ($status ne 'OPEN') {
   47: 	$r->set_handlers('PerlHandler'=>undef);
   48: 	&Apache::loncommon::content_type($r,'text/html');
   49: 	$r->send_http_header;
   50: 	return OK if $r->header_only;
   51: 	$r->print('<html><head><title>Go Away!</title>');
   52: 	my $addentries=' onLoad="'.&Apache::lonmenu::loadevents().
   53: 	    '" onUnload="'.&Apache::lonmenu::unloadevents().'"';
   54: 	$r->print(&Apache::lonmenu::registerurl(1));
   55: 	$r->print('</head>'.
   56: 		  &Apache::loncommon::bodytag('Go Away!','',$addentries,'','',
   57: 					      undef));
   58: 	$r->print('</body></html>');
   59: 	$r->print("Go Away!");
   60:     }
   61:     return OK;
   62: }
   63: 1;

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