version 1.3, 2004/06/28 16:26:55
|
version 1.10, 2005/04/25 21:40:33
|
Line 26
|
Line 26
|
|
|
use strict; |
use strict; |
package Apache::londatecheck; |
package Apache::londatecheck; |
use Apache::lonnet(); |
use Apache::lonnet; |
|
use Apache::lonlocal; |
use Apache::Constants qw(:common :http :methods); |
use Apache::Constants qw(:common :http :methods); |
|
|
sub content_date_check { |
sub content_date_check { |
my $symb=$ENV{'request.symb'}; |
my $symb=$env{'request.symb'}; |
my $open=&Apache::lonnet::EXT('resource.0.contentopen',$symb); |
my $open=&Apache::lonnet::EXT('resource.0.contentopen',$symb); |
my $close=&Apache::lonnet::EXT('resource.0.contentclose',$symb); |
my $close=&Apache::lonnet::EXT('resource.0.contentclose',$symb); |
if ( (defined($open) && $open ne '' && time < $open) || |
if ( (defined($open) && $open ne '' && time < $open) ) { |
(defined($close) && $close ne '' && time > $close)) { |
return ('CLOSED',$open,$close, |
return ('CLOSED',$open,$close); |
'<h1>'.&mt('Not open to be viewed').'</h1>'. |
|
&mt("This resource currently isn't open. ". |
|
"It will be available at [_1].", |
|
&Apache::lonlocal::locallocaltime($open))); |
|
} |
|
if ( (defined($close) && $close ne '' && time > $close) ) { |
|
return ('CLOSED',$open,$close, |
|
'<h1>'.&mt('Not open to be viewed').'</h1>'. |
|
&mt("This resource is no longer available to be viewed.")); |
} |
} |
return ('OPEN',$open,$close); |
return ('OPEN',$open,$close); |
} |
} |
|
|
sub handler { |
sub handler { |
my ($r)=@_; |
my ($r)=@_; |
my ($status)=&content_date_check(); |
if (&Apache::lonnet::allowed('bre',$r->uri) eq 'F') { |
|
return DECLINED; |
|
} |
|
my ($status,$open,$close,$msg)=&content_date_check(); |
if ($status ne 'OPEN') { |
if ($status ne 'OPEN') { |
$r->set_handlers('PerlHandler'=>undef); |
$r->set_handlers('PerlHandler'=>undef); |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
return OK if $r->header_only; |
return OK if $r->header_only; |
$r->print('<html><head><title>Go Away!</title>'); |
my $html=&Apache::lonxml::xmlbegin(); |
|
$r->print($html.'<head><title>'.&mt("Not Open").'</title>'); |
my $addentries=' onLoad="'.&Apache::lonmenu::loadevents(). |
my $addentries=' onLoad="'.&Apache::lonmenu::loadevents(). |
'" onUnload="'.&Apache::lonmenu::unloadevents().'"'; |
'" onUnload="'.&Apache::lonmenu::unloadevents().'"'; |
$r->print(&Apache::lonmenu::registerurl(1)); |
$r->print(&Apache::lonmenu::registerurl(1)); |
$r->print('</head>'. |
$r->print('</head>'.&Apache::structuretags::body_tag_start('web')); |
&Apache::loncommon::bodytag('Go Away!','',$addentries,'','', |
$r->print($msg); |
undef)); |
$r->print(&Apache::lonxml::xmlend().'</html>'); |
$r->print('</body></html>'); |
return OK; |
$r->print("Go Away!"); |
|
} |
} |
return OK; |
return DECLINED; |
} |
} |
1; |
1; |