--- loncom/interface/londocs.pm 2013/05/11 00:01:52 1.484.2.31 +++ loncom/interface/londocs.pm 2013/08/17 00:59:32 1.484.2.38 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.484.2.31 2013/05/11 00:01:52 raeburn Exp $ +# $Id: londocs.pm,v 1.484.2.38 2013/08/17 00:59:32 raeburn 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); } @@ -402,6 +407,11 @@ END } my ($errtext,$fatal) = &storemap($coursenum, $coursedom, $folder.'.'.$container,1); + unless ($fatal) { + if ($folder =~ /^supplemental/) { + &Apache::lonnet::get_numsuppfiles($coursenum,$coursedom,1); + } + } return ($errtext,$fatal,$fixuperrors); } @@ -488,7 +498,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 = ''; @@ -1615,11 +1625,13 @@ sub dbcopy { &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.'); + ' '.&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 bulletin 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$}) { @@ -2330,7 +2342,7 @@ sub editor { my $jumpto; unless ($supplementalflag) { - $jumpto = "'uploaded/$coursedom/$coursenum/$folder.$container'"; + $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container"; } unless ($allowed) { @@ -2704,7 +2716,7 @@ sub editor { } $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll') .'
' - .&mt('Currently no documents.') + .&mt('Currently empty') .'
' .&Apache::loncommon::end_scrollbox(); } @@ -2717,7 +2729,7 @@ sub editor { .''; } else { $to_show = '
' - .&mt('Currently no documents.') + .&mt('Currently empty') .'
' } } @@ -2802,8 +2814,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'; @@ -3123,11 +3157,9 @@ ENDREM push(@{$filtersref->{'canremove'}},$orderidx); } } - unless ($isexternal) { - $renamelink=(<$lt{'rn'} ENDREN - } $line.=(<
@@ -3486,7 +3518,8 @@ sub new_timebased_suffix { } unless ($type eq 'paste') { $locknotfreed .= - ' '.&mt('Please contact the domain coordinator for your LON-CAPA domain.'); + ' '.&mt('Please contact the [_1]helpdesk[_2] for assistance.', + '',''); } $locknotfreed .= '
'; } @@ -3651,8 +3684,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; @@ -3754,7 +3787,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\/.+)$/) { @@ -4031,7 +4064,7 @@ sub startContentScreen { $output .= '     '.&mt('Content Search').'     '."\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').'      '; @@ -4052,7 +4085,7 @@ sub endContentScreen { } sub supplemental_base { - return 'supplemental&'.&escape(&mt('Supplemental '.&Apache::loncommon::course_type().' Content')); + return 'supplemental&'.&escape(&mt('Supplemental Content')); } sub handler { @@ -4077,7 +4110,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 @@ -4093,8 +4127,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. @@ -4185,7 +4217,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&'. @@ -4230,7 +4262,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'). ':::::'); } } @@ -4256,7 +4288,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 = ''; @@ -4359,7 +4391,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(); } @@ -4411,7 +4443,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', @@ -4432,8 +4464,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', @@ -4581,7 +4613,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 = ''; } @@ -4637,6 +4669,7 @@ NSPROBFORM $pathitem $lt{'drbx'} + $help{'Dropbox'} NDBFORM @@ -4687,7 +4720,7 @@ NASOFORM $lt{'rost'} - $help{'Course Roster'} + $help{'Course_Roster'} NROSTFORM @@ -4707,7 +4740,7 @@ NROSTFORM $pathitem $lt{'webp'} - $help{'Web Page'} + $help{'Web_Page'} NWEBFORM @@ -4784,7 +4817,7 @@ NGFFORM ); } push(@importdoc, - {''.$lt{upl}.''=>$fileuploadform} + {''.$lt{upl}.''=>$fileuploadform} ); $fileuploadform = &create_form_ul(&create_list_elements(@importdoc)); @@ -4806,14 +4839,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; @@ -4924,7 +4957,7 @@ SNAMFORM $pathitem $lt{'webp'} - $help{'Web Page'} + $help{'Web_Page'} SWEBFORM @@ -4947,14 +4980,26 @@ 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) { @@ -5234,7 +5279,7 @@ sub generate_edit_table { $form = '
    '. '