--- loncom/interface/londocs.pm 2013/03/31 22:36:01 1.538 +++ loncom/interface/londocs.pm 2013/09/23 17:35:07 1.565 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.538 2013/03/31 22:36:01 raeburn Exp $ +# $Id: londocs.pm,v 1.565 2013/09/23 17:35:07 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -56,6 +56,7 @@ my $hashtied; my %alreadyseen=(); my $hadchanges; +my $suppchanges; my %help=(); @@ -79,7 +80,11 @@ sub storemap { $map,1,$report); if ($errtext) { return ($errtext,2); } - $hadchanges=1; + if ($map =~ /^default/) { + $hadchanges=1; + } else { + $suppchanges=1; + } return ($errtext,0); } @@ -340,10 +345,8 @@ sub group_import { } my $initialtext = &mt('Replace with your own content.'); my $newhtml = < - + - $name @@ -404,6 +407,13 @@ END } my ($errtext,$fatal) = &storemap($coursenum, $coursedom, $folder.'.'.$container,1); + unless ($fatal) { + if ($folder =~ /^supplemental/) { + &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1); + my ($errtext,$fatal) = &mapread($coursenum,$coursedom, + $folder.'.'.$container); + } + } return ($errtext,$fatal,$fixuperrors); } @@ -490,7 +500,7 @@ sub docs_change_log { } my $folderpath=$env{'form.folderpath'}; if ($folderpath eq '') { - $folderpath = 'default&'.&escape(&mt('Main '.$crstype.' Content').':::::'); + $folderpath = 'default&'.&escape(&mt('Main Content').':::::'); } $pathitem = ''; @@ -702,7 +712,7 @@ sub update_paste_buffer { my $url = $env{'docs.markedcopy_url_'.$suffix}; if (($cid =~ /^$match_domain(?:_)$match_courseid$/) && ($url ne '')) { - $pasteurls{$cid.'_'.$url}; + $pasteurls{$cid.'_'.$url} = 1; } } } @@ -834,7 +844,7 @@ sub print_paste_buffer { $othercourse = 1; if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) { if ($canpaste) { - $othercrs = '
'.&mt('(from another course).'); + $othercrs = '
'.&mt('(from another course)'); } } else { $canpaste = 0; @@ -902,7 +912,7 @@ sub print_paste_buffer { my ($pasteform,$form_start,$buttons,$form_end); if ($pasteitems) { $pasteitems .= '
'; - $form_start = '
'; + $form_start = ''; if (@pasteable) { $buttons = ''.(' 'x2); } @@ -1009,6 +1019,7 @@ sub paste_popup_js { my %lt = &Apache::lonlocal::texthash( show => 'Show Options', hide => 'Hide Options', + none => 'No items selected from clipboard.', ); return <<"END"; @@ -1038,11 +1049,33 @@ function showOptions(caller,suffix) { return; } +function validateClipboard() { + var numchk = 0; + if (document.pasteform.pasting.length > 1) { + for (var i=0; i 0) { + return true; + } else { + alert("$lt{'none'}"); + return false; + } +} + END } - sub do_paste_from_buffer { my ($coursenum,$coursedom,$folder,$container,$errors) = @_; @@ -1076,8 +1109,7 @@ sub do_paste_from_buffer { } my (%msgs,%before,%after,@dopaste,%is_map,%notinsupp,%notincrs,%duplicate, - %prefixchg,%srcdom,%srcnum,%marktomove,$save_err,$lockerrors,$allresult, - %msgs); + %prefixchg,%srcdom,%srcnum,%marktomove,$save_err,$lockerrors,$allresult); foreach my $suffix (@topaste) { my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url_'.$suffix}); @@ -1278,7 +1310,7 @@ sub do_paste_from_buffer { if ($prefix eq 'smppg') { $msg = &mt('Paste failed: An error occurred when copying the simple page.').' '.$errtext; } elsif ($prefix eq 'bulletinboard') { - $msg = &mt('Paste failed: An error occurred when copying the bulletin board.').' '.$errtext; + $msg = &mt('Paste failed: An error occurred when copying the discussion board.').' '.$errtext; } $results{$suffix} = $result; $msgerrs{$suffix} = $msg; @@ -1528,7 +1560,7 @@ sub get_newmap_url { sub dbcopy { my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_; my ($url,$result,$errtext); - my $url = $dbref->{'src'}; + $url = $dbref->{'src'}; if (ref($dbref) eq 'HASH') { if ($url =~ m{/(smppg|bulletinboard)$}) { my $prefix = $1; @@ -1553,7 +1585,7 @@ sub dbcopy { if ($prefix eq 'smppg') { $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url); } else { - $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a bulletin board [_1].',$url); + $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url); } if ($error) { $errtext .= '
'.$error; @@ -1589,16 +1621,18 @@ sub dbcopy { } } if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) { - $lockerrorsref->{$prefix} = + $lockerrorsref->{$prefix} = '
'. &mt('There was a problem removing a lockfile.'); if ($prefix eq 'smppg') { - $lockerrorsref->{$prefix} .= - &mt('This will prevent creation of additional simple pages in this course.'); + $lockerrorsref->{$prefix} .= + ' '.&mt('This will prevent creation of additional simple pages in this course.'); } else { - $lockerrorsref->{$prefix} .= &mt('This will prevent creation of additional bulletin boards in this course.'); + $lockerrorsref->{$prefix} .= ' '.&mt('This will prevent creation of additional discussion boards in this course.'); } - $lockerrorsref->{$prefix} .= &mt('Please contact the domain coordinator for your LON-CAPA domain.').'
'; + $lockerrorsref->{$prefix} .= ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.', + '',''). + ''; } } } elsif ($url =~ m{/syllabus$}) { @@ -2170,7 +2204,9 @@ sub update_parameter { } } } else { - map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.all'.$which}); + if ($env{'form.all'.$which}) { + map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.all'.$which}); + } } } my $haschanges = 0; @@ -2244,7 +2280,9 @@ sub update_parameter { sub handle_edit_cmd { my ($coursenum,$coursedom) =@_; - return if ($env{'form.cmd'} eq ''); + if ($env{'form.cmd'} eq '') { + return 0; + } my ($cmd,$idx)=split('_',$env{'form.cmd'}); my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]; @@ -2305,7 +2343,7 @@ sub editor { my $jumpto; unless ($supplementalflag) { - $jumpto = "'uploaded/$coursedom/$coursenum/$folder.$container'"; + $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container"; } unless ($allowed) { @@ -2349,24 +2387,30 @@ sub editor { my ($paste_res,$save_error,$pastemsgarray,$lockerror) = &do_paste_from_buffer($coursenum,$coursedom,$folder,$container, \%paste_errors); - if (ref($pastemsgarray) eq 'ARRAY') { - if (@{$pastemsgarray} > 0) { - - $r->print('

'. - join('
',@{$pastemsgarray}). - '

'); - } - } - if ($lockerror) { - $r->print('

'. - $lockerror. + if (ref($pastemsgarray) eq 'ARRAY') { + if (@{$pastemsgarray} > 0) { + $r->print('

'. + join('
',@{$pastemsgarray}). '

'); } - if ($save_error ne '') { - return $save_error; + } + if ($lockerror) { + $r->print('

'. + $lockerror. + '

'); + } + if ($save_error ne '') { + return $save_error; + } + if ($paste_res) { + my %errortext = &Apache::lonlocal::texthash ( + fail => 'Storage of folder contents failed', + failread => 'Reading folder contents failed', + failstore => 'Storage of folder contents failed', + ); + if ($errortext{$paste_res}) { + $r->print('

'.$errortext{$paste_res}.'

'); } - if ($paste_res ne 'ok') { - $r->print('

'.$paste_res.'

'); } if (keys(%paste_errors) > 0) { $r->print('

'."\n". @@ -2566,9 +2610,13 @@ sub editor { my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups); %filters = ( - canremove => [], - cancut => [], - cancopy => [], + canremove => [], + cancut => [], + cancopy => [], + hiddenresource => [], + encrypturl => [], + randomorder => [], + randompick => [], ); %curr_groups = &Apache::longroup::coursegroups(); &Apache::loncommon::start_data_table_count(); #setup a row counter @@ -2593,7 +2641,9 @@ sub editor { my $need_save; if (($allowed) || ($supplementalflag && $folder eq 'supplemental')) { - my $toolslink = ' - END } @@ -3191,6 +3271,9 @@ END my $rpckchk; if ($rpicknum) { $rpckchk = ' checked="checked"'; + if (($ishash) && (ref($filtersref->{'randompick'}) eq 'ARRAY')) { + push(@{$filtersref->{'randompick'}},$orderidx.':'.$rpicknum); + } } my $formname = 'edit_randompick_'.$orderidx; $rand_pick_text = @@ -3203,9 +3286,14 @@ $form_common."\n". } $rand_pick_text .= ''. $form_end; - my $ro_set= - ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':''); - my $formname = 'edit_rorder_'.$orderidx; + my $ro_set; + if ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i) { + $ro_set = 'checked="checked"'; + if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) { + push(@{$filtersref->{'randomorder'}},$orderidx); + } + } + $formname = 'edit_rorder_'.$orderidx; $rand_order_text = ''."\n". $form_param."\n". @@ -3281,10 +3369,19 @@ $form_end; my %lt=&Apache::lonlocal::texthash( 'hd' => 'Hidden', 'ec' => 'URL hidden'); - my $enctext= - ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="checked"':''); - my $hidtext= - ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="checked"':''); + my ($enctext,$hidtext); + if ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i) { + $enctext = ' checked="checked"'; + if (($ishash) && (ref($filtersref->{'encrypturl'}) eq 'ARRAY')) { + push(@{$filtersref->{'encrypturl'}},$orderidx); + } + } + if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) { + $hidtext = ' checked="checked"'; + if (($ishash) && (ref($filtersref->{'randomorder'}) eq 'ARRAY')) { + push(@{$filtersref->{'hiddenresource'}},$orderidx); + } + } my $formhidden = 'edit_hiddenresource_'.$orderidx; my $formurlhidden = 'edit_encrypturl_'.$orderidx; $line.=(<',''); } $locknotfreed .= ''; } @@ -3587,8 +3685,8 @@ sub list_symbs { sub verifycontent { my ($r) = @_; my $crstype = &Apache::loncommon::course_type(); - $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Documents')); - $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Documents')); + $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Content')); + $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Content')); $r->print(&startContentScreen('tools')); $r->print('

'.&mt($crstype.' content verification').'

'); $hashtied=0; @@ -3690,7 +3788,7 @@ sub checkversions { &changewarning($r,''); if ($env{'form.timerange'} eq 'all') { # show all documents - $header=&mt('All Documents in '.$crstype); + $header=&mt('All content in '.$crstype); $allsel=' selected="selected"'; foreach my $key (keys(%hash)) { if ($key=~/^ids\_(\/res\/.+)$/) { @@ -3968,7 +4066,7 @@ sub startContentScreen { $output .= '      '.&mt('Content Index').'      '."\n"; $output .= '
  • '.&mt('Supplemental Content').'
  • '; } else { - $output .= '
  •       '.&mt('Content Editor').'      
  • '."\n"; + $output .= '
  •       '.&mt('Main Content Editor').'      
  • '."\n"; $output .= '
  • '.&mt('Supplemental Content Editor').'
  • '."\n"; $output .= '
  •       '.&mt('Content Utilities').'      
  • '."\n"; '>      '.&mt('Content Utilities').'      '; @@ -3989,7 +4087,7 @@ sub endContentScreen { } sub supplemental_base { - return 'supplemental&'.&escape(&mt('Supplemental '.&Apache::loncommon::course_type().' Content')); + return 'supplemental&'.&escape(&mt('Supplemental Content')); } sub handler { @@ -4014,7 +4112,8 @@ sub handler { 'Supplemental','Score_Upload_Form','Adding_Pages', 'Importing_LON-CAPA_Resource','Importing_IMS_Course', 'Uploading_From_Harddrive', - 'Check_Resource_Versions','Verify_Content') { + 'Check_Resource_Versions','Verify_Content', + 'Course_Roster','Web_Page','Dropbox') { $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic); } # Composite help files @@ -4030,8 +4129,6 @@ sub handler { 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages'); $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files'); $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching'); - $help{'Course Roster'} = &Apache::loncommon::help_open_topic('Docs_Course_Roster'); - $help{'Web Page'} = &Apache::loncommon::help_open_topic('Docs_Web_Page'); my $allowed; # URI is /adm/supplemental when viewing supplemental docs in non-edit mode. @@ -4088,9 +4185,9 @@ sub handler { # supplementalflag=0: show standard documents # toolsflag=1: show utilities - $env{'form.folderpath'} = &unescape($env{'form.folderpath'}); - my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/); - if (($env{'form.folderpath'}=~/^default/) || ($env{'form.folderpath'} eq "")) { + my $unesc_folderpath = &unescape($env{'form.folderpath'}); + my $supplementalflag=($unesc_folderpath=~/^supplemental/); + if (($unesc_folderpath=~/^default/) || ($unesc_folderpath eq "")) { $supplementalflag=0; } if ($env{'form.forcesupplement'}) { $supplementalflag=1; } @@ -4122,7 +4219,7 @@ sub handler { } } elsif ($env{'form.command'} eq 'editdocs') { $env{'form.folderpath'} = 'default&'. - &escape(&mt('Main '.$crstype.' Content').':::::'); + &escape(&mt('Main Content').':::::'); &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}}); } elsif ($env{'form.command'} eq 'editsupp') { $env{'form.folderpath'} = 'supplemental&'. @@ -4167,7 +4264,7 @@ sub handler { if ($supplementalflag) { $env{'form.folderpath'}=&supplemental_base(); } else { - $env{'form.folderpath'}='default'.&escape(&mt('Main '.$crstype.' Content'). + $env{'form.folderpath'}='default&'.&escape(&mt('Main Content'). ':::::'); } } @@ -4193,7 +4290,7 @@ sub handler { if ($env{'form.folder'} eq '' || $env{'form.folder'} eq 'supplemental') { $folderpath='default&'. - &escape(&mt('Main '.$crstype.' Content').':::::'); + &escape(&mt('Main Content').':::::'); } } $containertag = ''; @@ -4296,7 +4393,7 @@ sub handler { # Process file upload - phase one - upload and parse primary file. undef($hadchanges); $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom, - \%allfiles,\%codebase,$context); + \%allfiles,\%codebase,$context,$crstype); if ($hadchanges) { &mark_hash_old(); } @@ -4348,7 +4445,7 @@ sub handler { my %lt=&Apache::lonlocal::texthash( 'copm' => 'All documents out of a published map into this folder', 'upfi' => 'Upload File', - 'upld' => 'Import Content', + 'upld' => 'Upload Content', 'srch' => 'Search', 'impo' => 'Import', 'lnks' => 'Import from Stored Links', @@ -4369,8 +4466,8 @@ sub handler { 'grpo' => 'Group Portfolio', 'rost' => 'Course Roster', 'abou' => 'Personal Information Page for a User', - 'imsf' => 'IMS Import', - 'imsl' => 'Import IMS package', + 'imsf' => 'IMS Upload', + 'imsl' => 'Upload IMS package', 'cms' => 'Origin of IMS package', 'se' => 'Select', 'file' => 'File', @@ -4518,7 +4615,7 @@ HIDDENFORM if ($folder eq '' || $supplementalflag) { $folder='default'; $savefolderpath = $env{'form.folderpath'}; - $env{'form.folderpath'}='default&'.&escape(&mt('Content')); + $env{'form.folderpath'}='default&'.&escape(&mt('Main Content')); $pathitem = ''; } @@ -4574,6 +4671,7 @@ NSPROBFORM $pathitem $lt{'drbx'} + $help{'Dropbox'} NDBFORM @@ -4624,7 +4722,7 @@ NASOFORM $lt{'rost'} - $help{'Course Roster'} + $help{'Course_Roster'} NROSTFORM @@ -4644,7 +4742,7 @@ NROSTFORM $pathitem $lt{'webp'} - $help{'Web Page'} + $help{'Web_Page'} NWEBFORM @@ -4721,7 +4819,7 @@ NGFFORM ); } push(@importdoc, - {''.$lt{upl}.''=>$fileuploadform} + {''.$lt{upl}.''=>$fileuploadform} ); $fileuploadform = &create_form_ul(&create_list_elements(@importdoc)); @@ -4743,14 +4841,14 @@ NGFFORM $communityform = &create_form_ul(&create_list_elements(@communityforma)); my %orderhash = ( - 'aa' => ['Import Content',$fileuploadform], - 'bb' => ['Published Content',$importpubform], - 'cc' => ['Grading Resources',$gradingform], + 'aa' => ['Upload',$fileuploadform], + 'bb' => ['Import',$importpubform], + 'cc' => ['Grading',$gradingform], ); unless ($container eq 'page') { $orderhash{'00'} = ['Newfolder',$newfolderform]; $orderhash{'dd'} = ['Collaboration',$communityform]; - $orderhash{'ee'} = ['Special Pages',$specialdocumentsform]; + $orderhash{'ee'} = ['Other',$specialdocumentsform]; } $hadchanges=0; @@ -4861,7 +4959,7 @@ SNAMFORM $pathitem $lt{'webp'} - $help{'Web Page'} + $help{'Web_Page'} SWEBFORM @@ -4884,15 +4982,27 @@ my @supimportdoc = ( $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc)); my %suporderhash = ( '00' => ['Supnewfolder', $supnewfolderform], - 'ee' => ['Import Content',$supupdocform], - 'ff' => ['Special Pages',&create_form_ul(&create_list_elements(@specialdocs))] + 'ee' => ['Upload',$supupdocform], + 'ff' => ['Other',&create_form_ul(&create_list_elements(@specialdocs))] ); if ($supplementalflag) { my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, $supplementalflag,\%suporderhash,$iconpath,$pathitem); if ($error) { $r->print('

    '.$error.'

    '); - } + } else { + if ($suppchanges) { + my %servers = &Apache::lonnet::internet_dom_servers($coursedom); + my @ids=&Apache::lonnet::current_machine_ids(); + foreach my $server (keys(%servers)) { + next if (grep(/^\Q$server\E$/,@ids)); + my $hashid=$coursenum.':'.$coursedom; + &Apache::lonnet::remote_devalidate_cache($server,'suppcount',$hashid); + } + &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1); + undef($suppchanges); + } + } } } elsif ($supplementalflag) { my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, @@ -5039,8 +5149,8 @@ sub remove_archive { } else { my $currcmd = $env{'form.cmd'}; my $position = $env{'form.position'}; - if ($position > 0) { - $env{'form.cmd'} = 'del_'.$position; + if ($position > 0) { + $env{'form.cmd'} = 'remove_'.$position; my ($title,$url,@rrest) = split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]); if (&handle_edit_cmd($docuname,$docudom)) { @@ -5075,13 +5185,13 @@ sub generate_admin_menu { my ($crstype) = @_; my $lc_crstype = lc($crstype); my ($home,$other,%outhash)=&authorhosts(); - my %lt=&Apache::lonlocal::texthash ( + my %lt= ( # do not translate here 'vc' => 'Verify Content', 'cv' => 'Check/Set Resource Versions', 'ls' => 'List Resource Identifiers', 'imse' => 'Export contents to IMS Archive', 'dcd' => "Dump $crstype Content to Authoring Space", - ); + ); my ($candump,$dumpurl); if ($home + $other > 0) { $candump = 'F'; @@ -5171,7 +5281,7 @@ sub generate_edit_table { $form = '
    '. '
    ' + my $toolslink; + if ($allowed || &Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { + $toolslink = '' @@ -2603,6 +2653,7 @@ sub editor { .'class="LC_toolbarItem" ' .'title="'.&mt('Supplemental Content Editor').'">' .'
    ' .&Apache::loncommon::help_open_menu('Navigation Screen', 'Navigation_Screen',undef,'RAT') .''.&mt('Tools:').'

    '; + } if ($shown) { if ($allowed) { $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll') @@ -2618,9 +2669,13 @@ sub editor { if ($folder !~ /^supplemental/) { $lists{'canhide'} = join(',',@allidx); $lists{'canrandomlyorder'} = join(',',@allmapidx); - foreach my $item ('canremove','cancut','cancopy') { + my @possfilters = ('canremove','cancut','cancopy','hiddenresource','encrypturl', + 'randomorder','randompick'); + foreach my $item (@possfilters) { if (ref($filters{$item}) eq 'ARRAY') { - $lists{$item} = join(',',@{$filters{$item}}); + if (@{$filters{$item}} > 0) { + $lists{$item} = join(',',@{$filters{$item}}); + } } } if (@allidx > 0) { @@ -2662,7 +2717,7 @@ sub editor { } $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll') .'
    ' - .&mt('Currently no documents.') + .&mt('Currently empty') .'
    ' .&Apache::loncommon::end_scrollbox(); } @@ -2675,7 +2730,7 @@ sub editor { .''; } else { $to_show = '
    ' - .&mt('Currently no documents.') + .&mt('Currently empty') .'
    ' } } @@ -2742,7 +2797,11 @@ sub multiple_check_form { ''; if ($caller eq 'settings') { $output .= - ''; + ''."\n". + ''."\n". + ''."\n". + ''."\n". + ''."\n"; } elsif ($caller eq 'actions') { $output .= ''. @@ -2756,8 +2815,30 @@ sub multiple_check_form { } sub process_file_upload { - my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_; + my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd,$crstype) = @_; # upload a file, if present + my $filesize = length($env{'form.uploaddoc'}); + if (!$filesize) { + $$upload_output = '
    '. + &mt('Unable to upload [_1]. (size = [_2] bytes)', + ''.$env{'form.uploaddoc.filename'}.'', + $filesize).'
    '. + &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'
    '. + '
    '; + return; + } + my $quotatype = 'unofficial'; + if ($crstype eq 'Community') { + $quotatype = 'community'; + } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.instcode'}) { + $quotatype = 'official'; + } + if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) { + $filesize = int($filesize/1000); #expressed in kb + $$upload_output = &Apache::loncommon::excess_filesize_warning($coursenum,$coursedom,'course', + $env{'form.uploaddoc.filename'},$filesize,'upload'); + return if ($$upload_output); + } my ($parseaction,$showupload,$nextphase,$mimetype); if ($env{'form.parserflag'}) { $parseaction = 'parse'; @@ -3025,7 +3106,7 @@ END } if ($denied{'copy'}) { - $copylink=(<$lt{'cp'} ENDCOPY } else { @@ -3034,7 +3115,7 @@ ENDCOPY $copylink=(< $form_common -$lt{'cp'} +$lt{'cp'} $form_end ENDCOPY if (($ishash) && (ref($filtersref->{'cancopy'}) eq 'ARRAY')) { @@ -3051,7 +3132,8 @@ ENDCUT $cutlink=(< $form_common -$lt{'ct'} + +$lt{'ct'} $form_end ENDCUT if (($ishash) && (ref($filtersref->{'cancut'}) eq 'ARRAY')) { @@ -3068,18 +3150,17 @@ ENDREM $removelink=(< $form_common -$lt{'rm'} + +$lt{'rm'} $form_end ENDREM if (($ishash) && (ref($filtersref->{'canremove'}) eq 'ARRAY')) { push(@{$filtersref->{'canremove'}},$orderidx); } } - unless ($isexternal) { - $renamelink=(<$lt{'rn'} ENDREN - } $line.=(<
    @@ -3100,11 +3181,10 @@ ENDREN $selectbox $form_end
    + $removelink $cutlink $copylink -