[LON-CAPA-cvs] cvs: loncom /interface lonmenu.pm lonpreferences.pm mydesk.tab

raeburn raeburn at source.lon-capa.org
Fri Apr 27 16:14:17 EDT 2018


raeburn		Fri Apr 27 20:14:17 2018 EDT

  Modified files:              
    /loncom/interface	mydesk.tab lonmenu.pm lonpreferences.pm 
  Log:
  - Return to Authoring Space or Resource Space after changing user preferences
    for ad hoc co-author role for DCs, and use of CodeMirror.
  
  
-------------- next part --------------
Index: loncom/interface/mydesk.tab
diff -u loncom/interface/mydesk.tab:1.176 loncom/interface/mydesk.tab:1.177
--- loncom/interface/mydesk.tab:1.176	Sat Oct  7 23:14:49 2017
+++ loncom/interface/mydesk.tab	Fri Apr 27 20:14:16 2018
@@ -1,4 +1,4 @@
-# $Id: mydesk.tab,v 1.176 2017/10/07 23:14:49 raeburn Exp $
+# $Id: mydesk.tab,v 1.177 2018/04/27 20:14:16 raeburn Exp $
 # primary menu links
 # Apache::lonmenu::primary_menu() generates a menu from these elements
 # prim: item belongs to primary menu
@@ -77,7 +77,7 @@
 #   - nvgr: cannot view other people's grades 
 #   - mgr: Manage grades
 #   - author: authors (au, ca, aa)
-#   - cca:  Grant/revoke role of co-author (author only)
+#   - cca: Grant/revoke role of co-author (author only)
 # prim:link:icon:alt:text:condition
 scnd:/adm/navmaps?postdata=[url]&postsymb=[symb]:::Contents:
 scnd:/adm/whatsnew:::What's New:whn
@@ -118,8 +118,8 @@
 scndsub:Settings:/adm/courseprefs:Course Settings:params
 scndsub:Settings:/adm/parmset:Content Settings:params
 scndsub:Settings:/adm/slotrequest?command=showslots:Slots:vgr
-scndsub:Settings:/adm/preferences?action=authorsettings:Editing Options:author
-scndsub:Settings:/adm/preferences?action=changedomcoord:Domain Access:cca
+scndsub:Settings:/adm/preferences?action=authorsettings[returnurl]:Editing Options:author
+scndsub:Settings:/adm/preferences?action=changedomcoord[returnurl]:Domain Access:cca
 scndsub:People:/adm/createuser:Users:viewusers
 scndsub:People:/adm/coursegroups:Groups:vcg
 scndsub:Public:/public/[cdom]/[cnum]/syllabus:Syllabus:crsedit
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.487 loncom/interface/lonmenu.pm:1.488
--- loncom/interface/lonmenu.pm:1.487	Sun Apr 15 00:28:07 2018
+++ loncom/interface/lonmenu.pm	Fri Apr 27 20:14:16 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.487 2018/04/15 00:28:07 raeburn Exp $
+# $Id: lonmenu.pm,v 1.488 2018/04/27 20:14:16 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -665,6 +665,20 @@
                     next unless (($env{'user.name'} ne '') && ($env{'user.domain'} ne ''));
                     $href =~ s/\[domain\]/$env{'user.domain'}/g;
                     $href =~ s/\[user\]/$env{'user.name'}/g;
+                } elsif (($href =~ m{^/adm/preferences\?}) && ($href =~ /\[returnurl\]/)) {
+                    my $returnurl = $ENV{'REQUEST_URI'};
+                    if ($ENV{'REQUEST_URI'} =~ m{/adm/preferences\?action=(?:changedomcoord|authorsettings)\&returnurl=([^\&]+)$}) {
+                        $returnurl = $1;
+                    }
+                    if (($returnurl =~ m{^/adm/createuser($|\?action=)}) ||
+                        ($returnurl =~ m{^/priv/$match_domain/$match_username}) ||
+                        ($returnurl =~ m{^/res(/?$|/$match_domain/$match_username)})) {
+                        $returnurl =~ s{\?.*$}{};
+                        $returnurl = '&returnurl='.&HTML::Entities::encode($returnurl,'"<>&\'');
+                    } else {
+                        undef($returnurl);
+                    }
+                    $href =~ s/\[returnurl\]/$returnurl/;
                 }
                 unless (($href eq '') || ($href =~ /^\#/)) {
                     if ($target eq '_top') {
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.224 loncom/interface/lonpreferences.pm:1.225
--- loncom/interface/lonpreferences.pm:1.224	Mon Sep 19 03:19:12 2016
+++ loncom/interface/lonpreferences.pm	Fri Apr 27 20:14:16 2018
@@ -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 @@
 }
 
 
-
 ################################################################
 #         Anonymous Discussion Name Change Subroutines         #
 ################################################################
@@ -757,8 +756,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 />
@@ -783,7 +784,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);
+    }
 }
 
 #################################################################
@@ -1919,8 +1924,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 />
@@ -1948,7 +1955,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);
+            }
     }
 }
 
@@ -2246,6 +2257,18 @@
     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 @@
           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 @@
     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