[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm /interface lonnavmaps.pm

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 21 Jul 2004 19:54:44 -0000


albertel		Wed Jul 21 15:54:44 2004 EDT

  Modified files:              
    /loncom/auth	lonroles.pm 
    /loncom/interface	lonnavmaps.pm 
  Log:
  - first pass at Concrod 'external nav window' request (BUG#3231)
       - create new env parm for stuent 'remotenavmap'
       - when entering course, lonroles will start up the window if it is closed
       - launch and close of the window works
  
  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.94 loncom/auth/lonroles.pm:1.95
--- loncom/auth/lonroles.pm:1.94	Sun Jul  4 01:53:35 2004
+++ loncom/auth/lonroles.pm	Wed Jul 21 15:54:43 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.94 2004/07/04 05:53:35 albertel Exp $
+# $Id: lonroles.pm,v 1.95 2004/07/21 19:54:43 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -40,12 +40,15 @@
 use Apache::lonlocal;
 
 sub redirect_user {
-    my ($r,$title,$url,$msg) = @_;
+    my ($r,$title,$url,$msg,$launch_nav) = @_;
     $msg = $title if (! defined($msg));
     &Apache::loncommon::content_type($r,'text/html');
     &Apache::loncommon::no_cache($r);
     $r->send_http_header;
     my $swinfo=&Apache::lonmenu::rawconfig();
+    if ($launch_nav eq 'on') {
+	$swinfo.=&Apache::lonnavmaps::launch_win('now','no');
+    }
     my $bodytag=&Apache::loncommon::bodytag('Switching Role');
 # Note to style police: 
 # This must only replace the spaces, nothing else, or it bombs elsewhere.
@@ -60,6 +63,7 @@
 $swinfo
 </script>
 <h1>$msg</h1>
+<a href="$url">Continue</a>
 </body>
 </html>
 ENDREDIR
@@ -246,7 +250,8 @@
                             #
                             # Send the user to the course they selected
                             &redirect_user($r,&mt('Entering Course'),
-                                           $furl,$msg);
+                                           $furl,$msg,
+					   $ENV{'environment.remotenavmap'});
                             return OK;
 			}
 		    }
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.267 loncom/interface/lonnavmaps.pm:1.268
--- loncom/interface/lonnavmaps.pm:1.267	Mon Jul 19 11:35:38 2004
+++ loncom/interface/lonnavmaps.pm	Wed Jul 21 15:54:43 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.267 2004/07/19 15:35:38 albertel Exp $
+# $Id: lonnavmaps.pm,v 1.268 2004/07/21 19:54:43 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -83,6 +83,30 @@
 # is not yet done and due in less then 24 hours
 my $hurryUpColor = "#FF0000";
 
+sub launch_win {
+    my ($mode,$script)=@_;
+    my $result;
+    if ($script ne 'no') {
+	$result.='<script type="text/javascript">';
+    }
+    $result.='function launch_navmapwin() {
+                 newWindow=open(\'/adm/navmaps?launchExternal\',\'loncapanav\',\'width=400,height=600,scrollbars=1\');
+               }';
+    if ($mode eq 'now') {
+	$result.="\nlaunch_navmapwin();\n";
+    }
+    if ($script ne 'no') {
+	$result.='</script>';
+    }
+    if ($mode eq 'link') {
+	$result.='<a href="javascript:launch_navmapwin();void(0);">'
+	    .&mt("Launch Navmaps in seperate window")."</a>";
+    }
+    return $result;
+}
+
+
+
 sub handler {
     my $r = shift;
     real_handler($r);
@@ -111,6 +135,28 @@
     &Apache::loncommon::no_cache($r);
     $r->send_http_header;
 
+    if ($ENV{QUERY_STRING} eq 'collapseExternal') {
+	&Apache::lonnet::put('environment',{'remotenavmap' => 'off'});
+	&Apache::lonnet::appenv('environment.remotenavmap' => 'off');
+	$r->print(<<"ENDSUBM");
+	<html>
+        <head>
+	  <script type="text/javascript">
+ 	    function submitthis() {
+		    self.close();
+	    }
+  	  </script>
+        </head>
+	<body bgcolor="#FFFFFF" onLoad="submitthis()"></body>
+        </html>
+ENDSUBM
+        return;
+    }
+    if ($ENV{QUERY_STRING} eq 'launchExternal') {
+	&Apache::lonnet::put('environment',{'remotenavmap' => 'on'});
+	&Apache::lonnet::appenv('environment.remotenavmap' => 'on');
+    }
+
     # Create the nav map
     my $navmap = Apache::lonnavmaps::navmap->new();
 
@@ -127,10 +173,23 @@
     
 # ----------------------------------------------------- Force menu registration
     my $addentries='';
+    my $more_unload;
+    if ($ENV{'environment.remotenavmap'} eq 'on') {
+	$r->print('<script type="text/javascript">
+                      function collapse() {
+                         this.document.location="/adm/navmaps?collapseExternal";
+                      }
+                   </script>');
+# FIXME need to be smarter to only catch window close events
+#	$more_unload="collapse()"
+    }
     if ($ENV{'form.register'}) {
-       $addentries=' onLoad="'.&Apache::lonmenu::loadevents().
-	   '" onUnload="'.&Apache::lonmenu::unloadevents().'"';
-       $r->print(&Apache::lonmenu::registerurl(1));
+	$addentries=' onLoad="'.&Apache::lonmenu::loadevents().
+	    '" onUnload="'.&Apache::lonmenu::unloadevents().';'.
+	    $more_unload.'"';
+	$r->print(&Apache::lonmenu::registerurl(1));
+    } else {
+	$addentries=' onUnload="'.$more_unload.'"';
     }
 
     # Header
@@ -173,6 +232,27 @@
         }
     }
 
+    if ($ENV{QUERY_STRING} eq 'launchExternal') {
+	$r->print('
+          <form name="returnwin" action="/adm/flip?postdata=return%3a" 
+                method="post" target="loncapaclient">
+          </form>');
+	$r->print('
+          <script type="text/javascript">
+              this.document.returnwin.submit();
+          </script>');
+    }
+
+    if ($ENV{'environment.remotenavmap'} ne 'on') {
+	$r->print(&launch_win('link','yes'));
+    } 
+    if ($ENV{'environment.remotenavmap'} eq 'on') {
+#        $r->print("<a href='navmaps?collapseExternal'>" .
+        $r->print("<a href='javascript:collapse();void(0);'>" .
+		  &mt("Close external navmaps").
+		  "</a>&nbsp;&nbsp;&nbsp;&nbsp;");
+    } 
+
     my $jumpToFirstHomework = 0;
     # Check to see if the student is jumping to next open, do-able problem
     if ($ENV{QUERY_STRING} eq 'jumpToFirstHomework') {
@@ -971,8 +1051,12 @@
         $nonLinkedText .= ' (' . $resource->countParts() . ' parts)';
     }
 
+    my $target;
+    if ($ENV{'environment.remotenavmap'} eq 'on') {
+	$target=' target="loncapaclient" ';
+    }
     if (!$params->{'resource_nolink'} && !$resource->is_sequence() && !$resource->is_empty_sequence) {
-        $result .= "  $curMarkerBegin<a href='$link'>$title$partLabel</a>$curMarkerEnd $nonLinkedText</td>";
+        $result .= "  $curMarkerBegin<a $target href='$link'>$title$partLabel</a>$curMarkerEnd $nonLinkedText</td>";
     } else {
         $result .= "  $curMarkerBegin$title$partLabel$curMarkerEnd $nonLinkedText</td>";
     }