--- loncom/interface/londocs.pm 2017/05/10 23:34:15 1.630 +++ loncom/interface/londocs.pm 2017/07/10 12:48:41 1.633 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.630 2017/05/10 23:34:15 raeburn Exp $ +# $Id: londocs.pm,v 1.633 2017/07/10 12:48:41 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1672,8 +1672,8 @@ sub do_paste_from_buffer { $srcdom{$suffix} = $srcd; $srcnum{$suffix} = $srcn; } elsif (($url =~ m{^/res/lib/templates/\w+\.problem$}) || - ($url =~ m{^/adm/$match_domain/$match_username/\d+/(bulletinboard|smppg|ext\.tool)$})) { - my $srctype= $1; + ($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 @@ -1683,7 +1683,9 @@ sub do_paste_from_buffer { next; } } - if (($srctype eq 'ext.tool') && ($srcd ne $coursedom)) { +# When buffer was populated using an active role in a different course +# disallow pasting of External Tool if course is in a different domain. + if (($url =~ m{/ext\.tool$}) && ($srcd ne $coursedom)) { $notindom{$suffix} = 1; next; } @@ -2164,6 +2166,8 @@ sub dbcopy { if (!$suffix) { if ($prefix eq 'smppg') { $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url); + } elsif ($prefix eq 'exttool') { + $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying an external tool [_1].',$url); } else { $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a discussion board [_1].',$url); } @@ -3014,8 +3018,9 @@ sub update_parameter { sub handle_edit_cmd { my ($coursenum,$coursedom) =@_; + my $haschanges = 0; if ($env{'form.cmd'} eq '') { - return 0; + return $haschanges; } my ($cmd,$idx)=split('_',$env{'form.cmd'}); @@ -3030,19 +3035,19 @@ sub handle_edit_cmd { &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]); } splice(@LONCAPA::map::order, $idx, 1); - + $haschanges = 1; } elsif ($cmd eq 'cut') { &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]); splice(@LONCAPA::map::order, $idx, 1); - + $haschanges = 1; } elsif ($cmd eq 'up' && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) { @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1]; - + $haschanges = 1; } elsif ($cmd eq 'down' && defined($LONCAPA::map::order[$idx+1])) { @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1]; - + $haschanges = 1; } elsif ($cmd eq 'rename') { my $comment = &LONCAPA::map::qtunescape($env{'form.title'}); if ($comment=~/\S/) { @@ -3052,11 +3057,26 @@ sub handle_edit_cmd { # Devalidate title cache my $renamed_url=&LONCAPA::map::qtescape($url); &Apache::lonnet::devalidate_title_cache($renamed_url); - - } else { - return 0; + $haschanges = 1; + } elsif ($cmd eq 'setalias') { + my $newvalue = $env{'form.alias'}; + if ($newvalue ne '') { + unless (Apache::lonnet::get_symb_from_alias($newvalue)) { + &LONCAPA::map::storeparameter($idx,'parameter_0_mapalias',$newvalue, + 'string'); + &remember_parms($idx,'mapalias','set',$newvalue); + $haschanges = 1; + } + } + } elsif ($cmd eq 'delalias') { + my $current = (&LONCAPA::map::getparameter($idx,'parameter_0_mapalias'))[0]; + if ($current ne '') { + &LONCAPA::map::delparameter($idx,'parameter_0_mapalias'); + &remember_parms($idx,'mapalias','del'); + $haschanges = 1; + } } - return 1; + return $haschanges; } sub editor { @@ -3180,7 +3200,7 @@ sub editor { # Rename, cut, copy or remove a single resource if (&handle_edit_cmd($coursenum,$coursedom)) { my $contentchg; - if ($env{'form.cmd'} =~ m{^(remove|cut)_}) { + if ($env{'form.cmd'} =~ m{^(remove|cut|setalias|delalias)_}) { $contentchg = 1; } ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg); @@ -3420,10 +3440,10 @@ sub editor { .&Apache::loncommon::start_data_table(undef,'contentlist') .&Apache::loncommon::start_data_table_header_row() .'