Annotation of loncom/publisher/lonupload.pm, revision 1.57

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>