--- loncom/interface/londocs.pm 2023/07/11 12:44:18 1.700 +++ loncom/interface/londocs.pm 2023/07/16 03:50:54 1.703 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.700 2023/07/11 12:44:18 raeburn Exp $ +# $Id: londocs.pm,v 1.703 2023/07/16 03:50:54 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1485,6 +1485,14 @@ sub print_paste_buffer { $nopaste = &mt('Paste from another course unavailable.'); } } + } elsif ($url =~ m{/res/($match_domain)/($match_username)/}) { + my ($audom,$auname) = ($1,$2); + unless (($auname eq $coursenum) && ($audom eq $coursedom)) { + if (&Apache::lonnet::is_course($audom,$auname)) { + $canpaste = 0; + $nopaste = &mt('Paste from another course unavailable.'); + } + } } if ($canpaste) { push(@pasteable,$suffix); @@ -1825,6 +1833,16 @@ sub do_paste_from_buffer { } $srcdom{$suffix} = $srcd; $srcnum{$suffix} = $srcn; + } elsif ($url =~ m{^/res/($match_domain)/($match_courseid)/}) { + my ($audom,$auname) = ($1,$2); +# When buffer was populated using an active role in a different course +# disallow pasting of published resources from Course Authoring Space + unless (($auname eq $coursenum) && ($audom eq $coursedom)) { + if (&Apache::lonnet::is_course($audom,$auname)) { + $othcrsres{$suffix} = 1; + next; + } + } } $srcmapidx{$suffix} = $mapidx; push(@dopaste,$suffix); @@ -1876,6 +1894,7 @@ sub do_paste_from_buffer { 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 domain.', + othcrsres => 'Paste failed: Item is a course-authored resource from a different course', duplicate => 'Paste failed: only one instance of a particular published sequence or page is allowed within each course.', ); @@ -2522,6 +2541,15 @@ sub contained_map_check { next; } } + if ($ressrc =~ m{^/res/($match_domain)/($match_courseid)/}) { + my ($srcdom,$srcnum) = ($1,$2); + unless (($srcnum eq $coursenum) && ($srcdom eq $coursedom)) { + if (&Apache::lonnet::is_course($srcdom,$srcnum)) { + $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc; + next; + } + } + } if ($ressrc =~ m{^/(res|uploaded)/.+\.(sequence|page)$}) { if ($1 eq 'uploaded') { $hierarchy->{$url}{$token->[2]->{'id'}} = $ressrc; @@ -4554,7 +4582,7 @@ $form_end; } else { $reinit = &mt('(re-initialize course to access)'); } - $line.=''.$editlink.$renamelink; + $line.=''.$editlink.$renamelink.''; if ($orig_url =~ /$LONCAPA::assess_re/) { $line.= '
'; if ($curralias ne '') { @@ -4565,7 +4593,7 @@ $form_end; $lt{'sa'}.'
'; } } - $line.=''; + $line.=''; my ($link,$nolink); if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) { if ($allowed && !$env{'request.role.adv'} && !$isfolder && !$ispage) { @@ -6233,10 +6261,7 @@ sub handler { my $fileupload=(< - - FIUP - my $checkbox=(<$lt{'parse'}? @@ -6256,6 +6281,8 @@ CHBO