[LON-CAPA-cvs] cvs: loncom /interface courseprefs.pm lonconfigsettings.pm

raeburn raeburn at source.lon-capa.org
Thu Jun 30 21:05:04 EDT 2022


raeburn		Fri Jul  1 01:05:04 2022 EDT

  Modified files:              
    /loncom/interface	courseprefs.pm lonconfigsettings.pm 
  Log:
  - Bug 6907
    Link Protection configuration for each launch application can include 
    the name of the parameter used in the launcher payload to contain a URL 
    in the launcher course to return to after exit from the LON-CAPA session. 
  
  
-------------- next part --------------
Index: loncom/interface/courseprefs.pm
diff -u loncom/interface/courseprefs.pm:1.111 loncom/interface/courseprefs.pm:1.112
--- loncom/interface/courseprefs.pm:1.111	Wed Apr  6 14:35:27 2022
+++ loncom/interface/courseprefs.pm	Fri Jul  1 01:05:04 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set configuration settings for a course
 #
-# $Id: courseprefs.pm,v 1.111 2022/04/06 14:35:27 raeburn Exp $
+# $Id: courseprefs.pm,v 1.112 2022/07/01 01:05:04 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1593,6 +1593,22 @@
                 $linkprot{$itemid}{$inner} = $env{$formitem};
             }
         }
