[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /auth lonroles.pm /interface loncommon.pm lonmenu.pm

raeburn raeburn at source.lon-capa.org
Fri Aug 3 13:35:39 EDT 2012


raeburn		Fri Aug  3 17:35:39 2012 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	loncommon.pm lonmenu.pm 
    /loncom/auth	lonroles.pm 
  Log:
  - For 2.11.
    - Remote Control retained in 2.11.
    - Reverse part of changes in loncommon.pm rev 1.949, 1.953, 1.962, 1.964.
    - Reverse part of changes in lonmenu.pm rev 1.316, 1.318, 1.321.
    - Reverse part of changes in lonroles.pm rev 1.245.
  
  
-------------- next part --------------
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1075.2.11 loncom/interface/loncommon.pm:1.1075.2.12
--- loncom/interface/loncommon.pm:1.1075.2.11	Wed Aug  1 04:34:00 2012
+++ loncom/interface/loncommon.pm	Fri Aug  3 17:35:32 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1075.2.11 2012/08/01 04:34:00 raeburn Exp $
+# $Id: loncommon.pm,v 1.1075.2.12 2012/08/03 17:35:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4954,6 +4954,9 @@
 
 =item * $bgcolor, used to override the bgcolor on a webpage to a specific value
 
+=item * $no_inline_link, if true and in remote mode, don't show the
+         'Switch To Inline Menu' link
+
 =item * $args, optional argument valid values are
             no_auto_mt_title -> prevents &mt()ing the title arg
             inherit_jsmath -> when creating popup window in a page,
@@ -4971,7 +4974,7 @@
 
 sub bodytag {
     my ($title,$function,$addentries,$bodyonly,$domain,$forcereg,
-        $no_nav_bar,$bgcolor,$args)=@_;
+        $no_nav_bar,$bgcolor,$no_inline_link,$args)=@_;
 
     my $public;
     if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public'))
@@ -5013,6 +5016,8 @@
     }
 
     if (!$realm) { $realm=' '; }
+# Set messages
+    my $messages=&domainlogo($domain);
 
     my $extra_body_attr = &make_attr_string($forcereg,\%design);
 
@@ -5047,6 +5052,7 @@
     $role = '<span class="LC_nobreak">('.$role.')</span>' if $role;
     &get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']);
 
+    unless ($env{'environment.remote'} eq 'on') {
         if ($no_nav_bar || $env{'form.inhibitmenu'} eq 'yes') { 
             return $bodytag; 
         } 
@@ -5103,6 +5109,42 @@
         }
 
         return $bodytag;
+    }
+
+#
+# Top frame rendering, Remote is up
+#
+
+    my $imgsrc = $img;
+    if ($img =~ /^\/adm/) {
+        $imgsrc = &lonhttpdurl($img);
+    }
+    my $upperleft='<img src="'.$imgsrc.'" alt="'.$function.'" />';
+
+    # Explicit link to get inline menu
+    my $menu= ($no_inline_link?''
+               :'<a href="/adm/remote?action=collapse" target="_top">'.&mt('Switch to Inline Menu Mode').'</a>');
+
+    if ($dc_info) {
+        $dc_info = qq|<span class="LC_cusr_subheading">($dc_info)</span>|;
+    }
+
+    unless ($env{'form.inhibitmenu'}) {
+        $bodytag .= qq|<div id="LC_nav_bar">$name $role</div>
+                       <ol class="LC_primary_menu LC_right">
+                       <li>$menu</li>
+                       </ol><div id="LC_realm"> $realm $dc_info</div>|;
+    }
+    return(<<ENDBODY);
+$bodytag
+<table id="LC_title_bar" class="LC_with_remote">
+<tr><td>$upperleft</td>
+    <td>$messages </td>
+</tr>
+<tr><td>$titleinfo $dc_info $menu</td>
+</tr>
+</table>
+ENDBODY
 }
 
 sub dc_courseid_toggle {
@@ -5134,8 +5176,15 @@
 		delete($attr_ref->{$key});
 	    }
 	}
