--- loncom/interface/loncommon.pm 2024/07/02 21:15:18 1.1075.2.166
+++ loncom/interface/loncommon.pm 2024/10/07 21:20:09 1.1075.2.172
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1075.2.166 2024/07/02 21:15:18 raeburn Exp $
+# $Id: loncommon.pm,v 1.1075.2.172 2024/10/07 21:20:09 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();
@@ -3670,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?";
@@ -5797,46 +5820,68 @@ sub bodytag {
unless (ref($args->{'bread_crumbs'}) eq 'ARRAY') {
$funclist = $forbodytag;
}
+ $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end');
} else {
# if ($env{'request.state'} eq 'construct') {
# $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls
# }
- $bodytag .= Apache::lonhtmlcommon::scripttag(
- Apache::lonmenu::utilityfunctions($httphost), 'start');
+ my $need_endlcint;
+ unless ($args->{'switchserver'}) {
+ $bodytag .= Apache::lonhtmlcommon::scripttag(
+ Apache::lonmenu::utilityfunctions($httphost), 'start');
+ $need_endlcint = 1;
+ }
- my ($left,$right) = Apache::lonmenu::primary_menu($args->{'links_disabled'});
+ if (($env{'environment.remote'} eq 'on') && ($env{'request.state'} eq 'construct')) {
+ unless ($env{'form.inhibitmenu'}) {
+ $bodytag .= &inline_for_remote($public,$role,$realm,$dc_info,$no_inline_link);
+ }
+ } else {
+ my ($left,$right) = Apache::lonmenu::primary_menu($args->{'links_disabled'});
- if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) {
- if ($dc_info) {
- $dc_info = qq|$dc_info|;
+ if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) {
+ if ($dc_info) {
+ $dc_info = qq|$dc_info|;
+ }
+ $bodytag .= qq|
$left $role
+ $realm $dc_info
|;
+ if ($need_endlcint) {
+ $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end');
+ }
+ return $bodytag;
}
- $bodytag .= qq|$left $role
- $realm $dc_info
|;
- return $bodytag;
- }
- unless ($env{'request.symb'} =~ m/\.page___\d+___/) {
- $bodytag .= qq|$left $role
|;
- }
+ unless ($env{'request.symb'} =~ m/\.page___\d+___/) {
+ $bodytag .= qq|$left $role
|;
+ }
- $bodytag .= $right;
+ $bodytag .= $right;
- if ($dc_info) {
- $dc_info = &dc_courseid_toggle($dc_info);
+ if ($dc_info) {
+ $dc_info = &dc_courseid_toggle($dc_info);
+ }
+ $bodytag .= qq|$realm $dc_info
|;
}
- $bodytag .= qq|$realm $dc_info
|;
#if directed to not display the secondary menu, don't.
if ($args->{'no_secondary_menu'}) {
+ if ($need_endlcint) {
+ $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end');
+ }
return $bodytag;
}
#don't show menus for public users
if (!$public){
- $bodytag .= Apache::lonmenu::secondary_menu($httphost,$args->{'links_disabled'});
+ unless (($env{'environment.remote'} eq 'on') &&
+ ($env{'request.state'} eq 'construct')) {
+ $bodytag .= Apache::lonmenu::secondary_menu($httphost,$args->{'links_disabled'});
+ }
$bodytag .= Apache::lonmenu::serverform();
- $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end');
+ if ($need_endlcint) {
+ $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end');
+ }
if ($env{'request.state'} eq 'construct') {
$bodytag .= &Apache::lonmenu::innerregister($forcereg,
$args->{'bread_crumbs'},'','',$hostname);
@@ -5856,11 +5901,13 @@ sub bodytag {
$bodytag .= $forbodytag;
}
}
- }else{
- # this is to seperate menu from content when there's no secondary
+ } else {
+ # this is to separate menu from content when there's no secondary
# menu. Especially needed for public accessible ressources.
$bodytag .= '
';
- $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end');
+ if ($need_endlcint) {
+ $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end');
+ }
}
return $bodytag;
@@ -5870,12 +5917,6 @@ sub bodytag {
# Top frame rendering, Remote is up
#
- my $imgsrc = $img;
- if ($img =~ /^\/adm/) {
- $imgsrc = &lonhttpdurl($img);
- }
- my $upperleft='';
-
my $help=($no_inline_link?''
:&Apache::loncommon::top_nav_help('Help'));
@@ -5894,26 +5935,37 @@ sub bodytag {
}
unless ($env{'form.inhibitmenu'}) {
- $bodytag .= qq|$name $role
- $realm $dc_info
|;
- }
- if ($env{'request.state'} eq 'construct') {
- if (!$public){
- if ($env{'request.state'} eq 'construct') {
- $funclist = &Apache::lonhtmlcommon::scripttag(
- &Apache::lonmenu::utilityfunctions($httphost), 'start').
- &Apache::lonhtmlcommon::scripttag('','end').
- &Apache::lonmenu::innerregister($forcereg,
- $args->{'bread_crumbs'});
- }
- }
+ $bodytag .= &inline_for_remote($public,$role,$realm,$dc_info,$no_inline_link);
}
return $bodytag."\n".$funclist;
}
+sub inline_for_remote {
+ my ($public,$role,$realm,$dc_info,$no_inline_link) = @_;
+ my $help=($no_inline_link?''
+ :&Apache::loncommon::top_nav_help('Help'));
+
+ # Explicit link to get inline menu
+ my $menu= ($no_inline_link?''
+ :''.&mt('Switch to Inline Menu Mode').'');
+
+ if ($dc_info) {
+ $dc_info = qq|($dc_info)|;
+ }
+
+ my $name = &plainname($env{'user.name'},$env{'user.domain'});
+ unless ($public) {
+ $name = &aboutmewrapper($name,$env{'user.name'},$env{'user.domain'},
+ undef,'LC_menubuttons_link');
+ }
+
+ return qq|$name $role
+ $realm $dc_info
|;
+}
+
sub dc_courseid_toggle {
my ($dc_info) = @_;
return ' '.
@@ -8084,7 +8136,7 @@ sub headtag {
$inhibitprint = &print_suppression();
}
- if (!$args->{'frameset'}) {
+ if (!$args->{'frameset'} && !$args->{'switchserver'}) {
$result .= &Apache::lonhtmlcommon::htmlareaheaders();
}
if ($args->{'force_register'}) {
@@ -8092,7 +8144,8 @@ sub headtag {
}
if (!$args->{'no_nav_bar'}
&& !$args->{'only_body'}
- && !$args->{'frameset'}) {
+ && !$args->{'frameset'}
+ && !$args->{'switchserver'}) {
$result .= &help_menu_js($httphost);
$result.=&modal_window();
$result.=&togglebox_script();
@@ -8260,8 +8313,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 .= ' /';
}
@@ -13156,7 +13213,9 @@ sub process_extracted_files {
my $url = '/uploaded/'.$docudom.'/'.$docuname.'/'.
$docstype.'/'.$mapinner{$outer}.'/'.$newidx.'/'.
$title;
- if (($outer !~ /\D/) && ($mapinner{$outer} !~ /\D/) && ($newidx !~ /\D/)) {
+ if (($outer !~ /\D/) &&
+ (($mapinner{$outer} eq 'default') || ($mapinner{$outer} !~ /\D/)) &&
+ ($newidx !~ /\D/)) {
if (!-e "$prefix$dir/$docstype/$mapinner{$outer}") {
mkdir("$prefix$dir/$docstype/$mapinner{$outer}",0755);
}
@@ -15195,7 +15254,8 @@ sub commit_studentrole {
}
$oldsecurl = $uurl;
$expire_role_result =
- &Apache::lonnet::assignrole($udom,$uname,$uurl,'st',$now,'','',$context);
+ &Apache::lonnet::assignrole($udom,$uname,$uurl,'st',$now,
+ '','','',$context);
if ($env{'request.course.sec'} ne '') {
if ($expire_role_result eq 'refused') {
my @roles = ('st');
@@ -17126,9 +17186,12 @@ sub recurse_supplemental {
if ($fatal) {
$errors ++;
} else {
- if ($#LONCAPA::map::resources > 0) {
- foreach my $res (@LONCAPA::map::resources) {
- my ($title,$src,$ext,$type,$status)=split(/\:/,$res);
+ my @order = @LONCAPA::map::order;
+ if (@order > 0) {
+ my @resources = @LONCAPA::map::resources;
+ my @resparms = @LONCAPA::map::resparms;
+ foreach my $idx (@order) {
+ my ($title,$src,$ext,$type,$status)=split(/\:/,$resources[$idx]);
if (($src ne '') && ($status eq 'res')) {
if ($src =~ m{^\Q/uploaded/$cdom/$cnum/\E(supplemental_\d+\.sequence)$}) {
($numfiles,$errors) = &recurse_supplemental($cnum,$cdom,$1,$numfiles,$errors);
@@ -17335,7 +17398,7 @@ sub create_captcha {
$output = ''."\n".
''.
&mt('Type in the letters/numbers shown below').' '.
- ''.
+ ''.
'
'.
'';
last;