[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface lonmsgdisplay.pm

raeburn raeburn at source.lon-capa.org
Mon Dec 13 19:20:07 EST 2021


raeburn		Tue Dec 14 00:20:07 2021 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonmsgdisplay.pm 
  Log:
  - For 2.11
    Backport 1.194, 1.195
  
  
Index: loncom/interface/lonmsgdisplay.pm
diff -u loncom/interface/lonmsgdisplay.pm:1.181.2.7 loncom/interface/lonmsgdisplay.pm:1.181.2.8
--- loncom/interface/lonmsgdisplay.pm:1.181.2.7	Wed Nov 11 22:04:25 2020
+++ loncom/interface/lonmsgdisplay.pm	Tue Dec 14 00:20:07 2021
@@ -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 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 @@
 	    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 @@
     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 @@
 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('<p class="LC_info">');
@@ -1128,7 +1131,7 @@
         }
         $r->print('</p>');
         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 @@
     $r->print('<input type="hidden" name="folder" value="'.$folder.'" /><input type="hidden" name="startdis" value="'.$postedstartdis.'" /><input type="hidden" name="interdis" value="'.$env{'form.interdis'}.'" /><input type="hidden" name="msgstatus" value="'.$msgstatus.'" /><input type="hidden" name="markedaction" value="" /></form>');
     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 = '<br /><br />'.
+    my ($numblocked,$startblock,$endblock,$by_ip,$clientip,$blockdom,$setters) = @_;
+    my $output;
+    if ($by_ip) {
+        $output = '<br /><br />'.
+                  &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).'<br />'.
+                  &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 = '<br /><br />'.
                   &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 .="<br /><br />".$blocktext;
 
     return $output;
@@ -2106,14 +2115,16 @@
     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("<br />".$blocktext);
         return;
     }




More information about the LON-CAPA-cvs mailing list