[LON-CAPA-cvs] cvs: loncom /publisher loncfile.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Tue, 17 Feb 2004 22:06:10 -0000


raeburn		Tue Feb 17 17:06:10 2004 EDT

  Modified files:              
    /loncom/publisher	loncfile.pm 
  Log:
  Modified to permit processing of testbank uploads and IMS package uploads.
  
  
Index: loncom/publisher/loncfile.pm
diff -u loncom/publisher/loncfile.pm:1.50 loncom/publisher/loncfile.pm:1.51
--- loncom/publisher/loncfile.pm:1.50	Mon Jan  5 11:48:50 2004
+++ loncom/publisher/loncfile.pm	Tue Feb 17 17:06:10 2004
@@ -9,7 +9,7 @@
 #  and displays a page showing the results of the action.
 #
 #
-# $Id: loncfile.pm,v 1.50 2004/01/05 16:48:50 www Exp $
+# $Id: loncfile.pm,v 1.51 2004/02/17 22:06:10 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -599,12 +599,17 @@
 
 sub NewDir1
 {
-  my ($request, $username, $domain, $fn, $newfilename) = @_;
+  my ($request, $username, $domain, $fn, $newfilename, $mode) = @_;
 
   my $result=&exists($username,$domain,$newfilename);
   if ($result) {
     $request->print('<font color="red">'.$result.'</font></form>');
   } else {
+    if ($mode eq 'testbank') {
+        $request->print('<input type="hidden" name="callingmode" value="testbank">');
+    } elsif ($mode eq 'imsimport') {
+        $request->print('<input type="hidden" name="callingmode" value="imsimport">');
+    }
     $request->print('<input type="hidden" name="newfilename" value="'.
 		    $newfilename.'" /><p>'.&mt('Make new directory').' '.
 		    &display($newfilename).'?</p>');
@@ -749,7 +754,11 @@
 	  $r->print('<p>'.&mt('No new filename specified.').'</p></form>');
       }
   } elsif ($ENV{'form.action'} eq 'newdir') {
-      &NewDir1($r, $uname, $udom, $fn, $newfilename);
+      my $mode = '';
+      if (exists($ENV{'form.callingmode'}) ) {
+          $mode = $ENV{'form.callingmode'};
+      }   
+      &NewDir1($r, $uname, $udom, $fn, $newfilename, $mode);
   }  elsif ($ENV{'form.action'} eq 'newfile' ||
 	    $ENV{'form.action'} eq 'newhtmlfile' ||
 	    $ENV{'form.action'} eq 'newproblemfile' ||
@@ -1121,7 +1130,11 @@
 	}
 	$dest = $newdir."/"
     }
-    $r->print('<h3><a href="'.&url($dest).'">'.&mt('Done').'</a></h3>');
+    if ( ($ENV{'form.action'} eq 'newdir') && ($ENV{'form.phase'} eq 'two') && ( ($ENV{'form.callingmode'} eq 'testbank') || ($ENV{'form.callingmode'} eq 'imsimport') ) ) {
+         $r->print('<h3><a href="javascript:self.close()">'.&mt('Done').'</a></h3>');
+    } else {
+         $r->print('<h3><a href="'.&url($dest).'">'.&mt('Done').'</a></h3>');
+    }
 }
 
 sub handler {
@@ -1189,9 +1202,24 @@
   &Apache::loncommon::content_type($r,'text/html');
   $r->send_http_header;
 
-  $r->print('<html><head><title>LON-CAPA Construction Space</title></head>');
-
-  $r->print(&Apache::loncommon::bodytag('Construction Space File Operation'));
+  if ( ($ENV{'form.action'} eq 'newdir') && ($ENV{'form.phase'} eq 'two') && ( ($ENV{'form.callingmode'} eq 'testbank') || ($ENV{'form.callingmode'} eq 'imsimport') ) ) {
+      my $newdirname = $ENV{'form.newfilename'};
+      $r->print('<html><head><title>LON-CAPA Construction Space</title><script language="Javascript">');
+      $r->print(qq|
+function writeDone() {
+    var winName = window.opener
+    window.focus();
+    winName.document.dataForm.newdir.value = "$newdirname"
+    setTimeout("self.close()",10000)
+}
+  </script>
+  </head>|);
+      my $loaditem = 'onLoad="writeDone()"';
+      $r->print(&Apache::loncommon::bodytag('Construction Space File Operation','',$loaditem));
+  } else {
+      $r->print('<html><head><title>LON-CAPA Construction Space</title></head>');
+      $r->print(&Apache::loncommon::bodytag('Construction Space File Operation'));
+  }
 
   
   $r->print('<h3>'.&mt('Location').': '.&display($fn).'</h3>');