--- loncom/interface/londocs.pm 2013/04/01 22:09:56 1.540 +++ loncom/interface/londocs.pm 2013/08/06 14:18:52 1.556 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.540 2013/04/01 22:09:56 raeburn Exp $ +# $Id: londocs.pm,v 1.556 2013/08/06 14:18:52 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -340,10 +340,8 @@ sub group_import { } my $initialtext = &mt('Replace with your own content.'); my $newhtml = < - + - $name @@ -490,7 +488,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 = ''; @@ -902,7 +900,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 +1007,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 +1037,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) = @_; @@ -2246,7 +2267,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]]; @@ -2307,7 +2330,7 @@ sub editor { my $jumpto; unless ($supplementalflag) { - $jumpto = "'uploaded/$coursedom/$coursenum/$folder.$container'"; + $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container"; } unless ($allowed) { @@ -2351,24 +2374,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". @@ -2568,9 +2597,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 @@ -2595,7 +2628,9 @@ sub editor { my $need_save; if (($allowed) || ($supplementalflag && $folder eq 'supplemental')) { - my $toolslink = '
' + my $toolslink; + if ($allowed || &Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { + $toolslink = '' @@ -2605,6 +2640,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') @@ -2620,9 +2656,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) { @@ -2664,7 +2704,7 @@ sub editor { } $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll') .'
' - .&mt('Currently no documents.') + .&mt('Currently empty') .'
' .&Apache::loncommon::end_scrollbox(); } @@ -2677,7 +2717,7 @@ sub editor { .''; } else { $to_show = '
' - .&mt('Currently no documents.') + .&mt('Currently empty') .'
' } } @@ -2744,7 +2784,11 @@ sub multiple_check_form { ''; if ($caller eq 'settings') { $output .= - ''; + ''."\n". + ''."\n". + ''."\n". + ''."\n". + ''."\n"; } elsif ($caller eq 'actions') { $output .= ''. @@ -2758,8 +2802,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'; @@ -3027,7 +3093,7 @@ END } if ($denied{'copy'}) { - $copylink=(<$lt{'cp'} ENDCOPY } else { @@ -3053,6 +3119,7 @@ ENDCUT $cutlink=(< $form_common + $lt{'ct'} $form_end ENDCUT @@ -3070,6 +3137,7 @@ ENDREM $removelink=(< $form_common + $lt{'rm'} $form_end ENDREM @@ -3077,11 +3145,9 @@ ENDREM push(@{$filtersref->{'canremove'}},$orderidx); } } - unless ($isexternal) { - $renamelink=(<$lt{'rn'} ENDREN - } $line.=(<
@@ -3192,6 +3258,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 = @@ -3204,8 +3273,13 @@ $form_common."\n". } $rand_pick_text .= ''. $form_end; - my $ro_set= - ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':''); + 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); + } + } my $formname = 'edit_rorder_'.$orderidx; $rand_order_text = ''."\n". @@ -3282,10 +3356,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.=(<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; @@ -3691,7 +3774,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\/.+)$/) { @@ -3969,7 +4052,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').'      '; @@ -3990,7 +4073,7 @@ sub endContentScreen { } sub supplemental_base { - return 'supplemental&'.&escape(&mt('Supplemental '.&Apache::loncommon::course_type().' Content')); + return 'supplemental&'.&escape(&mt('Supplemental Content')); } sub handler { @@ -4015,7 +4098,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 @@ -4031,8 +4115,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. @@ -4123,7 +4205,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&'. @@ -4168,7 +4250,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'). ':::::'); } } @@ -4194,7 +4276,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 = ''; @@ -4297,7 +4379,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(); } @@ -4349,7 +4431,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', @@ -4370,8 +4452,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', @@ -4519,7 +4601,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 = ''; } @@ -4575,6 +4657,7 @@ NSPROBFORM $pathitem $lt{'drbx'} + $help{'Dropbox'} NDBFORM @@ -4625,7 +4708,7 @@ NASOFORM $lt{'rost'} - $help{'Course Roster'} + $help{'Course_Roster'} NROSTFORM @@ -4645,7 +4728,7 @@ NROSTFORM $pathitem $lt{'webp'} - $help{'Web Page'} + $help{'Web_Page'} NWEBFORM @@ -4744,14 +4827,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; @@ -4862,7 +4945,7 @@ SNAMFORM $pathitem $lt{'webp'} - $help{'Web Page'} + $help{'Web_Page'} SWEBFORM @@ -4885,8 +4968,8 @@ 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, @@ -5172,7 +5255,7 @@ sub generate_edit_table { $form = '
    '. '