[LON-CAPA-cvs] cvs: loncom / lontrans.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Wed, 31 Mar 2004 17:02:51 -0000


raeburn		Wed Mar 31 12:02:51 2004 EDT

  Modified files:              
    /loncom	lontrans.pm 
  Log:
  URI translation modified for requests for uploaded files.
  Support added for requests for files in /raw/uploaded. Such requests are generated internally by lonnet::getfile() to request a file from the home server for a course.
  URI translation to the appropriate file in /home/httpd/lonUsers/$cdom/$cnum. Will also do URI translation to the same path for files in /uploaded, IF request comes from a user session hosted on the home server for the course.  For sessions hosted on other servers, URI translation does not occur here, but in the PerlHeaderParserHandler phase (via lonuploadrep.pm).
  
  
Index: loncom/lontrans.pm
diff -u loncom/lontrans.pm:1.6 loncom/lontrans.pm:1.7
--- loncom/lontrans.pm:1.6	Wed Nov 12 16:37:07 2003
+++ loncom/lontrans.pm	Wed Mar 31 12:02:51 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # URL translation for User Files
 #
-# $Id: lontrans.pm,v 1.6 2003/11/12 21:37:07 albertel Exp $
+# $Id: lontrans.pm,v 1.7 2004/03/31 17:02:51 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -33,14 +33,21 @@
 use Apache::lonnet();
 use Apache::File();
 use Apache::loncommon;
+use LONCAPA::Configuration;
 
 sub handler {
     my $r = shift;
-    if ($r->uri=~m|^/uploaded/|) {
-	my (undef,undef,$udom,$uname,$ufile)=split(/\//,$r->uri);
-	$ufile=~s/^[\~\.]+//;
-	$r->filename(&Apache::loncommon::propath($udom,$uname).
-		     '/userfiles/'.$ufile);
+    my $configvars = &LONCAPA::Configuration::read_conf('loncapa.conf');
+    if ($r->uri=~m|^(/raw)?/uploaded/|) {
+        my $fn = $r->uri();
+        $fn=~s/^\/raw//;
+        my (undef,undef,$udom,$uname,@ufile)=split(/\//,$fn);
+        $ufile[-1]=~s/^[\~\.]+//;
+        my $chome=&Apache::lonnet::homeserver($uname,$udom);
+        if ($chome eq $$configvars{'lonHostID'}) {
+            $r->filename(&Apache::loncommon::propath($udom,$uname).
+                     '/userfiles/'.(join('/',@ufile)));
+        }
     } elsif ($r->uri=~m|^/~|) {	
 	#internal authentication, needs fixup.
 	my $fn = $r->uri(); # non users do not get the full path request