[LON-CAPA-cvs] cvs: loncom / lontrans.pm /auth lonauth.pm migrateuser.pm switchserver.pm /interface loncommon.pm londocs.pm lonevaluate.pm lonhtmlcommon.pm lonnavdisplay.pm lontiny.pm lonwishlist.pm /lonnet/perl lonnet.pm /lti ltiauth.pm ltiutils.pm rat lonsequence.pm

raeburn raeburn at source.lon-capa.org
Fri Apr 13 22:30:11 EDT 2018


raeburn		Sat Apr 14 02:30:11 2018 EDT

  Modified files:              
    /loncom/interface	loncommon.pm londocs.pm lonevaluate.pm 
                     	lonhtmlcommon.pm lonnavdisplay.pm lontiny.pm 
                     	lonwishlist.pm 
    /loncom	lontrans.pm 
    /rat	lonsequence.pm 
    /loncom/lonnet/perl	lonnet.pm 
    /loncom/lti	ltiauth.pm ltiutils.pm 
    /loncom/auth	lonauth.pm switchserver.pm migrateuser.pm 
  Log:
  - Bug 6754 LON-CAPA as LTI Provider
    - Original LTI launch of LON-CAPA is for a resource, a map, or an entire 
      course, and display is for iframe, tab or window; retain this in %env.
  
  
-------------- next part --------------
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1311 loncom/interface/loncommon.pm:1.1312
--- loncom/interface/loncommon.pm:1.1311	Sat Apr 14 00:36:06 2018
+++ loncom/interface/loncommon.pm	Sat Apr 14 02:29:44 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1311 2018/04/14 00:36:06 raeburn Exp $
+# $Id: loncommon.pm,v 1.1312 2018/04/14 02:29:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -8722,9 +8722,16 @@
                 if (@advtools > 0) {
                     &Apache::lonmenu::advtools_crumbs(@advtools);
                 }
