--- loncom/interface/londocs.pm 2003/09/08 21:19:44 1.76
+++ loncom/interface/londocs.pm 2003/09/15 17:58:21 1.79
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.76 2003/09/08 21:19:44 www Exp $
+# $Id: londocs.pm,v 1.79 2003/09/15 17:58:21 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -136,8 +136,51 @@ sub dumpcourse {
# Do the dumping
unless ($outhash{'home_'.$ENV{'form.authorspace'}}) { return ''; }
my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'});
+ $r->print('
Copying Files ');
my $title=$ENV{'form.authorfolder'};
-
+ $title=~s/[^\w\/]+/\_/g;
+ my %replacehash=();
+ foreach (keys %ENV) {
+ if ($_=~/^form\.namefor\_(.+)/) {
+ $replacehash{$1}=$ENV{$_};
+ }
+ }
+ my $crs='/uploaded/'.$ENV{'request.course.id'}.'/';
+ $crs=~s/\_/\//g;
+ foreach (keys %replacehash) {
+ my $newfilename=$title.'/'.$replacehash{$_};
+ $newfilename=~s/[^\w\/\.]+/\_/g;
+ my @dirs=split(/\//,$newfilename);
+ my $path='/home/'.$ca.'/public_html';
+ my $makepath=$path;
+ my $fail=0;
+ for (my $i=0;$i<$#dirs;$i++) {
+ $makepath.='/'.$dirs[$i];
+ unless (-e $makepath) {
+ unless(mkdir($makepath,0777)) { $fail=1; }
+ }
+ }
+ $r->print(''.$_.' => '.$newfilename.' : ');
+ if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
+ if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
+ print $fh &Apache::loncreatecourse::rewritefile(
+ &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_),
+ (%replacehash,$crs => '')
+ );
+ } else {
+ print $fh
+ &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_);
+ }
+ $fh->close();
+ } else {
+ $fail=1;
+ }
+ if ($fail) {
+ $r->print('fail ');
+ } else {
+ $r->print('ok ');
+ }
+ }
} else {
# Input form
unless ($home==1) {
@@ -162,15 +205,25 @@ sub dumpcourse {
$title=~s/\W//gs;
$r->print('Folder in Construction Space ');
&tiehash();
+ $r->print('Filenames in Construction Space \n");
&untiehash();
$r->print(
- ' ');
+ '
');
}
}
@@ -658,7 +711,7 @@ sub handler {
$forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
# does this user have privileges to post, etc?
- $allowed=&Apache::lonnet::allowed('srm',$ENV{'request.course.id'});
+ $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
if ($allowed) {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
$script=&Apache::lonratedt::editscript('simple');