Diff for /loncom/interface/lontiny.pm between versions 1.7 and 1.8

version 1.7, 2021/08/10 15:28:14 version 1.8, 2021/11/03 01:04:03
Line 67  sub handler { Line 67  sub handler {
                     if ($cnum =~ /^$match_courseid$/) {                      if ($cnum =~ /^$match_courseid$/) {
                         my $chome = &Apache::lonnet::homeserver($cnum,$cdom);                          my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
                         if ($chome ne 'no_host') {                          if ($chome ne 'no_host') {
                             # Check for ltoken or linkkey                              &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['ttoken']);
                             my $newlauncher = &launch_check($r->uri,$symb,$cnum,$cdom);  
                             if ($env{'request.course.id'} eq $cdom.'_'.$cnum) {                              if ($env{'request.course.id'} eq $cdom.'_'.$cnum) {
                                   # Check for ttoken
                                   my $newlauncher = &launch_check($r->uri,$symb);
                                 my ($map,$resid,$url) = &Apache::lonnet::decode_symb($symb);                                  my ($map,$resid,$url) = &Apache::lonnet::decode_symb($symb);
                                 if (&Apache::lonnet::is_on_map($url)) {                                  if (&Apache::lonnet::is_on_map($url)) {
                                     my $realuri;                                      my $realuri;
Line 207  sub handler { Line 208  sub handler {
                                     }                                      }
                                     my $destination .= '/adm/roles?selectrole=1&'.$newrole.'=1'.                                      my $destination .= '/adm/roles?selectrole=1&'.$newrole.'=1'.
                                                        '&destinationurl='.&HTML::Entities::encode($r->uri);                                                         '&destinationurl='.&HTML::Entities::encode($r->uri);
                                       if ($env{'form.ttoken'}) {
                                           $destination .= '&ttoken='.$env{'form.ttoken'};
                                       }
                                     &do_redirect($r,$destination);                                      &do_redirect($r,$destination);
                                 } elsif (keys(%possroles) > 1) {                                  } elsif (keys(%possroles) > 1) {
                                     if (grep(/^(cc|co)$/,@allposs)) {                                      if (grep(/^(cc|co)$/,@allposs)) {
Line 219  sub handler { Line 223  sub handler {
                                         $newrole .= "./$cdom/$cnum";                                          $newrole .= "./$cdom/$cnum";
                                         my $destination .= '/adm/roles?selectrole=1&'.$newrole.'=1'.                                          my $destination .= '/adm/roles?selectrole=1&'.$newrole.'=1'.
                                                            '&destinationurl='.&HTML::Entities::encode($r->uri);                                                             '&destinationurl='.&HTML::Entities::encode($r->uri);
                                           if ($env{'form.ttoken'}) {
                                               $destination .= '&ttoken='.$env{'form.ttoken'};
                                           }
                                         &do_redirect($r,$destination);                                          &do_redirect($r,$destination);
                                     } else {                                      } else {
                                         my $hascustom;                                          my $hascustom;
Line 243  sub handler { Line 250  sub handler {
 }  }
   
 sub launch_check {  sub launch_check {
     my ($linkuri,$symb,$cnum,$cdom) = @_;      my ($linkuri,$symb) = @_;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['ltoken','linkkey']);  
     my ($linkprotector,$linkproturi,$linkkey,$newlauncher);      my ($linkprotector,$linkproturi,$linkkey,$newlauncher);
     if ($env{'form.ltoken'}) {      if ($env{'form.ttoken'}) {
         my %link_info = &Apache::lonnet::tmpget($env{'form.ltoken'});          my %link_info = &Apache::lonnet::tmpget($env{'form.ttoken'});
         &Apache::lonnet::tmpdel($env{'form.ltoken'});          &Apache::lonnet::tmpdel($env{'form.ttoken'});
         delete($env{'form.ltoken'});          delete($env{'form.ttoken'});
         if ($link_info{'linkprot'}) {          if ($link_info{'linkprot'}) {
             ($linkprotector,$linkproturi) = split(/:/,$link_info{'linkprot'},2);              ($linkprotector,$linkproturi) = split(/:/,$link_info{'linkprot'},2);
             if ($env{'user.linkprotector'}) {              if ($env{'user.linkprotector'}) {
Line 272  sub launch_check { Line 278  sub launch_check {
             } else {              } else {
                 &Apache::lonnet::appenv({'user.linkproturi' => $linkproturi});                  &Apache::lonnet::appenv({'user.linkproturi' => $linkproturi});
             }              }
         }          } elsif ($link_info{'linkkey'} ne '') {
     } elsif ($env{'form.linkkey'}) {              $linkkey = $link_info{'linkkey'};
         $linkkey = $env{'form.linkkey'};              my $keyedlinkuri = $linkuri;
         my $keyedlinkuri = $linkuri;              if ($env{'user.deeplinkkey'} ne '') {
         if ($env{'user.deeplinkkey'}) {                  my @linkkeys = split(/,/,$env{'user.deeplinkkey'});
             my @linkkeys = split(/,/,$env{'user.deeplinkkey'});                  unless (grep(/^\Q$linkkey\E$/,@linkkeys)) {
             unless (grep(/^\Q$linkkey\E$/,@linkkeys)) {                      push(@linkkeys,$linkkey);
                 push(@linkkeys,$linkkey);                      &Apache::lonnet::appenv({'user.deeplinkkey' => join(',',sort(@linkkeys))});
                 &Apache::lonnet::appenv({'user.deeplinkkey' => join(',',sort(@linkkeys))});                  }
             }              } else {
         } else {                  &Apache::lonnet::appenv({'user.deeplinkkey' => $linkkey});
             &Apache::lonnet::appenv({'user.deeplinkkey' => $linkkey});  
         }  
         if ($env{'user.keyedlinkuri'}) {  
             my @keyeduris = split(/,/,$env{'user.keyedlinkuri'});  
             unless (grep(/^\Q$keyedlinkuri\E$/,@keyeduris)) {  
                 push(@keyeduris,$keyedlinkuri);  
                 &Apache::lonnet::appenv({'user.keyedlinkuri' => join(',',sort(@keyeduris))});  
             }              }
         } else {              if ($env{'user.keyedlinkuri'}) {
             &Apache::lonnet::appenv({'user.keyedlinkuri' => $keyedlinkuri});                  my @keyeduris = split(/,/,$env{'user.keyedlinkuri'});
         }                  unless (grep(/^\Q$keyedlinkuri\E$/,@keyeduris)) {
         delete($env{'form.linkkey'});                      push(@keyeduris,$keyedlinkuri);
     }                      &Apache::lonnet::appenv({'user.keyedlinkuri' => join(',',sort(@keyeduris))});
     if ($env{'request.course.id'} eq $cdom.'_'.$cnum) {  
         my $currdeeplinklogin = $env{'request.deeplink.login'};  
         if ($linkprotector || $linkkey) {  
             my $deeplink;  
             if ($symb =~ /\.(page|sequence)$/) {  
                 my $mapname = &Apache::lonnet::deversion((&Apache::lonnet::decode_symb($symb))[2]);  
                 my $navmap = Apache::lonnavmaps::navmap->new();  
                 if (ref($navmap)) {  
                     $deeplink = $navmap->get_mapparam(undef,$mapname,'0.deeplink');  
                 }                  }
             } else {              } else {
                 $deeplink = &Apache::lonnet::EXT('resource.0.deeplink',$symb);                  &Apache::lonnet::appenv({'user.keyedlinkuri' => $keyedlinkuri});
             }              }
             if ($deeplink ne '') {          }
                 my $disallow;          if ($link_info{'checklaunch'}) {
                 my ($state,$others,$listed,$scope,$protect) = split(/,/,$deeplink);              $newlauncher = 1;
                 if (($protect ne 'none') && ($protect ne '')) {          }
                     my ($acctype,$item) = split(/:/,$protect);      }
                     if ($acctype =~ /lti(c|d)$/) {      my $currdeeplinklogin = $env{'request.deeplink.login'};
                         unless ($linkprotector.':'.$linkproturi eq $item.$1.':'.$linkuri) {      my $deeplink;
                             $disallow = 1;      if ($symb =~ /\.(page|sequence)$/) {
                         }          my $mapname = &Apache::lonnet::deversion((&Apache::lonnet::decode_symb($symb))[2]);
                     } elsif ($acctype eq 'key') {          my $navmap = Apache::lonnavmaps::navmap->new();
                         unless ($linkkey eq $item) {          if (ref($navmap)) {
                             $disallow = 1;              $deeplink = $navmap->get_mapparam(undef,$mapname,'0.deeplink');
                         }          }
       } else {
           $deeplink = &Apache::lonnet::EXT('resource.0.deeplink',$symb);
       }
       if ($deeplink ne '') {
           my $disallow;
           my ($state,$others,$listed,$scope,$protect) = split(/,/,$deeplink);
           if (($protect ne 'none') && ($protect ne '')) {
               my ($acctype,$item) = split(/:/,$protect);
               if ($acctype =~ /lti(c|d)$/) {
                   my $ltitype = $1;
                   if ($linkprotector) {
                       unless ($linkprotector.':'.$linkproturi eq $item.$ltitype.':'.$linkuri) {
                           $disallow = 1;
                     }                      }
                   } else {
                       $disallow = 1;
                 }                  }
                 if ($disallow) {              } elsif ($acctype eq 'key') {
                     if ($currdeeplinklogin eq $linkuri) {                  if ($linkkey ne '') {
                         &Apache::lonnet::delenv('request.deeplink.login');                      unless ($linkkey eq $item) {
                           $disallow = 1;
                     }                      }
                 } else {                  } else {
                     unless ($currdeeplinklogin eq $linkuri) {                      $disallow = 1;
                         if ($linkprotector) {  
                             &Apache::lonnet::appenv({'request.linkprot' => $linkprotector.':'.$linkproturi});  
                         } elsif ($linkkey) {  
                             &Apache::lonnet::appenv({'request.linkkey' => $linkkey});  
                         }  
                         $newlauncher = 1;  
                     }  
                     &Apache::lonnet::appenv({'request.deeplink.login' => $linkuri});  
                 }                  }
             }              }
           }
           if ($disallow) {
               if ($currdeeplinklogin eq $linkuri) {
                   &Apache::lonnet::delenv('request.deeplink.login');
               }
         } else {          } else {
               unless ($currdeeplinklogin eq $linkuri) {
                   if (($linkprotector) || ($linkkey ne '')) {
                       if ($linkprotector) {
                           &Apache::lonnet::appenv({'request.linkprot' => $linkprotector.':'.$linkproturi});
                       } elsif ($env{'request.linkprot'}) {
                           &Apache::lonnet::delenv({'request.linkprot'});
                       }
                       if ($linkkey ne '') {
                           &Apache::lonnet::appenv({'request.linkkey' => $linkkey});
                       } elsif ($env{'request.linkkey'} ne '') {
                           &Apache::lonnet::delenv({'request.linkkey'});
                       }
                       $newlauncher = 1;
                   }
               }
             &Apache::lonnet::appenv({'request.deeplink.login' => $linkuri});              &Apache::lonnet::appenv({'request.deeplink.login' => $linkuri});
         }          }
     } else {      } else {
         &Apache::lonnet::appenv({'request.deeplink.login' => $linkuri});  
         if ($linkprotector) {          if ($linkprotector) {
             &Apache::lonnet::appenv({'request.linkprot' => $linkprotector.':'.$linkproturi});              &Apache::lonnet::appenv({'request.linkprot' => $linkprotector.':'.$linkproturi});
         } elsif ($linkkey) {          } elsif ($env{'request.linkprot'}) {
               &Apache::lonnet::delenv({'request.linkprot'});
           }
           if ($linkkey ne '') {
             &Apache::lonnet::appenv({'request.linkkey' => $linkkey});              &Apache::lonnet::appenv({'request.linkkey' => $linkkey});
           } else {
               &Apache::lonnet::delenv({'request.linkkey'});
         }          }
           &Apache::lonnet::appenv({'request.deeplink.login' => $linkuri});
     }      }
     return $newlauncher;      return $newlauncher;
 }  }
Line 402  sub show_roles { Line 425  sub show_roles {
                 $preamble = &mt('You have the following active roles in this course:');                  $preamble = &mt('You have the following active roles in this course:');
             }              }
             $datatable = '<form name="" action="/adm/roles">'.              $datatable = '<form name="" action="/adm/roles">'.
                          '<input type="hidden" name="newrole" value="" />'.                           '<input type="hidden" name="newrole" value="" />'."\n".
                          '<input type="hidden" name="selectrole" value="1" />'.                           '<input type="hidden" name="selectrole" value="1" />'."\n".
                          '<input type="hidden" name="destinationurl" value="'.$r->uri.'" />'.                           '<input type="hidden" name="destinationurl" value="'.$r->uri.'" />'."\n";
                          &Apache::loncommon::start_data_table().              if ($env{'form.ttoken'}) {
                          &Apache::loncommon::start_data_table_header_row().                  $datatable .= '<input type="hidden" name="ttoken" value="'.$env{'form.ttoken'}.'" />'."\n";
                          '<th></th><th>'.&mt('User role').'</th>';              }
               $datatable .= &Apache::loncommon::start_data_table().
                             &Apache::loncommon::start_data_table_header_row().
                             '<th></th><th>'.&mt('User role').'</th>';
             if ($hassection) {              if ($hassection) {
                 $datatable .= '<th>'.&mt('Section').'</th>';                  $datatable .= '<th>'.&mt('Section').'</th>';
             }              }

Removed from v.1.7  
changed lines
  Added in v.1.8


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>