[LON-CAPA-cvs] cvs: loncom /html/res/adm/pages/annotator admannotations.pm /interface domainprefs.pm lonblockingstatus.pm loncommon.pm lonwishlistdisplay.pm

raeburn raeburn at source.lon-capa.org
Thu Dec 23 19:48:31 EST 2021


raeburn		Fri Dec 24 00:48:31 2021 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm lonblockingstatus.pm loncommon.pm 
                     	lonwishlistdisplay.pm 
    /loncom/html/res/adm/pages/annotator	admannotations.pm 
  Log:
  - Bug 6955 IP-based blocking.
    - Course search, Stored links, and Resource Annotations added to functions
      which can be blocked by client IP. (User with evb priv in course exempt).
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.396 loncom/interface/domainprefs.pm:1.397
--- loncom/interface/domainprefs.pm:1.396	Mon Dec  6 03:31:54 2021
+++ loncom/interface/domainprefs.pm	Fri Dec 24 00:48:30 2021
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.396 2021/12/06 03:31:54 raeburn Exp $
+# $Id: domainprefs.pm,v 1.397 2021/12/24 00:48:30 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1893,8 +1893,11 @@
         'printout' => 'Printouts',
         'passwd' => 'Change Password',
         'grades' => 'Gradebook',
+        'search' => 'Course search',
+        'wishlist' => 'Stored links',
+        'annotate' => 'Annotations',
     );
-    my $typeorder = ['com','chat','boards','port','groups','blogs','about','printout','grades','passwd'];
+    my $typeorder = ['com','chat','boards','port','groups','blogs','about','wishlist','printout','grades','search','annotate','passwd'];
     return ($typeorder,\%types);
 }
 
@@ -3902,7 +3905,7 @@
                   '<td>'.$choices{'run'}.'</td>'.
                   '<td class="LC_left_item"><span class="LC_nobreak"><label>'.
                   '<input type="radio" name="autoupdate_run"'.
-                  $updateoff.' value="0" />'.&mt('No').'</label> '.
+                  $updateoff.'value="0" />'.&mt('No').'</label> '.
                   '<label><input type="radio" name="autoupdate_run"'.
                   $updateon.'value="1" />'.&mt('Yes').'</label></span></td>'.
                   '</tr>';
Index: loncom/interface/lonblockingstatus.pm
diff -u loncom/interface/lonblockingstatus.pm:1.21 loncom/interface/lonblockingstatus.pm:1.22
--- loncom/interface/lonblockingstatus.pm:1.21	Tue Nov 30 17:35:10 2021
+++ loncom/interface/lonblockingstatus.pm	Fri Dec 24 00:48:30 2021
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # displays the blocking status table
 #
-# $Id: lonblockingstatus.pm,v 1.21 2021/11/30 17:35:10 raeburn Exp $
+# $Id: lonblockingstatus.pm,v 1.22 2021/12/24 00:48:30 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -44,7 +44,7 @@
     return OK if $r->header_only;
 
     my (%activities,$activity,$origurl,$origsymb);
-    map { $activities{$_} = 1; } ('boards','chat','com','blogs','about','groups','port','printout','docs','grades','passwd','search');
+    map { $activities{$_} = 1; } ('boards','chat','com','blogs','about','groups','port','printout','docs','grades','passwd','search','wishlist','annotate');
 
     # determine what kind of blocking we want details for
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['activity','url','symb']);
@@ -54,7 +54,8 @@
 
     if (($activity eq 'docs') || ($activity eq 'printout') ||
         ($activity eq 'grades') || ($activity eq 'passwd') ||
-        ($activity eq 'search')) {
+        ($activity eq 'search') || ($activity eq 'wishlist') ||
+        ($activity eq 'annotate')) {
         $title = 'Blocking Status Information';
         if ($activity eq 'docs') {
             $origurl = $env{'form.url'};
@@ -164,6 +165,8 @@
                    passwd     => 'Changing of passwords',
                    grades     => 'Course Gradebook',
                    search     => 'Content Search',
+                   wishlist   => 'Stored Links', 
+                   annotate   => 'Annotations',
                 );
 
     if ($activity eq 'groups' || $activity eq 'boards') {
@@ -198,7 +201,8 @@
                          ,$showstart, $showend);
         } elsif (($activity eq 'printout') || ($activity eq 'passwd') ||
                  ($activity eq 'grades') || ($activity eq 'search') ||
-                 ($activity eq 'about')) {
+                 ($activity eq 'about') || ($activity eq 'wishlist') ||
+                 ($activity eq 'annotate')) {
             if ($by_ip) {
                 $output = mt( $description
                               . ' unavailable from your current IP address: [_1] '
@@ -252,7 +256,7 @@
         if ($by_ip) {
             my $showdom = &Apache::lonnet::domain($blockdom);
             if ($showdom eq '') {
-                $showdom = $blockdom
+                $showdom = $blockdom;
             }
             $output .= '<br />'.
                        &mt('This restriction was set by an administrator in the [_1] LON-CAPA domain.'
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1372 loncom/interface/loncommon.pm:1.1373
--- loncom/interface/loncommon.pm:1.1372	Tue Nov 30 15:55:37 2021
+++ loncom/interface/loncommon.pm	Fri Dec 24 00:48:30 2021
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1372 2021/11/30 15:55:37 raeburn Exp $
+# $Id: loncommon.pm,v 1.1373 2021/12/24 00:48:30 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -5270,6 +5270,9 @@
                 }
             }
         }
+        if (($activity eq 'wishlist') || ($activity eq 'annotate')) {
+            return ();
+        }
     }
     if (defined($udom) && defined($uname)) {
         # If uname and udom are for a course, check for blocks in the course.
@@ -5286,7 +5289,10 @@
     my $startblock = 0;
     my $endblock = 0;
     my $triggerblock = '';
-    my %live_courses = &findallcourses(undef,$uname,$udom);
+    my %live_courses;
+    unless (($activity eq 'wishlist') || ($activity eq 'annotate')) {
+        %live_courses = &findallcourses(undef,$uname,$udom);
+    }
 
     # If uname is for a user, and activity is course-specific, i.e.,
     # boards, chat or groups, check for blocking in current course only.
@@ -5635,6 +5641,10 @@
         $text = &mt('Checking Course Update Blocked');
     } elsif ($activity eq 'about') {
         $text = &mt('Access to User Information Pages Blocked');
+    } elsif ($activity eq 'wishlist') {
+        $text = &mt('Access to Stored Links Blocked');
+    } elsif ($activity eq 'annotate') {
+        $text = &mt('Access to Annotations Blocked');
     }
     $output .= <<"END_BLOCK";
 <div class='$class'>
Index: loncom/interface/lonwishlistdisplay.pm
diff -u loncom/interface/lonwishlistdisplay.pm:1.6 loncom/interface/lonwishlistdisplay.pm:1.7
--- loncom/interface/lonwishlistdisplay.pm:1.6	Fri Feb 28 19:24:03 2014
+++ loncom/interface/lonwishlistdisplay.pm	Fri Dec 24 00:48:30 2021
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to display the wishlist (handler)
 #
-# $Id: lonwishlistdisplay.pm,v 1.6 2014/02/28 19:24:03 bisitz Exp $
+# $Id: lonwishlistdisplay.pm,v 1.7 2021/12/24 00:48:30 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -64,6 +64,21 @@
         return HTTP_NOT_ACCEPTABLE;
     }
 
