');
if ($numblocked > 0) {
- $r->print(&blocked_in_folder($numblocked,$startblock,$endblock,
+ $r->print(&blocked_in_folder($numblocked,$startblock,$endblock,$by_ip,$clientip,$blockdom,
\%setters));
}
return;
@@ -1314,20 +1321,26 @@ ENDDISHEADER
$r->print('');
if ($numblocked > 0) {
$r->print(&blocked_in_folder($numblocked,$startblock,$endblock,
- \%setters));
+ $by_ip,$clientip,$blockdom,\%setters));
}
}
sub blocked_in_folder {
- my ($numblocked,$startblock,$endblock,$setters) = @_;
- my $beginblock = &Apache::lonlocal::locallocaltime($startblock);
- my $finishblock = &Apache::lonlocal::locallocaltime($endblock);
- my $output = '
'.
+ my ($numblocked,$startblock,$endblock,$by_ip,$clientip,$blockdom,$setters) = @_;
+ my $output;
+ if ($by_ip) {
+ $output = '
'.
+ &mt('[quant,_1,message is, messages are] not viewable because display of LON-CAPA messages is blocked for your current IP address: [_2].',$numblocked,$clientip).' '.
+ &mt('Note: communication is being blocked for certain IP address(es).');
+ } else {
+ my $beginblock = &Apache::lonlocal::locallocaltime($startblock);
+ my $finishblock = &Apache::lonlocal::locallocaltime($endblock);
+ $output = '
'.
&mt('[quant,_1,message is, messages are] not viewable because display of LON-CAPA messages sent to you by other students between [_2] and [_3] is currently being blocked because of online exams.',$numblocked,$beginblock,$finishblock);
+ }
#$output .= &Apache::loncommon::build_block_table($startblock,$endblock,
# $setters);
-
- my ($blocked, $blocktext) = &Apache::loncommon::blocking_status("com");
+ my ($blocked, $blocktext) = &Apache::loncommon::blocking_status("com",$clientip);
$output .="
".$blocktext;
return $output;
@@ -1338,6 +1351,26 @@ sub blocked_in_folder {
sub compout {
my ($r,$forwarding,$replying,$broadcast,$replycrit,$folder,$dismode,
$multiforward)=@_;
+ my $clientip = &Apache::lonnet::get_requestor_ip($r);
+ my %setters;
+ my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) =
+ &Apache::loncommon::blockcheck(\%setters,'com',$clientip);
+ if ($by_ip) {
+ my $showdom = &Apache::lonnet::domain($blockdom);
+ if ($showdom eq '') {
+ $showdom = $blockdom;
+ }
+ $r->print(&Apache::loncommon::start_page('Messages'));
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Send and display messages'));
+ $r->print('
'.
+ &mt('Sending of LON-CAPA messages is blocked for your current IP address: [_1].',$clientip).'
'.
+ '
'.
+ &mt('Note: communication is being blocked for certain IP address(es).').
+ '
'.
+ &mt('This restriction was set by an administrator in the [_1] LON-CAPA domain.',$showdom).
+ '
');
+ return;
+ }
my $suffix=&Apache::lonmsg::foldersuffix($folder);
my ($cdom,$cnum,$group,$refarg);
if (exists($env{'form.group'})) {
@@ -2102,14 +2135,16 @@ sub displaymessage {
my %setters = ();
my $numblocked = 0;
my $crstype = &Apache::loncommon::course_type();
+ my $clientip = &Apache::lonnet::get_requestor_ip($r);
# info to generate "next" and "previous" buttons and check if message is blocked
- my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com');
- my @messages=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder,$msgstatus);
+ my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) =
+ &Apache::loncommon::blockcheck(\%setters,'com',$clientip);
+ my @messages=&sortedmessages(\%blocked,$startblock,$endblock,$by_ip,\$numblocked,$folder,$msgstatus);
if ( $blocked{$msgid} eq 'ON' ) {
&printheader($r,'/adm/email',&mt('Display a Message'));
#$r->print(&mt('You attempted to display a message that is currently blocked because you are enrolled in one or more courses for which there is an ongoing online exam.'));
- my($blocked, $blocktext) = &Apache::loncommon::blocking_status("com");
+ my($blocked, $blocktext) = &Apache::loncommon::blocking_status("com",$clientip);
$r->print(" ".$blocktext);
return;
}
@@ -2143,8 +2178,28 @@ sub displaymessage {
my $number_of_messages = scalar(@messages); #subtract 1 for last index
+ my $head_extra;
+
+# if student's view of resource will be included
+# get tag(s) for css file(s) in use, and pass to &header to include
+# in call to loncommon::start_page()
+
+ if (($env{'request.course.id'} eq $content{'courseid'}) &&
+ (&Apache::lonnet::allowed('vgr',$content{'courseid'}))) {
+ my $symb;
+ if (defined($content{'symb'})) {
+ $symb = $content{'symb'};
+ } elsif (defined($content{'baseurl'})) {
+ $symb=&Apache::lonnet::symbread($content{'baseurl'});
+ }
+ if ($symb) {
+ $head_extra = &Apache::loncommon::css_links($symb);
+ }
+ }
+
# start output
- &printheader($r,'/adm/email?display='.&escape($msgid),'Display a Message','',$content{'baseurl'});
+ &printheader($r,'/adm/email?display='.&escape($msgid),'Display a Message','',
+ $content{'baseurl'},$head_extra);
# Prepare available functions
my @functionlist;
@@ -2678,13 +2733,16 @@ sub displayresource {
# ================================================================== The Header
sub header {
- my ($r,$title,$baseurl)=@_;
+ my ($r,$title,$baseurl,$head_extra)=@_;
my $extra = &Apache::loncommon::studentbrowser_javascript();
if ($baseurl) {
$extra .= "";
}
$extra .= '';
+ if ($head_extra) {
+ $extra .= "\n$head_extra";
+ }
$r->print(&Apache::loncommon::start_page('Messages',
$extra));
$r->print(&Apache::lonhtmlcommon::breadcrumbs
@@ -2694,11 +2752,11 @@ sub header {
# ---------------------------------------------------------------- Print header
sub printheader {
- my ($r,$url,$desc,$title,$baseurl)=@_;
+ my ($r,$url,$desc,$title,$baseurl,$head_extra)=@_;
&Apache::lonhtmlcommon::add_breadcrumb
({href=>$url,
text=>$desc});
- &header($r,$title,$baseurl);
+ &header($r,$title,$baseurl,$head_extra);
}
# ------------------------------------------------------------ Store the comment
@@ -2755,7 +2813,14 @@ sub sendoffmail {
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
}
- if ($env{'form.send'}) {
+ my $clientip = &Apache::lonnet::get_requestor_ip($r);
+ my %setters;
+ my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) =
+ &Apache::loncommon::blockcheck(\%setters,'com',$clientip);
+ if ($by_ip) {
+ &printheader($r,'','Sending messages blocked from your location.');
+ return 'blocked';
+ } elsif ($env{'form.send'}) {
if (!$env{'form.multiforward'}) {
if ($group eq '') {
&printheader($r,'','Messages being sent.');
@@ -3100,9 +3165,24 @@ sub handler {
'sendreply','compose','sendmail','critical','recname','recdom',
'recordftf','sortedby','folder','startdis','interdis',
'showcommentbaseurl','dismode','group','subject','text','ref',
- 'msgstatus']);
+ 'msgstatus','btoken']);
$sqs='&sortedby='.$env{'form.sortedby'};
+# ----------- Check if access was from balancer to server with existing session
+
+ if ($env{'form.btoken'}) {
+ my %info = &Apache::lonnet::tmpget($env{'form.btoken'});
+ &Apache::lonnet::tmpdel($env{'form.btoken'});
+ delete($env{'form.btoken'});
+ unless ($env{'form.display'}) {
+ if (($info{'display'}) && ($info{'mailrecip'})) {
+ if (&unescape($info{'mailrecip'}) eq $env{'user.name'}.':'.$env{'user.domain'}) {
+ $env{'form.display'} = &unescape($info{'display'});
+ }
+ }
+ }
+ }
+
# ------------------------------------------------------ They checked for email
&Apache::lonnet::put('email_status',{'recnewemail'=>0});
@@ -3357,8 +3437,12 @@ sub handler {
my $count = keys(%forwardfail);
my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Could not forward [quant,_1,message].',$count),1);
foreach my $key (keys(%forwardfail)) {
- $message .= ' '.&mt('Could not deliver forwarded message.').' '.
- &mt('The recipient addresses may need to be corrected').' ('.$forwardfail{$key}.')';
+ $message .= ' '.&mt('Could not deliver forwarded message.').' ';
+ if ($forwardfail{$key} eq 'blocked') {
+ $message .= &mt('Sending messages is blocked from your IP address');
+ } else {
+ $message .= &mt('The recipient addresses may need to be corrected').' ('.$forwardfail{$key}.')';
+ }
}
$message = &Apache::loncommon::confirmwrapper($message);
$r->print($message);