--- loncom/auth/lonroles.pm 2021/11/28 19:18:00 1.357
+++ loncom/auth/lonroles.pm 2022/06/26 04:03:47 1.365
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.357 2021/11/28 19:18:00 raeburn Exp $
+# $Id: lonroles.pm,v 1.365 2022/06/26 04:03:47 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -149,19 +149,23 @@ my $registered_cleanup;
my $rosterupdates;
sub start_loading_course {
- my ($r,$title) = @_;
+ my ($r,$title,$only_body) = @_;
&Apache::loncommon::content_type($r,'text/html');
&Apache::loncommon::no_cache($r);
$r->send_http_header;
- my $swinfo=&Apache::lonmenu::rawconfig();
- # Breadcrumbs
- my $brcrum = [{'href' => '',
- 'text' => $title},];
- my $start_page = &Apache::loncommon::start_page($title,undef,
- {'bread_crumbs' => $brcrum,
- 'bread_crumbs_nomenu' => 1,
- 'links_disabled' => 1});
- $r->print(<print(&Apache::loncommon::start_page($title,undef,{'only_body' => 1,
+ 'add_progressbar' => 1}));
+ } else {
+ my $swinfo=&Apache::lonmenu::rawconfig();
+ # Breadcrumbs
+ my $brcrum = [{'href' => '',
+ 'text' => $title},];
+ my $start_page = &Apache::loncommon::start_page($title,undef,
+ {'bread_crumbs' => $brcrum,
+ 'bread_crumbs_nomenu' => 1,
+ 'links_disabled' => 1});
+ $r->print(<
//
ENDREDIR
+ }
return;
}
sub finish_loading_course {
- my ($r,$msg,$url) = @_;
- my $link = '';
+ my ($r,$msg,$url,$only_body) = @_;
+ my $link = '';
my $end_page = &Apache::loncommon::end_page();
my $js_url = &js_escape($url);
+ my $reenable;
+ unless ($only_body) {
+ $reenable = < a').removeAttr("aria-disabled");
+ \$('.isDisabled').removeClass("isDisabled");
+REENABLE
+ }
$r->print(<
// a').removeAttr("aria-disabled");
- \$('.isDisabled').removeClass("isDisabled");
+ $reenable
var url = "$js_url";
\$(location).attr('href',url);
});
+// ]]>
$link
$end_page
@@ -277,7 +290,8 @@ sub handler {
$update = $then;
}
- my ($norolelist,$blocked_by_ip,$blocked_type,$blocked_ipaddr);
+ my ($norolelist,$blocked_by_ip,$blocked_type,$clientip);
+ $clientip = &Apache::lonnet::get_requestor_ip($r);
if (($env{'request.course.id'}) && ($env{'request.deeplink.login'})) {
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
@@ -355,16 +369,15 @@ sub handler {
unless (defined($cached)) {
my %domconfig =
&Apache::lonnet::get_dom('configuration',['ipaccess'],$cdom);
- $ipaccessref = &do_cache_new('ipaccess',$cdom,$domconfig{'ipaccess'},1800);
+ $ipaccessref = &Apache::lonnet::do_cache_new('ipaccess',$cdom,$domconfig{'ipaccess'},1800);
}
if (ref($ipaccessref) eq 'HASH') {
- my $remote_ip = &Apache::lonnet::get_requestor_ip();
foreach my $id (keys(%{$ipaccessref})) {
if (ref($ipaccessref->{$id}) eq 'HASH') {
my $range = $ipaccessref->{$id}->{'ip'};
if ($range) {
my $type = 'exclude';
- if (&Apache::lonnet::ip_match($remote_ip,$range)) {
+ if (&Apache::lonnet::ip_match($clientip,$range)) {
$type = 'include';
}
if (ref($ipaccessref->{$id}->{'courses'}) eq 'HASH') {
@@ -386,9 +399,6 @@ sub handler {
}
}
}
- unless ($showrole) {
- $blocked_ipaddr = $remote_ip;
- }
}
}
}
@@ -764,9 +774,21 @@ ENDENTERKEY
}
my $crstype = &Apache::loncommon::course_type($cdom.'_'.$cnum);
$crstype = lc($crstype);
+ my ($msg,$critmsg_check,$title,$loadmsg,$only_body);
+ $critmsg_check = 1;
+ $title = &mt("Loading $crstype");
+ $loadmsg = &mt("Please be patient while your $crstype loads");
+ if (($env{'request.deeplink.login'}) && ($env{'request.linkprot'})) {
+ if ($env{'request.linkprot'} =~ /^\d+(c|d):\Q$env{'form.destinationurl'}\E$/) {
+ $title = &mt('Loading LON-CAPA session');
+ $loadmsg = &mt('Please be patient while LON-CAPA loads');
+ $only_body = 1;
+ $critmsg_check = 0;
+ }
+ }
my $preamble = ''.
'
'.
- &mt("Please be patient while your $crstype loads").
+ $loadmsg.
'
'.
'';
my $closure = <
ENDCLOSE
- my $title = &mt("Loading $crstype");
- &start_loading_course($r,$title);
+ &start_loading_course($r,$title,$only_body);
my %prog_state = &Apache::lonhtmlcommon::Create_PrgWin($r,undef,$preamble);
&Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,&mt('Loading ...'));
$r->rflush();
- my ($msg,$blockcrit,$critmsg_check);
- $critmsg_check = 1;
- $blockcrit = &Apache::loncommon::blocking_status('alert',$cnum,$cdom,undef,1);
- if ($blockcrit) {
- my $checkrole = "cm./$cdom/$cnum";
- if ($csec ne '') {
- $checkrole .= "/$csec";
- }
- unless ((&Apache::lonnet::allowed('evb',undef,undef,$checkrole)) &&
- ($trolecode !~ m{^st\./$cdom/$cnum})) {
- $critmsg_check = 0;
+ if ($critmsg_check) {
+ my $blockcrit = &Apache::loncommon::blocking_status('alert',$clientip,$cnum,$cdom,undef,1);
+ if ($blockcrit) {
+ my $checkrole = "cm./$cdom/$cnum";
+ if ($csec ne '') {
+ $checkrole .= "/$csec";
+ }
+ unless ((&Apache::lonnet::allowed('evb',undef,undef,$checkrole)) &&
+ ($trolecode !~ m{^st\./$cdom/$cnum})) {
+ $critmsg_check = 0;
+ }
}
}
my ($furl,$ferr)=
@@ -900,10 +921,13 @@ ENDCLOSE
($env{'request.lti.rosterid'} || $env{'request.lti.passbackid'})) {
&process_lti($r,$cdom,$cnum);
}
+ if ($env{'request.deeplink.login'}) {
+ &set_deeplink_target($cnum,$cdom);
+ }
$msg = ''.&mt('Entering [_1] ...',
$env{'course.'.$cdom.'_'.$cnum.'.description'}).
'
';
- &finish_loading_course($r,$msg,$dest);
+ &finish_loading_course($r,$msg,$dest,$only_body);
}
}
$r->rflush();
@@ -931,6 +955,9 @@ ENDCLOSE
($env{'request.lti.rosterid'} || $env{'request.lti.passbackid'})) {
&process_lti($r,$cdom,$cnum);
}
+ if ($env{'request.deeplink.login'}) {
+ &set_deeplink_target($cnum,$cdom);
+ }
# Check to see if the user is a CC entering a course
# for the first time
if ((($role eq 'cc') || ($role eq 'co'))
@@ -946,7 +973,7 @@ ENDCLOSE
$msg = ''.&mt('Entering [_1] ...',
$env{'course.'.$cdom.'_'.$cnum.'.description'}).
'
';
- &finish_loading_course($r,$msg,'/adm/placement');
+ &finish_loading_course($r,$msg,'/adm/placement',$only_body);
$r->rflush();
return OK;
}
@@ -1018,7 +1045,7 @@ ENDCLOSE
$env{'course.'.$cdom.'_'.$cnum.'.description'}).
'
';
}
- &finish_loading_course($r,$msg,$dest);
+ &finish_loading_course($r,$msg,$dest,$only_body);
$r->rflush();
return OK;
}
@@ -1033,7 +1060,7 @@ ENDCLOSE
$msg = ''.&mt('Entering [_1] ...',
$env{'course.'.$cdom.'_'.$cnum.'.description'}).
'
';
- &finish_loading_course($r,$msg,'/adm/whatsnew?refpage=start');
+ &finish_loading_course($r,$msg,'/adm/whatsnew?refpage=start',$only_body);
$r->rflush();
return OK;
}
@@ -1081,12 +1108,12 @@ ENDCLOSE
}
if ($env{'request.lti.login'}) {
undef($msg);
- &finish_loading_course($r,$msg,$furl);
+ &finish_loading_course($r,$msg,$furl,$only_body);
} else {
$msg = ''.&mt('Entering [_1] ...',
$env{'course.'.$cdom.'_'.$cnum.'.description'}).
'
';
- &finish_loading_course($r,$msg,$furl);
+ &finish_loading_course($r,$msg,$furl,$only_body);
}
}
$r->rflush();
@@ -1354,7 +1381,7 @@ ENDHEADER
}
$r->print(''.
&mt('The [_1] you selected is not available for access with a [_2] role from your current IP address: [_3].',
- lc($blocked_type),$blocked_role,$blocked_ipaddr).
+ lc($blocked_type),$blocked_role,$clientip).
'
');
}
}
@@ -1994,7 +2021,7 @@ sub findcourse_advice {
} else {
$r->print(''.&mt('If you were expecting to see an active role listed for a particular course, that course may not have been created yet.').'
');
if ($elapsed > 600) {
- $r->print(''.&mt('You may also have been assigned to a course in the time since you last logged-in, or checked for changes').
+ $r->print('
'.&mt('You may also have been assigned to a course in the time since you last logged-in, or checked for changes.').
'
'.
&mt('If that is the case you can use the "Check for changes" link in the gray Functions bar to update the list of your available course roles.').'
');
}
@@ -3549,6 +3576,34 @@ sub ltienroll {
}
}
+sub set_deeplink_target {
+ my ($cnum,$cdom) = @_;
+ if (($cnum ne '') && ($cdom ne '')) {
+ my $deeplink_symb = &Apache::loncommon::deeplink_login_symb($cnum,$cdom);
+ if ($deeplink_symb ne '') {
+ my $deeplink;
+ 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');
+ }
+ } elsif ($deeplink_symb ne '') {
+ $deeplink = &Apache::lonnet::EXT('resource.0.deeplink',$deeplink_symb);
+ }
+ if ($deeplink ne '') {
+ my ($state,$others,$listed,$scope,$protect,$display,$target) = split(/,/,$deeplink);
+ if ($target ne '') {
+ &Apache::lonnet::appenv({'request.deeplink.target' => $target});
+ } elsif (exists($env{'request.deeplink.target'})) {
+ &Apache::lonnet::delenv('request.deeplink.target');
+ }
+ }
+ }
+ }
+ return;
+}
+
1;
__END__