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

raeburn raeburn at source.lon-capa.org
Wed Jan 19 10:06:22 EST 2022


raeburn		Wed Jan 19 15:06:22 2022 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonmsgdisplay.pm 
  Log:
  - For 2.11
    Backport 1.196, 1.197
  
  
Index: loncom/interface/lonmsgdisplay.pm
diff -u loncom/interface/lonmsgdisplay.pm:1.181.2.8 loncom/interface/lonmsgdisplay.pm:1.181.2.9
--- loncom/interface/lonmsgdisplay.pm:1.181.2.8	Tue Dec 14 00:20:07 2021
+++ loncom/interface/lonmsgdisplay.pm	Wed Jan 19 15:06:22 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging display
 #
-# $Id: lonmsgdisplay.pm,v 1.181.2.8 2021/12/14 00:20:07 raeburn Exp $
+# $Id: lonmsgdisplay.pm,v 1.181.2.9 2022/01/19 15:06:22 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1351,6 +1351,26 @@
 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('<p class="LC_warning">'.
+                 &mt('Sending of LON-CAPA messages is blocked for your current IP address: [_1].',$clientip).'</p>'.
+                 '<ul><li>'.
+                 &mt('Note: communication is being blocked for certain IP address(es).').
+                 '</li><li>'.
+                 &mt('This restriction was set by an administrator in the [_1] LON-CAPA domain.',$showdom).
+                 '</li></ul>');
+        return;
+    }
     my $suffix=&Apache::lonmsg::foldersuffix($folder);
     my ($cdom,$cnum,$group,$refarg);
     if (exists($env{'form.group'})) {
@@ -2793,7 +2813,14 @@
         $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.');
@@ -3395,8 +3422,12 @@
                 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 .= '<br />'.&mt('Could not deliver forwarded message.').'</span> '.
-                                &mt('The recipient addresses may need to be corrected').' ('.$forwardfail{$key}.')';
+                    $message .= '<br />'.&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);




More information about the LON-CAPA-cvs mailing list