-	$attr_ref->{'onload'}  = $on_load;
-	$attr_ref->{'onunload'}= $on_unload;
+        if ($env{'environment.remote'} eq 'on') {
+            $attr_ref->{'onload'}  =
+                &Apache::lonmenu::loadevents().  $on_load;
+            $attr_ref->{'onunload'}=
+                &Apache::lonmenu::unloadevents().$on_unload;
+        } else {  
+	    $attr_ref->{'onload'}  = $on_load;
+	    $attr_ref->{'onunload'}= $on_unload;
+        }
     }
 
     my $attr_string;
@@ -7100,8 +7149,8 @@
     if (!$args->{'frameset'}) {
 	$result .= &Apache::lonhtmlcommon::htmlareaheaders();
     }
-    if ($args->{'force_register'} && $env{'request.noversionuri'} !~ m{^/res/adm/pages/}) {
-        $result .= Apache::lonxml::display_title();
+    if ($args->{'force_register'}) {
+        $result .= &Apache::lonmenu::registerurl(1);
     }
     if (!$args->{'no_nav_bar'} 
 	&& !$args->{'only_body'}
@@ -7310,6 +7359,8 @@
              skip_phases    -> hash ref of 
                                     head -> skip the <html><head> generation
                                     body -> skip all <body> generation
+             no_inline_link -> if true and in remote mode, don't show the
+                                    'Switch To Inline Menu' link
              no_auto_mt_title -> prevent &mt()ing the title arg
              inherit_jsmath -> when creating popup window in a page,
                                     should it have jsmath forced on by the
@@ -7345,7 +7396,8 @@
                          $args->{'function'},       $args->{'add_entries'},
                          $args->{'only_body'},      $args->{'domain'},
                          $args->{'force_register'}, $args->{'no_nav_bar'},
-                         $args->{'bgcolor'},        $args);
+                         $args->{'bgcolor'},        $args->{'no_inline_link'},
+                         $args);
         }
     }
 
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.369.2.16 loncom/interface/lonmenu.pm:1.369.2.17
--- loncom/interface/lonmenu.pm:1.369.2.16	Fri Aug  3 01:37:23 2012
+++ loncom/interface/lonmenu.pm	Fri Aug  3 17:35:32 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.369.2.16 2012/08/03 01:37:23 raeburn Exp $
+# $Id: lonmenu.pm,v 1.369.2.17 2012/08/03 17:35:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -131,6 +131,26 @@
 
 This gets called in order to register a URL in the body of the document
 
+=item loadevents()
+
+=item unloadevents()
+
+=item startupremote()
+
+=item setflags()
+
+=item maincall()
+
+=item load_remote_msg()
+
+=item get_menu_name()
+
+=item reopenmenu()
+
+=item open()
+
+Open the menu
+
 =item clear()
 
 =item switch()
@@ -458,6 +478,34 @@
     return $menu;
 }
 
