--- loncom/interface/loncommon.pm 2023/10/06 13:40:53 1.1075.2.161.2.20
+++ loncom/interface/loncommon.pm 2024/07/31 22:14:33 1.1075.2.168
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1075.2.161.2.20 2023/10/06 13:40:53 raeburn Exp $
+# $Id: loncommon.pm,v 1.1075.2.168 2024/07/31 22:14:33 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::lonnavmaps();
use HTML::Entities;
use Apache::lonhtmlcommon();
use Apache::loncoursedata();
@@ -71,7 +70,6 @@ use Apache::lonuserutils();
use Apache::lonuserstate();
use Apache::courseclassifier();
use LONCAPA qw(:DEFAULT :match);
-use LONCAPA::map();
use HTTP::Request;
use DateTime::TimeZone;
use DateTime::Locale;
@@ -84,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);
@@ -431,7 +427,7 @@ sub studentbrowser_javascript {
-ENDJS
- }
$endbodytag=
- "$endbodyjs
".
+ "
".
&mt('Continue').''.
$endbodytag;
}
@@ -7705,11 +7318,6 @@ fieldset {
/* overflow: hidden; */
}
-fieldset#LC_selectuser {
- margin: 0;
- padding: 0;
-}
-
article.geogebraweb div {
margin: 0;
}
@@ -8253,10 +7861,6 @@ a#LC_content_toolbar_edittoplevel {
background-image:url(/res/adm/pages/edittoplevel.gif);
}
-a#LC_content_toolbar_printout {
- background-image:url(/res/adm/pages/printout.gif);
-}
-
ul#LC_toolbar li a:hover {
background-position: bottom center;
}
@@ -8468,13 +8072,8 @@ Inputs: $title - optional title for the
3- whether the side effect should occur
(side effect of setting
$env{'internal.head.redirect'} to the url
- redirected to)
- 4- whether the redirect target should be
- the opener of the current (pop-up)
- window (side effect of setting
- $env{'internal.head.to_opener'} to
- 1, if true.
- 5- whether encrypt check should be skipped
+ redirected too)
+ 4- whether encrypt check should be skipped
domain -> force to color decorate a page for a specific
domain
function -> force usage of a specific rolish color scheme
@@ -8537,45 +8136,17 @@ sub headtag {
}
}
if (ref($args->{'redirect'})) {
- my ($time,$url,$inhibit_continue,$to_opener,$skip_enc_check) = @{$args->{'redirect'}};
+ my ($time,$url,$inhibit_continue,$skip_enc_check) = @{$args->{'redirect'}};
if (!$skip_enc_check) {
- $url = &Apache::lonenc::check_encrypt($url);
+ $url = &Apache::lonenc::check_encrypt($url);
}
if (!$inhibit_continue) {
$env{'internal.head.redirect'} = $url;
}
- $result.=<<"ADDMETA";
+ $result.=<
-ADDMETA
- if ($to_opener) {
- $env{'internal.head.to_opener'} = 1;
- my $dest = &js_escape($url);
- my $timeout = int($time * 1000);
- $result .=<<"ENDJS";
-
-ENDJS
- } else {
- $result.=<<"ADDMETA";
ADDMETA
- }
} else {
unless (($args->{'frameset'}) || ($args->{'js_ready'}) || ($args->{'only_body'}) || ($args->{'no_nav_bar'})) {
my $requrl = $env{'request.uri'};
@@ -8621,7 +8192,7 @@ ADDMETA
my $newserver = &Apache::lonnet::spareserver(undef,30000,undef,1,$dom_in_use);
if (($newserver eq '') && ($offloadoth)) {
my @domains = &Apache::lonnet::current_machine_domains();
- if (($dom_in_use ne '') && (!grep(/^\Q$dom_in_use\E$/,@domains))) {
+ if (($dom_in_use ne '') && (!grep(/^\Q$dom_in_use\E$/,@domains))) {
($newserver) = &Apache::lonnet::choose_server($dom_in_use);
}
}
@@ -8712,8 +8283,12 @@ OFFLOAD
$title = 'The LearningOnline Network with CAPA';
}
if (!$args->{'no_auto_mt_title'}) { $title = &mt($title); }
- $result .= '
LON-CAPA '.$title.''
- .'';
+ } else {
+ $result .= ' LON-CAPA '.$title.'';
+ }
+ $result .= "\n".'{'frameset'}) {
$result .= ' /';
}
@@ -8925,7 +8500,6 @@ $args - additional optional args support
links_disabled -> Links in primary and secondary menus are disabled
(Can enable them once page has loaded - see lonroles.pm
for an example).
- links_target -> Target for links, e.g., _parent (optional).
=back
@@ -8938,83 +8512,12 @@ sub start_page {
#&Apache::lonnet::logthis("start_page ".join(':',caller(0)));
$env{'internal.start_page'}++;
- my ($result,@advtools,$ltiscope,$ltiuri,%ltimenu,$menucoll,%menu);
+ my ($result,@advtools);
if (! exists($args->{'skip_phases'}{'head'}) ) {
$result .= &xml_begin($args->{'frameset'}) . &headtag($title, $head_extra, $args);
}
-
- if (($env{'request.course.id'}) && ($env{'request.lti.login'})) {
- if ($env{'course.'.$env{'request.course.id'}.'.lti.override'}) {
- unless ($env{'course.'.$env{'request.course.id'}.'.lti.topmenu'}) {
- $args->{'no_primary_menu'} = 1;
- }
- unless ($env{'course.'.$env{'request.course.id'}.'.lti.inlinemenu'}) {
- $args->{'no_inline_menu'} = 1;
- }
- if ($env{'course.'.$env{'request.course.id'}.'.lti.lcmenu'}) {
- map { $ltimenu{$_} = 1; } split(/,/,$env{'course.'.$env{'request.course.id'}.'.lti.lcmenu'});
- }
- } else {
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider');
- if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') {
- unless ($lti{$env{'request.lti.login'}}{'topmenu'}) {
- $args->{'no_primary_menu'} = 1;
- }
- unless ($lti{$env{'request.lti.login'}}{'inlinemenu'}) {
- $args->{'no_inline_menu'} = 1;
- }
- if (ref($lti{$env{'request.lti.login'}}{'lcmenu'}) eq 'ARRAY') {
- map { $ltimenu{$_} = 1; } @{$lti{$env{'request.lti.login'}}{'lcmenu'}};
- }
- }
- }
- ($ltiscope,$ltiuri) = &LONCAPA::ltiutils::lti_provider_scope($env{'request.lti.uri'},
- $env{'course.'.$env{'request.course.id'}.'.domain'},
- $env{'course.'.$env{'request.course.id'}.'.num'});
- } elsif ($env{'request.course.id'}) {
- my $expiretime=600;
- if ((time-$env{'course.'.$env{'request.course.id'}.'.last_cache'}) > $expiretime) {
- &Apache::lonnet::coursedescription($env{'request.course.id'},{'freshen_cache' => 1});
- }
- my ($deeplinkmenu,$menuref);
- ($menucoll,$deeplinkmenu,$menuref) = &menucoll_in_effect();
- if ($menucoll) {
- if (ref($menuref) eq 'HASH') {
- %menu = %{$menuref};
- }
- if ($menu{'top'} eq 'n') {
- $args->{'no_primary_menu'} = 1;
- }
- if ($menu{'inline'} eq 'n') {
- unless (&Apache::lonnet::allowed('opa')) {
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- my $crstype = &course_type();
- my $now = time;
- my $ccrole;
- if ($crstype eq 'Community') {
- $ccrole = 'co';
- } else {
- $ccrole = 'cc';
- }
- if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) {
- my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum});
- if ((($start) && ($start<0)) ||
- (($end) && ($end<$now)) ||
- (($start) && ($now<$start))) {
- $args->{'no_inline_menu'} = 1;
- }
- } else {
- $args->{'no_inline_menu'} = 1;
- }
- }
- }
- }
- }
-
- my $showncrumbs;
+
if (! exists($args->{'skip_phases'}{'body'}) ) {
if ($args->{'frameset'}) {
my $attr_string = &make_attr_string($args->{'force_register'},
@@ -9027,8 +8530,7 @@ sub start_page {
$args->{'only_body'}, $args->{'domain'},
$args->{'force_register'}, $args->{'no_nav_bar'},
$args->{'bgcolor'}, $args->{'no_inline_link'},
- $args, \@advtools,
- $ltiscope,$ltiuri,\%ltimenu,$menucoll,\%menu,\$showncrumbs);
+ $args, \@advtools);
}
}
@@ -9050,7 +8552,6 @@ sub start_page {
#Breadcrumbs
if (exists($args->{'bread_crumbs'}) or exists($args->{'bread_crumbs_component'})) {
- unless ($showncrumbs) {
&Apache::lonhtmlcommon::clear_breadcrumbs();
#if any br links exists, add them to the breadcrumbs
if (exists($args->{'bread_crumbs'}) and ref($args->{'bread_crumbs'}) eq 'ARRAY') {
@@ -9064,26 +8565,17 @@ sub start_page {
}
my $menulink;
# if arg: bread_crumbs_nomenu is true pass 0 as $menulink item.
- if ((exists($args->{'bread_crumbs_nomenu'})) ||
- ($ltiscope eq 'map') || ($ltiscope eq 'resource')) {
+ if (exists($args->{'bread_crumbs_nomenu'})) {
$menulink = 0;
} else {
undef($menulink);
}
- my $linkprotout;
- if ($env{'request.deeplink.login'}) {
- my $linkprotout = &Apache::lonmenu::linkprot_exit();
- if ($linkprotout) {
- &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$linkprotout);
- }
- }
#if bread_crumbs_component exists show it as headline else show only the breadcrumbs
if(exists($args->{'bread_crumbs_component'})){
$result .= &Apache::lonhtmlcommon::breadcrumbs($args->{'bread_crumbs_component'},'',$menulink);
- } else {
+ }else{
$result .= &Apache::lonhtmlcommon::breadcrumbs('','',$menulink);
}
- }
} elsif (($env{'environment.remote'} eq 'on') &&
($env{'form.inhibitmenu'} ne 'yes') &&
($env{'request.noversionuri'} =~ m{^/res/}) &&
@@ -9125,147 +8617,6 @@ sub end_page {
return $result;
}
-sub menucoll_in_effect {
- my ($menucoll,$deeplinkmenu,%menu);
- if ($env{'request.course.id'}) {
- $menucoll = $env{'course.'.$env{'request.course.id'}.'.menudefault'};
- if ($env{'request.deeplink.login'}) {
- my ($deeplink_symb,$deeplink,$check_login_symb);
- my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- if ($env{'request.noversionuri'} =~ m{^/(res|uploaded)/}) {
- if ($env{'request.noversionuri'} =~ /\.(page|sequence)$/) {
- my $navmap = Apache::lonnavmaps::navmap->new();
- if (ref($navmap)) {
- $deeplink = $navmap->get_mapparam(undef,
- &Apache::lonnet::declutter($env{'request.noversionuri'}),
- '0.deeplink');
- } else {
- $check_login_symb = 1;
- }
- } else {
- my $symb=&Apache::lonnet::symbread();
- if ($symb) {
- $deeplink = &Apache::lonnet::EXT('resource.0.deeplink',$symb);
- } else {
- $check_login_symb = 1;
- }
- }
- } else {
- $check_login_symb = 1;
- }
- if ($check_login_symb) {
- $deeplink_symb = &deeplink_login_symb($cnum,$cdom);
- if ($deeplink_symb =~ /\.(page|sequence)$/) {
- my $mapname = &Apache::lonnet::deversion((&Apache::lonnet::decode_symb($deeplink_symb))[2]);
- my $navmap = Apache::lonnavmaps::navmap->new();
- if (ref($navmap)) {
- $deeplink = $navmap->get_mapparam(undef,$mapname,'0.deeplink');
- }
- } else {
- $deeplink = &Apache::lonnet::EXT('resource.0.deeplink',$deeplink_symb);
- }
- }
- if ($deeplink ne '') {
- my ($state,$others,$listed,$scope,$protect,$display,$target) = split(/,/,$deeplink);
- if ($display =~ /^\d+$/) {
- $deeplinkmenu = 1;
- $menucoll = $display;
- }
- }
- }
- if ($menucoll) {
- %menu = &page_menu($env{'course.'.$env{'request.course.id'}.'.menucollections'},$menucoll);
- }
- }
- return ($menucoll,$deeplinkmenu,\%menu);
-}
-
-sub deeplink_login_symb {
- my ($cnum,$cdom) = @_;
- my $login_symb;
- if ($env{'request.deeplink.login'}) {
- $login_symb = &symb_from_tinyurl($env{'request.deeplink.login'},$cnum,$cdom);
- }
- return $login_symb;
-}
-
-sub symb_from_tinyurl {
- my ($url,$cnum,$cdom) = @_;
- if ($url =~ m{^\Q/tiny/$cdom/\E(\w+)$}) {
- my $key = $1;
- my ($tinyurl,$login);
- my ($result,$cached)=&Apache::lonnet::is_cached_new('tiny',$cdom."\0".$key);
- if (defined($cached)) {
- $tinyurl = $result;
- } else {
- my $configuname = &Apache::lonnet::get_domainconfiguser($cdom);
- my %currtiny = &Apache::lonnet::get('tiny',[$key],$cdom,$configuname);
- if ($currtiny{$key} ne '') {
- $tinyurl = $currtiny{$key};
- &Apache::lonnet::do_cache_new('tiny',$cdom."\0".$key,$currtiny{$key},600);
- }
- }
- if ($tinyurl ne '') {
- my ($cnumreq,$symb) = split(/\&/,$tinyurl);
- if (wantarray) {
- return ($cnumreq,$symb);
- } elsif ($cnumreq eq $cnum) {
- return $symb;
- }
- }
- }
- if (wantarray) {
- return ();
- } else {
- return;
- }
-}
-
-sub usable_exttools {
- my %tooltypes;
- if ($env{'request.course.id'}) {
- if ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'}) {
- if ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'} eq 'both') {
- %tooltypes = (
- crs => 1,
- dom => 1,
- );
- } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'} eq 'crs') {
- $tooltypes{'crs'} = 1;
- } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'} eq 'dom') {
- $tooltypes{'dom'} = 1;
- }
- } else {
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- my $crstype = lc($env{'course.'.$env{'request.course.id'}.'.type'});
- if ($crstype eq '') {
- $crstype = 'course';
- }
- if ($crstype eq 'course') {
- if ($env{'course.'.$env{'request.course.id'}.'internal.coursecode'}) {
- $crstype = 'official';
- } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.textbook'}) {
- $crstype = 'textbook';
- } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.lti'}) {
- $crstype = 'lti';
- } else {
- $crstype = 'unofficial';
- }
- }
- my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
- if ($domdefaults{$crstype.'domexttool'}) {
- $tooltypes{'dom'} = 1;
- }
- if ($domdefaults{$crstype.'exttool'}) {
- $tooltypes{'crs'} = 1;
- }
- }
- }
- return %tooltypes;
-}
-
sub wishlist_window {
return(<<'ENDWISHLIST');