[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm /xml londefdef.pm

sakharuk lon-capa-cvs@mail.lon-capa.org
Mon, 30 Aug 2004 18:25:56 -0000


sakharuk		Mon Aug 30 14:25:56 2004 EDT

  Modified files:              
    /loncom/xml	londefdef.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  Bug 3335 (Printing of simplepages and aboutme doesn't work) is finally fixed. I probably have to add some chunck for the possible replication of *.ps pictures but I want to do this after your (Guy) judgement.
  
  
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.238 loncom/xml/londefdef.pm:1.239
--- loncom/xml/londefdef.pm:1.238	Wed Aug 25 15:57:27 2004
+++ loncom/xml/londefdef.pm	Mon Aug 30 14:25:55 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.238 2004/08/25 19:57:27 albertel Exp $
+# $Id: londefdef.pm,v 1.239 2004/08/30 18:25:55 sakharuk Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -2434,6 +2434,8 @@
 	    $currentstring.='[IMAGE: '.$alttag.']';
 	}
     } elsif ($target eq 'tex') {
+	my $oldSRC=$src;
+        $oldSRC=~s/\.(gif|jpg|png)$/\.eps/;
 	$src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
 	#if original gif/jpg/png file exist do following:
 	if (-e $src) {
@@ -2442,6 +2444,7 @@
             my ($file,$path)=&file_path($src); 
 	    my $newsrc = $src;
 	    $newsrc =~ s/\.(gif|jpg|png)$/.eps/i;
+	    my $dummy_content=&Apache::lonnet::getfile($oldSRC);
 	    $file=~s/\.(gif|jpg|png)$/.eps/i;
 	    #where can we find the picture?
 	    if (-e $newsrc) {
@@ -3710,7 +3713,11 @@
 	$newsrc=~s/\/home\/httpd\/lonUsers//;
 	$newsrc=~s/\/([^\/]+)\/(\w)\/(\w)\/(\w)\//\/$1\//;
     }
-    return ' \graphicspath{{/home/httpd/prtspool'.$newsrc.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
+    if ($newsrc=~/\/userfiles\//) {
+	return ' \graphicspath{{'.$newsrc.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
+    } else {
+	return ' \graphicspath{{/home/httpd/prtspool'.$newsrc.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
+    }
 }
 
 sub file_path {     
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.535 loncom/lonnet/perl/lonnet.pm:1.536
--- loncom/lonnet/perl/lonnet.pm:1.535	Fri Aug 27 17:39:54 2004
+++ loncom/lonnet/perl/lonnet.pm	Mon Aug 30 14:25:56 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.535 2004/08/27 21:39:54 albertel Exp $
+# $Id: lonnet.pm,v 1.536 2004/08/30 18:25:56 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -5056,20 +5056,15 @@
     $location = $file;
     $location =~ s:/~(.*?)/(.*):/home/$1/public_html/$2:;
   } elsif ($file=~/^\/*uploaded/) { # is an uploaded file
-      if ($file=~/^\/uploaded\/([^\/]+)\/([^\/]+)\/(\/)?simplepage\/([^\/]+)$/) {
-	  $location=&Apache::loncommon::propath($1,$2).'/userfiles/simplepage/'.$4;
-	  if (not -e $location) {
-	      $file=~/^\/uploaded\/(.*)$/;
-	      $location=$Apache::lonnet::perlvar{'lonDocRoot'}.'/userfiles/'.$1;
-	  }
-      } elsif ($file=~/^\/uploaded\/([^\/]+)\/([^\/]+)\/aboutme\/([^\/]+)$/) {
-	  $location=&Apache::loncommon::propath($1,$2).'/userfiles/aboutme/'.$3;
-         if (not -e $location) {
-	     $file=~/^\/uploaded\/(.*)$/;
-	     $location=$Apache::lonnet::perlvar{'lonDocRoot'}.'/userfiles/'.$1;
-         }
+      $file=~/^\/uploaded\/([^\/]+)\/([^\/]+)\/(\/)?(.*)$/;
+      my $home=&homeserver($2,$1);
+      my $allowed=0;
+      my @ids=&current_machine_ids();
+      foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
+      if ($allowed) {
+	  $location=&Apache::loncommon::propath($1,$2).'/userfiles/'.$4;
       } else {
-	  $location=$file;
+	  $location=$Apache::lonnet::perlvar{'lonDocRoot'}.'/userfiles/'.$1.'/'.$2.'/'.$4;
       }
   } else {
     $file=~s/^\Q$perlvar{'lonDocRoot'}\E//;