+sub registerurl {
+    my ($forcereg) = @_;
+    my $result = '';
+    if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
+    my $force_title='';
+    if ($env{'request.state'} eq 'construct') {
+        $force_title=&Apache::lonxml::display_title();
+    }
+    if (($env{'environment.remote'} eq 'off') ||
+        ((($env{'request.publicaccess'}) ||
+         (!&Apache::lonnet::is_on_map(
+           &unescape($env{'request.noversionuri'})))) &&
+        (!$forcereg))) {
+        return
+        $result
+       .'<script type="text/javascript">'."\n"
+       .'// <![CDATA['."\n"
+       .'function LONCAPAreg(){;} function LONCAPAstale(){}'."\n"
+       .'// ]]>'."\n"
+       .'</script>'
+       .$force_title;
+    }
+# Graphical display after login only
+    if ($env{'request.registered'} && !$forcereg) { return ''; }
+    $result.=&innerregister($forcereg);
+    return $result.$force_title;
+}
+
 sub innerregister {
     my ($forcereg,$bread_crumbs) = @_;
     my $const_space = ($env{'request.state'} eq 'construct');
@@ -467,8 +515,19 @@
 
     $env{'request.registered'} = 1;
 
+    my $noremote = ($env{'environment.remote'} eq 'off');
+
     undef(@inlineremote);
 
+    my $reopen=&Apache::lonmenu::reopenmenu();
+
+    my $newmail='';
+
+    if (&Apache::lonmsg::newmail() && !$noremote) {
+        # We have new mail and remote is up
+        $newmail= 'swmenu.setstatus("you have","messages");';
+    }
+
     my $resurl; 
     if ( $env{'request.symb'} && $env{'request.course.id'} ) {
 
@@ -507,10 +566,48 @@
         &Apache::lonhtmlcommon::clear_breadcrumbs();
         &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
     }
+    my $timesync   = ( $noremote ? '' : 'swmenu.syncclock(1000*'.time.');' );
 # =============================================================================
 # ============================ This is for URLs that actually can be registered
-    return '' unless ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/}) 
-                       || $forcereg );
+    unless ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/})
+                       || ($forcereg)) {
+        unless ($noremote) {
+# Not registered, graphical
+           return (<<ENDDONOTREGTHIS);
+
+<script type="text/javascript">
+// <![CDATA[
+// BEGIN LON-CAPA Internal
+var swmenu=null;
+
+    function LONCAPAreg() {
+          swmenu=$reopen
+          $timesync
+          swmenu.currentStale=1;
+          swmenu.clearbut(2,1);
+          swmenu.clearbut(2,3);
+          swmenu.clearbut(8,1);
+          swmenu.clearbut(8,2);
+          swmenu.clearbut(8,3);
+          if (swmenu.currentURL) {
+             swmenu.switchbutton
+              (3,1,'reload.gif','return','location','go(currentURL)');
+          } else {
+              swmenu.clearbut(3,1);
+          }
+    }
+
+    function LONCAPAstale() {
+    }
+
+// END LON-CAPA Internal
+// ]]>
+</script>
+ENDDONOTREGTHIS
+
+        }
+        return '';
+    }
 
 # -- This applies to homework problems for users with grading privileges
 	my $crs='/'.$env{'request.course.id'};
@@ -792,7 +889,7 @@
 s&9&1&wishlist-link.png&Stored Links&wishlistlink[_2]&set_wishlistlink()&Save a link for this resource in your personal Stored Links repository&&1
 ENDMENUITEMS
                     $got_wishlist = 1;
-                } 
+                }
             }
 	}
         my $buttons='';
@@ -813,44 +910,94 @@
                 }
             }
         }