+    my $clientip = &Apache::lonnet::get_requestor_ip($r);
+    my ($blocked,$blocktext) =
+        &Apache::loncommon::blocking_status('wishlist',$clientip);
+    if ($blocked) {
+        &Apache::lonhtmlcommon::clear_breadcrumbs();
+        &Apache::lonhtmlcommon::add_breadcrumb(
+               { href => '/adm/wishlist',
+                 text => 'Stored Links'});
+        my $startPage = &Apache::loncommon::start_page('Stored Links');
+        my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Stored Links','Wishlist');
+        my $endpage = &Apache::loncommon::end_page();
+        $r->print($startPage.$breadcrumbs.$blocktext);
+        return OK;
+    }
+
     if (&Apache::lonwishlist::getWishlist() ne 'error') {
         # get wishlist entries from user-data db-file and build a tree out of these entries
         %TreeHash = &Apache::lonwishlist::getWishlist();
Index: loncom/html/res/adm/pages/annotator/admannotations.pm
diff -u loncom/html/res/adm/pages/annotator/admannotations.pm:1.36 loncom/html/res/adm/pages/annotator/admannotations.pm:1.37
--- loncom/html/res/adm/pages/annotator/admannotations.pm:1.36	Sat Dec 29 22:31:16 2018
+++ loncom/html/res/adm/pages/annotator/admannotations.pm	Fri Dec 24 00:48:31 2021
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # This will take annotations and then plug them into a page.
 #
-# $Id: admannotations.pm,v 1.36 2018/12/29 22:31:16 raeburn Exp $
+# $Id: admannotations.pm,v 1.37 2021/12/24 00:48:31 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -175,6 +175,27 @@
 END_HTML2
 }
 
+sub block_check {
+    my ($clientip) = @_;
+    my ($blocked,$blocktext) =
+        &Apache::loncommon::blocking_status('annotate',$clientip);
+    if ($blocked) {
+        my %lt = &Apache::lonlocal::texthash(
+                                              'close' => 'Close',
+                                            );
+        my $start_page =
+            &Apache::loncommon::start_page('Annotations',undef,
+                                           {'only_body'   => 1,});
+        my $end_page = '<form name="annotInfo" method="post" action="">'."\n".
+                       '<input type="button" id="close" name="close" value="'.$lt{'close'}.'"'.
+                       ' onclick="javascript:window.close();" />'."\n".
+                       '</form>'."\n".
+                       &Apache::loncommon::end_page();
+        return ($blocked,$start_page.$blocktext.$end_page);
+    } else {
+        return ();
+    }
+}
 
 # ---------------------------------------------------------------Main Handler
 
@@ -185,6 +206,15 @@
     $r->send_http_header;
     return OK if $r->header_only;
 
+    my $clientip = &Apache::lonnet::get_requestor_ip($r);
+    if ($clientip ne '') {
+        my ($blocked,$output) = &block_check($clientip);
+        if ($blocked) {
+            $r->print($output);
+            return OK;
+        }
+    }
+
     my $page;
 
     my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($env{'form.symbold'},1);


More information about the LON-CAPA-cvs mailing list