--- loncom/interface/londocs.pm 2008/12/13 00:19:07 1.320 +++ loncom/interface/londocs.pm 2008/12/15 03:02:19 1.321 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.320 2008/12/13 00:19:07 raeburn Exp $ +# $Id: londocs.pm,v 1.321 2008/12/15 03:02:19 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1270,7 +1270,9 @@ ENDPASTE sub do_paste_from_buffer { my ($coursenum,$coursedom,$folder) = @_; - return 0 if (!$env{'form.pastemarked'}); + if (!$env{'form.pastemarked'}) { + return; + } # paste resource to end of list my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}); @@ -1283,8 +1285,16 @@ sub do_paste_from_buffer { my $newurl=$1.$newid.'.'.$2; my $storefn=$newurl; $storefn=~s{^/\w+/$match_domain/$match_username/}{}; - &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn, - &Apache::lonnet::getfile($url)); + my $paste_map_result = + &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn, + &Apache::lonnet::getfile($url)); + if ($paste_map_result eq '/adm/notfound.html') { + if ($url=~/\.page$/) { + return &mt('Paste failed: an error occurred saving the composite page'); + } else { + return &mt('Paste failed: an error occurred saving the folder'); + } + } $url = $newurl; } # published maps can only exists once, so remove it from paste buffer when done @@ -1326,6 +1336,7 @@ sub do_paste_from_buffer { $LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res'; push(@LONCAPA::map::order, $newidx); + return 'ok'; # Store the result } @@ -1444,9 +1455,14 @@ sub editor { } if ($env{'form.pastemarked'}) { - &do_paste_from_buffer($coursenum,$coursedom,$folder); - ($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container); - return $errtext if ($fatal); + my $paste_res = + &do_paste_from_buffer($coursenum,$coursedom,$folder); + if ($paste_res eq 'ok') { + ($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container); + return $errtext if ($fatal); + } elsif ($paste_res ne '') { + $r->print('
'.$paste_res.'
'); + } } $r->print($upload_output);