--- loncom/interface/londocs.pm 2013/05/11 00:01:52 1.484.2.31 +++ loncom/interface/londocs.pm 2013/04/02 00:07:08 1.541 @@ -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.541 2013/04/02 00:07:08 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -340,8 +340,10 @@ sub group_import { } my $initialtext = &mt('Replace with your own content.'); my $newhtml = < + + + $name @@ -350,7 +352,7 @@ $initialtext END $env{'form.output'}=$newhtml; - my $result = + my $result = &Apache::lonnet::finishuserfileupload($coursenum,$coursedom, 'output', "$filepath/$residx/$fname.html"); @@ -375,7 +377,7 @@ END removefrommap => \%removefrommap, removeparam => \%removeparam, ); - my ($result,$msgsarray,$lockerror) = + my ($result,$msgsarray,$lockerror) = &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated); if (keys(%import_errors) > 0) { $fixuperrors = @@ -1064,6 +1066,7 @@ END } + sub do_paste_from_buffer { my ($coursenum,$coursedom,$folder,$container,$errors) = @_; @@ -1307,7 +1310,7 @@ sub do_paste_from_buffer { next; } if ($lockerr{$prefix}) { - $lockerrs{$suffix} = $lockerr{$prefix}; + $lockerrs{$suffix} = $lockerr{$prefix}; } } } @@ -1346,7 +1349,7 @@ sub do_paste_from_buffer { if ($newdocsdir eq '') { $newdocsdir = 'default'; } - if (($prefixchg{$suffix}) || + if (($prefixchg{$suffix}) || ($srcdom{$suffix} ne $coursedom) || ($srcnum{$suffix} ne $coursenum) || ($env{'form.docs.markedcopy_options_'.$suffix} ne 'move')) { @@ -1553,7 +1556,7 @@ sub dbcopy { if (ref($dbref) eq 'HASH') { if ($url =~ m{/(smppg|bulletinboard)$}) { my $prefix = $1; - if (($dbref->{'cdom'} =~ /^$match_domain$/) && + if (($dbref->{'cdom'} =~ /^$match_domain$/) && ($dbref->{'cnum'} =~ /^$match_courseid$/)) { my $db_name; my $marker = (split(m{/},$url))[4]; @@ -1588,12 +1591,12 @@ sub dbcopy { my $photo = $contents{'uploaded.photourl'}; my ($subdir,$fname) = ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$}); - my $newphoto; + my $newphoto; if ($fname ne '') { my $content = &Apache::lonnet::getfile($photo); unless ($content eq '-1') { $env{'form.'.$suffix.'.photourl'} = $content; - $newphoto = + $newphoto = &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname"); delete($env{'form.'.$suffix.'.photourl'}); } @@ -1610,11 +1613,11 @@ 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} .= + $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.'); @@ -1736,7 +1739,7 @@ sub url_paste_fixups { } next if ($token->[2]->{'type'} eq 'external'); if ($token->[2]->{'type'} eq 'zombie') { - next if ($skip); + next if ($skip); $zombies->{$oldurl}{$id} = $ressrc; $changed = 1; } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) { @@ -2182,7 +2185,7 @@ sub update_parameter { 'randomorder' => {}, ); foreach my $which (keys(%allchecked)) { - $env{'form.all'.$which} =~ s/,$//; + $env{'form.all'.$which} =~ s/,$//; if ($which eq 'randompick') { foreach my $item (split(/,/,$env{'form.all'.$which})) { my ($res,$value) = split(/:/,$item); @@ -2209,7 +2212,7 @@ sub update_parameter { foreach my $which (keys(%allchecked)) { if (($which eq 'randompick' || $which eq 'randomorder')) { next if (!$is_map); - } + } my $oldvalue = 0; my $newvalue = 0; if ($allchecked{$which}{$res}) { @@ -2267,9 +2270,7 @@ sub update_parameter { sub handle_edit_cmd { my ($coursenum,$coursedom) =@_; - if ($env{'form.cmd'} eq '') { - return 0; - } + return if ($env{'form.cmd'} eq ''); my ($cmd,$idx)=split('_',$env{'form.cmd'}); my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]; @@ -2597,13 +2598,9 @@ sub editor { my ($to_show,$output,@allidx,@allmapidx,%filters,%lists,%curr_groups); %filters = ( - canremove => [], - cancut => [], - cancopy => [], - hiddenresource => [], - encrypturl => [], - randomorder => [], - randompick => [], + canremove => [], + cancut => [], + cancopy => [], ); %curr_groups = &Apache::longroup::coursegroups(); &Apache::loncommon::start_data_table_count(); #setup a row counter @@ -2628,9 +2625,7 @@ sub editor { my $need_save; if (($allowed) || ($supplementalflag && $folder eq 'supplemental')) { - my $toolslink; - if ($allowed || &Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { - $toolslink = ''. '
' + my $toolslink = '' @@ -2640,7 +2635,6 @@ 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') @@ -2656,23 +2650,19 @@ sub editor { if ($folder !~ /^supplemental/) { $lists{'canhide'} = join(',',@allidx); $lists{'canrandomlyorder'} = join(',',@allmapidx); - my @possfilters = ('canremove','cancut','cancopy','hiddenresource','encrypturl', - 'randomorder','randompick'); - foreach my $item (@possfilters) { + foreach my $item ('canremove','cancut','cancopy') { if (ref($filters{$item}) eq 'ARRAY') { - if (@{$filters{$item}} > 0) { - $lists{$item} = join(',',@{$filters{$item}}); - } + $lists{$item} = join(',',@{$filters{$item}}); } } if (@allidx > 0) { my $path; if ($env{'form.folderpath'}) { - $path = + $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); } if (@allidx > 1) { - $to_show .= + $to_show .= &Apache::loncommon::continue_data_table_row(). '
 '. @@ -2784,11 +2774,7 @@ sub multiple_check_form { ''; if ($caller eq 'settings') { $output .= - ''."\n". - ''."\n". - ''."\n". - ''."\n". - ''."\n"; + ''; } elsif ($caller eq 'actions') { $output .= ''. @@ -3071,7 +3057,7 @@ END } if ($denied{'copy'}) { - $copylink=(<$lt{'cp'} ENDCOPY } else { @@ -3097,7 +3083,6 @@ ENDCUT $cutlink=(< $form_common - $lt{'ct'} $form_end ENDCUT @@ -3115,7 +3100,6 @@ ENDREM $removelink=(< $form_common - $lt{'rm'} $form_end ENDREM @@ -3238,9 +3222,6 @@ 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 = @@ -3253,20 +3234,15 @@ $form_common."\n". } $rand_pick_text .= ''. $form_end; - 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 $ro_set= + ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':''); my $formname = 'edit_rorder_'.$orderidx; $rand_order_text = '
'."\n". $form_param."\n". $form_common."\n". ''. -$form_end; +$form_end; } } elsif ($supplementalflag && !$allowed) { $url .= ($url =~ /\?/) ? '&':'?'; @@ -3336,19 +3312,10 @@ $form_end; my %lt=&Apache::lonlocal::texthash( 'hd' => 'Hidden', 'ec' => 'URL hidden'); - 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 $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 $formhidden = 'edit_hiddenresource_'.$orderidx; my $formurlhidden = 'edit_encrypturl_'.$orderidx; $line.=(<    '.&mt('Content Overview').'    '."\n"; $output .= '     '.&mt('Content Search').'     '."\n"; + $output .= '      '.&mt('Content Index').'      '."\n"; $output .= '
  • '.&mt('Supplemental Content').'
  • '; } else { $output .= '
  •       '.&mt('Content Editor').'      
  • '."\n"; @@ -4424,7 +4392,7 @@ sub handler { 'navc' => 'Table of Contents', 'sipa' => 'Simple Course Page', 'sipr' => 'Simple Problem', - 'webp' => 'Blank Web Page (editable)', + 'webp' => 'Blank Web Page (editable)', 'drbx' => 'Drop Box', 'scuf' => 'External Scores (handgrade, upload, clicker)', 'bull' => 'Discussion Board', @@ -5329,7 +5297,7 @@ sub editing_js { p_msb => 'Title for the Problem', p_mdb => 'Title for the Drop Box', p_mbb => 'Title for the Discussion Board', - p_mwp => 'Title for Web Page', + p_mwp => 'Title for Web Page', p_mab => "Enter user:domain for User's Personal Information Page", p_mab2 => 'Personal Information Page of ', p_mab_alrt1 => 'Not a valid user:domain', @@ -5338,14 +5306,10 @@ sub editing_js { p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!', p_rmr2a => 'Remove[_99]', p_rmr2b => '?[_99]', - p_rmr3a => 'Remove those [_2]', - p_rmr3b => 'items?[_2]', p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!', p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.', p_ctr2a => 'Cut[_98]', p_ctr2b => '?[_98]', - p_ctr3a => 'Cut those[_2]', - p_ctr3b => 'items?[_2]', rpck => 'Enter number to pick (e.g., 3)', imsfile => 'You must choose an IMS package for import', imscms => 'You must select which Course Management System was the source of the IMS package', @@ -5353,9 +5317,6 @@ sub editing_js { titbl => 'Title is blank', more => '(More ...)', less => '(Less ...)', - noor => 'No actions selected or changes to settings specified.', - noch => 'No changes to settings specified.', - noac => 'No actions selected.', ); my $crstype = &Apache::loncommon::course_type(); @@ -5379,8 +5340,6 @@ sub editing_js { if (&Apache::lonnet::is_on_map($res)) { $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($res),'<>&"').'?symb='. &HTML::Entities::encode($caller,'<>&"'); - } else { - $backtourl = '/adm/navmaps'; } } } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') { @@ -5443,7 +5402,7 @@ function makewebpage(type) { formname = this.document.forms.newwebpage; } if (title) { - var webpage = formname.importdetail.value; + var webpage = formname.importdetail.value; formname.importdetail.value = escape(title)+'='+webpage; formname.submit(); } @@ -5991,8 +5950,6 @@ function checkSubmits() { var numchanges = 0; var form = document.saveactions; var doactions = multiActions(); - var cutwarnings = 0; - var remwarnings = 0; if (doactions == 1) { var remidxlist = document.cumulativeactions.allremoveidx.value; if ((remidxlist != '') && (remidxlist != null)) { @@ -6002,11 +5959,6 @@ function checkSubmits() { if (document.getElementById('remove_'+remidxs[i]).checked) { form.multiremove.value += remidxs[i]+','; numchanges ++; - if (document.getElementById('skip_remove_'+remidxs[i])) { - if (document.getElementById('skip_remove_'+remidxs[i]).value == 0) { - remwarnings ++; - } - } } } } @@ -6019,11 +5971,6 @@ function checkSubmits() { if (document.getElementById('cut_'+cutidxs[i]).checked == true) { form.multicut.value += cutidxs[i]+','; numchanges ++; - if (document.getElementById('skip_cut_'+cutidxs[i])) { - if (document.getElementById('skip_cut_'+cutidxs[i]).value == 0) { - cutwarnings ++; - } - } } } } @@ -6045,12 +5992,10 @@ function checkSubmits() { } } var dosettings = multiSettings(); - var haschanges = 0; if (dosettings == 1) { form.allencrypturl.value = ''; form.allhiddenresource.value = ''; - form.changeparms.value = 'all'; - var patt=new RegExp(",\$"); + form.changeparms.value = 'all'; var allidxlist = document.cumulativesettings.allidx.value; if ((allidxlist != '') && (allidxlist != null)) { var allidxs = allidxlist.split(','); @@ -6067,8 +6012,6 @@ function checkSubmits() { } } } - form.allhiddenresource.value = form.allhiddenresource.value.replace(patt,""); - form.allencrypturl.value = form.allencrypturl.value.replace(patt,""); } } form.allrandompick.value = ''; @@ -6087,55 +6030,12 @@ function checkSubmits() { form.allrandomorder.value += allmapidxs[i]+','; } } - form.allrandompick.value = form.allrandompick.value.replace(patt,""); - form.allrandomorder.value = form.allrandomorder.value.replace(patt,""); - } - if (document.cumulativesettings.currhiddenresource.value != form.allhiddenresource.value) { - haschanges = 1; - } - if (document.cumulativesettings.currencrypturl.value != form.allencrypturl.value) { - haschanges = 1; - } - if (document.cumulativesettings.currrandomorder.value != form.allrandomorder.value) { - haschanges = 1; - } - if (document.cumulativesettings.currrandompick.value != form.allrandompick.value) { - haschanges = 1; - } - } - if (doactions == 1) { - if (numchanges > 0) { - if ((cutwarnings > 0) || (remwarnings > 0)) { - if (remwarnings > 0) { - if (!confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr3a"} '+remwarnings+' $lt{"p_rmr3b"}')) { - return false; - } - } - if (cutwarnings > 0) { - if (!confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr3a"} '+cutwarnings+' $lt{"p_ctr3b"}')) { - return false; - } - } - } - form.submit(); - return true; - } - } - if (dosettings == 1) { - if (haschanges == 1) { - form.submit(); - return true; - } - } - if ((dosettings == 1) && (doactions == 1)) { - alert("$lt{'noor'}"); - } else { - if (dosettings == 1) { - alert("$lt{'noch'}"); - } else { - alert("$lt{'noac'}"); } } + if ((numchanges > 0) || (dosettings == 1)) { + form.submit(); + return true; + } return false; }