Annotation of loncom/auth/londatecheck.pm, revision 1.3

1.2       albertel    1: # Checks contentopen/close settings disable subsequent PerlHandlers if not open
1.3     ! albertel    2: # $Id: londatecheck.pm,v 1.2 2004/06/01 14:40:59 albertel Exp $
1.2       albertel    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:     my $close=&Apache::lonnet::EXT('resource.0.contentclose',$symb);
1.2       albertel   36:     if ( (defined($open)  && $open  ne '' && time < $open) ||
                     37: 	 (defined($close) && $close ne '' && time > $close)) {
1.1       albertel   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>