File:  [LON-CAPA] / loncom / publisher / lonupload.pm
Revision 1.67: download - view: text, annotated - select for diffs
Fri Sep 11 20:12:30 2015 UTC (8 years, 7 months ago) by raeburn
Branches: MAIN
CVS tags: version_2_11_2_uiuc, version_2_11_2_educog, version_2_11_2, HEAD
- Add trailing slash to URL linked to via 'Back to Directory' when upload of
  file was followed by upload of dependencies (e.g., image files in a web page)
  to avoid spurious warning message:
  "You do not have authoring privileges for this resource".

    1: # The LearningOnline Network with CAPA
    2: # Handler to upload files into construction space
    3: #
    4: # $Id: lonupload.pm,v 1.67 2015/09/11 20:12:30 raeburn Exp $
    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: #
   28: ###
   29: 
   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: 
   72: output relevant interface phase (phaseone, phasetwo, phasethree or phasefour)
   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: 
   85: =over
   86: 
   87: =item phaseone()
   88: 
   89: Interface for specifying file to upload.
   90: 
   91: =item phasetwo()
   92: 
   93: Interface for handling post-conditions about uploading (such
   94: as overwriting an existing file).
   95: 
   96: =item phasethree()
   97: 
   98: Interface for handling secondary uploads of embedded objects
   99: in an html file.
  100: 
  101: =item phasefour()
  102: 
  103: Interface for handling optional renaming of links to embedded
  104: objects. 
  105: 
  106: =item upfile_store()
  107: 
  108: Store contents of uploaded file into temporary space.  Invoked
  109: by phaseone subroutine.
  110: 
  111: =item check_extension()
  112: 
  113: Checks if filename extension is permitted and checks type
  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: 
  121: package Apache::lonupload;
  122: 
  123: use strict;
  124: use Apache::File;
  125: use File::Copy;
  126: use File::Basename;
  127: use Apache::Constants qw(:common :http :methods);
  128: use Apache::loncommon();
  129: use Apache::lonnet;
  130: use HTML::Entities();
  131: use Apache::lonlocal;
  132: use Apache::lonnet;
  133: use LONCAPA();
  134: 
  135: my $DEBUG=0;
  136: 
  137: sub Debug {
  138:     # Put out the indicated message but only if DEBUG is true.
  139:     if ($DEBUG) {
  140: 	my ($r,$message) = @_;
  141: 	$r->log_reason($message);
  142:     }
  143: }
  144: 
  145: sub upfile_store {
  146:     my $r=shift;
  147: 	
  148:     my $fname=$env{'form.upfile.filename'};
  149:     $fname=~s/\W//g;
  150:     
  151:     chomp($env{'form.upfile'});
  152:   
  153:     my $datatoken=$env{'user.name'}.'_'.$env{'user.domain'}.
  154: 		  '_upload_'.$fname.'_'.time.'_'.$$;
  155:     {
  156:        my $fh=Apache::File->new('>'.$r->dir_config('lonDaemons').
  157:                                    '/tmp/'.$datatoken.'.tmp');
  158:        print $fh $env{'form.upfile'};
  159:     }
  160:     return $datatoken;
  161: }
  162: 
  163: sub phaseone {
  164:     my ($r,$fn,$mode,$uname,$udom)=@_;
  165:     my $action = '/adm/upload';
  166:     if ($mode eq 'testbank') {
  167:         $action = '/adm/testbank';
  168:     } elsif ($mode eq 'imsimport') {
  169:         $action = '/adm/imsimport';
  170:     }
  171: 
  172:     # Check for file to be uploaded
  173:     $env{'form.upfile.filename'}=~s/\\/\//g;
  174:     $env{'form.upfile.filename'}=~s/^.*\/([^\/]+)$/$1/;
  175:     if (!$env{'form.upfile.filename'}) {
  176:         $r->print('<p class="LC_warning">'.&mt('No upload file specified.').'</p>'.
  177:                   &earlyout($fn,$uname,$udom));
  178:         return;
  179:     }
  180: 
  181:     # Append the name of the uploaded file
  182:     $fn.=$env{'form.upfile.filename'};
  183:     $fn=~s/(\/)+/\//g;
  184: 
  185:     # Check for illegal filename
  186:     &Debug($r, "Filename for upload: $fn");
  187:     if (!(($fn) && ($fn!~/\/$/))) {
  188:         $r->print('<p class="LC_warning">'.&mt('Illegal filename.').'</p>');
  189:         return;
  190:     }
  191:     # Check if quota exceeded
  192:     my $filesize = length($env{'form.upfile'});
  193:     if (!$filesize) {
  194:         $r->print('<p class="LC_warning">'.
  195:                   &mt('Unable to upload [_1]. (size = [_2] bytes)',
  196:                       '<span class="LC_filename">'.$env{'form.upfile.filename'}.'</span>',
  197:                       $filesize).'<br />'.
  198:                   &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'<br />'.
  199:                   '</p>'.
  200:                   &earlyout($fn,$uname,$udom));
  201:         return;
  202:     }
  203:     $filesize = int($filesize/1000); #expressed in kb
  204:     my $output = &Apache::loncommon::excess_filesize_warning($uname,$udom,'author',
  205:                                                              $env{'form.upfile.filename'},$filesize,'upload');
  206:     if ($output) {
  207:         $r->print($output.&earlyout($fn,$uname,$udom));
  208:         return;
  209:     }
  210: 
  211: # Split part that I can change from the part that I cannot change
  212:     my ($fn1,$fn2)=($fn=~/^(\/priv\/[^\/]+\/[^\/]+\/)(.*)$/);
  213:     # Display additional options for upload
  214:     # and upload button
  215:     $r->print(
  216:         '<form action="'.$action.'" method="post" name="fileupload">'
  217:        .'<input type="hidden" name="phase" value="two" />'
  218:        .'<input type="hidden" name="datatoken" value="'.&upfile_store.'" />'
  219:     );
  220:     $r->print(
  221:         &Apache::lonhtmlcommon::start_pick_box()
  222:        .&Apache::lonhtmlcommon::row_title(&mt('Save uploaded file as'))
  223:        .'<span class="LC_filename">'.$fn1.'</span>'
  224:        .'<input type="hidden" name="filename1" value="'.$fn1.'" />'
  225:        .'<input type="text" size="50" name="filename2" value="'.$fn2.'" />'
  226:        .&Apache::lonhtmlcommon::row_closure()
  227:        .&Apache::lonhtmlcommon::row_title(&mt('File Type'))
  228:        .'<select name="filetype">'
  229:        .'<option value="standard" selected="selected">'.&mt('Regular file').'</option>'
  230:        .'<option value="testbank">'.&mt('Testbank file').'</option>'
  231:        .'<option value="imsimport">'.&mt('IMS package').'</option>'
  232:        .'</select>'.&Apache::loncommon::help_open_topic("Uploading_File_Options")
  233:        .&Apache::lonhtmlcommon::row_closure(1)
  234:        .&Apache::lonhtmlcommon::end_pick_box()
  235:     );
  236:     $r->print(
  237:         '<p>'
  238:        .'<input type="button" value="'.&mt('Upload').'" onclick="javascript:verifyForm()"/>'
  239:        .'</p>'
  240:        .'</form>'
  241:     );
  242: 
  243:    # Check for bad extension and warn user
  244:     if ($fn=~/\.(\w+)$/ && 
  245:         (&Apache::loncommon::fileembstyle($1) eq 'hdn')) {
  246:                 $r->print('<p class="LC_error">'
  247:                           .&mt('The extension on this file, [_1], is reserved internally by LON-CAPA.',
  248:                                '<span class="LC_filename">'.$1.'</span>')
  249:                           .' <br />'.&mt('Please change the extension.')
  250:                           .'</p>');
  251:     } elsif($fn=~/\.(\w+)$/ && 
  252:                     !defined(&Apache::loncommon::fileembstyle($1))) {
  253:                 $r->print('<p class="LC_error">'
  254:                          .&mt('The extension on this file, [_1], is not recognized by LON-CAPA.',
  255:                               '<span class="LC_filename">'.$1.'</span>')
  256:                          .' <br />'.&mt('Please change the extension.')
  257:                          .'</p>');
  258:     }
  259: }
  260: 
  261: sub phasetwo {
  262:     my ($r,$fn,$mode)=@_;
  263: 
  264:     my $output;
  265:     my $action = '/adm/upload';
  266:     my $returnflag = '';
  267:     if ($mode eq 'testbank') {
  268:         $action = '/adm/testbank';
  269:     } elsif ($mode eq 'imsimport') {
  270:         $action = '/adm/imsimport';
  271:     }
  272:     $fn=~s/\/+/\//g;
  273:     if ($fn) {
  274: 	my $target= $r->dir_config('lonDocRoot').'/'.$fn;
  275: 	&Debug($r, "target -> ".$target);
  276: #     target is the full filesystem path of the destination file.
  277: 	my $base = &File::Basename::basename($fn);
  278: 	my $path = &File::Basename::dirname($fn);
  279: 	$base    = &HTML::Entities::encode($base,'<>&"');
  280: 	my $url  = $path."/".$base; 
  281: 	&Debug($r, "URL is now ".$url);
  282: 	my $datatoken=$env{'form.datatoken'};
  283: 	if (($fn) && ($datatoken)) {
  284:             if ($env{'form.cancel'}) {
  285:                 my $source=$r->dir_config('lonDaemons').'/tmp/'.$datatoken.'.tmp';
  286:                 my $dirpath=$path.'/';
  287:                 $dirpath=~s/\/+/\//g;
  288:                 $output .= '<p class="LC_warning">'.&mt('Upload cancelled.').'</p>'
  289:                           .'<p><a href="'.$dirpath.'">'.
  290:                           &mt('Back to Directory').'</a></p>';
  291:             } elsif ((-e $target) && (!$env{'form.override'})) {
  292:                 $output .= '<form action="'.$action.'" method="post">'
  293:                           .'<p class="LC_warning">'
  294:                           .&mt('File [_1] already exists.',
  295:                                '<span class="LC_filename">'.$fn.'</span>')
  296:                          .'<input type="hidden" name="phase" value="two" />'
  297:                          .'<input type="hidden" name="filename" value="'.$url.'" />'
  298:                          .'<input type="hidden" name="datatoken" value="'.$datatoken.'" />'
  299:                          .'<p>'
  300:                          .'<input type="submit" name="cancel" value="'.&mt('Cancel').'" />'
  301:                          .' <input type="submit" name="override" value="'.&mt('Overwrite').'" />'
  302:                          .'</p>'
  303:                          .'</form>';
  304:             } else {
  305: 		my $source=$r->dir_config('lonDaemons').'/tmp/'.$datatoken.'.tmp';
  306: 		my $dirpath=$path.'/';
  307: 		$dirpath=~s/\/+/\//g;
  308: 		# Check for bad extension and disallow upload
  309:                 my $result;
  310:                 ($result,$returnflag) = &check_extension($fn,$mode,$source,$target,$action,$dirpath,$url);
  311:                 $output .= $result;
  312: 	    }
  313: 	} else {
  314: 	    $output .= '<span class="LC_error">'.
  315: 		      &mt('Please use browser "Back" button and pick a filename').
  316: 		      '</span><br />';
  317: 	}
  318:     } else {
  319: 	$output .= '<span class="LC_error">'.
  320: 		   &mt('Please use browser "Back" button and pick a filename').
  321: 		   '</span><br />';
  322:     }
  323:     return ($output,$returnflag);
  324: }
  325: 
  326: sub check_extension {
  327:     my ($fn,$mode,$source,$target,$action,$dirpath,$url) = @_;
  328:     my ($result,$returnflag);
  329:     # Check for bad extension and disallow upload
  330:     if ($fn=~/\.(\w+)$/ &&
  331:         (&Apache::loncommon::fileembstyle($1) eq 'hdn')) {
  332:         $result .= '<p class="LC_warning">'.
  333:                    &mt('File [_1] could not be copied.',
  334:                        '<span class="LC_filename">'.$fn.'</span> ').
  335:                    '<br />'.
  336:                    &mt('The extension on this file is reserved internally by LON-CAPA.').
  337:                    '</p>';
  338:     } elsif ($fn=~/\.(\w+)$/ &&
  339:              !defined(&Apache::loncommon::fileembstyle($1))) {
  340:         $result .= '<p class="LC_warning">'.
  341:                    &mt('File [_1] could not be copied.',
  342:                        '<span class="LC_filename">'.$fn.'</span> ').
  343:                    '<br />'.
  344:                    &mt('The extension on this file is not recognized by LON-CAPA.').
  345:                    '</p>';
  346:     } elsif (-d $target) {
  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 target is an existing directory.').
  352:                    '</p>';
  353:     } elsif (copy($source,$target)) {
  354:         chmod(0660, $target); # Set permissions to rw-rw---.
  355:         if ($mode eq 'testbank' || $mode eq 'imsimport') {
  356:             $returnflag = 'ok';
  357:             $result .= '<p class="LC_success">'
  358:                       .&mt('Your file - [_1] - was uploaded successfully.',
  359:                            '<span class="LC_filename">'.$fn.'<span>')
  360:                       .'</p>';
  361:         } else {
  362:             $result .= '<p class="LC_success">'
  363:                       .&mt('File copied.')  
  364:                       .'</p>';
  365:         }
  366:         # Check for embedded objects.
  367:         my (%allfiles,%codebase);
  368:         my ($text,$header,$css,$js);
  369:         if (($mode ne 'imsimport') && ($target =~ /\.(htm|html|shtml)$/i)) {
  370:             my (%allfiles,%codebase);
  371:             &Apache::lonnet::extract_embedded_items($target,\%allfiles,\%codebase);
  372:             if (keys(%allfiles) > 0) {
  373:                 my ($currentpath) = ($url =~ m{^(.+)/[^/]+$});
  374:                 my $state = &embedded_form_elems('upload_embedded',$url,$mode);
  375:                 my ($embedded,$num,$pathchg) = 
  376:                     &Apache::loncommon::ask_for_embedded_content($action,$state,\%allfiles,
  377:                                                                  \%codebase,
  378:                                                                  {'error_on_invalid_names'   => 1,
  379:                                                                   'ignore_remote_references' => 1,
  380:                                                                   'current_path'             => $currentpath});
  381:                 if ($embedded) {
  382:                     $result .= '<h3>'.&mt('Reference Warning').'</h3>';
  383:                     if ($num) {
  384:                         $result .= '<p>'.&mt('Completed upload of the file.').' '.&mt('This file contained references to other files.').'</p>'.
  385:                                    '<p>'.&mt('Please select the locations from which the referenced files are to be uploaded.').'</p>'.
  386:                                    $embedded;
  387:                         if ($mode eq 'testbank') {
  388:                             $returnflag = 'embedded';
  389:                             $result .=  '<p>'.&mt('Or [_1]continue[_2] the testbank import without these files.','<a href="javascript:document.testbankForm.submit();">','</a>').'</p>';
  390:                         }
  391:                     } else {
  392:                         $result .= '<p>'.&mt('Completed upload of the file.').'</p>'.$embedded;
  393:                         if ($pathchg) {
  394:                             if ($mode eq 'testbank') {
  395:                                 $returnflag = 'embedded';
  396:                                 $result .=  '<p>'.&mt('Or [_1]continue[_2] the testbank import without modifying the reference(s).','<a href="javascript:document.testbankForm.submit();">','</a>').'</p>';
  397:                             }
  398:                         }
  399:                     }
  400:                 }
  401:             }
  402:         }
  403:         if (($mode ne 'imsimport') && ($mode ne 'testbank')) {
  404:             $result .= '<br /><a href="'.$url.'">'.
  405:                         &mt('View file').'</a>';
  406:         }
  407:     } else {
  408:         $result .= &mt('Failed to copy: [_1].',$!);
  409:     }
  410:     if ($mode ne 'imsimport' && $mode ne 'testbank') {
  411:         $result .= '<br /><a href="'.$dirpath.'">'.
  412:                    &mt('Back to Directory').'</a><br />';
  413:     }
  414:     return ($result,$returnflag);
  415: }
  416: 
  417: sub phasethree {
  418:     my ($r,$fn,$uname,$udom,$mode) = @_;
  419: 
  420:     my $action = '/adm/upload'; 
  421:     if ($mode eq 'testbank') {
  422:         $action = '/adm/testbank';
  423:     } elsif ($mode eq 'imsimport') {
  424:         $action = '/adm/imsimport';
  425:     }
  426:     my $url_root = "/priv/$udom/$uname";
  427:     my $dir_root = $r->dir_config('lonDocRoot').$url_root;
  428:     my $path = &File::Basename::dirname($fn);
  429:     $path =~ s{^\Q$url_root\E}{};
  430:     my $dirpath = $url_root.$path.'/';
  431:     $dirpath=~s{/+}{/}g;
  432:     my $filename = &HTML::Entities::encode($env{'form.filename'},'<>&"');
  433:     my $state = &embedded_form_elems('modify_orightml',$filename,$mode).
  434:                 '<input type="hidden" name="phase" value="four" />';
  435:     my ($result,$returnflag) = 
  436:         &Apache::loncommon::upload_embedded($mode,$path,$uname,$udom,
  437:                                             $dir_root,$url_root,undef,
  438:                                             undef,undef,$state,$action);
  439:     if ($mode ne 'imsimport' && $mode ne 'testbank') {
  440:         $result .= '<br /><h3><a href="'.$fn.'">'.
  441:                   &mt('View main file').'</a></h3>'.
  442:                   '<h3><a href="'.$dirpath.'">'.
  443:                   &mt('Back to Directory').'</a></h3><br />';
  444:     }
  445:     return ($result,$returnflag);
  446: }
  447: 
  448: sub embedded_form_elems {
  449:     my ($action,$filename,$mode) = @_;
  450:     return <<STATE;
  451:     <input type="hidden" name="action" value="$action" />
  452:     <input type="hidden" name="mode" value="$mode" />
  453:     <input type="hidden" name="filename" value="$filename" />
  454: STATE
  455: }
  456: 
  457: sub phasefour {
  458:     my ($r,$fn,$uname,$udom,$mode) = @_;
  459: 
  460:     my $action = '/adm/upload';
  461:     if ($mode eq 'testbank') {
  462:         $action = '/adm/testbank';
  463:     } elsif ($mode eq 'imsimport') {
  464:         $action = '/adm/imsimport';
  465:     }
  466:     my $result;
  467:     my $url_root = "/priv/$udom/$uname";
  468:     my $dir_root = $r->dir_config('lonDocRoot').$url_root;
  469:     my $path = &File::Basename::dirname($fn);
  470:     $path =~ s{^\Q$url_root\E}{};
  471:     my $dirpath = $url_root.$path.'/';
  472:     $dirpath=~s{/+}{/}g;
  473:     my $outcome = 
  474:         &Apache::loncommon::modify_html_refs($mode,$path,$uname,$udom,$dir_root);
  475:     $result .= $outcome;
  476:     if ($mode ne 'imsimport' && $mode ne 'testbank') {
  477:         $result .= '<br /><h3><a href="'.$fn.'">'.
  478:                   &mt('View main file').'</a></h3>'.
  479:                   '<h3><a href="'.$dirpath.'">'.
  480:                   &mt('Back to Directory').'</a></h3><br />';
  481:     }
  482:     return $result;
  483: }
  484: 
  485: sub earlyout {
  486:     my ($fn,$uname,$udom) = @_;
  487:     if ($fn =~ m{^(/priv/$udom/$uname(?:.*)/)[^/]*}) {
  488:         return &Apache::lonhtmlcommon::actionbox(
  489:                ['<a href="'.$1.'">'.&mt('Return to Directory').'</a>']);
  490:     }
  491:     return;
  492: }
  493: 
  494: # ---------------------------------------------------------------- Main Handler
  495: sub handler {
  496: 
  497:     my $r=shift;
  498:     my $javascript = '';
  499:     my $fn=$env{'form.filename'};
  500: 
  501:     if ($env{'form.filename1'}) {
  502:        $fn=$env{'form.filename1'}.$env{'form.filename2'};
  503:     }
  504:     $fn=~s/\/+/\//g;
  505: 
  506:     unless ($fn) {
  507:         $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
  508:                        ' unspecified filename for upload', $r->filename);
  509:         return HTTP_NOT_FOUND;
  510:     }
  511: 
  512:     my ($uname,$udom)=&Apache::lonnet::constructaccess($fn);
  513: 
  514:     unless (($uname) && ($udom)) {
  515:         $r->log_reason($uname.' at '.$udom.
  516:                        ' trying to publish file '.$env{'form.filename'}.
  517:                        ' - not authorized',
  518:                        $r->filename);
  519:         return HTTP_NOT_ACCEPTABLE;
  520:     }
  521: 
  522: # ----------------------------------------------------------- Start page output
  523: 
  524:     &Apache::loncommon::content_type($r,'text/html');
  525:     $r->send_http_header;
  526: 
  527:     unless ($env{'form.phase'} eq 'two') {
  528:         $javascript = <<"ENDJS";
  529: <script type="text/javascript">
  530: // <![CDATA[
  531: function verifyForm() {
  532:     var mode = document.fileupload.filetype.options[document.fileupload.filetype.selectedIndex].value
  533:     if (mode == "testbank") {
  534:         document.fileupload.action = "/adm/testbank";
  535:     }
  536:     if (mode == "imsimport") {
  537:         document.fileupload.action = "/adm/imsimport";
  538:     }
  539:     if (mode == "standard") {
  540:         document.fileupload.action = "/adm/upload";
  541:     }
  542:     document.fileupload.submit();
  543: }
  544: // ]]>
  545: </script>
  546: ENDJS
  547:     }
  548: 
  549:     my $londocroot = $r->dir_config('lonDocRoot');
  550:     my $trailfile = $fn;
  551:     $trailfile =~ s{^/(priv/)}{$londocroot/$1};
  552: 
  553:     # Breadcrumbs
  554:     my $brcrum = [{'href' => &Apache::loncommon::authorspace($fn),
  555:                    'text' => 'Authoring Space'},
  556:                   {'href' => '/adm/upload',
  557:                    'text' => 'Upload file to Authoring Space'}];
  558:     $r->print(&Apache::loncommon::start_page('Upload file to Authoring Space',
  559:                                              $javascript,
  560:                                              {'bread_crumbs' => $brcrum,})
  561:              .&Apache::loncommon::head_subbox(
  562:                 &Apache::loncommon::CSTR_pageheader($trailfile))
  563:     );
  564:   
  565:     if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
  566:         $r->print('<p class="LC_info">'
  567:                  .&mt('Co-Author [_1]',$uname.':'.$udom)
  568:                  .'</p>'
  569:         );
  570:     }
  571:     if ($env{'form.phase'} eq 'four') {
  572:         my $output = &phasefour($r,$fn,$uname,$udom,'author');
  573:         $r->print($output);
  574:     } elsif ($env{'form.phase'} eq 'three') {
  575:         my ($output,$rtnflag) = &phasethree($r,$fn,$uname,$udom,'author');
  576:         $r->print($output);
  577:     } elsif ($env{'form.phase'} eq 'two') {
  578: 	my ($output,$returnflag) = &phasetwo($r,$fn);
  579:         $r->print($output);
  580:     } else {
  581: 	&phaseone($r,$fn,undef,$uname,$udom);
  582:     }
  583: 
  584:     $r->print(&Apache::loncommon::end_page());
  585:     return OK;  
  586: }
  587: 
  588: 1;
  589: __END__
  590: 
  591: 

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