-
+        if ($noremote) {
 	    my $addremote=0;
 	    foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
-    if ($addremote) {
+            if ($addremote) {
 
-        &Apache::lonhtmlcommon::clear_breadcrumb_tools();
+                &Apache::lonhtmlcommon::clear_breadcrumb_tools();
 
-            &Apache::lonhtmlcommon::add_breadcrumb_tool(
-                'navigation', @inlineremote[21,23]);
+                &Apache::lonhtmlcommon::add_breadcrumb_tool(
+                    'navigation', @inlineremote[21,23]);
+
+                my $countdown = &countdown_timer();
+                if (&hidden_button_check() eq 'yes') {
+                    if ($countdown) {
+                        &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown);
+                    }
+                } else {
+                    my @tools = @inlineremote[93,91,81,82,83];
+                    if ($countdown) {
+                        unshift(@tools,$countdown);
+                    }
+                    &Apache::lonhtmlcommon::add_breadcrumb_tool(
+                        'tools', at tools);
 
-        my $countdown = &countdown_timer();
-        if (&hidden_button_check() eq 'yes') {
-            if ($countdown) {
-                &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown);
+                    #publish button in construction space
+                    if ($env{'request.state'} eq 'construct'){
+                        &Apache::lonhtmlcommon::add_breadcrumb_tool(
+                            'advtools', $inlineremote[63]);
+                    } else {
+                        &Apache::lonhtmlcommon::add_breadcrumb_tool(
+                            'tools', $inlineremote[63]);
+                    }
+                    unless ($env{'request.noversionuri'}=~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) {
+                        &Apache::lonhtmlcommon::add_breadcrumb_tool(
+                            'advtools', @inlineremote[61,71,72,73,74,92]);
+                    }
+                }
             }
         } else {
-            my @tools = @inlineremote[93,91,81,82,83];
-            if ($countdown) {
-                unshift(@tools,$countdown);
-            }
-            &Apache::lonhtmlcommon::add_breadcrumb_tool(
-                'tools', at tools);
+            my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
+            $requri=&Apache::lonenc::check_encrypt(&unescape($requri));
+            my $cursymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
+            my $navstatus=&get_nav_status();
+            my $clearcstr;
 
-            #publish button in construction space
-            if ($env{'request.state'} eq 'construct'){
-                &Apache::lonhtmlcommon::add_breadcrumb_tool(
-                     'advtools', $inlineremote[63]);
-            } else {
-                &Apache::lonhtmlcommon::add_breadcrumb_tool(
-                     'tools', $inlineremote[63]);
-            }
-            
-            unless ($env{'request.noversionuri'}=~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) {
-                &Apache::lonhtmlcommon::add_breadcrumb_tool(
-                    'advtools', @inlineremote[61,71,72,73,74,92]);
-            }
+            if ($env{'user.adv'}) { $clearcstr='clearbut(6,1)'; }
+            return <<ENDREGTHIS;
+
+<script type="text/javascript">
+// <![CDATA[
+// BEGIN LON-CAPA Internal
+var swmenu=null;
+
+    function LONCAPAreg() {
+          swmenu=$reopen;
+          swmenu.clearTimeout(swmenu.menucltim);
+          $timesync
+          $newmail
+          $buttons
+          swmenu.currentURL="$requri";
+          swmenu.reloadURL=swmenu.currentURL+window.location.search;
+          swmenu.currentSymb="$cursymb";
+          swmenu.reloadSymb="$cursymb";
+          swmenu.currentStale=0;
+          $navstatus
+          $hwkadd
+          $editbutton
+    }
+
+    function LONCAPAstale() {
+          swmenu=$reopen
+          swmenu.currentStale=1;
+          if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) {
+             swmenu.switchbutton
+             (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
+          }
+          swmenu.clearbut(7,2);
+          swmenu.clearbut(7,3);
+          swmenu.menucltim=swmenu.setTimeout(
+ 'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
+ 'clearbut(9,1);clearbut(9,3);clearbut(6,3);$clearcstr',
+                          2000);
+      }
+
+// END LON-CAPA Internal
+// ]]>
+</script>
+ENDREGTHIS
         }
-    }
 
     return   &Apache::lonhtmlcommon::scripttag('', 'start')
            . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
@@ -893,10 +1040,22 @@
     return $cfile;
 }
 
