Annotation of loncom/publisher/lonupload.pm, revision 1.68
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to upload files into construction space
3: #
1.68 ! raeburn 4: # $Id: lonupload.pm,v 1.67 2015/09/11 20:12:30 raeburn Exp $
1.8 matthew 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.10 harris41 28: ###
1.1 www 29:
1.39 jms 30: =head1 NAME
31:
32: Apache::lonupload - upload files into construction space
33:
34: =head1 SYNOPSIS
35:
36: Invoked by /etc/httpd/conf/srm.conf:
37:
38: <Location /adm/upload>
39: PerlAccessHandler Apache::lonacc
40: SetHandler perl-script
41: PerlHandler Apache::lonupload
42: ErrorDocument 403 /adm/login
43: ErrorDocument 404 /adm/notfound.html
44: ErrorDocument 406 /adm/unauthorized.html
45: ErrorDocument 500 /adm/errorhandler
46: </Location>
47:
48: =head1 INTRODUCTION
49:
50: This module uploads a file sitting on a client computer into
51: library server construction space.
52:
53: This is part of the LearningOnline Network with CAPA project
54: described at http://www.lon-capa.org.
55:
56: =head1 HANDLER SUBROUTINE
57:
58: This routine is called by Apache and mod_perl.
59:
60: =over 4
61:
62: =item *
63:
64: Initialize variables
65:
66: =item *
67:
68: Start page output
69:
70: =item *
71:
1.51 raeburn 72: output relevant interface phase (phaseone, phasetwo, phasethree or phasefour)
1.39 jms 73:
74: =item *
75:
76: (phase one is to specify upload file; phase two is to handle conditions
77: subsequent to specification--like overwriting an existing file; phase three
78: is to handle processing of secondary uploads - of embedded objects in an
79: html file).
80:
81: =back
82:
83: =head1 OTHER SUBROUTINES
84:
1.40 jms 85: =over
1.39 jms 86:
1.40 jms 87: =item phaseone()
1.39 jms 88:
1.40 jms 89: Interface for specifying file to upload.
1.39 jms 90:
1.40 jms 91: =item phasetwo()
1.39 jms 92:
1.40 jms 93: Interface for handling post-conditions about uploading (such
1.39 jms 94: as overwriting an existing file).
95:
1.40 jms 96: =item phasethree()
1.39 jms 97:
1.40 jms 98: Interface for handling secondary uploads of embedded objects
1.39 jms 99: in an html file.
100:
1.51 raeburn 101: =item phasefour()
102:
103: Interface for handling optional renaming of links to embedded
104: objects.
105:
1.40 jms 106: =item upfile_store()
1.39 jms 107:
1.40 jms 108: Store contents of uploaded file into temporary space. Invoked
1.39 jms 109: by phaseone subroutine.
110:
1.40 jms 111: =item check_extension()
1.39 jms 112:
1.40 jms 113: Checks if filename extension is permitted and checks type
1.39 jms 114: of file - if html file, calls parser to check for embedded objects.
115: Invoked by phasetwo subroutine.
116:
117: =back
118:
119: =cut
120:
1.1 www 121: package Apache::lonupload;
122:
123: use strict;
124: use Apache::File;
125: use File::Copy;
1.13 foxr 126: use File::Basename;
1.1 www 127: use Apache::Constants qw(:common :http :methods);
1.10 harris41 128: use Apache::loncommon();
1.13 foxr 129: use Apache::lonnet;
1.14 foxr 130: use HTML::Entities();
1.20 www 131: use Apache::lonlocal;
1.29 albertel 132: use Apache::lonnet;
1.68 ! raeburn 133: use LONCAPA qw(:DEFAULT :match);
1.12 foxr 134:
135: my $DEBUG=0;
136:
137: sub Debug {
1.30 albertel 138: # Put out the indicated message but only if DEBUG is true.
1.22 albertel 139: if ($DEBUG) {
1.30 albertel 140: my ($r,$message) = @_;
141: $r->log_reason($message);
1.22 albertel 142: }
1.12 foxr 143: }
1.1 www 144:
1.2 www 145: sub upfile_store {
146: my $r=shift;
147:
1.29 albertel 148: my $fname=$env{'form.upfile.filename'};
1.2 www 149: $fname=~s/\W//g;
150:
1.29 albertel 151: chomp($env{'form.upfile'});
1.1 www 152:
1.68 ! raeburn 153: my $datatoken;
! 154: if (($env{'user.name'} =~ /^$match_username$/) && ($env{'user.domain'} =~ /^$match_domain$/)) {
! 155: $datatoken=$env{'user.name'}.'_'.$env{'user.domain'}.
! 156: '_upload_'.$fname.'_'.time.'_'.$$;
! 157: }
! 158: return if ($datatoken eq '');
1.2 www 159: {
160: my $fh=Apache::File->new('>'.$r->dir_config('lonDaemons').
161: '/tmp/'.$datatoken.'.tmp');
1.29 albertel 162: print $fh $env{'form.upfile'};
1.1 www 163: }
1.2 www 164: return $datatoken;
165: }
166:
167: sub phaseone {
1.63 raeburn 168: my ($r,$fn,$mode,$uname,$udom)=@_;
1.25 raeburn 169: my $action = '/adm/upload';
170: if ($mode eq 'testbank') {
171: $action = '/adm/testbank';
172: } elsif ($mode eq 'imsimport') {
173: $action = '/adm/imsimport';
174: }
1.49 bisitz 175:
176: # Check for file to be uploaded
1.29 albertel 177: $env{'form.upfile.filename'}=~s/\\/\//g;
178: $env{'form.upfile.filename'}=~s/^.*\/([^\/]+)$/$1/;
1.49 bisitz 179: if (!$env{'form.upfile.filename'}) {
1.63 raeburn 180: $r->print('<p class="LC_warning">'.&mt('No upload file specified.').'</p>'.
181: &earlyout($fn,$uname,$udom));
1.49 bisitz 182: return;
183: }
184:
1.55 www 185: # Append the name of the uploaded file
1.49 bisitz 186: $fn.=$env{'form.upfile.filename'};
187: $fn=~s/(\/)+/\//g;
188:
189: # Check for illegal filename
190: &Debug($r, "Filename for upload: $fn");
191: if (!(($fn) && ($fn!~/\/$/))) {
192: $r->print('<p class="LC_warning">'.&mt('Illegal filename.').'</p>');
193: return;
194: }
1.63 raeburn 195: # Check if quota exceeded
196: my $filesize = length($env{'form.upfile'});
197: if (!$filesize) {
198: $r->print('<p class="LC_warning">'.
199: &mt('Unable to upload [_1]. (size = [_2] bytes)',
200: '<span class="LC_filename">'.$env{'form.upfile.filename'}.'</span>',
201: $filesize).'<br />'.
202: &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'<br />'.
203: '</p>'.
204: &earlyout($fn,$uname,$udom));
205: return;
206: }
207: $filesize = int($filesize/1000); #expressed in kb
1.65 raeburn 208: my $output = &Apache::loncommon::excess_filesize_warning($uname,$udom,'author',
209: $env{'form.upfile.filename'},$filesize,'upload');
1.64 raeburn 210: if ($output) {
211: $r->print($output.&earlyout($fn,$uname,$udom));
1.63 raeburn 212: return;
213: }
1.64 raeburn 214:
1.55 www 215: # Split part that I can change from the part that I cannot change
216: my ($fn1,$fn2)=($fn=~/^(\/priv\/[^\/]+\/[^\/]+\/)(.*)$/);
1.49 bisitz 217: # Display additional options for upload
218: # and upload button
219: $r->print(
220: '<form action="'.$action.'" method="post" name="fileupload">'
221: .'<input type="hidden" name="phase" value="two" />'
222: .'<input type="hidden" name="datatoken" value="'.&upfile_store.'" />'
223: );
224: $r->print(
225: &Apache::lonhtmlcommon::start_pick_box()
226: .&Apache::lonhtmlcommon::row_title(&mt('Save uploaded file as'))
1.55 www 227: .'<span class="LC_filename">'.$fn1.'</span>'
228: .'<input type="hidden" name="filename1" value="'.$fn1.'" />'
229: .'<input type="text" size="50" name="filename2" value="'.$fn2.'" />'
1.49 bisitz 230: .&Apache::lonhtmlcommon::row_closure()
231: .&Apache::lonhtmlcommon::row_title(&mt('File Type'))
232: .'<select name="filetype">'
233: .'<option value="standard" selected="selected">'.&mt('Regular file').'</option>'
234: .'<option value="testbank">'.&mt('Testbank file').'</option>'
235: .'<option value="imsimport">'.&mt('IMS package').'</option>'
236: .'</select>'.&Apache::loncommon::help_open_topic("Uploading_File_Options")
237: .&Apache::lonhtmlcommon::row_closure(1)
238: .&Apache::lonhtmlcommon::end_pick_box()
239: );
240: $r->print(
241: '<p>'
242: .'<input type="button" value="'.&mt('Upload').'" onclick="javascript:verifyForm()"/>'
243: .'</p>'
244: .'</form>'
245: );
1.13 foxr 246:
1.49 bisitz 247: # Check for bad extension and warn user
248: if ($fn=~/\.(\w+)$/ &&
249: (&Apache::loncommon::fileembstyle($1) eq 'hdn')) {
1.41 bisitz 250: $r->print('<p class="LC_error">'
1.49 bisitz 251: .&mt('The extension on this file, [_1], is reserved internally by LON-CAPA.',
252: '<span class="LC_filename">'.$1.'</span>')
1.41 bisitz 253: .' <br />'.&mt('Please change the extension.')
254: .'</p>');
1.49 bisitz 255: } elsif($fn=~/\.(\w+)$/ &&
256: !defined(&Apache::loncommon::fileembstyle($1))) {
1.41 bisitz 257: $r->print('<p class="LC_error">'
1.49 bisitz 258: .&mt('The extension on this file, [_1], is not recognized by LON-CAPA.',
259: '<span class="LC_filename">'.$1.'</span>')
1.41 bisitz 260: .' <br />'.&mt('Please change the extension.')
261: .'</p>');
1.22 albertel 262: }
1.1 www 263: }
264:
265: sub phasetwo {
1.58 raeburn 266: my ($r,$fn,$mode)=@_;
1.55 www 267:
1.37 raeburn 268: my $output;
1.25 raeburn 269: my $action = '/adm/upload';
270: my $returnflag = '';
271: if ($mode eq 'testbank') {
272: $action = '/adm/testbank';
273: } elsif ($mode eq 'imsimport') {
274: $action = '/adm/imsimport';
275: }
1.22 albertel 276: $fn=~s/\/+/\//g;
1.55 www 277: if ($fn) {
1.58 raeburn 278: my $target= $r->dir_config('lonDocRoot').'/'.$fn;
1.22 albertel 279: &Debug($r, "target -> ".$target);
1.13 foxr 280: # target is the full filesystem path of the destination file.
1.22 albertel 281: my $base = &File::Basename::basename($fn);
282: my $path = &File::Basename::dirname($fn);
1.26 albertel 283: $base = &HTML::Entities::encode($base,'<>&"');
1.22 albertel 284: my $url = $path."/".$base;
285: &Debug($r, "URL is now ".$url);
1.68 ! raeburn 286: my $datatoken;
! 287: if ($env{'form.datatoken'} =~ /^$match_username\_$match_domain\_upload_\w*_\d+_\d+$/) {
! 288: $datatoken = $env{'form.datatoken'};
! 289: }
1.22 albertel 290: if (($fn) && ($datatoken)) {
1.36 www 291: if ($env{'form.cancel'}) {
292: my $source=$r->dir_config('lonDaemons').'/tmp/'.$datatoken.'.tmp';
293: my $dirpath=$path.'/';
294: $dirpath=~s/\/+/\//g;
1.49 bisitz 295: $output .= '<p class="LC_warning">'.&mt('Upload cancelled.').'</p>'
296: .'<p><a href="'.$dirpath.'">'.
297: &mt('Back to Directory').'</a></p>';
298: } elsif ((-e $target) && (!$env{'form.override'})) {
299: $output .= '<form action="'.$action.'" method="post">'
300: .'<p class="LC_warning">'
301: .&mt('File [_1] already exists.',
302: '<span class="LC_filename">'.$fn.'</span>')
303: .'<input type="hidden" name="phase" value="two" />'
304: .'<input type="hidden" name="filename" value="'.$url.'" />'
305: .'<input type="hidden" name="datatoken" value="'.$datatoken.'" />'
306: .'<p>'
307: .'<input type="submit" name="cancel" value="'.&mt('Cancel').'" />'
308: .' <input type="submit" name="override" value="'.&mt('Overwrite').'" />'
309: .'</p>'
310: .'</form>';
1.36 www 311: } else {
1.22 albertel 312: my $source=$r->dir_config('lonDaemons').'/tmp/'.$datatoken.'.tmp';
1.27 www 313: my $dirpath=$path.'/';
314: $dirpath=~s/\/+/\//g;
1.22 albertel 315: # Check for bad extension and disallow upload
1.37 raeburn 316: my $result;
317: ($result,$returnflag) = &check_extension($fn,$mode,$source,$target,$action,$dirpath,$url);
318: $output .= $result;
1.22 albertel 319: }
320: } else {
1.37 raeburn 321: $output .= '<span class="LC_error">'.
1.22 albertel 322: &mt('Please use browser "Back" button and pick a filename').
1.37 raeburn 323: '</span><br />';
1.22 albertel 324: }
1.1 www 325: } else {
1.37 raeburn 326: $output .= '<span class="LC_error">'.
327: &mt('Please use browser "Back" button and pick a filename').
328: '</span><br />';
329: }
330: return ($output,$returnflag);
331: }
332:
333: sub check_extension {
334: my ($fn,$mode,$source,$target,$action,$dirpath,$url) = @_;
335: my ($result,$returnflag);
336: # Check for bad extension and disallow upload
337: if ($fn=~/\.(\w+)$/ &&
338: (&Apache::loncommon::fileembstyle($1) eq 'hdn')) {
1.49 bisitz 339: $result .= '<p class="LC_warning">'.
340: &mt('File [_1] could not be copied.',
341: '<span class="LC_filename">'.$fn.'</span> ').
342: '<br />'.
343: &mt('The extension on this file is reserved internally by LON-CAPA.').
344: '</p>';
1.37 raeburn 345: } elsif ($fn=~/\.(\w+)$/ &&
346: !defined(&Apache::loncommon::fileembstyle($1))) {
1.49 bisitz 347: $result .= '<p class="LC_warning">'.
348: &mt('File [_1] could not be copied.',
349: '<span class="LC_filename">'.$fn.'</span> ').
350: '<br />'.
351: &mt('The extension on this file is not recognized by LON-CAPA.').
352: '</p>';
1.37 raeburn 353: } elsif (-d $target) {
1.49 bisitz 354: $result .= '<p class="LC_warning">'.
355: &mt('File [_1] could not be copied.',
356: '<span class="LC_filename">'.$fn.'</span>').
357: '<br />'.
358: &mt('The target is an existing directory.').
359: '</p>';
1.37 raeburn 360: } elsif (copy($source,$target)) {
361: chmod(0660, $target); # Set permissions to rw-rw---.
362: if ($mode eq 'testbank' || $mode eq 'imsimport') {
363: $returnflag = 'ok';
1.49 bisitz 364: $result .= '<p class="LC_success">'
365: .&mt('Your file - [_1] - was uploaded successfully.',
366: '<span class="LC_filename">'.$fn.'<span>')
367: .'</p>';
1.37 raeburn 368: } else {
1.49 bisitz 369: $result .= '<p class="LC_success">'
370: .&mt('File copied.')
371: .'</p>';
1.37 raeburn 372: }
373: # Check for embedded objects.
374: my (%allfiles,%codebase);
375: my ($text,$header,$css,$js);
376: if (($mode ne 'imsimport') && ($target =~ /\.(htm|html|shtml)$/i)) {
377: my (%allfiles,%codebase);
378: &Apache::lonnet::extract_embedded_items($target,\%allfiles,\%codebase);
379: if (keys(%allfiles) > 0) {
1.50 raeburn 380: my ($currentpath) = ($url =~ m{^(.+)/[^/]+$});
1.51 raeburn 381: my $state = &embedded_form_elems('upload_embedded',$url,$mode);
382: my ($embedded,$num,$pathchg) =
383: &Apache::loncommon::ask_for_embedded_content($action,$state,\%allfiles,
384: \%codebase,
385: {'error_on_invalid_names' => 1,
386: 'ignore_remote_references' => 1,
387: 'current_path' => $currentpath});
1.50 raeburn 388: if ($embedded) {
1.51 raeburn 389: $result .= '<h3>'.&mt('Reference Warning').'</h3>';
390: if ($num) {
391: $result .= '<p>'.&mt('Completed upload of the file.').' '.&mt('This file contained references to other files.').'</p>'.
392: '<p>'.&mt('Please select the locations from which the referenced files are to be uploaded.').'</p>'.
393: $embedded;
394: if ($mode eq 'testbank') {
395: $returnflag = 'embedded';
396: $result .= '<p>'.&mt('Or [_1]continue[_2] the testbank import without these files.','<a href="javascript:document.testbankForm.submit();">','</a>').'</p>';
397: }
398: } else {
399: $result .= '<p>'.&mt('Completed upload of the file.').'</p>'.$embedded;
400: if ($pathchg) {
401: if ($mode eq 'testbank') {
402: $returnflag = 'embedded';
1.66 bisitz 403: $result .= '<p>'.&mt('Or [_1]continue[_2] the testbank import without modifying the reference(s).','<a href="javascript:document.testbankForm.submit();">','</a>').'</p>';
1.51 raeburn 404: }
405: }
406: }
1.37 raeburn 407: }
408: }
409: }
410: if (($mode ne 'imsimport') && ($mode ne 'testbank')) {
1.49 bisitz 411: $result .= '<br /><a href="'.$url.'">'.
412: &mt('View file').'</a>';
1.37 raeburn 413: }
414: } else {
415: $result .= &mt('Failed to copy: [_1].',$!);
416: }
417: if ($mode ne 'imsimport' && $mode ne 'testbank') {
1.49 bisitz 418: $result .= '<br /><a href="'.$dirpath.'">'.
419: &mt('Back to Directory').'</a><br />';
1.37 raeburn 420: }
421: return ($result,$returnflag);
422: }
423:
424: sub phasethree {
425: my ($r,$fn,$uname,$udom,$mode) = @_;
1.55 www 426:
1.51 raeburn 427: my $action = '/adm/upload';
428: if ($mode eq 'testbank') {
429: $action = '/adm/testbank';
430: } elsif ($mode eq 'imsimport') {
431: $action = '/adm/imsimport';
432: }
1.56 raeburn 433: my $url_root = "/priv/$udom/$uname";
434: my $dir_root = $r->dir_config('lonDocRoot').$url_root;
1.51 raeburn 435: my $path = &File::Basename::dirname($fn);
1.58 raeburn 436: $path =~ s{^\Q$url_root\E}{};
1.67 raeburn 437: my $dirpath = $url_root.$path.'/';
438: $dirpath=~s{/+}{/}g;
1.51 raeburn 439: my $filename = &HTML::Entities::encode($env{'form.filename'},'<>&"');
440: my $state = &embedded_form_elems('modify_orightml',$filename,$mode).
441: '<input type="hidden" name="phase" value="four" />';
442: my ($result,$returnflag) =
443: &Apache::loncommon::upload_embedded($mode,$path,$uname,$udom,
444: $dir_root,$url_root,undef,
445: undef,undef,$state,$action);
446: if ($mode ne 'imsimport' && $mode ne 'testbank') {
1.58 raeburn 447: $result .= '<br /><h3><a href="'.$fn.'">'.
1.51 raeburn 448: &mt('View main file').'</a></h3>'.
1.67 raeburn 449: '<h3><a href="'.$dirpath.'">'.
1.51 raeburn 450: &mt('Back to Directory').'</a></h3><br />';
451: }
452: return ($result,$returnflag);
453: }
454:
455: sub embedded_form_elems {
456: my ($action,$filename,$mode) = @_;
457: return <<STATE;
458: <input type="hidden" name="action" value="$action" />
459: <input type="hidden" name="mode" value="$mode" />
460: <input type="hidden" name="filename" value="$filename" />
461: STATE
462: }
463:
464: sub phasefour {
465: my ($r,$fn,$uname,$udom,$mode) = @_;
1.55 www 466:
1.51 raeburn 467: my $action = '/adm/upload';
468: if ($mode eq 'testbank') {
469: $action = '/adm/testbank';
470: } elsif ($mode eq 'imsimport') {
471: $action = '/adm/imsimport';
472: }
1.37 raeburn 473: my $result;
1.56 raeburn 474: my $url_root = "/priv/$udom/$uname";
475: my $dir_root = $r->dir_config('lonDocRoot').$url_root;
1.37 raeburn 476: my $path = &File::Basename::dirname($fn);
1.58 raeburn 477: $path =~ s{^\Q$url_root\E}{};
1.67 raeburn 478: my $dirpath = $url_root.$path.'/';
479: $dirpath=~s{/+}{/}g;
1.60 raeburn 480: my $outcome =
481: &Apache::loncommon::modify_html_refs($mode,$path,$uname,$udom,$dir_root);
482: $result .= $outcome;
1.37 raeburn 483: if ($mode ne 'imsimport' && $mode ne 'testbank') {
1.58 raeburn 484: $result .= '<br /><h3><a href="'.$fn.'">'.
1.51 raeburn 485: &mt('View main file').'</a></h3>'.
1.67 raeburn 486: '<h3><a href="'.$dirpath.'">'.
1.51 raeburn 487: &mt('Back to Directory').'</a></h3><br />';
1.1 www 488: }
1.37 raeburn 489: return $result;
1.1 www 490: }
491:
1.63 raeburn 492: sub earlyout {
493: my ($fn,$uname,$udom) = @_;
494: if ($fn =~ m{^(/priv/$udom/$uname(?:.*)/)[^/]*}) {
495: return &Apache::lonhtmlcommon::actionbox(
496: ['<a href="'.$1.'">'.&mt('Return to Directory').'</a>']);
497: }
498: return;
499: }
500:
1.10 harris41 501: # ---------------------------------------------------------------- Main Handler
1.1 www 502: sub handler {
503:
1.22 albertel 504: my $r=shift;
1.25 raeburn 505: my $javascript = '';
1.55 www 506: my $fn=$env{'form.filename'};
507:
508: if ($env{'form.filename1'}) {
509: $fn=$env{'form.filename1'}.$env{'form.filename2'};
510: }
511: $fn=~s/\/+/\//g;
512:
513: unless ($fn) {
514: $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
515: ' unspecified filename for upload', $r->filename);
516: return HTTP_NOT_FOUND;
1.22 albertel 517: }
518:
1.61 raeburn 519: my ($uname,$udom)=&Apache::lonnet::constructaccess($fn);
1.58 raeburn 520:
521: unless (($uname) && ($udom)) {
522: $r->log_reason($uname.' at '.$udom.
523: ' trying to publish file '.$env{'form.filename'}.
524: ' - not authorized',
525: $r->filename);
526: return HTTP_NOT_ACCEPTABLE;
527: }
528:
529: # ----------------------------------------------------------- Start page output
530:
531: &Apache::loncommon::content_type($r,'text/html');
532: $r->send_http_header;
533:
1.29 albertel 534: unless ($env{'form.phase'} eq 'two') {
1.58 raeburn 535: $javascript = <<"ENDJS";
536: <script type="text/javascript">
537: // <![CDATA[
1.25 raeburn 538: function verifyForm() {
1.28 raeburn 539: var mode = document.fileupload.filetype.options[document.fileupload.filetype.selectedIndex].value
1.25 raeburn 540: if (mode == "testbank") {
1.28 raeburn 541: document.fileupload.action = "/adm/testbank";
1.25 raeburn 542: }
543: if (mode == "imsimport") {
1.28 raeburn 544: document.fileupload.action = "/adm/imsimport";
1.25 raeburn 545: }
546: if (mode == "standard") {
1.28 raeburn 547: document.fileupload.action = "/adm/upload";
1.25 raeburn 548: }
1.28 raeburn 549: document.fileupload.submit();
1.25 raeburn 550: }
1.58 raeburn 551: // ]]>
552: </script>
553: ENDJS
1.25 raeburn 554: }
1.1 www 555:
1.58 raeburn 556: my $londocroot = $r->dir_config('lonDocRoot');
557: my $trailfile = $fn;
558: $trailfile =~ s{^/(priv/)}{$londocroot/$1};
1.1 www 559:
1.47 bisitz 560: # Breadcrumbs
1.59 raeburn 561: my $brcrum = [{'href' => &Apache::loncommon::authorspace($fn),
1.62 raeburn 562: 'text' => 'Authoring Space'},
1.47 bisitz 563: {'href' => '/adm/upload',
1.62 raeburn 564: 'text' => 'Upload file to Authoring Space'}];
565: $r->print(&Apache::loncommon::start_page('Upload file to Authoring Space',
1.47 bisitz 566: $javascript,
567: {'bread_crumbs' => $brcrum,})
568: .&Apache::loncommon::head_subbox(
1.58 raeburn 569: &Apache::loncommon::CSTR_pageheader($trailfile))
1.47 bisitz 570: );
1.3 www 571:
1.29 albertel 572: if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
1.52 www 573: $r->print('<p class="LC_info">'
1.46 bisitz 574: .&mt('Co-Author [_1]',$uname.':'.$udom)
1.44 bisitz 575: .'</p>'
576: );
1.22 albertel 577: }
1.51 raeburn 578: if ($env{'form.phase'} eq 'four') {
579: my $output = &phasefour($r,$fn,$uname,$udom,'author');
580: $r->print($output);
581: } elsif ($env{'form.phase'} eq 'three') {
1.53 raeburn 582: my ($output,$rtnflag) = &phasethree($r,$fn,$uname,$udom,'author');
1.37 raeburn 583: $r->print($output);
584: } elsif ($env{'form.phase'} eq 'two') {
1.58 raeburn 585: my ($output,$returnflag) = &phasetwo($r,$fn);
1.37 raeburn 586: $r->print($output);
1.22 albertel 587: } else {
1.63 raeburn 588: &phaseone($r,$fn,undef,$uname,$udom);
1.22 albertel 589: }
1.1 www 590:
1.31 albertel 591: $r->print(&Apache::loncommon::end_page());
1.22 albertel 592: return OK;
1.1 www 593: }
1.7 www 594:
595: 1;
596: __END__
1.10 harris41 597:
598:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>