'
@@ -237,7 +240,8 @@ sub phaseone {
}
sub phasetwo {
- my ($r,$tfn,$uname,$udom,$mode)=@_;
+ my ($r,$fn,$uname,$udom,$mode)=@_;
+
my $output;
my $action = '/adm/upload';
my $returnflag = '';
@@ -246,12 +250,9 @@ sub phasetwo {
} elsif ($mode eq 'imsimport') {
$action = '/adm/imsimport';
}
- my $fn='/priv/'.$uname.'/'.$tfn;
$fn=~s/\/+/\//g;
- &Debug($r, "Filename is ".$tfn);
- if ($tfn) {
- &Debug($r, "Filename for tfn = ".$tfn);
- my $target='/home/'.$uname.'/public_html'.$tfn;
+ if ($fn) {
+ my $target='/home/httpd/html/'.$fn;
&Debug($r, "target -> ".$target);
# target is the full filesystem path of the destination file.
my $base = &File::Basename::basename($fn);
@@ -350,22 +351,33 @@ sub check_extension {
my (%allfiles,%codebase);
&Apache::lonnet::extract_embedded_items($target,\%allfiles,\%codebase);
if (keys(%allfiles) > 0) {
- my $state = <
-
-
-
-
-STATE
- $result .= "".&mt("Reference Warning")." ".
- "".&mt("Completed upload of the file. This file contained references to other files.")."
".
- "".&mt("Please select the locations from which the referenced files are to be uploaded.")."
".
- &Apache::loncommon::ask_for_embedded_content($action,$state,\%allfiles,\%codebase,
- {'error_on_invalid_names' => 1,
- 'ignore_remote_references' => 1,});
- if ($mode eq 'testbank') {
- $returnflag = 'embedded';
- $result .= ''.&mt('Or [_1]continue[_2] the testbank import without these files','',' ').'
';
+ my ($currentpath) = ($url =~ m{^(.+)/[^/]+$});
+ my $state = &embedded_form_elems('upload_embedded',$url,$mode);
+ my ($embedded,$num,$pathchg) =
+ &Apache::loncommon::ask_for_embedded_content($action,$state,\%allfiles,
+ \%codebase,
+ {'error_on_invalid_names' => 1,
+ 'ignore_remote_references' => 1,
+ 'current_path' => $currentpath});
+ if ($embedded) {
+ $result .= ''.&mt('Reference Warning').' ';
+ if ($num) {
+ $result .= ''.&mt('Completed upload of the file.').' '.&mt('This file contained references to other files.').'
'.
+ ''.&mt('Please select the locations from which the referenced files are to be uploaded.').'
'.
+ $embedded;
+ if ($mode eq 'testbank') {
+ $returnflag = 'embedded';
+ $result .= ''.&mt('Or [_1]continue[_2] the testbank import without these files.','',' ').'
';
+ }
+ } else {
+ $result .= ''.&mt('Completed upload of the file.').'
'.$embedded;
+ if ($pathchg) {
+ if ($mode eq 'testbank') {
+ $returnflag = 'embedded';
+ $result .= ''.&mt('Or [_1]continue[_2] the testbank import without modifying the references(s).','',' ').'
';
+ }
+ }
+ }
}
}
}
@@ -385,18 +397,61 @@ STATE
sub phasethree {
my ($r,$fn,$uname,$udom,$mode) = @_;
+
+ my $action = '/adm/upload';
+ if ($mode eq 'testbank') {
+ $action = '/adm/testbank';
+ } elsif ($mode eq 'imsimport') {
+ $action = '/adm/imsimport';
+ }
+ my $dir_root = '/home/httpd/html/priv/'.$udom.'/'.$uname;
+ my $url_root = '/priv/'.$udom.'/'.$uname;
+ my $path = &File::Basename::dirname($fn);
+ my $filename = &HTML::Entities::encode($env{'form.filename'},'<>&"');
+ my $state = &embedded_form_elems('modify_orightml',$filename,$mode).
+ ' ';
+ my ($result,$returnflag) =
+ &Apache::loncommon::upload_embedded($mode,$path,$uname,$udom,
+ $dir_root,$url_root,undef,
+ undef,undef,$state,$action);
+ if ($mode ne 'imsimport' && $mode ne 'testbank') {
+ $result .= ' '.
+ ' ';
+ }
+ return ($result,$returnflag);
+}
+
+sub embedded_form_elems {
+ my ($action,$filename,$mode) = @_;
+ return <
+
+
+STATE
+}
+
+sub phasefour {
+ my ($r,$fn,$uname,$udom,$mode) = @_;
+
+ my $action = '/adm/upload';
+ if ($mode eq 'testbank') {
+ $action = '/adm/testbank';
+ } elsif ($mode eq 'imsimport') {
+ $action = '/adm/imsimport';
+ }
my $result;
- my $dir_root = '/home/'.$uname.'/public_html';
- my $url_root = '/priv/'.$uname;
- my $base = &File::Basename::basename($fn);
+ my $dir_root = '/home/httpd/html/priv/'.$udom.'/'.$uname;
+ my $url_root = '/priv/'.$udom.'/'.$uname;
my $path = &File::Basename::dirname($fn);
- $result = &Apache::loncommon::upload_embedded($mode,$path,$uname,$udom,
- $dir_root,$url_root);
+ $result .= &Apache::loncommon::modify_html_refs($mode,$path,
+ $uname,$udom,$dir_root);
if ($mode ne 'imsimport' && $mode ne 'testbank') {
- $result = ''.
- &mt('View main file').' '.
- ''.
- &mt('Back to Directory').' ';
+ $result .= ' '.
+ ' ';
}
return $result;
}
@@ -409,12 +464,18 @@ sub handler {
my $uname;
my $udom;
my $javascript = '';
-#
-# phase two: re-attach user
-#
- if ($env{'form.uploaduname'}) {
- $env{'form.filename'}='/priv/'.$env{'form.uploaduname'}.'/'.
- $env{'form.filename'};
+
+ my $fn=$env{'form.filename'};
+
+ if ($env{'form.filename1'}) {
+ $fn=$env{'form.filename1'}.$env{'form.filename2'};
+ }
+ $fn=~s/\/+/\//g;
+
+ unless ($fn) {
+ $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
+ ' unspecified filename for upload', $r->filename);
+ return HTTP_NOT_FOUND;
}
unless ($env{'form.phase'} eq 'two') {
@@ -434,9 +495,7 @@ function verifyForm() {
}
|;
}
- ($uname,$udom)=
- &Apache::loncacc::constructaccess($env{'form.filename'},
- $r->dir_config('lonDefDomain'));
+ ($uname,$udom)=&Apache::loncacc::constructaccess($fn);
unless (($uname) && ($udom)) {
$r->log_reason($uname.' at '.$udom.
@@ -446,19 +505,6 @@ function verifyForm() {
return HTTP_NOT_ACCEPTABLE;
}
- my $fn;
- if ($env{'form.filename'}) {
- $fn=$env{'form.filename'};
- $fn=~s/^https?\:\/\/[^\/]+\///;
- $fn=~s/^\///;
- $fn=~s{(~|priv/)($LONCAPA::username_re)}{};
- $fn=~s/\/+/\//g;
- } else {
- $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
- ' unspecified filename for upload', $r->filename);
- return HTTP_NOT_FOUND;
- }
-
# ----------------------------------------------------------- Start page output
@@ -481,14 +527,16 @@ function verifyForm() {
);
if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
- $r->print(''
+ $r->print('
'
.&mt('Co-Author [_1]',$uname.':'.$udom)
.'
'
);
}
-
- if ($env{'form.phase'} eq 'three') {
- my $output = &phasethree($r,$fn,$uname,$udom,'author');
+ if ($env{'form.phase'} eq 'four') {
+ my $output = &phasefour($r,$fn,$uname,$udom,'author');
+ $r->print($output);
+ } elsif ($env{'form.phase'} eq 'three') {
+ my ($output,$rtnflag) = &phasethree($r,$fn,$uname,$udom,'author');
$r->print($output);
} elsif ($env{'form.phase'} eq 'two') {
my ($output,$returnflag) = &phasetwo($r,$fn,$uname,$udom);