--- loncom/interface/londocs.pm 2023/07/11 22:24:29 1.702 +++ 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.702 2023/07/11 22:24:29 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; @@ -9148,7 +9176,7 @@ END - +Course Authoring Rights END close($fh); }