+        my $urlitem = 'form.linkprot_returnurl_'.$idx;
+        my $urlparamname = 'form.linkprot_urlparam_'.$idx;
+        if ($env{$urlitem} == 1) {
+            $env{$urlparamname} =~ s/(`)/'/g;
+        } elsif (exists($env{$urlparamname})) {
+            $env{$urlparamname} = '';
+        }
+        unless ($idx eq 'add') {
+            if ((!$current{'returnurl'} && ($env{$urlparamname} ne '')) ||
+                ($current{'returnurl'} && ($env{$urlparamname} eq ''))) {
+                $haschanges{$itemid} = 1;
+            }
+        }
+        if ($env{$urlparamname} ne '') {
+            $linkprot{$itemid}{'returnurl'} = $env{$urlparamname};
+        }
         if ($ltiauth) {
             my $reqitem = 'form.linkprot_requser_'.$idx;
             $env{$reqitem} =~ s/(`)/'/g;
@@ -2266,7 +2282,7 @@
                     my %values = %{$changes->{$id}};
                     my %desc = &linkprot_names();
                     my $display;
-                    foreach my $title ('name','lifetime','version','key','secret') {
+                    foreach my $title ('name','lifetime','version','key','secret','returnurl') {
                         if (($title eq 'key') || ($title eq 'secret')) {
                             if (ref($ltienc{$id}) eq 'HASH') {
                                 if (exists($ltienc{$id}{$title})) {
@@ -2282,6 +2298,10 @@
                             if ($values{$title} eq 'LTI-1p0') {
                                 $display .= $desc{$title}.': 1.1, ';
                             }
+                        } elsif ($title eq 'returnurl') {
+                            if ($values{$title}) {
+                                $display .= &mt('Return URL parameter').': '.$values{$title}.', '; 
+                            }
                         } else {
                             $display .= $desc{$title}.': '.$values{$title}.', ';
                         }
@@ -2802,7 +2822,7 @@
     return;
 }
 
-function toggleLinkProtReqUser(form,item,extra,valon,styleon,num) {
+function toggleLinkProtExtra(form,item,extra,valon,styleon,num) {
     if (document.getElementById('linkprot_'+extra+'_'+num)) {
         var extraid = document.getElementById('linkprot_'+extra+'_'+num);
         var itemname = form.elements['linkprot_'+item+'_'+num];
@@ -5709,10 +5729,10 @@
                     '<tr '.$css_class.'><td><span class="LC_nobreak">'.
                     '<label><input type="checkbox" name="linkprot_del" value="'.$i.'"'.$disabled.' />'.
                     &mt('Delete?').'</label></span></td><td>';
-                my ($usersty,$onclickrequser,%checkedrequser);
+                my ($usersty,$onclickrequser,%checkedrequser,$onclickreturnurl,%checkedreturnurl);
                 if ($ltiauth) {
                     $usersty = 'display:none';
-                    $onclickrequser = ' onclick="toggleLinkProtReqUser(this.form,'."'requser','optional','1','block','$i'".');"';
+                    $onclickrequser = ' onclick="toggleLinkProtExtra(this.form,'."'requser','optional','1','block','$i'".');"';
                     %checkedrequser = (
                         no => ' checked="checked"',
                         yes  => '',
@@ -5726,6 +5746,15 @@
                         $usersty = 'display:inline-block';
                     }
                 }
+                $onclickreturnurl = ' onclick="toggleLinkProtExtra(this.form,'."'returnurl','divurlparam','1','inline-block','$i'".');"';
+                %checkedreturnurl = (
+                    no => ' checked="checked"',
+                    yes  => '',
+                );
+                if ($values{'returnurl'} ne '') {
+                    $checkedreturnurl{'yes'} = $checkedreturnurl{'no'};
+                    $checkedreturnurl{'no'} = '';
+                }
                 $datatable .=
                     '<span class="LC_nobreak">'.$desc{'name'}.
                     ':<input type="text" size="15" name="linkprot_name_'.$i.'" value="'.$values{'name'}.'" autocomplete="off"'.$disabled.' /></span> '.
@@ -5734,15 +5763,7 @@
                     '<option value="LTI-1p0" '.$selected.'>1.1</option></select></span> '."\n".
                     (' 'x2).
                     '<span class="LC_nobreak">'.$desc{'lifetime'}.':<input type="text" name="linkprot_lifetime_'.$i.'"'.
-                    ' value="'.$values{'lifetime'}.'" size="3"'.$disabled.' /></span>';
-                if ($ltiauth) {
-                    $datatable .= (' 'x2).'<span class="LC_nobreak">'.$desc{'requser'}.'?'.
-                                  '<label><input type="radio" name="linkprot_requser_'.$i.'" value="0"'.
-                                  $onclickrequser.$checkedrequser{'no'}.$disabled.' />'.&mt('No').'</label> '.
-                                  '<label><input type="radio" name="linkprot_requser_'.$i.'" value="1"'.
-                                  $onclickrequser.$checkedrequser{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>';
-                }
-                $datatable .= '<br /><br />';
+                    ' value="'.$values{'lifetime'}.'" size="3"'.$disabled.' /></span><br /><br />';
                 if ($values{'key'} ne '') {
                     $datatable .= '<span class="LC_nobreak">'.$desc{'key'};
                     if ($noedit) {
@@ -5796,8 +5817,22 @@
                             '<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span>';
                     }
                 }
+                $datatable .= '<br /><br />'.
+                              '<span class="LC_nobreak">'.$desc{'returnurl'}.'?'.
+                              '<label><input type="radio" name="linkprot_returnurl_'.$i.'" value="0"'.
+                              $onclickreturnurl.$checkedreturnurl{'no'}.$disabled.' />'.&mt('No').'</label> '.
+                              '<label><input type="radio" name="linkprot_returnurl_'.$i.'" value="1"'.
+                              $onclickreturnurl.$checkedreturnurl{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>'.
+                              '  </span><div id="linkprot_divurlparam_'.$i.'" style="display:none" />'.
+                              '<span class="LC_nobreak">'.&mt('Parameter name').':'.
+                              '<input type="text" size="15" name="linkprot_urlparam_'.$i.'" value="'.$values{'returnurl'}.'" autocomplete="off"'.$disabled.' />'.
+                              '</span></div> ';
                 if ($ltiauth) {
-                    $datatable .= 
+                    $datatable .= (' 'x2).'<span class="LC_nobreak">'.$desc{'requser'}.'?'.
+                                  '<label><input type="radio" name="linkprot_requser_'.$i.'" value="0"'.
+                                  $onclickrequser.$checkedrequser{'no'}.$disabled.' />'.&mt('No').'</label> '.
+                                  '<label><input type="radio" name="linkprot_requser_'.$i.'" value="1"'.
+                                  $onclickrequser.$checkedrequser{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>'.
                         '</fieldset>'.
                         '<fieldset id="linkprot_optional_'.$i.'" style="'.$usersty.'"><legend>'.$lt{'opti'}.'</legend>'.
                         &linkprot_options($i,$itemcount,$disabled,\%values,\%desc).
@@ -5813,31 +5848,29 @@
                   '<input type="hidden" name="linkprot_maxnum" value="'.$next.'" />'."\n".
                   '<input type="checkbox" name="linkprot_add" value="1"'.$disabled.' />'.&mt('Add').'</span></td>'."\n".
                   '<td width="100%">';
-    my ($usersty,$onclickrequser,%checkedrequser);
+    my ($usersty,$onclickrequser,%checkedrequser,$onclickreturnurl,%checkedreturnurl);
     if ($ltiauth) {
         $usersty = 'display:none';
-        $onclickrequser = ' onclick="toggleLinkProtReqUser(this.form,'."'requser','optional','1','block','add'".');"';
+        $onclickrequser = ' onclick="toggleLinkProtExtra(this.form,'."'requser','optional','1','block','add'".');"';
         %checkedrequser = (
             no => ' checked="checked"',
             yes  => '',
         );
         $datatable .= '<fieldset><legend>'.$lt{'requ'}.'</legend>';
     }
+    $onclickreturnurl = ' onclick="toggleLinkProtExtra(this.form,'."'returnurl','divurlparam','1','inline-block','add'".');"';
+    %checkedreturnurl = (
+        no => ' checked="checked"',
+        yes => '',
+    );
     $datatable .= '<span class="LC_nobreak">'.$desc{'name'}.
                   ':<input type="text" size="15" name="linkprot_name_add" value="" autocomplete="off"'.$disabled.' /></span> '."\n".
                   (' 'x2).
                   '<span class="LC_nobreak">'.$desc{'version'}.':<select name="linkprot_version_add"'.$disabled.'>'.
                   '<option value="LTI-1p0" selected="selected">1.1</option></select></span> '."\n".
                   (' 'x2).
-                  '<span class="LC_nobreak">'.$desc{'lifetime'}.':<input type="text" size="3" name="linkprot_lifetime_add" value="300"'.$disabled.' /></span> '."\n";
-    if ($ltiauth) {
-        $datatable .= (' 'x2).'<span class="LC_nobreak">'.$desc{'requser'}.'?'.
-                      '<label><input type="radio" name="linkprot_requser_add" value="0"'.
-                      $onclickrequser.$checkedrequser{'no'}.$disabled.' />'.&mt('No').'</label> '.
-                      '<label><input type="radio" name="linkprot_requser_add" value="1"'.
-                      $onclickrequser.$checkedrequser{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>';
-    }
-    $datatable .= '<br /><br />';
+                  '<span class="LC_nobreak">'.$desc{'lifetime'}.':<input type="text" size="3" name="linkprot_lifetime_add" value="300"'.$disabled.' /></span> '."\n".
+                  '<br /><br />';
     if ($switchserver) {
         $datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.$switchmessage.'</span>'."\n";
     } else {
@@ -5846,6 +5879,23 @@
                       '<span class="LC_nobreak">'.$desc{'secret'}.':<input type="password" size="20" name="linkprot_secret_add" value="" autocomplete="off"'.$disabled.' />'.
                       '<label><input type="checkbox" name="linkprot_visible_add" id="linkprot_visible_add" onclick="if (this.checked) { this.form.linkprot_secret_add.type='."'text'".' } else { this.form.linkprot_secret_add.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label></span> '."\n";
     }
+    $datatable .= '<br /><br />'.
+                  '<span class="LC_nobreak">'.$desc{'returnurl'}.'?'.
+                  '<label><input type="radio" name="linkprot_returnurl_add" value="0"'.
+                  $onclickreturnurl.$checkedreturnurl{'no'}.$disabled.' />'.&mt('No').'</label> '.
+                  '<label><input type="radio" name="linkprot_returnurl_add" value="1"'.
+                  $onclickreturnurl.$checkedreturnurl{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>'.
+                  '  </span><div id="linkprot_divurlparam_add" style="display:none" />'.
+                  '<span class="LC_nobreak">'.&mt('Parameter name').':'.
+                  '<input type="text" size="15" name="linkprot_urlparam_add" value="" autocomplete="off"'.$disabled.' />'.
+                  '</span></div> ';
+    if ($ltiauth) {
+        $datatable .= (' 'x2).'<span class="LC_nobreak">'.$desc{'requser'}.'?'.
+                      '<label><input type="radio" name="linkprot_requser_add" value="0"'.
+                      $onclickrequser.$checkedrequser{'no'}.$disabled.' />'.&mt('No').'</label> '.
+                      '<label><input type="radio" name="linkprot_requser_add" value="1"'.
+                      $onclickrequser.$checkedrequser{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>';
+    }
     if ($ltiauth) {
         $datatable .= '</fieldset>'.
                       '<fieldset id="linkprot_optional_add" style="'.$usersty.'"><legend>'.$lt{'opti'}.'</legend>'.
@@ -5864,6 +5914,7 @@
                                           'lifetime'  => 'Nonce lifetime (s)',
                                           'name'      => 'Launcher Application',
                                           'secret'    => 'Secret',
+                                          'returnurl' => 'Launcher return URL',
                                           'requser'   => 'Use identity',
                                           'email'     => 'Email address',
                                           'sourcedid' => 'User ID',
@@ -5919,7 +5970,7 @@
             $checked{'auth'} = ' checked="checked"';
         }
     }
-    my $onclickuser = ' onclick="toggleLinkProtReqUser(this.form,'."'mapuser','userfield','other','inline-block','$num'".');"';
+    my $onclickuser = ' onclick="toggleLinkProtExtra(this.form,'."'mapuser','userfield','other','inline-block','$num'".');"';
     my $output = '<div class="LC_floatleft"><span class="LC_nobreak">'.
                  &mt('Source of LON-CAPA username in LTI request').': ';
     foreach my $option ('sourcedid','email','other') {
Index: loncom/interface/lonconfigsettings.pm
diff -u loncom/interface/lonconfigsettings.pm:1.64 loncom/interface/lonconfigsettings.pm:1.65
--- loncom/interface/lonconfigsettings.pm:1.64	Tue Apr  5 12:27:39 2022
+++ loncom/interface/lonconfigsettings.pm	Fri Jul  1 01:05:04 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: lonconfigsettings.pm,v 1.64 2022/04/05 12:27:39 raeburn Exp $
+# $Id: lonconfigsettings.pm,v 1.65 2022/07/01 01:05:04 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -427,9 +427,10 @@
                                     $onload .= "toggleLinkProt(document.display,'$num','secret');";
                                 }
                             }
+                            $onload .= "toggleLinkProtExtra(document.display,'returnurl','divurlparam','1','inline-block','$num');";
                             if ($ltiauth) {
-                                $onload .= "toggleLinkProtReqUser(document.display,'requser','optional','1','block','$num');".
-                                           "toggleLinkProtReqUser(document.display,'mapuser','userfield','other','inline-block','$num');";
+                                $onload .= "toggleLinkProtExtra(document.display,'requser','optional','1','block','$num');".
+                                           "toggleLinkProtExtra(document.display,'mapuser','userfield','other','inline-block','$num');";
                             }
                             if ($ishome) {
                                 $onload .= "uncheckLinkProtMakeVis('visible','$num');";


More information about the LON-CAPA-cvs mailing list