--- loncom/interface/lonpreferences.pm 2016/09/19 03:19:12 1.224 +++ loncom/interface/lonpreferences.pm 2018/04/27 20:14:16 1.225 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.224 2016/09/19 03:19:12 raeburn Exp $ +# $Id: lonpreferences.pm,v 1.225 2018/04/27 20:14:16 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -477,7 +477,6 @@ sub verify_and_change_rolespref { } - ################################################################ # Anonymous Discussion Name Change Subroutines # ################################################################ @@ -757,8 +756,10 @@ sub domcoordchanger { my $text=&mt('By default, the Domain Coordinator can enter your Authoring Space.'); my $construction=&mt('Block access to Authoring Space'); my $change=&mt('Save'); + my $returnurl = &HTML::Entities::encode($env{'form.returnurl'},'"<>&\''); $r->print(< + $text

@@ -783,7 +784,11 @@ sub verify_and_change_domcoord { } my $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]',''.&mt('Block access to Authoring Space').'',''.$status.'')); $message=&Apache::loncommon::confirmwrapper($message); - &print_main_menu($r,$message); + if ($env{'form.returnurl'}) { + &do_redirect($r,$env{'form.returnurl'},$message); + } else { + &print_main_menu($r,$message); + } } ################################################################# @@ -1919,8 +1924,10 @@ sub author_space_settings { my $text=&mt('By default, CodeMirror an editor with advanced functionality for editing code is activated for authors.'); my $cmoff=&mt('Deactivate CodeMirror. This can improve performance on slow computers and accessibility.'); my $change=&mt('Save'); + my $returnurl = &HTML::Entities::encode($env{'form.returnurl'},'"<>&\''); $r->print(< + $text

@@ -1948,7 +1955,11 @@ sub change_authoring_settings { } my $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]',''.&mt('Deactivate CodeMirror in Authoring Space').'',''.$status.'')); $message=&Apache::loncommon::confirmwrapper($message); - &print_main_menu($r,$message); + if ($env{'form.returnurl'}) { + &do_redirect($r,$env{'form.returnurl'},$message); + } else { + &print_main_menu($r,$message); + } } } @@ -2246,6 +2257,18 @@ sub handler { if (($env{'form.action'} eq 'changerolespref') && ($env{'form.returnurl'} eq '/adm/roles')) { $brlink ='/adm/roles'; $brtxt = 'User Roles'; + } elsif ((($env{'form.action'} eq 'changedomcoord') || + ($env{'form.action'} eq 'authorsettings')) && + (($env{'form.returnurl'} =~ m{^/(priv/|res($|/))}) || + ($env{'form.returnurl'} eq '/adm/createuser'))) { + $brlink = $env{'form.returnurl'}; + if ($env{'form.returnurl'} eq '/adm/createuser') { + $brtxt = 'User Management'; + } elsif ($env{'form.returnurl'} =~ m{^/res($\/)}) { + $brtxt = 'Browse published resources'; + } else { + $brtxt = 'Authoring Space'; + } } else { $brlink ='/adm/preferences'; $brtxt = 'Set User Preferences'; @@ -2256,7 +2279,7 @@ sub handler { text => $brtxt, help => $brhelp,}); if(!exists $env{'form.action'}) { - &print_main_menu($r); + &print_main_menu($r); }elsif($env{'form.action'} eq 'changepass'){ &passwordchanger($r); }elsif($env{'form.action'} eq 'verify_and_change_pass'){ @@ -2405,5 +2428,16 @@ sub updateable_userinfo { return %updateable; } +sub do_redirect { + my ($r,$url,$msg) = @_; + $r->print( + &Apache::loncommon::start_page('Switching Server ...',undef, + {'redirect' => [0.5,$url]}). + '
'."\n". + "$msg\n". + &Apache::loncommon::end_page()); + return; +} + 1; __END__