--- loncom/interface/loncommon.pm 2022/01/16 23:25:47 1.1075.2.161.2.2
+++ loncom/interface/loncommon.pm 2024/12/29 23:15:23 1.1075.2.176
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1075.2.161.2.2 2022/01/16 23:25:47 raeburn Exp $
+# $Id: loncommon.pm,v 1.1075.2.176 2024/12/29 23:15:23 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;
}
@@ -5695,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.
@@ -5719,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'))
@@ -5804,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 = '
'.$title.'
';
#
# Extra info if you are the DC
my $dc_info = '';
- if (($env{'user.adv'}) && ($env{'request.course.id'}) && $showcrstitle &&
+ if (($env{'user.adv'}) && ($env{'request.course.id'}) &&
(exists($env{'user.role.dc./'.$env{'course.'.$cid.'.domain'}.'/'}))) {
$dc_info = $cid.' '.$env{'course.'.$cid.'.internal.coursecode'};
$dc_info =~ s/\s+$//;
}
- my $crstype;
- if ($cid) {
- $crstype = $env{'course.'.$cid.'.type'};
- } elsif ($args->{'crstype'}) {
- $crstype = $args->{'crstype'};
- }
-
$role = '('.$role.')' if ($role && !$env{'browser.mobile'});
if ($env{'request.state'} eq 'construct') { $forcereg=1; }
@@ -5852,15 +5810,18 @@ sub bodytag {
my $funclist;
if (($env{'environment.remote'} eq 'on') && ($env{'request.state'} ne 'construct')) {
- $bodytag .= Apache::lonhtmlcommon::scripttag(Apache::lonmenu::utilityfunctions($httphost), 'start')."\n".
- Apache::lonmenu::serverform();
- my $forbodytag;
- &Apache::lonmenu::prepare_functions($env{'request.noversionuri'},
- $forcereg,$args->{'group'},
- $args->{'bread_crumbs'},
- $advtoolsref,'','',\$forbodytag);
- unless (ref($args->{'bread_crumbs'}) eq 'ARRAY') {
- $funclist = $forbodytag;
+ unless ($args->{'switchserver'}) {
+ $bodytag .= Apache::lonhtmlcommon::scripttag(Apache::lonmenu::utilityfunctions($httphost), 'start')."\n".
+ Apache::lonmenu::serverform();
+ my $forbodytag;
+ &Apache::lonmenu::prepare_functions($env{'request.noversionuri'},
+ $forcereg,$args->{'group'},
+ $args->{'bread_crumbs'},
+ $advtoolsref,'','',\$forbodytag);
+ unless (ref($args->{'bread_crumbs'}) eq 'ARRAY') {
+ $funclist = $forbodytag;
+ }
+ $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end');
}
} else {
@@ -5868,10 +5829,18 @@ sub bodytag {
# $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;
+ }
- unless ($args->{'no_primary_menu'}) {
+ 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/}) {
@@ -5880,6 +5849,9 @@ sub bodytag {
}
$bodytag .= qq|$left $role
$realm $dc_info
|;
+ if ($need_endlcint) {
+ $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end');
+ }
return $bodytag;
}
@@ -5897,26 +5869,29 @@ sub bodytag {
#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){
- unless ($args->{'no_inline_menu'}) {
- $bodytag .= Apache::lonmenu::secondary_menu($httphost,$ltiscope,$ltimenu,
- $args->{'no_primary_menu'},
- $menucoll,$menuref,
- $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,$ltiscope,$ltiuri);
+ $args->{'bread_crumbs'},'','',$hostname);
} elsif ($forcereg) {
$bodytag .= &Apache::lonmenu::innerregister($forcereg,undef,
$args->{'group'},
$args->{'hide_buttons'},
- $hostname,$ltiscope,$ltiuri);
+ $hostname);
} else {
my $forbodytag;
&Apache::lonmenu::prepare_functions($env{'request.noversionuri'},
@@ -5928,11 +5903,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;
@@ -5942,18 +5919,17 @@ sub bodytag {
# Top frame rendering, Remote is up
#
- my $imgsrc = $img;
- if ($img =~ /^\/adm/) {
- $imgsrc = &lonhttpdurl($img);
+ my $linkattr;
+ if ($args->{'links_disabled'}) {
+ $linkattr = 'class="LCisDisabled" aria-disabled="true"';
}
- my $upperleft='';
my $help=($no_inline_link?''
- :&Apache::loncommon::top_nav_help('Help'));
+ :&top_nav_help('Help',$linkattr));
# Explicit link to get inline menu
my $menu= ($no_inline_link?''
- :''.&mt('Switch to Inline Menu Mode').'');
+ :''.&mt('Switch to Inline Menu Mode').'');
if ($dc_info) {
$dc_info = qq|($dc_info)|;
@@ -5961,31 +5937,46 @@ sub bodytag {
my $name = &plainname($env{'user.name'},$env{'user.domain'});
unless ($public) {
+ my $class = 'LC_menubuttons_link';
+ if ($args->{'links_disabled'}) {
+ $class .= ' LCisDisabled';
+ }
$name = &aboutmewrapper($name,$env{'user.name'},$env{'user.domain'},
- undef,'LC_menubuttons_link');
+ undef,$class);
}
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 ' '.
@@ -6065,6 +6056,9 @@ sub endbodytag {
$endbodytag;
}
}
+ if ((ref($args) eq 'HASH') && ($args->{'dashjs'})) {
+ $endbodytag = &Apache::lonhtmlcommon::dash_to_minus_js().$endbodytag;
+ }
return $endbodytag;
}
@@ -6138,6 +6132,7 @@ body {
line-height:130%;
font-size:0.83em;
color:$font;
+ background-color: $pgbg_or_bgcolor;
}
a:focus,
@@ -8119,6 +8114,7 @@ Inputs: $title - optional title for the
(side effect of setting
$env{'internal.head.redirect'} to the url
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
@@ -8152,7 +8148,7 @@ sub headtag {
$inhibitprint = &print_suppression();
}
- if (!$args->{'frameset'}) {
+ if (!$args->{'frameset'} && !$args->{'switchserver'}) {
$result .= &Apache::lonhtmlcommon::htmlareaheaders();
}
if ($args->{'force_register'}) {
@@ -8160,7 +8156,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();
@@ -8181,8 +8178,10 @@ sub headtag {
}
}
if (ref($args->{'redirect'})) {
- my ($time,$url,$inhibit_continue) = @{$args->{'redirect'}};
- $url = &Apache::lonenc::check_encrypt($url);
+ my ($time,$url,$inhibit_continue,$skip_enc_check) = @{$args->{'redirect'}};
+ if (!$skip_enc_check) {
+ $url = &Apache::lonenc::check_encrypt($url);
+ }
if (!$inhibit_continue) {
$env{'internal.head.redirect'} = $url;
}
@@ -8235,7 +8234,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);
}
}
@@ -8326,8 +8325,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 .= ' /';
}
@@ -8528,6 +8531,11 @@ $args - additional optional args support
no_auto_mt_title -> prevent &mt()ing the title arg
bread_crumbs -> Array containing breadcrumbs
bread_crumbs_component -> if exists show it as headline else show only the breadcrumbs
+ bread_crumbs_style -> breadcrumbs are contained within ,
+ and &standard_css() contains CSS for #LC_breadcrumbs, if you want
+ to override those values, or add to them, specify the value to
+ include in the style attribute to include in the div tag by using
+ bread_crumbs_style (e.g., overflow: visible)
bread_crumbs_nomenu -> if true will pass false as the value of $menulink
to lonhtmlcommon::breadcrumbs
group -> includes the current group, if page is for a
@@ -8551,81 +8559,11 @@ 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;
- }
- }
- }
- }
- }
if (! exists($args->{'skip_phases'}{'body'}) ) {
if ($args->{'frameset'}) {
@@ -8639,8 +8577,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);
+ $args, \@advtools);
}
}
@@ -8675,17 +8612,19 @@ 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);
}
#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 {
- $result .= &Apache::lonhtmlcommon::breadcrumbs('','',$menulink);
+ $result .= &Apache::lonhtmlcommon::breadcrumbs($args->{'bread_crumbs_component'},
+ '',$menulink,'',
+ $args->{'bread_crumbs_style'});
+ }else{
+ $result .= &Apache::lonhtmlcommon::breadcrumbs('','',$menulink,'',
+ $args->{'bread_crumbs_style'});
}
} elsif (($env{'environment.remote'} eq 'on') &&
($env{'form.inhibitmenu'} ne 'yes') &&
@@ -8728,103 +8667,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) = 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 wishlist_window {
return(<<'ENDWISHLIST');