[LON-CAPA-cvs] cvs: rat / lonpageflip.pm loncom/auth lonroles.pm
raeburn
raeburn at source.lon-capa.org
Mon Jul 19 10:26:40 EDT 2021
raeburn Mon Jul 19 14:26:40 2021 EDT
Modified files:
/loncom/auth lonroles.pm
/rat lonpageflip.pm
Log:
- Support case where first URL in course is an external resource and
encrypturl in use.
- Use symb in first_url from lonuserstate::readmap() for other resources
besides external resource.
- Retrieve symb in first_url in lonpageflip::first_accessible_resource()
when encrypturl in use.
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.350 loncom/auth/lonroles.pm:1.351
--- loncom/auth/lonroles.pm:1.350 Sat Jun 12 23:14:56 2021
+++ loncom/auth/lonroles.pm Mon Jul 19 14:26:40 2021
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.350 2021/06/12 23:14:56 raeburn Exp $
+# $Id: lonroles.pm,v 1.351 2021/07/19 14:26:40 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -902,23 +902,44 @@
}
}
# Are we allowed to look at the first resource?
- my $access;
- if ($furl =~ m{^(/adm/wrapper|)/ext/}) {
- # If it's an external resource,
- # strip off the symb argument and possible query
- my ($exturl,$symb) = ($furl =~ m{^(.+)(?:\?|\&)symb=(.+)$});
- # Unencode $symb
- $symb = &unescape($symb);
- # Then check for permission
- $access = &Apache::lonnet::allowed('bre',$exturl,$symb);
- # For other resources just check for permission
+ #
+ # $furl returned by lonuserstate::readmap() has format:
+ # $url?symb=escaped($symb). If the resource has the
+ # encrypturl parameter in effect, the entire string
+ # $url?symb=escaped($symb) is encrypted as a string
+ # beginning /enc/.
+ #
+ my ($access,$unencfurl,$unencsymb);
+ if ($furl =~ m{^(.+)(?:\?|\&)symb=([^&]+)(?:$|&)}) {
+ my ($poss_url,$poss_symb) = ($1,$2);
+ $unencsymb = &unescape($poss_symb);
+ $unencfurl = $poss_url;
+ } elsif ($furl =~ m{^/enc/}) {
+ my $unenc = &Apache::lonenc::unencrypted($furl);
+ if ($unenc =~ m{^(.+)(?:\?|\&)symb=([^&]+)(?:$|&)}) {
+ ($unencfurl,$unencsymb) = ($1,$2);
+ $unencsymb = &unescape($unencsymb);
+ } else {
+ $unencfurl = $unenc;
+ }
} else {
- $access = &Apache::lonnet::allowed('bre',$furl);
+ $unencfurl = $furl;
}
- if ((!$access) || ($access eq 'D')) {
+ if ($unencsymb) {
+ my $symb = &Apache::lonnet::symbclean($unencsymb);
+ if (($symb ne '') && (&Apache::lonnet::symbverify($symb,$unencfurl))) {
+ $access = &Apache::lonnet::allowed('bre',$unencfurl,$symb);
+ } else {
+ $access = &Apache::lonnet::allowed('bre',$unencfurl);
+ }
+ } else {
+ $access = &Apache::lonnet::allowed('bre',$unencfurl);
+ }
+ if ((!$access) || ($access eq 'B') || ($access eq 'D')) {
$furl = &Apache::lonpageflip::first_accessible_resource();
- } elsif ($access eq 'B') {
- $furl = '/adm/navmaps?showOnlyHomework=1';
+ if ($furl eq '') {
+ $furl = '/adm/navmaps?showOnlyHomework=1';
+ }
}
if ($env{'request.lti.login'}) {
undef($msg);
Index: rat/lonpageflip.pm
diff -u rat/lonpageflip.pm:1.104 rat/lonpageflip.pm:1.105
--- rat/lonpageflip.pm:1.104 Mon Jun 7 19:04:20 2021
+++ rat/lonpageflip.pm Mon Jul 19 14:26:40 2021
@@ -2,7 +2,7 @@
#
# Page flip handler
#
-# $Id: lonpageflip.pm,v 1.104 2021/06/07 19:04:20 raeburn Exp $
+# $Id: lonpageflip.pm,v 1.105 2021/07/19 14:26:40 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -256,9 +256,13 @@
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'.db',
&GDBM_READER(),0640)) {
$furl=$hash{'first_url'};
- my %args;
- my ($url,$args) = split(/\?/,$furl);
- foreach my $pair (split(/\&/,$args)) {
+ my (%args,$url,$argstr);
+ if ($furl =~ m{^/enc/}) {
+ ($url,$argstr) = split(/\?/,&Apache::lonenc::unencrypted($furl));
+ } else {
+ ($url,$argstr) = split(/\?/,$furl);
+ }
+ foreach my $pair (split(/\&/,$argstr)) {
my ($name,$value) = split(/=/,$pair);
$args{&unescape($name)} = &unescape($value);
}
@@ -268,13 +272,17 @@
# Wow, we cannot see this ... move forward to the next one that we can see
my ($newrid,$newmap)=&move($hash{'first_rid'},$hash{'first_mapurl'},'forward',1);
# Build the new URL
- my ($newmapid,$newresid)=split(/\./,$newrid);
- my $symb=&Apache::lonnet::encode_symb($newmap,$newresid,$hash{'src_'.$newrid});
- $furl=&add_get_param($hash{'src_'.$newrid},{ 'symb' => $symb });
- if ($hash{'encrypted_'.$newrid}) {
- $furl=&Apache::lonenc::encrypted($furl);
+ if ($newrid eq '') {
+ $furl = '/adm/navmaps';
+ } else {
+ my ($newmapid,$newresid)=split(/\./,$newrid);
+ my $symb=&Apache::lonnet::encode_symb($newmap,$newresid,$hash{'src_'.$newrid});
+ $furl=&add_get_param($hash{'src_'.$newrid},{ 'symb' => $symb });
+ if ($hash{'encrypted_'.$newrid}) {
+ $furl=&Apache::lonenc::encrypted($furl);
+ }
}
- }
+ }
untie(%hash);
return $furl;
} else {
More information about the LON-CAPA-cvs
mailing list