[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface lonpreferences.pm

raeburn raeburn at source.lon-capa.org
Mon Sep 3 10:03:04 EDT 2018


raeburn		Mon Sep  3 14:03:04 2018 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonpreferences.pm 
  Log:
  - For 2.11
    Backport 1.225, 1.226, 1.227
  
  
-------------- next part --------------
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.196.4.23 loncom/interface/lonpreferences.pm:1.196.4.24
--- loncom/interface/lonpreferences.pm:1.196.4.23	Mon Sep 19 03:21:20 2016
+++ loncom/interface/lonpreferences.pm	Mon Sep  3 14:03:03 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Preferences
 #
-# $Id: lonpreferences.pm,v 1.196.4.23 2016/09/19 03:21:20 raeburn Exp $
+# $Id: lonpreferences.pm,v 1.196.4.24 2018/09/03 14:03:03 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -722,8 +722,10 @@
     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(<<ENDSCREEN);
 <form name="prefs" action="/adm/preferences" method="post">
+<input type="hidden" name="returnurl" value="$returnurl" />
 <input type="hidden" name="action" value="verify_and_change_domcoord" />
 $text<br />
 <label><input type="checkbox" name="construction"$constchecked />$construction</label><br />
@@ -748,7 +750,11 @@
     }
     my $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]','<i>'.&mt('Block access to Authoring Space').'</i>','<tt>'.$status.'</tt>'));
     $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);
+    }
 }
 
 #################################################################
@@ -1154,7 +1160,6 @@
 ' . $colorchooser . '
 </script>
 ');
-
     $r->print(<<ENDCOL);
 
 <form name="parmform" action="">
@@ -1472,7 +1477,7 @@
 }
 
 sub verify_and_change_password {
-    my ($r,$caller,$mailtoken) = @_;
+    my ($r,$caller,$mailtoken,$ended) = @_;
     my ($user,$domain,$homeserver);
     my ($blocked,$blocktext) =
         &Apache::loncommon::blocking_status('passwd');
@@ -1617,6 +1622,9 @@
             $r->print($message.'<br />');
         } else {
             &print_main_menu($r, $message);
+            if (ref($ended)) {
+                $$ended = 1;
+            }
         }
     } else {
 	# error error: run in circles, scream and shout
@@ -1631,6 +1639,9 @@
                 &mt("The password for user [_1] was not changed.",'<i>'.$user.'</i>').' '.&mt('Please make sure your old password was entered correctly.'),1);
             $message=&Apache::loncommon::confirmwrapper($message);
             &print_main_menu($r, $message);
+            if (ref($ended)) {
+                $$ended = 1;
+            }
         }
     }
     return;
@@ -1885,8 +1896,10 @@
             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(<<ENDSCREEN);
         <form name="prefs" action="/adm/preferences" method="post">
+        <input type="hidden" name="returnurl" value="$returnurl" />
         <input type="hidden" name="action" value="change_authoring_settings" />
         $text<br />
         <label><input type="checkbox" name="cmoff"$constchecked />$cmoff</label><br />
@@ -1914,7 +1927,11 @@
             }
             my $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]','<i>'.&mt('Deactivate CodeMirror in Authoring Space').'</i>','<tt>'.$status.'</tt>'));
             $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);
+            }
     }
 }
 
@@ -2227,10 +2244,22 @@
                                    ['action','wysiwyg','returnurl','refpage']);
     #
     Apache::lonhtmlcommon::clear_breadcrumbs();
-    my ($brlink,$brtxt,$brhelp);
+    my ($brlink,$brtxt,$brhelp,$ended);
     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';
