--- loncom/lonnet/perl/lonnet.pm 2021/06/15 20:52:28 1.1460 +++ loncom/lonnet/perl/lonnet.pm 2021/07/19 15:48:27 1.1461 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.1460 2021/06/15 20:52:28 raeburn Exp $ +# $Id: lonnet.pm,v 1.1461 2021/07/19 15:48:27 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -8117,7 +8117,7 @@ sub customaccess { # ------------------------------------------------- Check for a user privilege sub allowed { - my ($priv,$uri,$symb,$role,$clientip,$noblockcheck,$ignorecache)=@_; + my ($priv,$uri,$symb,$role,$clientip,$noblockcheck,$ignorecache,$nodeeplinkcheck,$nodeeplinkout)=@_; my $ver_orguri=$uri; $uri=&deversion($uri); my $orguri=$uri; @@ -8342,7 +8342,10 @@ sub allowed { if ($env{'user.priv.'.$env{'request.role'}.'./'} =~/\Q$priv\E\&([^\:]*)/) { my $value = $1; - my $deeplinkblock = &deeplink_check($priv,$symb,$uri); + my $deeplinkblock; + unless ($nodeeplinkcheck) { + $deeplinkblock = &deeplink_check($priv,$symb,$uri); + } if ($deeplinkblock) { $thisallowed='D'; } elsif ($noblockcheck) { @@ -8365,7 +8368,10 @@ sub allowed { $refuri=&declutter($refuri); my ($match) = &is_on_map($refuri); if ($match) { - my $deeplinkblock = &deeplink_check($priv,$symb,$refuri); + my $deeplinkblock; + unless ($nodeeplinkcheck) { + $deeplinkblock = &deeplink_check($priv,$symb,$refuri); + } if ($deeplinkblock) { $thisallowed='D'; } elsif ($noblockcheck) { @@ -8441,7 +8447,10 @@ sub allowed { =~/\Q$priv\E\&([^\:]*)/) { my $value = $1; if ($priv eq 'bre') { - my $deeplinkblock = &deeplink_check($priv,$symb,$uri); + my $deeplinkblock; + unless ($nodeeplinkcheck) { + $deeplinkblock = &deeplink_check($priv,$symb,$uri); + } if ($deeplinkblock) { $thisallowed = 'D'; } elsif ($noblockcheck) { @@ -8486,7 +8495,10 @@ sub allowed { =~/\Q$priv\E\&([^\:]*)/) { my $value = $1; if ($priv eq 'bre') { - my $deeplinkblock = &deeplink_check($priv,$symb,$refuri); + my $deeplinkblock; + unless ($nodeeplinkcheck) { + $deeplinkblock = &deeplink_check($priv,$symb,$refuri); + } if ($deeplinkblock) { $thisallowed = 'D'; } elsif ($noblockcheck) { @@ -8669,6 +8681,17 @@ sub allowed { } } +# Restricted for deeplinked session? + + if ($env{'request.deeplink.login'}) { + if ($env{'acc.deeplinkout'} && !$nodeeplinkout) { + if (!$symb) { $symb=&symbread($uri,1); } + if (($symb) && ($env{'acc.deeplinkout'}=~/\&\Q$symb\E\&/)) { + return ''; + } + } + } + # Restricted by state or randomout? if ($thisallowed=~/X/) { @@ -9026,29 +9049,9 @@ sub deeplink_check { @symbs = keys(%possibles); } - my ($login,$switchrole,$allow); - if ($env{'request.deeplink.login'} =~ m{^\Q/tiny/$cdom/\E(\w+)$}) { - my $key = $1; - my $tinyurl; - 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,$posslogin) = split(/\&/,$tinyurl); - if ($cnumreq eq $cnum) { - $login = $posslogin; - } else { - $switchrole = 1; - } - } + my ($deeplink_symb,$allow); + if ($env{'request.deeplink.login'}) { + $deeplink_symb = &Apache::loncommon::deeplink_login_symb($cnum,$cdom); } foreach my $symb (@symbs) { last if ($allow); @@ -9059,15 +9062,20 @@ sub deeplink_check { my ($listed,$scope,$access) = split(/,/,$deeplink); if ($access eq 'any') { $allow = 1; - } elsif ($login) { + } elsif ($deeplink_symb) { if ($access eq 'only') { if ($scope eq 'res') { - if ($symb eq $login) { + if ($symb eq $deeplink_symb) { $allow = 1; } } elsif (($scope eq 'map') || ($scope eq 'rec')) { - my ($map_from_symb) = &deversion((&decode_symb($symb))[0]); - my ($map_from_login) = &deversion((&decode_symb($login))[0]); + my ($map_from_symb,$map_from_login); + $map_from_symb = &deversion((&decode_symb($symb))[0]); + if ($deeplink_symb =~ /\.(page|sequence)$/) { + $map_from_login = &deversion((&decode_symb($deeplink_symb))[2]); + } else { + $map_from_login = &deversion((&decode_symb($deeplink_symb))[0]); + } if (($map_from_symb) && ($map_from_login)) { if ($map_from_symb eq $map_from_login) { $allow = 1; @@ -12260,7 +12268,7 @@ sub EXT_cache_set { # --------------------------------------------------------- Value of a Variable sub EXT { - my ($varname,$symbparm,$udom,$uname,$usection,$recurse,$cid)=@_; + my ($varname,$symbparm,$udom,$uname,$usection,$recurse,$cid,$recurseupref)=@_; unless ($varname) { return ''; } #get real user name/domain, courseid and symb my $courseid; @@ -12414,6 +12422,10 @@ sub EXT { } my ($section, $group, @groups, @recurseup, $recursed); + if (ref($recurseupref) eq 'ARRAY') { + @recurseup = @{$recurseupref}; + $recursed = 1; + } my ($courselevelm,$courseleveli,$courselevel,$mapp); if (($courseid eq '') && ($cid)) { $courseid = $cid;