--- loncom/interface/lonmsgdisplay.pm 2020/11/11 22:04:25 1.181.2.7 +++ loncom/interface/lonmsgdisplay.pm 2021/12/14 00:20:07 1.181.2.8 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging display # -# $Id: lonmsgdisplay.pm,v 1.181.2.7 2020/11/11 22:04:25 raeburn Exp $ +# $Id: lonmsgdisplay.pm,v 1.181.2.8 2021/12/14 00:20:07 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -912,7 +912,7 @@ sub discrit { } sub sortedmessages { - my ($blocked,$startblock,$endblock,$numblocked,$folder,$msgstatus) = @_; + my ($blocked,$startblock,$endblock,$by_ip,$numblocked,$folder,$msgstatus) = @_; my $suffix=&Apache::lonmsg::foldersuffix($folder); my @messages = &Apache::lonnet::getkeys('nohist_email'.$suffix); #unpack the varibles and repack into temp for sorting @@ -944,7 +944,8 @@ sub sortedmessages { push(@temp1,$content{'recuser'},$content{'recdomain'}); } # Check whether message was sent during blocking period. - if ($sendtime >= $startblock && ($sendtime <= $endblock && $endblock > 0) ) { + if (($by_ip) || + (($sendtime >= $startblock) && ($sendtime <= $endblock && $endblock > 0))) { $$blocked{$msgid} = 'ON'; $$numblocked ++; } else { @@ -1071,7 +1072,9 @@ sub disfolder { my %blocked = (); my %setters = (); my $numblocked = 0; - my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com'); + my $clientip = &Apache::lonnet::get_requestor_ip($r); + my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) = + &Apache::loncommon::blockcheck(\%setters,'com',$clientip); my %js_lt = &Apache::lonlocal::texthash( sede => 'Select a destination folder to which the messages will be moved.', nome => 'No messages have been selected to apply this action to.', @@ -1115,7 +1118,7 @@ sub disfolder { ENDDISHEADER my $fsqs='&folder='.$folder; - my @temp=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder,$msgstatus); + my @temp=&sortedmessages(\%blocked,$startblock,$endblock,$by_ip,\$numblocked,$folder,$msgstatus); my $totalnumber=$#temp+1; if ($totalnumber < 1) { $r->print('

'); @@ -1128,7 +1131,7 @@ ENDDISHEADER } $r->print('

'); 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; @@ -1318,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; @@ -2106,14 +2115,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; }