--- loncom/interface/loncommon.pm 2021/12/30 21:11:56 1.1075.2.161.2.1
+++ loncom/interface/loncommon.pm 2024/07/04 23:00:26 1.1075.2.167
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1075.2.161.2.1 2021/12/30 21:11:56 raeburn Exp $
+# $Id: loncommon.pm,v 1.1075.2.167 2024/07/04 23:00:26 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -61,7 +61,6 @@ use POSIX qw(strftime mktime);
use Apache::lonmenu();
use Apache::lonenc();
use Apache::lonlocal;
-use Apache::lonnet();
use HTML::Entities;
use Apache::lonhtmlcommon();
use Apache::loncoursedata();
@@ -83,8 +82,6 @@ use Crypt::DES;
use DynaLoader; # for Crypt::DES version
use File::Copy();
use File::Path();
-use String::CRC32();
-use Short::URL();
# ---------------------------------------------- Designs
use vars qw(%defaultdesign);
@@ -3672,6 +3669,30 @@ sub syllabuswrapper {
# -----------------------------------------------------------------------------
+sub aboutme_on {
+ my ($uname,$udom)=@_;
+ unless ($uname) { $uname=$env{'user.name'}; }
+ unless ($udom) { $udom=$env{'user.domain'}; }
+ return if ($udom eq 'public' && $uname eq 'public');
+ my $hashkey=$uname.':'.$udom;
+ my ($aboutme,$cached)=&Apache::lonnet::is_cached_new('aboutme',$hashkey);
+ if ($cached) {
+ return $aboutme;
+ }
+ $aboutme = &Apache::lonnet::usertools_access($uname,$udom,'aboutme');
+ &Apache::lonnet::do_cache_new('aboutme',$hashkey,$aboutme,3600);
+ return $aboutme;
+}
+
+sub devalidate_aboutme_cache {
+ my ($uname,$udom)=@_;
+ if (!$udom) { $udom =$env{'user.domain'}; }
+ if (!$uname) { $uname=$env{'user.name'}; }
+ return if ($udom eq 'public' && $uname eq 'public');
+ my $id=$uname.':'.$udom;
+ &Apache::lonnet::devalidate_cache_new('aboutme',$id);
+}
+
sub track_student_link {
my ($linktext,$sname,$sdom,$target,$start,$only_body) = @_;
my $link ="/adm/trackstudent?";
@@ -4755,6 +4776,17 @@ sub blockcheck {
}
}
}
+ } elsif (($activity eq 'com') || ($activity eq 'port') || ($activity eq 'blogs') ||
+ ($activity eq 'about') || ($activity eq 'wishlist') || ($activity eq 'passwd')) {
+ my $checkrole;
+ if ($env{'request.role.domain'} eq '') {
+ $checkrole = "cm./$env{'user.domain'}/";
+ } else {
+ $checkrole = "cm./$env{'request.role.domain'}/";
+ }
+ if (($checkrole) && (&Apache::lonnet::allowed('evb',undef,undef,$checkrole))) {
+ $has_evb = 1;
+ }
}
unless ($has_evb || $check_ipaccess) {
my @machinedoms = &Apache::lonnet::current_machine_domains();
@@ -4800,6 +4832,9 @@ sub blockcheck {
}
}
}
+ 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.
@@ -4825,9 +4860,8 @@ sub blockcheck {
# boards, chat or groups, check for blocking in current course only.
if (($activity eq 'boards' || $activity eq 'chat' ||
- $activity eq 'groups' || $activity eq 'printout' ||
- $activity eq 'search' || $activity eq 'reinit' ||
- $activity eq 'alert') && ($env{'request.course.id'})) {
+ $activity eq 'groups' || $activity eq 'printout') &&
+ ($env{'request.course.id'})) {
foreach my $key (keys(%live_courses)) {
if ($key ne $env{'request.course.id'}) {
delete($live_courses{$key});
@@ -5161,10 +5195,6 @@ END_MYBLOCK
$text = &mt('Gradebook Blocked');
} elsif ($activity eq 'search') {
$text = &mt('Search Blocked');
- } elsif ($activity eq 'alert') {
- $text = &mt('Checking Critical Messages Blocked');
- } elsif ($activity eq 'reinit') {
- $text = &mt('Checking Course Update Blocked');
} elsif ($activity eq 'about') {
$text = &mt('Access to User Information Pages Blocked');
} elsif ($activity eq 'wishlist') {
@@ -5205,34 +5235,13 @@ sub check_ip_acc {
}
my $name;
- my %access = (
- allowfrom => 1,
- denyfrom => 0,
- );
- my @allows;
- my @denies;
- foreach my $item (split(',',$acc)) {
- $item =~ s/^\s*//;
- $item =~ s/\s*$//;
- if ($item =~ /^\!(.+)$/) {
- push(@denies,$1);
- } else {
- push(@allows,$item);
- }
- }
- my $numdenies = scalar(@denies);
- my $numallows = scalar(@allows);
- my $count = 0;
- foreach my $pattern (@denies,@allows) {
- $count ++;
- my $acctype = 'allowfrom';
- if ($count <= $numdenies) {
- $acctype = 'denyfrom';
- }
+ foreach my $pattern (split(',',$acc)) {
+ $pattern =~ s/^\s*//;
+ $pattern =~ s/\s*$//;
if ($pattern =~ /\*$/) {
#35.8.*
$pattern=~s/\*//;
- if ($ip =~ /^\Q$pattern\E/) { $allowed=$access{$acctype}; }
+ if ($ip =~ /^\Q$pattern\E/) { $allowed=1; }
} elsif ($pattern =~ /(\d+\.\d+\.\d+)\.\[(\d+)-(\d+)\]$/) {
#35.8.3.[34-56]
my $low=$2;
@@ -5240,7 +5249,7 @@ sub check_ip_acc {
$pattern=$1;
if ($ip =~ /^\Q$pattern\E/) {
my $last=(split(/\./,$ip))[3];
- if ($last <=$high && $last >=$low) { $allowed=$access{$acctype}; }
+ if ($last <=$high && $last >=$low) { $allowed=1; }
}
} elsif ($pattern =~ /^\*/) {
#*.msu.edu
@@ -5250,10 +5259,10 @@ sub check_ip_acc {
my $netaddr=inet_aton($ip);
($name)=gethostbyaddr($netaddr,AF_INET);
}
- if ($name =~ /\Q$pattern\E$/i) { $allowed=$access{$acctype}; }
+ if ($name =~ /\Q$pattern\E$/i) { $allowed=1; }
} elsif ($pattern =~ /\d+\.\d+\.\d+\.\d+/) {
#127.0.0.1
- if ($ip =~ /^\Q$pattern\E/) { $allowed=$access{$acctype}; }
+ if ($ip =~ /^\Q$pattern\E/) { $allowed=1; }
} else {
#some.name.com
if (!defined($name)) {
@@ -5261,16 +5270,9 @@ sub check_ip_acc {
my $netaddr=inet_aton($ip);
($name)=gethostbyaddr($netaddr,AF_INET);
}
- if ($name =~ /\Q$pattern\E$/i) { $allowed=$access{$acctype}; }
- }
- if ($allowed =~ /^(0|1)$/) { last; }
- }
- if ($allowed eq '') {
- if ($numdenies && !$numallows) {
- $allowed = 1;
- } else {
- $allowed = 0;
+ if ($name =~ /\Q$pattern\E$/i) { $allowed=1; }
}
+ if ($allowed) { last; }
}
return $allowed;
}
@@ -5466,8 +5468,12 @@ sub domainlogo {
&Apache::lonnet::repcopy($local_name);
}
$imgsrc = &lonhttpdurl($imgsrc);
- }
- return '';
+ }
+ my $alttext = $domain;
+ if ($designhash{$domain.'.login.alttext_domlogo'} ne '') {
+ $alttext = $designhash{$domain.'.login.alttext_domlogo'};
+ }
+ return '
';
} elsif (defined(&Apache::lonnet::domain($domain,'description'))) {
return &Apache::lonnet::domain($domain,'description');
} else {
@@ -5691,19 +5697,6 @@ Inputs:
inlineremote items to be added in "Functions" menu below
breadcrumbs.
-=item * $ltiscope, optional argument, will be one of: resource, map or
- course, if LON-CAPA is in LTI Provider context. Value is
- the scope of use, i.e., launch was for access to a single, a map
- or the entire course.
-
-=item * $ltiuri, optional argument, if LON-CAPA is in LTI Provider
- context, this will contain the URL for the landing item in
- the course, after launch from an LTI Consumer
-
-=item * $ltimenu, optional argument, if LON-CAPA is in LTI Provider
- context, this will contain a reference to hash of items
- to be included in the page header and/or inline menu.
-
=back
Returns: A uniform header for LON-CAPA web pages.
@@ -5715,8 +5708,7 @@ other decorations will be returned.
sub bodytag {
my ($title,$function,$addentries,$bodyonly,$domain,$forcereg,
- $no_nav_bar,$bgcolor,$no_inline_link,$args,$advtoolsref,
- $ltiscope,$ltiuri,$ltimenu,$menucoll,$menuref)=@_;
+ $no_nav_bar,$bgcolor,$no_inline_link,$args,$advtoolsref)=@_;
my $public;
if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public'))
@@ -5800,46 +5792,16 @@ sub bodytag {
undef($role);
}
- my $showcrstitle = 1;
- if (($cid) && ($env{'request.lti.login'})) {
- if (ref($ltimenu) eq 'HASH') {
- unless ($ltimenu->{'role'}) {
- undef($role);
- }
- unless ($ltimenu->{'coursetitle'}) {
- $realm=' ';
- $showcrstitle = 0;
- }
- }
- } elsif (($cid) && ($menucoll)) {
- if (ref($menuref) eq 'HASH') {
- unless ($menuref->{'role'}) {
- undef($role);
- }
- unless ($menuref->{'crs'}) {
- $realm=' ';
- $showcrstitle = 0;
- }
- }
- }
-
my $titleinfo = '