[LON-CAPA-cvs] cvs: loncom /interface portfolio.pm

banghart lon-capa-cvs@mail.lon-capa.org
Wed, 25 Aug 2004 17:30:49 -0000


banghart		Wed Aug 25 13:30:49 2004 EDT

  Modified files:              
    /loncom/interface	portfolio.pm 
  Log:
  
  	On delete directory, resets current_path to parent of 
  	deleted directory.
  
  
  
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.31 loncom/interface/portfolio.pm:1.32
--- loncom/interface/portfolio.pm:1.31	Tue Aug 24 17:30:00 2004
+++ loncom/interface/portfolio.pm	Wed Aug 25 13:30:49 2004
@@ -321,16 +321,24 @@
 sub delete_dir_confirmed {
     my ($r)=@_;
     my $directory_name = $ENV{'form.currentpath'};
-    $r->print('<br />'.$directory_name.'<br />');
     $directory_name =~ m/\/$/;
     $directory_name = $`;
     my $result=&Apache::lonnet::removeuserfile($ENV{'user.name'},
 					       $ENV{'user.domain'},'portfolio'.
 					       $directory_name);
+					       
     if ($result ne 'ok') {
 	$r->print('<font color="red"> An error occured (dir) ('.$result.
-#		  ') while trying to delete '.&display_file().'</font><br />');
 		  ') while trying to delete '.$directory_name.'</font><br />');
+    } else {
+        my @dirs = split m!/!, $directory_name;
+        
+#        $directory_name =~ m/^(\/*\/)(\/*.)$/;
+        $directory_name='/';
+        for (my $i=1; $i < (@dirs - 1); $i ++){
+            $directory_name .= $dirs[$i].'/';
+        }
+        $ENV{'form.currentpath'} = $directory_name;
     }
     $r->print(&done());
 }