@@ -2242,14 +2271,16 @@
           help => $brhelp,});
     if(!exists $env{'form.action'}) {
 	    &print_main_menu($r);
+            $ended = 1;
     }elsif($env{'form.action'} eq 'changepass'){
         &passwordchanger($r);
     }elsif($env{'form.action'} eq 'verify_and_change_pass'){
-        &verify_and_change_password($r,'preferences');
+        &verify_and_change_password($r,'preferences','',\$ended);
     }elsif($env{'form.action'} eq 'changescreenname'){
         &screennamechanger($r);
     }elsif($env{'form.action'} eq 'verify_and_change_screenname'){
         &verify_and_change_screenname($r);
+        $ended = 1;
     }elsif($env{'form.action'} eq 'changemsgforward'){
         &msgforwardchanger($r);
     }elsif($env{'form.action'} eq 'verify_and_change_msgforward'){
@@ -2258,38 +2289,47 @@
         &colorschanger($r);
     }elsif($env{'form.action'} eq 'verify_and_change_colors'){
         &verify_and_change_colors($r);
+        $ended = 1;
     }elsif($env{'form.action'} eq 'changelanguages'){
         &languagechanger($r);
     }elsif($env{'form.action'} eq 'verify_and_change_languages'){
         &verify_and_change_languages($r);
+        $ended = 1;
     }elsif($env{'form.action'} eq 'changewysiwyg'){
         &wysiwygchanger($r);
     }elsif($env{'form.action'} eq 'set_wysiwyg'){
         &verify_and_change_wysiwyg($r);
+        $ended = 1;
     }elsif($env{'form.action'} eq 'changediscussions'){
         &discussionchanger($r);
     }elsif($env{'form.action'} eq 'verify_and_change_discussion'){
         &verify_and_change_discussion($r);
+        $ended = 1;
     }elsif($env{'form.action'} eq 'changerolespref'){
         &rolesprefchanger($r);
     }elsif($env{'form.action'} eq 'verify_and_change_rolespref'){
         &verify_and_change_rolespref($r);
+        $ended = 1;
     }elsif($env{'form.action'} eq 'changetexenginepref'){
         &texenginechanger($r);
     }elsif($env{'form.action'} eq 'verify_and_change_texengine'){
         &verify_and_change_texengine($r);
+        $ended = 1;
     }elsif($env{'form.action'} eq 'changeicons'){
         &iconchanger($r);
     }elsif($env{'form.action'} eq 'verify_and_change_icons'){
         &verify_and_change_icons($r);
+        $ended = 1;
     }elsif($env{'form.action'} eq 'changeclicker'){
         &clickerchanger($r);
     }elsif($env{'form.action'} eq 'verify_and_change_clicker'){
         &verify_and_change_clicker($r);
+        $ended = 1;
     }elsif($env{'form.action'} eq 'changedomcoord'){
         &domcoordchanger($r);
     }elsif($env{'form.action'} eq 'verify_and_change_domcoord'){
         &verify_and_change_domcoord($r);
+        $ended = 1;
     }elsif($env{'form.action'} eq 'lockwarning'){
         &lockwarning($r);
     }elsif($env{'form.action'} eq 'verify_and_change_locks'){
@@ -2298,26 +2338,29 @@
         &coursedisplaychanger($r);
     }elsif($env{'form.action'} eq 'verify_and_change_coursepage'){
         &verify_and_change_coursepage($r);
+        $ended = 1;
     }elsif($env{'form.action'} eq 'authorsettings'){
         &author_space_settings($r);
     }elsif($env{'form.action'} eq 'change_authoring_settings'){
         &change_authoring_settings($r);
+        $ended = 1;
     }elsif($env{'form.action'} eq 'debugtoggle'){
         if (&can_toggle_debug()) {
             &toggle_debug();
         }
 	&print_main_menu($r);
+        $ended = 1;
     } elsif ($env{'form.action'} eq 'changelockednames') {
         &lockednameschanger($r);
     } elsif ($env{'form.action'} eq 'verify_and_change_lockednames') {
         &verify_and_change_lockednames($r);
+        $ended = 1;
     }
 
     # Properly end the HTML page of all preference pages
     # started in each sub routine
     # Exception: print_main_menu has its own end_page call
-    unless (!exists $env{'form.action'} ||
-            $env{'form.action'} eq 'debugtoggle') {
+    unless ($ended) {
         $r->print(&Apache::loncommon::end_page());
     }
 
@@ -2390,5 +2433,16 @@
     return %updateable;
 }
 
+sub do_redirect {
+    my ($r,$url,$msg) = @_;
+    $r->print(
+        &Apache::loncommon::start_page('Switching Server ...',undef,
+                                       {'redirect'       => [0.5,$url]}).
+        '<div style="padding:0;clear:both;margin:0;border:0"></div>'."\n".
+        "$msg\n".
+        &Apache::loncommon::end_page());
+    return;
+}
+
 1;
 __END__


More information about the LON-CAPA-cvs mailing list