+                my $ltiscope;
+                if (($env{'request.course.id'}) && ($env{'request.lti.login'})) {
+                    my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+                    my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+                    ($ltiscope) = &LONCAPA::ltiutils::lti_provider_scope($env{'request.lti.uri'},$cdom,$cnum);
+                }
                 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') ||
                      ((($args->{'crstype'} eq 'Placement') || (($env{'request.course.id'}) &&
                      ($env{'course.'.$env{'request.course.id'}.'.type'} eq 'Placement'))) &&
                      (!$env{'request.role.adv'}))) {
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.652 loncom/interface/londocs.pm:1.653
--- loncom/interface/londocs.pm:1.652	Sat Apr 14 00:10:48 2018
+++ loncom/interface/londocs.pm	Sat Apr 14 02:29:44 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.652 2018/04/14 00:10:48 raeburn Exp $
+# $Id: londocs.pm,v 1.653 2018/04/14 02:29:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -5225,13 +5225,17 @@
     if (!defined($message)) {
 	$message='Changes will become active for your current session after [_1], or the next time you log in.';
     }
+    my $windowname = 'loncapaclient';
+    if ($env{'request.lti.login'}) {
+        $windowname .= 'lti';
+    }
     $r->print("\n\n".
 '<script type="text/javascript">'."\n".
 '// <![CDATA['."\n".
 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
 '// ]]>'."\n".
 '</script>'."\n".
-'<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
+'<form name="reinitform" method="post" action="/adm/roles" target="'.$windowname.'">'.
 '<input type="hidden" name="orgurl" value="'.$url.
 '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
 &mt($message,' <input type="hidden" name="'.
@@ -6153,9 +6157,13 @@
        }
        my $postexec='';
        if ($folder eq 'default') {
+           my $windowname = 'loncapaclient';
+           if ($env{'request.lti.login'}) {
+               $windowname .= 'lti';
+           }
            $r->print('<script type="text/javascript">'."\n"
                     .'// <![CDATA['."\n"
-                    .'this.window.name="loncapaclient";'."\n"
+                    .'this.window.name="'.$windowname.'";'."\n"
                     .'// ]]>'."\n"
                     .'</script>'."\n"
        );
Index: loncom/interface/lonevaluate.pm
diff -u loncom/interface/lonevaluate.pm:1.30 loncom/interface/lonevaluate.pm:1.31
--- loncom/interface/lonevaluate.pm:1.30	Fri Jan 17 17:10:12 2014
+++ loncom/interface/lonevaluate.pm	Sat Apr 14 02:29:44 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Evaluate
 #
-# $Id: lonevaluate.pm,v 1.30 2014/01/17 17:10:12 bisitz Exp $
+# $Id: lonevaluate.pm,v 1.31 2018/04/14 02:29:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -76,6 +76,11 @@
 
     my $warning='';
 
+    my $windowname = 'loncapaclient';
+    if ($env{'request.lti.login'}) {
+        $windowname .= 'lti';
+    }
+
     if ($env{'form.submiteval'} eq 'true') {
 # ------------------------------------------------ User is submitting something
         my $complete=1;
@@ -90,7 +95,7 @@
 	    my $showurl=&Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($feedurl));
             my $js = &Apache::lonhtmlcommon::scripttag(<<ENDJS);
     function goback() {
-        if ((window.name=='loncapaclient')) {
+        if ((window.name=='$windowname')) {
             window.location='$showurl';
         } else {
             self.close();
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.391 loncom/interface/lonhtmlcommon.pm:1.392
--- loncom/interface/lonhtmlcommon.pm:1.391	Mon Dec 18 16:36:34 2017
+++ loncom/interface/lonhtmlcommon.pm	Sat Apr 14 02:29:44 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.391 2017/12/18 16:36:34 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.392 2018/04/14 02:29:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -78,7 +78,11 @@
 sub coursepreflink {
    my ($text,$category)=@_;
    if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {
-      return '<a target="_top" href="'.&HTML::Entities::encode("/adm/courseprefs?phase=display&actions=$category",'<>&"').'"><span class="LC_setting">'.$text.'</span></a>';
+       my $target =' target="_top"';
+       if (($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) {
+           $target ='';
+       }
+       return '<a'.$target.' href="'.&HTML::Entities::encode("/adm/courseprefs?phase=display&actions=$category",'<>&"').'"><span class="LC_setting">'.$text.'</span></a>';
    } else {
       return '';
    }
@@ -1925,9 +1929,13 @@
                     }
                 }
             }
+            my $target;
+            unless (($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) {
+                $target='_top';
+            }
             $menulink =  {  href   =>'/adm/menu',
                             title  =>'Go to main menu',
-                            target =>'_top',
+                            target =>$target,
                             text   =>$description,
                             no_mt  =>$no_mt_descr, };
             if($last) {
Index: loncom/interface/lonnavdisplay.pm
diff -u loncom/interface/lonnavdisplay.pm:1.35 loncom/interface/lonnavdisplay.pm:1.36
--- loncom/interface/lonnavdisplay.pm:1.35	Thu Nov 16 13:41:56 2017
+++ loncom/interface/lonnavdisplay.pm	Sat Apr 14 02:29:44 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Display Handler
 #
-# $Id: lonnavdisplay.pm,v 1.35 2017/11/16 13:41:56 raeburn Exp $
+# $Id: lonnavdisplay.pm,v 1.36 2018/04/14 02:29:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -39,6 +39,7 @@
 use Apache::lonlocal;
 use Apache::londocs();
 use Apache::lonuserstate;
+use LONCAPA::ltiutils;
 
 sub handler {
     my $r = shift;
@@ -125,6 +126,20 @@
         }
     }
 
+    if ($env{'request.lti.login'}) {
+        if ($env{'request.lti.uri'} ne '') {
+            my $cid = $env{'request.course.id'};
+            my $cnum = $env{'course.'.$cid.'.num'};
+            my $cdom = $env{'course.'.$cid.'.domain'};
+            my ($scope,$url) = &LONCAPA::ltiutils::lti_provider_scope($env{'request.lti.uri'},$cdom,$cnum);
+            if (($scope eq 'map') || ($scope eq 'resource')) {
+                &Apache::loncommon::content_type($r,'text/html');
+                $r->header_out(Location => $url);
+                return REDIRECT;
+            }
+        }
+    }
+
     # Create the nav map
     my $navmap = Apache::lonnavmaps::navmap->new();
 
Index: loncom/interface/lontiny.pm
diff -u loncom/interface/lontiny.pm:1.1 loncom/interface/lontiny.pm:1.2
--- loncom/interface/lontiny.pm:1.1	Fri Jan 12 13:33:38 2018
+++ loncom/interface/lontiny.pm	Sat Apr 14 02:29:44 2018
@@ -2,7 +2,7 @@
 # Extract domain, courseID, and symb from a shortened URL,
 # and switch role to a role in designated course.
 #
-# $Id: lontiny.pm,v 1.1 2018/01/12 13:33:38 raeburn Exp $
+# $Id: lontiny.pm,v 1.2 2018/04/14 02:29:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -132,13 +132,16 @@
 
 sub do_redirect {
     my ($r,$destination) = @_;
-    my $windowinfo = Apache::lonhtmlcommon::scripttag('self.name="loncapaclient";');
+    my $windowname = 'loncapaclient';
+    if ($env{'request.lti.login'}) {
+        $windowname .= 'lti';
+    }
     my $header = '<meta HTTP-EQUIV="Refresh" CONTENT="0; url='.$destination.'" />';
     my $args = {'bread_crumbs' => [{'href' => '','text' => 'Role initialization'},],};
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
     $r->print(&Apache::loncommon::start_page('Valid link',$header,$args).
-              &Apache::lonhtmlcommon::scripttag('self.name="loncapaclient";').
+              &Apache::lonhtmlcommon::scripttag('self.name="'.$windowname.'";').
               '<h1>'.&mt('Welcome').'</h1>'.
               '<p>'.&mt('Welcome to the Learning[_1]Online[_2] Network with CAPA. Please wait while your session is being set up.','<i>','</i>').'</p><p>'.
               '<a href="'.$destination.'">'.&mt('Continue').'</a></p>'.
Index: loncom/interface/lonwishlist.pm
diff -u loncom/interface/lonwishlist.pm:1.26 loncom/interface/lonwishlist.pm:1.27
--- loncom/interface/lonwishlist.pm:1.26	Mon May 22 19:18:41 2017
+++ loncom/interface/lonwishlist.pm	Sat Apr 14 02:29:44 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Utility-routines for wishlist
 #
-# $Id: lonwishlist.pm,v 1.26 2017/05/22 19:18:41 droeschl Exp $
+# $Id: lonwishlist.pm,v 1.27 2018/04/14 02:29:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1480,6 +1480,11 @@
     $root = $rootgiven;
     @childrenRt = $root->children();
 
+    my $windowname = 'loncapaclient';
+    if ($env{'request.lti.login'}) {
+        $windowname .= 'lti';
+    }
+
     # breadcrumbs and start_page
     &Apache::lonhtmlcommon::clear_breadcrumbs();
     &Apache::lonhtmlcommon::add_breadcrumb(
@@ -1488,7 +1493,7 @@
     my $startPage = &Apache::loncommon::start_page('Stored Links',undef,
                                                      {'add_entries' => {
                                                         'onload' => 'javascript:onLoadAction('."'".$mode."'".');',
-                                                        'onunload' => 'javascript:window.name = '."'loncapaclient'"}});
+                                                        'onunload' => 'javascript:window.name = '."'$windowname'"}});
 
     my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Stored Links','Wishlist');
 
Index: loncom/lontrans.pm
diff -u loncom/lontrans.pm:1.19 loncom/lontrans.pm:1.20
--- loncom/lontrans.pm:1.19	Sat Jan 13 18:58:33 2018
+++ loncom/lontrans.pm	Sat Apr 14 02:29:51 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # URL translation for User Files
 #
-# $Id: lontrans.pm,v 1.19 2018/01/13 18:58:33 raeburn Exp $
+# $Id: lontrans.pm,v 1.20 2018/04/14 02:29:51 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -44,15 +44,27 @@
         my $handle = &Apache::lonnet::check_for_valid_session($r,undef,\%user);
         if (($handle ne '') && ($user{'lti'})) {
             if ($realuri =~ m{^uploaded/$match_domain/$match_courseid/(default|supplemental)(|_\d+)\.(?:sequence|page)___\d+___.+$}) {
+                if ($user{'ltiuri'} ne $realuri) {
+                    &Apache::lonnet::appenv({'request.lti.uri' => $realuri});
+                }
                 my ($map,$resid,$url) = split(/___/,$realuri);
                 $realuri = &Apache::lonnet::clutter($url).'?symb='.$realuri;
             } elsif ($realuri =~ m{^tiny/$match_domain/\w+$}) {
-                $realuri = '/'.$realuri;    
+                $realuri = '/'.$realuri;
+                if ($user{'ltiuri'} ne $realuri) {
+                    &Apache::lonnet::appenv({'request.lti.uri' => $realuri});
+                }
             } elsif ($realuri =~ m{($match_domain)/($match_courseid)$}) {
                 $realuri = '/adm/navmaps';
+                if ($user{'ltiuri'} ne '') {
+                    &Apache::lonnet::delenv('request.lti.uri');
+                }
             } else {
                 $realuri = '/'.$realuri;
                 if ($realuri =~ m{/default_\d+\.sequence$}) {
+                    if ($user{'ltiuri'} ne $realuri) {
+                        &Apache::lonnet::appenv({'request.lti.uri' => $realuri});
+                    }
                     $realuri .= (($realuri =~/\?/)?'&':'?').'navmap=1';
                 }
             }
Index: rat/lonsequence.pm
diff -u rat/lonsequence.pm:1.48 rat/lonsequence.pm:1.49
--- rat/lonsequence.pm:1.48	Mon Sep  4 23:47:17 2017
+++ rat/lonsequence.pm	Sat Apr 14 02:29:57 2018
@@ -2,7 +2,7 @@
 #
 # Sequence Handler
 #
-# $Id: lonsequence.pm,v 1.48 2017/09/04 23:47:17 raeburn Exp $
+# $Id: lonsequence.pm,v 1.49 2018/04/14 02:29:57 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -36,6 +36,7 @@
 use Apache::Constants qw(:common :http REDIRECT);
 use GDBM_File;
 use LONCAPA::map();
+use LONCAPA::ltiutils;
 use LONCAPA;
 use Apache::lonpageflip();
 use Apache::loncommon();
@@ -251,21 +252,30 @@
            if (ref($navmap)) {
                # renderer call
                if (&Apache::lonnet::is_on_map($requrl)) {
+                   my $ltiscope;
+                   if (($env{'request.lti.login'}) && ($env{'request.lti.uri'})) {
+                       my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+                       my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+                       ($ltiscope) = &LONCAPA::ltiutils::lti_provider_scope($env{'request.lti.uri'},$cdom,$cnum);
+                   }
                    my $mapurl = &Apache::lonnet::declutter($requrl);
-                   my @crumbs = ({text  => $crstype.' Contents',
-                                  href  => "javascript:gopost('/adm/navmaps','')"});
-                   my $res = $navmap->getResourceByUrl($mapurl);
-                   if (ref($res)) {
-                       my $symb = $res->symb();
-                       if ($symb) {
-                           my ($parent) = &Apache::lonnet::decode_symb($res->symb());
-                           if ($parent ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
-                               my @mapcrumbs = $navmap->recursed_crumbs($parent);
-                               if (@mapcrumbs) {
-                                   push(@crumbs, at mapcrumbs);
+                   my @crumbs;
+                   unless (($ltiscope eq 'resource') || ($ltiscope eq 'map')) {
+                       @crumbs = ({text  => $crstype.' Contents',
+                                   href  => "javascript:gopost('/adm/navmaps','')"});
+                       my $res = $navmap->getResourceByUrl($mapurl);
+                       if (ref($res)) {
+                           my $symb = $res->symb();
+                           if ($symb) {
+                               my ($parent) = &Apache::lonnet::decode_symb($res->symb());
+                               if ($parent ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
+                                   my @mapcrumbs = $navmap->recursed_crumbs($parent);
+                                   if (@mapcrumbs) {
+                                       push(@crumbs, at mapcrumbs);
+                                   }
                                }
+                               $env{'request.symb'} = $symb;
                            }
-                           $env{'request.symb'} = $symb;
                        }
                    }
                    my $maptitle = &Apache::lonnet::gettitle($mapurl);
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1374 loncom/lonnet/perl/lonnet.pm:1.1375
--- loncom/lonnet/perl/lonnet.pm:1.1374	Mon Apr  2 18:23:57 2018
+++ loncom/lonnet/perl/lonnet.pm	Sat Apr 14 02:30:01 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1374 2018/04/02 18:23:57 raeburn Exp $
+# $Id: lonnet.pm,v 1.1375 2018/04/14 02:30:01 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -708,6 +708,10 @@
         $userhashref->{'name'} = $disk_env{'user.name'};
         $userhashref->{'domain'} = $disk_env{'user.domain'};
         $userhashref->{'lti'} = $disk_env{'request.lti.login'};
+        if ($userhashref->{'lti'}) {
+            $userhashref->{'ltitarget'} = $disk_env{'request.lti.target'};
+            $userhashref->{'ltiuri'} = $disk_env{'request.lti.uri'};
+        }
     }
 
     return $handle;
Index: loncom/lti/ltiauth.pm
diff -u loncom/lti/ltiauth.pm:1.7 loncom/lti/ltiauth.pm:1.8
--- loncom/lti/ltiauth.pm:1.7	Fri Mar 23 18:08:45 2018
+++ loncom/lti/ltiauth.pm	Sat Apr 14 02:30:07 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Basic LTI Authentication Module
 #
-# $Id: ltiauth.pm,v 1.7 2018/03/23 18:08:45 raeburn Exp $
+# $Id: ltiauth.pm,v 1.8 2018/04/14 02:30:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -815,11 +815,14 @@
         &Apache::lonauth::success($r,$uname,$udom,$uhome,'noredirect');
         if ($symb) {
             $env{'form.symb'} = $symb;
+            $env{'request.lti.uri'} = $symb;
         } else {
             if ($mapurl) {
                 $env{'form.origurl'} = $mapurl;
+                $env{'request.lti.uri'} = $mapurl;
             } elsif ($tail =~ m{^\Q/tiny/$cdom/\E\w+$}) {
                 $env{'form.origurl'} = $tail;
+                $env{'request.lti.uri'} = $tail;
             } else {
                 unless ($tail eq '/adm/roles') {
                     $env{'form.origurl'} = '/adm/navmaps';
@@ -855,6 +858,9 @@
             }
         }
         $env{'request.lti.login'} = 1;
+        if ($params->{'launch_presentation_document_target'}) {
+            $env{'request.lti.target'} = $params->{'launch_presentation_document_target'};
+        }
         foreach my $key (%{$params}) {
             delete($env{'form.'.$key});
         }
@@ -876,6 +882,7 @@
                   'username'  => $uname,
                   'server'    => $lonhost,
                   'lti.login' => 1,
+                  'lti.uri'   => $tail,
                  );
         if ($role) {
             $info{'role'} = $role;
@@ -907,6 +914,10 @@
                 $info{'lti.rosterurl'} = $params->{'ext_ims_lis_memberships_url'};
             }
         }
+        if ($params->{'launch_presentation_document_target'}) {
+            $info{'lti.target'} = $params->{'launch_presentation_document_target'};
+        }
+
         unless ($info{'symb'}) {
             if ($mapurl) {
                 $info{'origurl'} = $mapurl;
Index: loncom/lti/ltiutils.pm
diff -u loncom/lti/ltiutils.pm:1.5 loncom/lti/ltiutils.pm:1.6
--- loncom/lti/ltiutils.pm:1.5	Thu Jan  4 12:19:25 2018
+++ loncom/lti/ltiutils.pm	Sat Apr 14 02:30:07 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Utility functions for managing LON-CAPA LTI interactions 
 #
-# $Id: ltiutils.pm,v 1.5 2018/01/04 12:19:25 raeburn Exp $
+# $Id: ltiutils.pm,v 1.6 2018/04/14 02:30:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -458,4 +458,85 @@
     }
 }
 
+#
+# LON-CAPA as LTI Provider
+#
+# Use the part of the launch URL after /adm/lti to determine
+# the scope for the current session (i.e., restricted to a
+# single resource, to a single folder/map, or to an entire
+# course).
+#
+# Returns an array containing scope: resource, map, or course
+# and the LON-CAPA URL that is displayed post-launch, including
+# accommodation of URL encryption, and translation of a tiny URL
+# to the actual URL
+#
+
+sub lti_provider_scope {
+    my ($tail,$cdom,$cnum) = @_;
+    my ($scope,$realuri);
+    if ($tail =~ m{^/uploaded/$cdom/$cnum/(?:default|supplemental)(?:|_\d+)\.(?:sequence|page)(|___\d+___.+)$}) {
+        my $rest = $1;
+        if ($rest eq '') {
+            $scope = 'map';
+            $realuri = $tail;
+        } else {
+            $scope = 'resource';
+            my ($map,$resid,$url) = &Apache::lonnet::decode_symb($tail);
+            $realuri = &Apache::lonnet::clutter($url);
+            if (($url =~ /\.sequence$/) &&
+                ($env{'course.'.$env{'request.course.id'}.'.type'} ne 'Placement')) {
+                $realuri .= '?navmap=1';
+            } else {
+                $realuri .= '?symb='.$tail;
+            }
+        }
+    } elsif ($tail =~ m{^/tiny/$cdom/(\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 ($cnum,$symb) = split(/\&/,$tinyurl,2);
+            my ($map,$resid,$url) = &Apache::lonnet::decode_symb($symb);
+            if ($url =~ /\.(page|sequence)$/) {
+                $scope = 'map';
+            } else {
+                $scope = 'resource';
+            }
+            if ((&Apache::lonnet::EXT('resource.0.encrypturl',$symb) =~ /^yes$/i) &&
+                (!$env{'request.role.adv'})) {
+                $realuri = &Apache::lonenc::encrypted(&Apache::lonnet::clutter($url));
+                if (($url =~ /\.sequence$/) &&
+                    ($env{'course.'.$env{'request.course.id'}.'.type'} ne 'Placement')) {
+                    $realuri .= '?navmap=1';
+                } else {
+                    $realuri .= '?symb='.&Apache::lonenc::encrypted($symb);
+                }
+            } else {
+                $realuri = &Apache::lonnet::clutter($url);
+                if (($url =~ /\.sequence$/) &&
+                    ($env{'course.'.$env{'request.course.id'}.'.type'} ne 'Placement')) {
+                    $realuri .= '?navmap=1';
+                } else {
+                    $realuri .= '?symb='.$symb;
+                }
+            }
+        }
+    } elsif ($tail =~ m{^/$cdom/$cnum$}) {
+        $scope = 'course';
+        $realuri = '/adm/navmaps';
+    }
+    return ($scope,$realuri);
+}
+
 1;
Index: loncom/auth/lonauth.pm
diff -u loncom/auth/lonauth.pm:1.149 loncom/auth/lonauth.pm:1.150
--- loncom/auth/lonauth.pm:1.149	Fri Mar 23 01:01:29 2018
+++ loncom/auth/lonauth.pm	Sat Apr 14 02:30:11 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # User Authentication Module
 #
-# $Id: lonauth.pm,v 1.149 2018/03/23 01:01:29 raeburn Exp $
+# $Id: lonauth.pm,v 1.150 2018/04/14 02:30:11 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -160,7 +160,11 @@
         $destination .= 'source=login';
     }
 
-    my $windowinfo = Apache::lonhtmlcommon::scripttag('self.name="loncapaclient";');
+    my $windowname = 'loncapaclient';
+    if ($env{'request.lti.login'}) {
+        $windowname .= 'lti';
+    }
+    my $windowinfo = Apache::lonhtmlcommon::scripttag('self.name="'.$windowname.'";');
     my $header = '<meta HTTP-EQUIV="Refresh" CONTENT="0; url='.$destination.'" />';
     my $brcrum = [{'href' => '',
                    'text' => 'Successful Login'},];
Index: loncom/auth/switchserver.pm
diff -u loncom/auth/switchserver.pm:1.39 loncom/auth/switchserver.pm:1.40
--- loncom/auth/switchserver.pm:1.39	Fri Mar 23 01:01:29 2018
+++ loncom/auth/switchserver.pm	Sat Apr 14 02:30:11 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Switch Servers Handler
 #
-# $Id: switchserver.pm,v 1.39 2018/03/23 01:01:29 raeburn Exp $
+# $Id: switchserver.pm,v 1.40 2018/04/14 02:30:11 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -235,6 +235,9 @@
     if ($env{'request.lti.login'}) {
         $info{'lti.login'} = $env{'request.lti.login'};
     }
+    if ($env{'request.lti.uri'}) {
+        $info{'lti.uri'} = $env{'request.lti.uri'};
+    }
     if ($env{'request.lti.reqcrs'}) {
         $info{'lti.reqcrs'} = $env{'request.lti.reqcrs'};
     }
@@ -259,6 +262,9 @@
     if ($env{'request.lti.rosterurl'}) {
         $info{'lti.rosterurl'} = $env{'request.lti.rosterurl'};
     }
+    if ($env{'request.lti.target'}) {
+        $info{'lti.target'} = $env{'request.lti.target'};
+    }
     my $token = &Apache::lonnet::tmpput(\%info,$env{'form.otherserver'});
     my $url =$protocol.'://'.$switch_to.'/adm/login?'.
 	'domain='.$env{'user.domain'}.
Index: loncom/auth/migrateuser.pm
diff -u loncom/auth/migrateuser.pm:1.28 loncom/auth/migrateuser.pm:1.29
--- loncom/auth/migrateuser.pm:1.28	Sat Apr 14 01:50:43 2018
+++ loncom/auth/migrateuser.pm	Sat Apr 14 02:30:11 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Starts a user off based of an existing token.
 #
-# $Id: migrateuser.pm,v 1.28 2018/04/14 01:50:43 raeburn Exp $
+# $Id: migrateuser.pm,v 1.29 2018/04/14 02:30:11 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -88,6 +88,12 @@
             if ($data->{'lti.selfenrollrole'}) {
                 $lti_env{'request.lti.selfenrollrole'} = $data->{'lti.selfenrollrole'};
             }
+            if ($data->{'lti.uri'}) {
+                $lti_env{'request.lti.uri'} = $data->{'lti.uri'};
+            }
+            if ($data->{'lti.target'}) {
+                $lti_env{'request.lti.target'} = $data->{'lti.target'};
+            }
         }
         if ($data->{'lti.passbackid'}) {
             $lti_env{'request.lti.passbackid'} = $data->{'lti.passbackid'};
@@ -388,6 +394,7 @@
                     $form{'lti.reqcrs'} = $data{'lti.reqcrs'};
                     $form{'lti.reqrole'} = $data{'lti.reqrole'};
                     $form{'lti.sourcecrs'} = $data{'lti.sourcecrs'};
+                    $form{'lti.uri'} = $data{'lti.uri'};
                     if ($data{'lti.passbackid'}) {
                         $form{'lti.passbackid'} = $data{'lti.passbackid'};
                     }
@@ -400,6 +407,9 @@
                     if ($data{'lti.rosterurl'}) {
                         $form{'lti.rosterurl'} = $data{'lti.rosterurl'};
                     }
+                    if ($data{'lti.target'}) {
+                        $form{'lti.target'} = $data{'lti.target'};
+                    }
                     &Apache::loncommon::content_type($r,'text/html');
                     $r->send_http_header;
                     &Apache::ltiauth::lti_reqcrs($r,$data{'domain'},\%form,$data{'username'},$data{'domain'});


More information about the LON-CAPA-cvs mailing list