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

foxr lon-capa-cvs@mail.lon-capa.org
Mon, 29 Jul 2002 01:55:51 -0000


foxr		Sun Jul 28 21:55:51 2002 EDT

  Modified files:              
    /loncom/publisher	loncfile.pm 
  Log:
  Get cancel actions to work.
  
  Still need to :
    validate bugzilla issues.
    ensure this stuff works for non filesystem auth.
    Clean up final copy to remove detritus I've introduced in debug.
  
  
  
Index: loncom/publisher/loncfile.pm
diff -u loncom/publisher/loncfile.pm:1.12 loncom/publisher/loncfile.pm:1.13
--- loncom/publisher/loncfile.pm:1.12	Sat Jul 27 22:16:59 2002
+++ loncom/publisher/loncfile.pm	Sun Jul 28 21:55:51 2002
@@ -10,7 +10,7 @@
 #
 
 #
-# $Id: loncfile.pm,v 1.12 2002/07/28 02:16:59 foxr Exp $
+# $Id: loncfile.pm,v 1.13 2002/07/29 01:55:51 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -393,25 +393,19 @@
 
 =item  $request - Apache Request Object [in] - Apache server request object.
 
-=item  $user    - string [in] - Name of the user initiating the request.
-
-=item  $file    - A filename.
+=item  $cancelurl - the url to go to on cancel.
 
 =back
 
 =cut
 
 sub CloseForm1 {
-   my ($request, $user, $file) = @_;
-   my $url = "/priv/".$file;
-   
-   
-   $url =~ s/public_html\///;
-   $url =~ s/\/home//;
-   $url =~ s/\/\//\//;
+   my ($request,  $cancelurl) = @_;
+
 
+   &Debug($request, "Cancel url is: ".$cancelurl);
    $request->print('<p><input type=submit value=Continue></p></form>');
-   $request->print('<form action="'.$url.
+   $request->print('<form action="'.$cancelurl.
 		   '" method=GET"><p><input type=submit value=Cancel><p></form>');
 
 }
@@ -487,6 +481,9 @@
     &Debug($request, "Username - ".$user." filename: ".$filename."\n");
     my $conspace = $filename;
 
+    my $cancelurl = "/priv/".$filename;
+    $cancelurl    =~ s/\/home\///;
+    $cancelurl    =~ s/\/public_html//;
     
     if(-e $conspace) {
 	if($ENV{'form.newfilename'}) {
@@ -497,7 +494,7 @@
 			    $newfilename.
 			    '"><p>Rename <tt>'.$filename.'</tt> to <tt>'.
 			    $dir.'/'.$newfilename.'</tt>?</p>');
-	    &CloseForm1($request, $user, $filename);
+	    &CloseForm1($request, $cancelurl);
 	} else {
 	    $request->print('<p>No new filename specified</p></form>');
 	    return;
@@ -524,6 +521,7 @@
 
 =item   $user      - string [in] Name of session user.
 
+
 =item   $filename  - string [in] Name fo the file to be deleted:
                 Filename is the full filesystem path to the file.
 
@@ -532,13 +530,18 @@
 =cut
 
 sub Delete1 {
-  my ($request, $user, $filename) = @_;
+  my ($request, $user,  $filename) = @_;
+
+  my $cancelurl = '/priv/'.$filename;
+  $cancelurl    =~ s/\/home\///;
+  $cancelurl    =~ s/\/public_html//;
+  
 
   if( -e $filename) {
     $request->print('<input type=hidden name=newfilename value="'.
 		    $filename.'">');
     $request->print('<p> Delete <tt>'.$filename.'</tt>?</p>');
-    &CloseForm1($request, $user, $filename);
+    &CloseForm1($request, $cancelurl);
   } else {
     $request->print('<p> No Such file: <tt>'.$filename.'</tt></p></form>');
   }
@@ -576,6 +579,11 @@
 sub Copy1 {
   my ($request, $user, $domain, $dir, $filename, $newfilename) = @_;
 
+  my $cancelurl = "/priv/".$filename;
+  $cancelurl    =~ s/\/home\///;
+  $cancelurl    =~ s/\/public_html//;
+    
+
 
   if(-e $filename) {
     $request->print(&checksuffix($filename,$newfilename));
@@ -584,7 +592,7 @@
 		    $dir.'/'.$newfilename.
 		    '"><p>Copy <tt>'.$filename.'</tt> to'.
 		    '<tt>'.$dir.'/'.$newfilename.'</tt>/?</p>');
-    &CloseForm1($request, $user, $filename);
+    &CloseForm1($request, $cancelurl);
   } else {
     $request->print('<p>No such file <tt>'.$filename.'</p></form>');
   }
@@ -633,7 +641,10 @@
 
   my $fullpath = '/home/'.$username.'/public_html/'.
     $path.'/'.$newdir;
-  Debug($request, "Full path is : ".$fullpath);
+
+  my $cancelurl = '/priv/'.$username.'/'.$path;
+
+  &Debug($request, "Full path is : ".$fullpath);
 
   if(-e $fullpath) {
     $request->print('<p>Directory exists.</p></form>');
@@ -642,7 +653,7 @@
     $request->print('<input type=hidden name=newfilename value="'.
 		    $newdir.'"><p>Make new directory <tt>'.
 		    $path."/".$newdir.'</tt>?</p>');
-    &CloseForm1($request, $username, $newdir);
+    &CloseForm1($request, $cancelurl);
 
   }
 }