[LON-CAPA-cvs] cvs: loncom /auth lonauth.pm lonroles.pm migrateuser.pm /interface lontiny.pm
raeburn
raeburn at source.lon-capa.org
Sat Jun 30 20:03:45 EDT 2018
raeburn Sun Jul 1 00:03:45 2018 EDT
Modified files:
/loncom/auth lonauth.pm lonroles.pm migrateuser.pm
/loncom/interface lontiny.pm
Log:
- Bug 6754 LON-CAPA as LTI Provider
- If LTI Consumer does not provide 'launch_presentation_document_target'
set $env{'request.lti.target'} to iframe, if LON-CAPA display in iframe.
Index: loncom/auth/lonauth.pm
diff -u loncom/auth/lonauth.pm:1.152 loncom/auth/lonauth.pm:1.153
--- loncom/auth/lonauth.pm:1.152 Tue May 8 15:44:11 2018
+++ loncom/auth/lonauth.pm Sun Jul 1 00:03:42 2018
@@ -1,7 +1,7 @@
# The LearningOnline Network
# User Authentication Module
#
-# $Id: lonauth.pm,v 1.152 2018/05/08 15:44:11 raeburn Exp $
+# $Id: lonauth.pm,v 1.153 2018/07/01 00:03:42 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -170,7 +170,6 @@
$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'},];
my $args = {'bread_crumbs' => $brcrum,};
@@ -207,20 +206,40 @@
}
$r->send_http_header;
- my $start_page;
+ my ($start_page,$js,$pagebody,$end_page);
if ($env{'request.lti.login'}) {
- $args = {'only_body' => 1,};
- $start_page=&Apache::loncommon::start_page('',$header,$args);
- } else {
- $start_page=&Apache::loncommon::start_page('Successful Login',
- $header,$args);
+ $args = {'only_body' => 1};
+ if ($env{'request.lti.target'} eq '') {
+ my $ltitarget = (($destination =~ /\?/) ? '&' : '?').
+ 'ltitarget=iframe';
+ $js = <<"ENDJS";
+
+<script type="text/javascript">
+// <![CDATA[
+function setLTItarget() {
+ var newloc = '$destination';
+ if (parent !== window) {
+ newloc += '$ltitarget';
}
- my $end_page =&Apache::loncommon::end_page();
+ window.location.href=newloc;
+}
+// ]]>
+</script>
- my $continuelink='<a href="'.$destination.'">'.&mt('Continue').'</a>';
+ENDJS
+ $args->{'add_entries'} = {'onload' => "javascript:setLTItarget();"};
+ $pagebody = '<noscript><span class="LC_warning">'
+ .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
+ .'</span></noscript>';
+ } else {
+ $args->{'redirect'} = [0,$destination,1];
+ }
+ $start_page=&Apache::loncommon::start_page('',$js,$args);
+ } else {
+ $args->{'redirect'} = [0,$destination];
+ $start_page=&Apache::loncommon::start_page('Successful Login',
+ $js,$args);
- my $pagebody;
- unless ($env{'request.lti.login'}) {
my %lt=&Apache::lonlocal::texthash(
'wel' => 'Welcome',
'pro' => 'Login problems?',
@@ -232,11 +251,11 @@
$pagebody .= '<p><a href="'.$loginhelp.'">'.$lt{'pro'}.'</a></p>';
}
}
+ $end_page = &Apache::loncommon::end_page();
$r->print(<<ENDSUCCESS);
$start_page
$windowinfo
$pagebody
-$continuelink
$end_page
ENDSUCCESS
return;
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.338 loncom/auth/lonroles.pm:1.339
--- loncom/auth/lonroles.pm:1.338 Mon May 28 23:26:12 2018
+++ loncom/auth/lonroles.pm Sun Jul 1 00:03:42 2018
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.338 2018/05/28 23:26:12 raeburn Exp $
+# $Id: lonroles.pm,v 1.339 2018/07/01 00:03:42 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -272,6 +272,12 @@
# ================================================================== Roles Init
if ($env{'form.selectrole'}) {
+ if (($env{'request.lti.login'}) && ($env{'request.lti.target'} eq '')) {
+ if ($env{'form.ltitarget'} eq 'iframe') {
+ &Apache::lonnet::appenv({'request.lti.target' => 'iframe'});
+ delete($env{'form.ltitarget'});
+ }
+ }
my $locknum=&Apache::lonnet::get_locks();
if ($locknum) { return 409; }
Index: loncom/auth/migrateuser.pm
diff -u loncom/auth/migrateuser.pm:1.32 loncom/auth/migrateuser.pm:1.33
--- loncom/auth/migrateuser.pm:1.32 Tue May 8 15:44:11 2018
+++ loncom/auth/migrateuser.pm Sun Jul 1 00:03:42 2018
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Starts a user off based of an existing token.
#
-# $Id: migrateuser.pm,v 1.32 2018/05/08 15:44:11 raeburn Exp $
+# $Id: migrateuser.pm,v 1.33 2018/07/01 00:03:42 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -483,13 +483,13 @@
return OK;
}
- my $next_url='/adm/roles?selectrole=1&'.&escape($data{'role'}).'=1';
+ my $next_url='/adm/roles?selectrole=1&'.&escape($data{'role'}).'=1';
if ($data{'origurl'} ne '') {
- $next_url .= '&orgurl='.&escape($data{'origurl'});
+ $next_url .= '&orgurl='.&escape($data{'origurl'});
if ($data{'lti.login'}) {
if (($data{'origurl'} =~ m{/default_\d+\.sequence$}) ||
($data{'origurl'} =~ m{^/res/.+\.sequence$})) {
- $next_url .= '&navmap=1';
+ $next_url .= '&navmap=1';
}
}
}
Index: loncom/interface/lontiny.pm
diff -u loncom/interface/lontiny.pm:1.3 loncom/interface/lontiny.pm:1.4
--- loncom/interface/lontiny.pm:1.3 Thu May 10 03:49:51 2018
+++ loncom/interface/lontiny.pm Sun Jul 1 00:03: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.3 2018/05/10 03:49:51 raeburn Exp $
+# $Id: lontiny.pm,v 1.4 2018/07/01 00:03:44 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -86,8 +86,34 @@
}
}
my @allposs = keys(%possroles);
+ if ($env{'request.lti.login'}) {
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
+ if ($env{'request.lti.target'} eq '') {
+ if ($env{'form.ltitarget'} eq 'iframe') {
+ &Apache::lonnet::appenv({'request.lti.target' => 'iframe'});
+ delete($env{'form.ltitarget'});
+ }
+ }
+ if ($env{'form.selectrole'}) {
+ foreach my $role (@allposs) {
+ my $newrole = "$role./$cdom/$cnum";
+ if ($possroles{$allposs[0]} ne '') {
+ $newrole .= "/$possroles{$role}";
+ }
+ if ($env{"form.$newrole"}) {
+ my $destination .= '/adm/roles?selectrole=1&'.$newrole.'=1'.
+ '&destinationurl='.&HTML::Entities::encode($r->uri);
+ if ($env{'form.ltitarget'} eq 'iframe') {
+ $destination .= '<itarget=iframe';
+ }
+ &do_redirect($r,$destination);
+ return OK;
+ }
+ }
+ }
+ }
if (@allposs == 0) {
- &show_roles($r,\%crsenv,\%possroles)
+ &show_roles($r,\%crsenv,\%possroles);
} elsif (@allposs == 1) {
my $newrole = "$allposs[0]./$cdom/$cnum";
$newrole = "$allposs[0]./$cdom/$cnum";
More information about the LON-CAPA-cvs
mailing list