[LON-CAPA-cvs] cvs: loncom /interface lonfeedback.pm lonmsg.pm /lonnet/perl lonnet.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 07 May 2004 12:03:53 -0000


albertel		Fri May  7 08:03:53 2004 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
    /loncom/interface	lonfeedback.pm lonmsg.pm 
  Log:
  - finishuploadfile works better with a directory specfied
  - bb posts, and emails no longer use token wrapper
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.493 loncom/lonnet/perl/lonnet.pm:1.494
--- loncom/lonnet/perl/lonnet.pm:1.493	Fri Apr 30 19:10:11 2004
+++ loncom/lonnet/perl/lonnet.pm	Fri May  7 08:03:53 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.493 2004/04/30 23:10:11 albertel Exp $
+# $Id: lonnet.pm,v 1.494 2004/05/07 12:03:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1309,6 +1309,12 @@
     my ($docuname,$docudom,$docuhome,$formname,$fname)=@_;
     my $path=$docudom.'/'.$docuname.'/';
     my $filepath=$perlvar{'lonDocRoot'};
+    my ($fnamepath,$file);
+    $file=$fname;
+    if ($fname=~m|/|) {
+        ($fnamepath,$file) = ($fname =~ m|^(.*)/([^/]+)$|);
+	$path.=$fnamepath.'/';
+    }
     my @parts=split(/\//,$filepath.'/userfiles/'.$path);
     my $count;
     for ($count=4;$count<=$#parts;$count++) {
@@ -1319,21 +1325,21 @@
     }
 # Save the file
     {
-       open(my $fh,'>'.$filepath.'/'.$fname);
+	&Apache::lonnet::logthis("Saving to $filepath $file");
+       open(my $fh,'>'.$filepath.'/'.$file);
        print $fh $ENV{'form.'.$formname};
        close($fh);
     }
 # Notify homeserver to grep it
 #
-    my $fetchresult= &reply('fetchuserfile:'.$docudom.'/'.$docuname.'/'.$fname,
-			    $docuhome);
+    my $fetchresult= &reply('fetchuserfile:'.$path.$file,$docuhome);
     if ($fetchresult eq 'ok') {
 #
 # Return the URL to it
-        return '/uploaded/'.$path.$fname;
+        return '/uploaded/'.$path.$file;
     } else {
-        &logthis('Failed to transfer '.$docudom.'/'.$docuname.'/'.$fname.
-         ' to host '.$docuhome.': '.$fetchresult);
+        &logthis('Failed to transfer '.$path.$file.' to host '.$docuhome.
+		 ': '.$fetchresult);
         return '/adm/notfound.html';
     }    
 }
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.81 loncom/interface/lonfeedback.pm:1.82
--- loncom/interface/lonfeedback.pm:1.81	Wed May  5 19:04:57 2004
+++ loncom/interface/lonfeedback.pm	Fri May  7 08:03:53 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.81 2004/05/05 23:04:57 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.82 2004/05/07 12:03:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -159,12 +159,13 @@
                     $subject=&Apache::lontexconvert::msgtexconverted($subject);
                 }
 		if ($contrib{$idx.':attachmenturl'}) {
-		    my ($fname,$ft)
-                        =($contrib{$idx.':attachmenturl'}=~/\/(\w+)\.(\w+)$/);
-		    $message.='<p>'.&mt('Attachment').': <a href="'.
-			&Apache::lonnet::tokenwrapper(
-                                             $contrib{$idx.':attachmenturl'}).
-			'"><tt>'.$fname.'.'.$ft.'</tt></a></p>';
+		    my ($fname)
+                        =($contrib{$idx.':attachmenturl'}=~m|/([^/]+)$|);
+		    &Apache::lonnet::allowuploaded('/adm/feedback',
+					   $contrib{$idx.':attachmenturl'});
+		    $message.='<p>'.&mt('Attachment').
+			': <a href="'.$contrib{$idx.':attachmenturl'}.'"><tt>'.
+			$fname.'</tt></a></p>';
 		}
 		if ($message) {
 		    if ($hidden) {
@@ -976,7 +977,7 @@
       my $attachmenturl='';
       if ($ENV{'form.attachment.filename'}) {
 	  unless (length($ENV{'form.attachment'})>131072) {
-	      $attachmenturl=&Apache::lonnet::userfileupload('attachment');
+	      $attachmenturl=&Apache::lonnet::userfileupload('attachment',undef,'feedback');
 	  }
       }
 # Filter HTML out of message (could be nasty)
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.98 loncom/interface/lonmsg.pm:1.99
--- loncom/interface/lonmsg.pm:1.98	Mon May  3 15:10:39 2004
+++ loncom/interface/lonmsg.pm	Fri May  7 08:03:53 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging
 #
-# $Id: lonmsg.pm,v 1.98 2004/05/03 19:10:39 sakharuk Exp $
+# $Id: lonmsg.pm,v 1.99 2004/05/07 12:03:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -176,9 +176,11 @@
        if ($notoken) {
 	   $content{'message'}.='<p>'.&mt('Attachment').': <tt>'.$fname.'.'.$ft.'</tt>';
        } else {
-	   $content{'message'}.='<p>'.&mt('Attachment').': <a href="'.
-	       &Apache::lonnet::tokenwrapper($content{'attachmenturl'}).
-	       '"><tt>'.$fname.'.'.$ft.'</tt></a>';
+	   &Apache::lonnet::allowuploaded('/adm/msg',
+					  $content{'attachmenturl'});
+	   $content{'message'}.='<p>'.&mt('Attachment').
+	       ': <a href="'.$content{'attachmenturl'}.'"><tt>'.
+	       $fname.'.'.$ft.'</tt></a>';
        }
     }
     return %content;