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

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 28 May 2003 15:20:40 -0000


matthew		Wed May 28 11:20:40 2003 EDT

  Modified files:              
    /loncom/interface/spreadsheet	Spreadsheet.pm 
  Log:
  Fix bug 1518 - spreadsheet temporary filename was changed if you edited 
  the default spreadsheet.
  
  
Index: loncom/interface/spreadsheet/Spreadsheet.pm
diff -u loncom/interface/spreadsheet/Spreadsheet.pm:1.8 loncom/interface/spreadsheet/Spreadsheet.pm:1.9
--- loncom/interface/spreadsheet/Spreadsheet.pm:1.8	Tue May 27 17:17:22 2003
+++ loncom/interface/spreadsheet/Spreadsheet.pm	Wed May 28 11:20:40 2003
@@ -1,5 +1,5 @@
 #
-# $Id: Spreadsheet.pm,v 1.8 2003/05/27 21:17:22 matthew Exp $
+# $Id: Spreadsheet.pm,v 1.9 2003/05/28 15:20:40 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -157,7 +157,8 @@
                 $newfilename =~ /^\W*$/) {
                 $newfilename = 'default.'.$self->{'type'};
             }
-        } elsif ($newfilename !~ /^\/res\/.*\.spreadsheet/) {
+        } elsif ($newfilename !~ /^\/res\/.*\.spreadsheet/ &&
+                 $newfilename !~ /^default\.$self->{'type'}$/ ) {
             my $regexp = '_'.$self->{'type'}.'$';
             if ($newfilename !~ /$regexp/) {
                 $newfilename .= '_'.$self->{'type'};
@@ -1604,14 +1605,14 @@
 
 sub save_tmp {
     my $self = shift;
-    my $fn=$ENV{'user.name'}.'_'.
+    my $filename=$ENV{'user.name'}.'_'.
         $ENV{'user.domain'}.'_spreadsheet_'.$self->{'usymb'}.'_'.
            $self->{'filename'};
-    $fn=~s/\W/\_/g;
-    $fn=$Apache::lonnet::tmpdir.$fn.'.tmp';
+    $filename=~s/\W/\_/g;
+    $filename=$Apache::lonnet::tmpdir.$filename.'.tmp';
     $self->temporary(1);
     my $fh;
-    if ($fh=Apache::File->new('>'.$fn)) {
+    if ($fh=Apache::File->new('>'.$filename)) {
         my %f = $self->formulas();
         while( my ($cell,$formula) = each(%f)) {
             next if ($formula eq 'import');