[LON-CAPA-cvs] cvs: loncom /interface loncreatecourse.pm londocs.pm

www lon-capa-cvs@mail.lon-capa.org
Thu, 01 Jul 2004 21:54:25 -0000


www		Thu Jul  1 17:54:25 2004 EDT

  Modified files:              
    /loncom/interface	loncreatecourse.pm londocs.pm 
  Log:
  Work on Bug #2999
  
  - I don't think Dump Course actually worked anymore. Somehow, a "/"-prefix
  was added to the directory listings, which is messing things up big time.
  
  See Bug #3161.
  
  
Index: loncom/interface/loncreatecourse.pm
diff -u loncom/interface/loncreatecourse.pm:1.61 loncom/interface/loncreatecourse.pm:1.62
--- loncom/interface/loncreatecourse.pm:1.61	Tue Jun 29 10:56:32 2004
+++ loncom/interface/loncreatecourse.pm	Thu Jul  1 17:54:24 2004
@@ -1,7 +1,7 @@
 #meserver The LearningOnline Network
 # Create a course
 #
-# $Id: loncreatecourse.pm,v 1.61 2004/06/29 14:56:32 raeburn Exp $
+# $Id: loncreatecourse.pm,v 1.62 2004/07/01 21:54:24 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -42,19 +42,34 @@
 
 # ================================================ Get course directory listing
 
-#FIXME - doesn't support directories under /userfiles/ BUG#2999
+my @output=();
+
 sub crsdirlist {
     my ($courseid,$which)=@_;
+    @output=();
+    return &innercrsdirlist($courseid,$which);
+}
+
+sub innercrsdirlist {
+    my ($courseid,$which,$path)=@_;
+    my $dirptr=16384;
     unless ($which) { $which=''; }
+    unless ($path)  { $path=''; }
     my %crsdata=&Apache::lonnet::coursedescription($courseid);
     my @listing=&Apache::lonnet::dirlist
 	($which,$crsdata{'domain'},$crsdata{'num'},
 	 &Apache::loncommon::propath($crsdata{'domain'},$crsdata{'num'}));
-    my @output=();
     foreach (@listing) {
-	#FIXME if list is a DIR need to recurse
 	unless ($_=~/^\./) {
-	    push (@output,(split(/\&/,$_))[0]);
+	    my @unpackline = split (/\&/,$_);
+	    if ($unpackline[3]&$dirptr) {
+# is a directory, recurse
+		&innercrsdirlist($courseid,$which.'/'.$unpackline[0],
+				            $path.'/'.$unpackline[0]);
+	    } else { 
+# is a file, put into output
+		push (@output,$path.'/'.$unpackline[0]);
+	    }
 	}
     }
     return @output;
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.131 loncom/interface/londocs.pm:1.132
--- loncom/interface/londocs.pm:1.131	Sun Jun 27 12:43:28 2004
+++ loncom/interface/londocs.pm	Thu Jul  1 17:54:24 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.131 2004/06/27 16:43:28 www Exp $
+# $Id: londocs.pm,v 1.132 2004/07/01 21:54:24 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -157,7 +157,7 @@
 	$crs=~s/\_/\//g;
 	foreach (keys %replacehash) {
 	    my $newfilename=$title.'/'.$replacehash{$_};
-	    $newfilename=~s/[^\w\/\.]+/\_/g;
+	    $newfilename=~s/[^\w\/\.\/]+/\_/g;
 	    my @dirs=split(/\//,$newfilename);
 	    my $path='/home/'.$ca.'/public_html';
 	    my $makepath=$path;
@@ -224,7 +224,7 @@
 		$title=$_;
 	    }
 	    $title=~s/\.(\w+)$//;
-	    $title=~s/\W+/\_/gs;
+	    $title=~s/[^\w\/]+/\_/gs;
 	    $title.='.'.$ext;
 	    $r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td></tr>\n");
 	}