+sub loadevents() {
+    if ($env{'request.state'} eq 'construct' ||
+        $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
+    return 'LONCAPAreg();';
+}
+
+sub unloadevents() {
+    if ($env{'request.state'} eq 'construct' ||
+        $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
+    return 'LONCAPAstale();';
+}
+
 sub startupremote {
     my ($lowerurl)=@_;
-    if ($env{'environment.remote'} eq 'off') {
-     return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
+    unless ($env{'environment.remote'} eq 'on') {
+        return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
     }
 #
 # The Remote actually gets launched!
@@ -974,7 +1133,7 @@
 }
 
 sub maincall() {
-    if ($env{'environment.remote'} eq 'off') { return ''; }
+    unless ($env{'environment.remote'} eq 'on') { return ''; }
     return(<<ENDMAINCALL);
 <script type="text/javascript">
 // <![CDATA[
@@ -987,7 +1146,7 @@
 sub load_remote_msg {
     my ($lowerurl)=@_;
 
-    if ($env{'environment.remote'} eq 'off') { return ''; }
+    unless ($env{'environment.remote'} eq 'on') { return ''; }
 
     my $esclowerurl=&escape($lowerurl);
     my $link=&mt('[_1]Continue[_2] on in Inline Menu mode'
@@ -1011,7 +1170,7 @@
 
 
 sub reopenmenu {
-   if ($env{'environment.remote'} eq 'off') { return ''; }
+   unless ($env{'environment.remote'} eq 'on') { return ''; }
    my $menuname = &get_menu_name();
    my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
    return('window.open('.$nothing.',"'.$menuname.'","",false);');
@@ -1020,7 +1179,7 @@
 
 sub open {
     my $returnval='';
-    if ($env{'environment.remote'} eq 'off') {
+    unless ($env{'environment.remote'} eq 'on') {
         return
         '<script type="text/javascript">'."\n"
        .'// <![CDATA['."\n"
@@ -1055,8 +1214,13 @@
 
 sub clear {
     my ($row,$col)=@_;
-    $inlineremote[10*$row+$col]='';
-    return ''; 
+    if ($env{'environment.remote'} eq 'on') {
+       if (($row<1) || ($row>13)) { return ''; }
+       return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
+    } else {
+        $inlineremote[10*$row+$col]='';
+        return '';
+    }
 }
 
 # ============================================ Switch a button or create a link
@@ -1073,6 +1237,14 @@
     my $idx=10*$row+$col;
     $category_members{$cat}.=':'.$idx;
 
+    if ($env{'environment.remote'} eq 'on') {
+        if (($row<1) || ($row>13)) { return ''; }
+# Remote
+        $img=~s/\.png$/\.gif/;
+        return "\n".
+ qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
+    }
+
 # Inline Menu
     if ($nobreak==2) { return ''; }
     my $text=$top.' '.$bot;
@@ -1134,6 +1306,13 @@
     return $output;
 }
 
+sub openmenu {
+    my $menuname = &get_menu_name();
+    unless ($env{'environment.remote'} eq 'on') { return ''; }
+    my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
+    return "window.open(".$nothing.",'".$menuname."');";
+}
+
 sub inlinemenu {
     undef(@inlineremote);
     undef(%category_members);
@@ -1176,7 +1355,13 @@
 #
     my $textualoverride=shift;
     my $output='';
-    return '' unless $textualoverride;
+    if ($env{'environment.remote'} eq 'on') {
+       $output.=
+ "window.status='Opening Remote Control';var swmenu=".&openmenu().
+"\nwindow.status='Configuring Remote Control ';";
+    } else {
+        unless ($textualoverride) { return ''; }
+    }
     my $uname=$env{'user.name'};
     my $udom=$env{'user.domain'};
     my $adv=$env{'user.adv'};
@@ -1351,6 +1536,12 @@
           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
         }
     }
+    if ($env{'environment.remote'} eq 'on') {
+        $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
+        if (&Apache::lonmsg::newmail()) {
+            $output.='swmenu.setstatus("you have","messages");';
+        }
+    }
     return $output;
 }
 
@@ -1379,7 +1570,7 @@
 # ======================================================================= Close
 
 sub close {
-    if ($env{'environment.remote'} eq 'off') { return ''; }
+    unless ($env{'environment.remote'} eq 'on') { return ''; }
     my $menuname = &get_menu_name();
     return(<<ENDCLOSE);
 <script type="text/javascript">
@@ -1664,6 +1855,16 @@
 ENDCONSTSPACEFORM
 }
 
+sub get_nav_status {
+    my $navstatus="swmenu.w_loncapanav_flag=";
+    if ($env{'environment.remotenavmap'} eq 'on') {
+        $navstatus.="1";
+    } else {
+        $navstatus.="-1";
+    }
+    return $navstatus;
+}
+
 sub hidden_button_check {
     if ( $env{'request.course.id'} eq ''
          || $env{'request.role.adv'} ) {
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.269 loncom/auth/lonroles.pm:1.269.2.1
--- loncom/auth/lonroles.pm:1.269	Sat Jul 21 21:09:03 2012
+++ loncom/auth/lonroles.pm	Fri Aug  3 17:35:39 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.269 2012/07/21 21:09:03 raeburn Exp $
+# $Id: lonroles.pm,v 1.269.2.1 2012/08/03 17:35:39 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -149,6 +149,7 @@
     &Apache::loncommon::content_type($r,'text/html');
     &Apache::loncommon::no_cache($r);
     $r->send_http_header;
+    my $swinfo=&Apache::lonmenu::rawconfig();
 
     # Breadcrumbs
     my $brcrum = [{'href' => $url,
@@ -163,6 +164,11 @@
     $url=~s/ /\%20/g;
     $r->print(<<ENDREDIR);
 $start_page
+<script type="text/javascript">
+// <![CDATA[
+$swinfo
+// ]]>
+</script>
 <p>$msg</p>
 $end_page
 ENDREDIR


More information about the LON-CAPA-cvs mailing list