--- loncom/interface/londocs.pm 2020/01/16 15:21:23 1.484.2.72.2.7 +++ loncom/interface/londocs.pm 2020/04/10 12:52:34 1.484.2.72.4.2 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.484.2.72.2.7 2020/01/16 15:21:23 raeburn Exp $ +# $Id: londocs.pm,v 1.484.2.72.4.2 2020/04/10 12:52:34 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -43,7 +43,6 @@ use Apache::lonnavdisplay(); use Apache::lonextresedit(); use Apache::lontemplate(); use Apache::lonsimplepage(); -use Apache::loncourserespicker(); use HTML::Entities; use HTML::TokeParser; use GDBM_File; @@ -657,7 +656,7 @@ sub group_import { my $marker = $2; my $info = $3; my ($toolid,%toolhash,%toolsettings); - my @extras = ('linktext','explanation','crslabel','crstitle'); + my @extras = ('linktext','explanation','crslabel','crstitle','crsappend'); my @toolinfo = split(/:/,$info); if ($residx) { %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum); @@ -668,7 +667,7 @@ sub group_import { $toolid =~ s/\D//g; ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'}, $toolhash{'linktext'},$toolhash{'explanation'}, - $toolhash{'crslabel'},$toolhash{'crstitle'}) = @toolinfo; + $toolhash{'crslabel'},$toolhash{'crstitle'},$toolhash{'crsappend'}) = @toolinfo; foreach my $item (@extras) { $toolhash{$item} = &unescape($toolhash{$item}); } @@ -1326,8 +1325,7 @@ sub print_paste_buffer { } $is_uploaded_map = 1; } - } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) || - ($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg|ext\.tool)$})) { + } elsif ($url =~ m{^/adm/($match_domain)/($match_username)/\d+/(bulletinboard|smppg|ext\.tool)$}) { if ($cid ne $env{'request.course.id'}) { my ($srcdom,$srcnum) = split(/_/,$cid); if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) { @@ -1348,7 +1346,7 @@ sub print_paste_buffer { push(@pasteable,$suffix); } my $buffer; - if ($is_external) { + if ($is_external) { $buffer = &mt('External Resource').': '. &LONCAPA::map::qtescape($env{'docs.markedcopy_title_'.$suffix}).' ('. &LONCAPA::map::qtescape($url).')'; @@ -1661,7 +1659,8 @@ sub do_paste_from_buffer { } $srcdom{$suffix} = $srcd; $srcnum{$suffix} = $srcn; - } elsif ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$}) { + } elsif (($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg)$}) || + ($url =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$})) { my ($srcd,$srcn) = split(/_/,$cid); # When paste buffer was populated using an active role in a different course # check for mdc privilege in the course from which the resource was pasted @@ -1729,7 +1728,7 @@ sub do_paste_from_buffer { %msgs = &Apache::lonlocal::texthash ( notinsupp => 'Paste failed: content type is not supported within Supplemental Content', notincrs => 'Paste failed: Item is from a different course which you do not have rights to edit.', - notindom => 'Paste failed: Item is an external tool from a course in a different donain.', + notindom => 'Paste failed: Item is an external tool from a course in a different domain.', duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.', ); @@ -1838,7 +1837,7 @@ sub do_paste_from_buffer { } } } - if ($url=~ m{/(ext\.tool)$}) { + if ($url=~ m{/(bulletinboard|smppg|ext\.tool)$}) { my $prefix = $1; my $fromothercrs; #need to copy the db contents to a new one, unless this is a move. @@ -1862,7 +1861,11 @@ sub do_paste_from_buffer { $url = $newurl; $title=&mt('Copy of').' '.$title; } else { - if ($prefix eq 'ext.tool') { + 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 discussion board.').' '.$errtext; + } elsif ($prefix eq 'ext.tool') { $msg = &mt('Paste failed: An error occurred when copying the external tool.').' '.$errtext; } $results{$suffix} = $result; @@ -2599,8 +2602,7 @@ sub apply_fixups { } } } - my $total = scalar(@LONCAPA::map::order) - 1; - for (my $i=$total; $i>=0; $i--) { + for (my $i=0; $i<@LONCAPA::map::order; $i++) { my $idx = $LONCAPA::map::order[$i]; if (defined($LONCAPA::map::resources[$idx])) { my $changed; @@ -2610,7 +2612,7 @@ sub apply_fixups { splice(@LONCAPA::map::order,$i,1); if (ref($currparam{$idx}) eq 'ARRAY') { foreach my $name (@{$currparam{$idx}}) { - &LONCAPA::map::delparameter($idx,$name); + &LONCAPA::map::delparameter($idx,'parameter_'.$name); } } next; @@ -2652,7 +2654,7 @@ sub apply_fixups { foreach my $idx (keys(%remparam)) { if (ref($remparam{$idx}) eq 'ARRAY') { foreach my $name (@{$remparam{$idx}}) { - &LONCAPA::map::delparameter($idx,$name); + &LONCAPA::map::delparameter($idx,'parameter_'.$name); } } } @@ -3927,7 +3929,7 @@ END } } if ($url ne '') { - $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($shownsymb); + $url.=(($url=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&'); } } elsif (!$env{'request.role.adv'}) { my $checkencrypt; @@ -3948,7 +3950,7 @@ END my $shownsymb = &Apache::lonenc::encrypted($symb); my $shownurl = &Apache::lonenc::encrypted($url); if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) { - $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb); + $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&'); if ($env{'request.enc'} ne '') { delete($env{'request.enc'}); } @@ -4498,47 +4500,6 @@ sub list_symbs { $r->print(&endContentScreen()); } -sub short_urls { - my ($r,$canedit) = @_; - my $crstype = &Apache::loncommon::course_type(); - my $formname = 'shortenurl'; - $r->print(&Apache::loncommon::start_page('Display/Set Shortened URLs')); - $r->print(&Apache::lonhtmlcommon::breadcrumbs('Shortened URLs')); - $r->print(&startContentScreen('tools')); - my ($navmap,$errormsg) = - &Apache::loncourserespicker::get_navmap_object($crstype,'shorturls'); - my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my (%maps,%resources,%titles); - if (!ref($navmap)) { - $r->print($errormsg. - &endContentScreen()); - return ''; - } else { - $r->print('
'.&mt('Created [quant,_1,URL]',$numnew).'
'); - } - if ((ref($errors) eq 'ARRAY') && (@{$errors} > 0)) { - $r->print(&mt('The following errors occurred when processing your request to create shortened URLs:').''.$error.'
'); } if ($hadchanges) { - unless (&is_hash_old()) { - &mark_hash_old(); - } + &mark_hash_old(); } + &changewarning($r,''); } } @@ -6010,6 +5910,7 @@ SNFFORM $help{'Adding_External_Resource'}, undef,undef,undef,undef,undef,undef, $disabled); + my $supexttoolform = &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem, $help{'Adding_External_Tool'}, @@ -6142,7 +6043,6 @@ my %suporderhash = ( sub embedded_form_elems { my ($phase,$primaryurl,$newidx) = @_; my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); - $newidx =~s /\D+//g; return <