[LON-CAPA-cvs] cvs: rat / lonratsrv.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 27 Jun 2002 16:43:57 -0000


albertel		Thu Jun 27 12:43:57 2002 EDT

  Modified files:              
    /rat	lonratsrv.pm 
  Log:
  - now understands internally authenticated users and properly saves their files.
    (BUG#569)
  
  
Index: rat/lonratsrv.pm
diff -u rat/lonratsrv.pm:1.18 rat/lonratsrv.pm:1.19
--- rat/lonratsrv.pm:1.18	Mon Jun 24 10:05:51 2002
+++ rat/lonratsrv.pm	Thu Jun 27 12:43:57 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Server for RAT Maps
 #
-# $Id: lonratsrv.pm,v 1.18 2002/06/24 14:05:51 www Exp $
+# $Id: lonratsrv.pm,v 1.19 2002/06/27 16:43:57 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -197,7 +197,7 @@
 # ----------------------------------------------------------- Saves map to disk
 
 sub savemap {
-    my ($fn,$errtext)=@_;
+    my ($fn,$errtext,$r)=@_;
     my %alltypes;
     my %allvalues;
     if (($fn=~/\.sequence$/) ||
@@ -262,19 +262,17 @@
            } elsif ($parts[0] eq 'objparms') {
                undef %alltypes;
                undef %allvalues;
-               foreach (split(/:/,$parts[$#parts])) {
+               map {
                    my ($type,$name,$value)=split(/\_\_\_/,$_);
                    $alltypes{$name}=$type;
                    $allvalues{$name}=$value;
-               }
-               foreach (keys %allvalues) {
-                  if ($allvalues{$_} ne '') {
+               } split(/:/,$parts[$#parts]);
+               map {
                    $outstr.='<param to="'.$parts[1].'" type="'
                           .$alltypes{$_}.'" name="'.$_
                           .'" value="'.$allvalues{$_}.'">'
                           ."</param>\n";
-	          }
-               }
+               } keys %allvalues;
            } elsif (($parts[0] ne '') && ($graphdef)) {
 # ------------------------------------------------------------- Graphical input
                $outstr.='<'.$parts[0];
@@ -297,7 +295,7 @@
         }
     } else {
 # -------------------------------------------- Cannot write to that file, error
-        $errtext.='Map not saved: The specified path does not exist. ';
+        $errtext.='Map not saved: The specified '.$fn.' path does not exist. '.$r->uri();
     }
     return $errtext;
 }
@@ -318,11 +316,18 @@
   $url=~s/\/loadonly\/ratserver$/\/save\/ratserver/;
   
   my $fn=$r->filename;
+  my $lonDocRoot=$r->dir_config('lonDocRoot');
+  if ( $fn =~ /$lonDocRoot/ ) {
+      #internal authentication, needs fixup.
+      $fn = $url;
+      $fn=~s|^/~(\w+)|/home/$1/public_html|;
+      $fn=~s|/[^/]*/ratserver$||;
+  }
   my $errtext='';
   my $outtext='';
 
   if ($mode ne 'loadonly') {
-     $errtext=&savemap($fn,$errtext);
+     $errtext=&savemap($fn,$errtext,$r);
   }
   ($outtext,$errtext)=&loadmap($fn,$errtext);