[LON-CAPA-cvs] cvs: loncom / loncapa_apache.conf /auth londatecheck.pm

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 31 May 2004 20:24:11 -0000


albertel		Mon May 31 16:24:11 2004 EDT

  Added files:                 
    /loncom/auth	londatecheck.pm 

  Modified files:              
    /loncom	loncapa_apache.conf 
  Log:
  -n adding in functionality so that contentopne/close date settings are respected for html ish pages.
  
  
Index: loncom/loncapa_apache.conf
diff -u loncom/loncapa_apache.conf:1.80 loncom/loncapa_apache.conf:1.81
--- loncom/loncapa_apache.conf:1.80	Mon May 31 10:55:18 2004
+++ loncom/loncapa_apache.conf	Mon May 31 16:24:11 2004
@@ -1,7 +1,7 @@
 ##
 ## loncapa_apache.conf -- Apache HTTP LON-CAPA configuration file
 ##
-## $Id: loncapa_apache.conf,v 1.80 2004/05/31 14:55:18 albertel Exp $
+## $Id: loncapa_apache.conf,v 1.81 2004/05/31 20:24:11 albertel Exp $
 ##
 
 #
@@ -241,6 +241,7 @@
 
 <LocationMatch "^/+(uploaded|res|\~).*\.(xml|html|htm|xhtml|xhtm|sty)$">
 SetHandler perl-script
+PerlHandler Apache::londatecheck
 PerlHandler Apache::lonxml
 </LocationMatch>
 

Index: loncom/auth/londatecheck.pm
+++ loncom/auth/londatecheck.pm
use strict;
package Apache::londatecheck;
use Apache::lonnet();
use Apache::Constants qw(:common :http :methods);

sub content_date_check {
    my $symb=$ENV{'request.symb'};
    my $open=&Apache::lonnet::EXT('resource.0.contentopen',$symb);
    &Apache::lonnet::logthis("Hrrm got an open of $open");
    my $close=&Apache::lonnet::EXT('resource.0.contentclose',$symb);
    if ( (defined($open)  && time < $open) ||
	 (defined($close) && time > $close)) {
	return ('CLOSED',$open,$close);
    }
    return ('OPEN',$open,$close);
}

sub handler {
    my ($r)=@_;
    my ($status)=&content_date_check();
    if ($status ne 'OPEN') {
	$r->set_handlers('PerlHandler'=>undef);
	&Apache::loncommon::content_type($r,'text/html');
	$r->send_http_header;
	return OK if $r->header_only;
	$r->print('<html><head><title>Go Away!</title>');
	my $addentries=' onLoad="'.&Apache::lonmenu::loadevents().
	    '" onUnload="'.&Apache::lonmenu::unloadevents().'"';
	$r->print(&Apache::lonmenu::registerurl(1));
	$r->print('</head>'.
		  &Apache::loncommon::bodytag('Go Away!','',$addentries,'','',
					      undef));
	$r->print('</body></html>');
	$r->print("Go Away!");
    }
    return OK;
}
1;