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

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 30 Apr 2004 23:10:13 -0000


albertel		Fri Apr 30 19:10:13 2004 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - helper ffunction for removing /uploaded urls
  - when uploading files get stuck in a directory now by default, but the dir can e specified
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.492 loncom/lonnet/perl/lonnet.pm:1.493
--- loncom/lonnet/perl/lonnet.pm:1.492	Thu Apr 29 13:25:11 2004
+++ loncom/lonnet/perl/lonnet.pm	Fri Apr 30 19:10:11 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.492 2004/04/29 17:25:11 albertel Exp $
+# $Id: lonnet.pm,v 1.493 2004/04/30 23:10:11 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1268,7 +1268,8 @@
 # output: url of file in userspace
 
 sub userfileupload {
-    my ($formname,$coursedoc)=@_;
+    my ($formname,$coursedoc,$subdir)=@_;
+    if (!defined($subdir)) { $subdir='unknown'; }
     my $fname=$ENV{'form.'.$formname.'.filename'};
 # Replace Windows backslashes by forward slashes
     $fname=~s/\\/\//g;
@@ -1285,6 +1286,7 @@
     my $docuname='';
     my $docudom='';
     my $docuhome='';
+    $fname="$subdir/$fname";
     if ($coursedoc) {
 	$docuname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
 	$docudom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
@@ -1334,6 +1336,12 @@
          ' to host '.$docuhome.': '.$fetchresult);
         return '/adm/notfound.html';
     }    
+}
+
+sub removeuploadedurl {
+    my ($url)=@_;
+    my (undef,undef,$udom,$uname,$fname)=split('/',$url,5);
+    return &Apache::lonnet::removeuserfile($uname,$udom,$fname);
 }
 
 sub removeuserfile {