[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm rat lonuserstate.pm

raeburn raeburn at source.lon-capa.org
Wed Oct 5 12:11:26 EDT 2022


raeburn		Wed Oct  5 16:11:26 2022 EDT

  Modified files:              
    /rat	lonuserstate.pm 
    /loncom/auth	lonroles.pm 
  Log:
  - For 'Map not loaded' error on course initialization for a map in /res which
    user can edit switch server loads map (or parent map) in Authoring Space. 
  
  
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.169 rat/lonuserstate.pm:1.170
--- rat/lonuserstate.pm:1.169	Tue Oct  4 20:39:57 2022
+++ rat/lonuserstate.pm	Wed Oct  5 16:11:25 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construct and maintain state and binary representation of course for user
 #
-# $Id: lonuserstate.pm,v 1.169 2022/10/04 20:39:57 raeburn Exp $
+# $Id: lonuserstate.pm,v 1.170 2022/10/05 16:11:25 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -504,6 +504,8 @@
                 } else {
                     $errinfo .= &mt('To rectify this problem, create and publish the missing file');
                 }
+                my $fileurl = $uri;
+                $fileurl =~s{^/res/}{/priv/};
                 if ($fileswitch) {
                     my $rolename = &Apache::lonnet::plaintext($filerole);
                     my $rolecode;
@@ -513,10 +515,10 @@
                         $rolecode = $filerole.'./'.$audomfile.'/'.$aunamefile;
                     }
                     $errinfo .= '.<br />'.&mt('You will need to [_1]switch server[_2].',
-                                             '<a href="/adm/switchserver?otherserver='.$switchserver.'&role='.$rolecode.'">','</a>');
+                                             '<a href="/adm/switchserver?otherserver='.$switchserver.'&role='.$rolecode.
+                                             '&origurl='.&escape($fileurl).'">','</a>');
                 } else {
-                    my $fileurl = $uri;
-                    $fileurl =~s{^/res/}{/priv/};
+                    &js_escape(\$fileurl);
                     $errinfo .= ': <a href="javascript:go('."'$fileurl'".');">'.&mt('Create the missing file').'</a>';
                 }
             }
@@ -537,18 +539,20 @@
                     } else {
                         $errinfo .= &mt('To rectify this problem edit the parent map to remove the reference to the missing file');
                     }
+                    my $mapurl = $hash{'map_id_'.$parent_pc};
+                    $mapurl =~s{^/res/}{/priv/};
                     if ($switchserver) {
                         $errinfo .= '.<br />';
                         if ((&Apache::lonnet::will_trust('othcoau',$env{'user.domain'},$audom)) &&
                             (&Apache::lonnet::will_trust('coaurem',$audom,$env{'user.domain'}))) {
                             $errinfo .= &mt('You will need to [_1]switch server[_2].',
-                                            '<a href="/adm/switchserver?otherserver='.$switchserver.'&role='.$rolecode.'">','</a>');
+                                            '<a href="/adm/switchserver?otherserver='.$switchserver.'&role='.$rolecode.
+                                            '&origurl='.&escape($mapurl).'">','</a>');
                         } else {
                             $errinfo .= &mt('Session switch required but prohibited.');
                         }
                     } else {
-                        my $mapurl = $hash{'map_id_'.$parent_pc};
-                        $mapurl =~s{^/res/}{/priv/};
+                        &js_escape(\$mapurl);
                         $errinfo .= ': <a href="javascript:go('."'$mapurl'".');">'.&mt('Edit the map').'</a>';
                     }
                 } elsif ($uploaded && $courseid) {
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.366 loncom/auth/lonroles.pm:1.367
--- loncom/auth/lonroles.pm:1.366	Fri Jul  1 04:05:16 2022
+++ loncom/auth/lonroles.pm	Wed Oct  5 16:11:26 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.366 2022/07/01 04:05:16 raeburn Exp $
+# $Id: lonroles.pm,v 1.367 2022/10/05 16:11:26 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1130,6 +1130,12 @@
                             $redirect_url .= $where;
                         }
                         $redirect_url .= '/';
+                        if ($env{'form.orgurl'} =~ /^\Q$redirect_url\E/) {
+                            my ($path) = ($env{'form.orgurl'} =~ m{^(.+)/[^/]+$});
+                            if (($path ne '') && (-e $Apache::lonnet::perlvar{'lonDocRoot'}.$path)) {
+                                $redirect_url = $env{'form.orgurl'};
+                            }
+                        }
                         &redirect_user($r,&mt('Entering Authoring Space'),
                                        $redirect_url);
                         return OK;




More information about the LON-CAPA-cvs mailing list