--- loncom/interface/lonchatfetch.pm 2009/02/25 18:44:29 1.34
+++ loncom/interface/lonchatfetch.pm 2021/11/30 15:55:37 1.40
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Chat Fetching
#
-# $Id: lonchatfetch.pm,v 1.34 2009/02/25 18:44:29 bisitz Exp $
+# $Id: lonchatfetch.pm,v 1.40 2021/11/30 15:55:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -63,19 +63,12 @@ sub handler {
''.&unescape($group_info{description}).
'
';
}
- } elsif (! &Apache::lonnet::allowed('pch',$env{'request.course.id'}.
+ } elsif (! &Apache::lonnet::allowed('plc',$env{'request.course.id'}.
($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
) {
return HTTP_NOT_ACCEPTABLE;
}
- my $loaderror=&Apache::lonnet::overloaderror($r);
- if ($loaderror) { return $loaderror; }
- $loaderror=
- &Apache::lonnet::overloaderror($r,
- $env{'course.'.$env{'request.course.id'}.'.home'});
- if ($loaderror) { return $loaderror; }
-
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
return OK if $r->header_only;
@@ -128,10 +121,16 @@ sub handler {
$contrib=&unescape($contrib);
&Apache::lonfeedback::newline_to_br(\$contrib);
($contrib,my $errors)=&Apache::lontexconvert::msgtexconverted($contrib);
- if ($errors) { $contrib.=&mt('[Message not fully displayed due to incorrect embedded TeX]'); }
+ if ($errors) {
+ $contrib.=' '
+ .&mt('(Message not fully displayed due to incorrect embedded TeX.)')
+ .'';
+ }
if ($errors && $snum eq $env{'user.name'} &&
$sdom eq $env{'user.domain'} ) {
- $contrib.='
'.&mt('[TeX error message: [_1]',$errors);
+ $contrib.='
'
+ .&mt('TeX error message: [_1]',$errors)
+ .'';
}
$contrib=~s/\n/ /g;
$contrib=~s/\'/\&\#39\;/g;
@@ -163,9 +162,9 @@ sub handler {
$color=substr($color,0,6);
my $timestamp=localtime($msgtime);
my ($mhour,$mmin,$msec)=($timestamp=~/(\d\d)\:(\d\d)\:(\d\d)/);
- $newstuff.=''.
+ $newstuff.=''.
$sender.' ('.$mhour.':'.$mmin.':'.$msec.'): '.
- $contrib."
";
+ $contrib."
";
$bottomid='LC_'.$id;
} else {
$entry=~/^(\w+)/;
@@ -178,10 +177,17 @@ sub handler {
$refresh_cmd .= "&group=$group";
}
my $headarg;
- my ($blocked,$blocktext) = &blockstatus();
+ my $clientip = &Apache::lonnet::get_requestor_ip($r);
+ my ($blocked,$blocktext) = &blockstatus($clientip);
if ($blocked) {
$newstuff = $blocktext;
$headarg = {'only_body' => 1,};
+
+ $r->print(<
+ parent.location.href="/adm/blockingstatus/?activity=chat"
+
+ENDSCRIPT
} else {
$headarg = {'redirect' => [5,$refresh_cmd,1],
'only_body' => 1,};
@@ -217,9 +223,11 @@ sub get_seeid_status {
}
sub blockstatus {
+ my ($clientip) = @_;
my ($blocked,$output);
my %setters;
- my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'chat');
+ my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) =
+ &Apache::loncommon::blockcheck(\%setters,'chat',$clientip);
if ($startblock && $endblock) {
$blocked = 1;
my $endblocktime = &Apache::lonlocal::locallocaltime($endblock);
@@ -232,9 +240,21 @@ sub blockstatus {
my ($openblock,$closeblock) = @{$setters{$course}{times}[$i]};
$openblock = &Apache::lonlocal::locallocaltime($openblock);
$closeblock= &Apache::lonlocal::locallocaltime($closeblock);
- $output .= &mt('Block for [_1] starts: [_2], ends [_3], set by: [_4]
',$courseinfo{'description'},$openblock,$closeblock,$fullname);
+ $output .= &mt('Block for [_1] starts: [_2], ends [_3], set by: [_4]',$courseinfo{'description'},$openblock,$closeblock,$fullname).'
';
}
}
+ } elsif ($by_ip) {
+ $blocked = 1;
+ my $showdom = &Apache::lonnet::domain($blockdom);
+ if ($showdom eq '') {
+ $showdom = $blockdom;
+ }
+ $output = &mt('Chat Room is unavailable from your current IP address: [_1], '
+ .'because communication is blocked for certain IP address(es).'
+ ,$clientip).
+ '
'.
+ &mt('This restriction was set by an administrator in the [_1] LON-CAPA domain.'
+ ,$showdom);
}
return ($blocked,$output);
}