version 1.528, 2013/01/09 04:01:16
|
version 1.529, 2013/01/09 04:31:57
|
Line 40 use Apache::lonxml;
|
Line 40 use Apache::lonxml;
|
use Apache::lonclonecourse; |
use Apache::lonclonecourse; |
use Apache::lonnavmaps; |
use Apache::lonnavmaps; |
use Apache::lonnavdisplay(); |
use Apache::lonnavdisplay(); |
use Apache::lonuserstate(); |
|
use Apache::lonextresedit(); |
use Apache::lonextresedit(); |
use HTML::Entities; |
use HTML::Entities; |
use HTML::TokeParser; |
use HTML::TokeParser; |
Line 271 sub dumpcourse {
|
Line 270 sub dumpcourse {
|
|
|
sub group_import { |
sub group_import { |
my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_; |
my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_; |
|
my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap, |
|
%removeparam,$importuploaded,$fixuperrors); |
|
$allmaps = {}; |
while (@files) { |
while (@files) { |
my ($name, $url, $residx) = @{ shift(@files) }; |
my ($name, $url, $residx) = @{ shift(@files) }; |
if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) |
if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) |
Line 297 sub group_import {
|
Line 298 sub group_import {
|
} |
} |
} |
} |
if ($url) { |
if ($url) { |
|
if (($caller eq 'londocs') && |
|
($folder =~ /^default/)) { |
|
unless ($donechk) { |
|
my $chome = &Apache::lonnet::homeserver($coursenum,$coursedom); |
|
my $cid = $coursedom.'_'.$coursenum; |
|
$allmaps = |
|
&Apache::loncommon::allmaps_incourse($coursedom,$coursenum, |
|
$chome,$cid); |
|
$donechk = 1; |
|
} |
|
if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) { |
|
&contained_map_check($url,$folder,\%removefrommap,\%removeparam, |
|
\%addedmaps,\%hierarchy,\%titles,$allmaps); |
|
$importuploaded = 1; |
|
} elsif ($url =~ m{^/res/.+\.(page|sequence)$}) { |
|
next if ($allmaps->{$url}); |
|
} |
|
} |
if (!$residx |
if (!$residx |
|| defined($LONCAPA::map::zombies[$residx])) { |
|| defined($LONCAPA::map::zombies[$residx])) { |
$residx = &LONCAPA::map::getresidx($url,$residx); |
$residx = &LONCAPA::map::getresidx($url,$residx); |
Line 310 sub group_import {
|
Line 329 sub group_import {
|
join(':', ($name, $url, $ext, 'normal', 'res')); |
join(':', ($name, $url, $ext, 'normal', 'res')); |
} |
} |
} |
} |
return &storemap($coursenum, $coursedom, $folder.'.'.$container,1); |
if ($importuploaded) { |
|
my %import_errors; |
|
my %updated = ( |
|
removefrommap => \%removefrommap, |
|
removeparam => \%removeparam, |
|
); |
|
&apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated); |
|
if (keys(%import_errors) > 0) { |
|
$fixuperrors = |
|
'<p span class="LC_warning">'."\n". |
|
&mt('The following files are either dependencies of a web page or references within a folder and/or composite page for which errors occurred during import:')."\n". |
|
'<ul>'."\n"; |
|
foreach my $key (sort(keys(%import_errors))) { |
|
$fixuperrors .= '<li>'.$key.'</li>'."\n"; |
|
} |
|
$fixuperrors .= '</ul></p>'."\n"; |
|
} |
|
} |
|
my ($errtext,$fatal) = |
|
&storemap($coursenum, $coursedom, $folder.'.'.$container,1); |
|
return ($errtext,$fatal,$fixuperrors); |
} |
} |
|
|
sub log_docs { |
sub log_docs { |
Line 895 sub do_paste_from_buffer {
|
Line 934 sub do_paste_from_buffer {
|
%dbcopies,%zombies,%params,%docmoves,%mapmoves,%newsubdir,%newurls); |
%dbcopies,%zombies,%params,%docmoves,%mapmoves,%newsubdir,%newurls); |
$oldurl = $url; |
$oldurl = $url; |
if ($is_map) { |
if ($is_map) { |
if ($folder =~ /^default/) { |
|
my $lastchange = &Apache::lonnet::get_coursechange($coursedom,$coursenum); |
|
if ($lastchange > $env{'request.course.tied'}) { |
|
&reinit_role($coursedom,$coursenum,$env{"course.$env{'request.course.id'}.home"}); |
|
} |
|
} |
|
# If pasting a map, check if map contains other maps |
# If pasting a map, check if map contains other maps |
my (%allmaps,%hierarchy,%titles); |
my ($allmaps,%hierarchy,%titles); |
|
$allmaps = {}; |
if ($folder =~ /^default/) { |
if ($folder =~ /^default/) { |
my $navmap = Apache::lonnavmaps::navmap->new(); |
$allmaps = |
if (defined($navmap)) { |
&Apache::loncommon::allmaps_incourse($coursedom,$coursenum, |
foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_map() },1,0,1)) { |
$env{"course.$env{'request.course.id'}.home"}, |
$allmaps{$res->src()} = 1; |
$env{'request.course.id'}); |
} |
|
} |
|
} |
} |
&contained_map_check($url,$folder,\%removefrommap,\%removeparam, |
&contained_map_check($url,$folder,\%removefrommap,\%removeparam, |
\%addedmaps,\%hierarchy,\%titles,\%allmaps); |
\%addedmaps,\%hierarchy,\%titles,$allmaps); |
if ($url=~ m{^/uploaded/}) { |
if ($url=~ m{^/uploaded/}) { |
my $newurl; |
my $newurl; |
unless ($env{'form.docs.markedcopy_options'} eq 'move') { |
unless ($env{'form.docs.markedcopy_options'} eq 'move') { |
($newurl,my $error) = |
($newurl,my $error) = |
&get_newmap_url($url,$folder,$prefixchg,$coursedom,$coursenum, |
&get_newmap_url($url,$folder,$prefixchg,$coursedom,$coursenum, |
$srcdom,$srcnum,\$title,\%allmaps,\%newurls); |
$srcdom,$srcnum,\$title,$allmaps,\%newurls); |
if ($error) { |
if ($error) { |
return ($error); |
return ($error); |
} |
} |
Line 934 sub do_paste_from_buffer {
|
Line 966 sub do_paste_from_buffer {
|
if (($srcdom ne $coursedom) || ($srcnum ne $coursenum) || ($prefixchg) || |
if (($srcdom ne $coursedom) || ($srcnum ne $coursenum) || ($prefixchg) || |
(($newurl ne '') && ($newurl ne $url))) { |
(($newurl ne '') && ($newurl ne $url))) { |
unless (&url_paste_fixups($url,$folder,$prefixchg,$coursedom,$coursenum, |
unless (&url_paste_fixups($url,$folder,$prefixchg,$coursedom,$coursenum, |
\%allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies, |
$allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies, |
\%zombies,\%params,\%mapmoves,\%mapchanges,\%tomove, |
\%zombies,\%params,\%mapmoves,\%mapchanges,\%tomove, |
\%newsubdir,\%newurls)) { |
\%newsubdir,\%newurls)) { |
$mapmoves{$url} = 1; |
$mapmoves{$url} = 1; |
} |
} |
$url = $newurl; |
$url = $newurl; |
} elsif ($env{'docs.markedcopy_nested'}) { |
} elsif ($env{'docs.markedcopy_nested'}) { |
&url_paste_fixups($url,$folder,$prefixchg,$coursedom,$coursenum,\%allmaps,\%rewrites, |
&url_paste_fixups($url,$folder,$prefixchg,$coursedom,$coursenum,$allmaps,\%rewrites, |
\%retitles,\%copies,\%dbcopies,\%zombies,\%params,\%mapmoves, |
\%retitles,\%copies,\%dbcopies,\%zombies,\%params,\%mapmoves, |
\%mapchanges,\%tomove,\%newsubdir,\%newurls); |
\%mapchanges,\%tomove,\%newsubdir,\%newurls); |
} |
} |
Line 950 sub do_paste_from_buffer {
|
Line 982 sub do_paste_from_buffer {
|
&Apache::lonnet::delenv('docs.markedcopy'); |
&Apache::lonnet::delenv('docs.markedcopy'); |
# if pasting published map (main content are only) check map is not already in course |
# if pasting published map (main content are only) check map is not already in course |
if ($folder =~ /^default/) { |
if ($folder =~ /^default/) { |
if ($allmaps{$url}) { |
if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) { |
return (&mt('Paste failed: only one instance of a particular published sequence or page is allowed within each course.')); |
return (&mt('Paste failed: only one instance of a particular published sequence or page is allowed within each course.')); |
} |
} |
} |
} |
Line 1016 sub do_paste_from_buffer {
|
Line 1048 sub do_paste_from_buffer {
|
} |
} |
# Apply any changes to maps, or copy dependencies for uploaded HTML pages |
# Apply any changes to maps, or copy dependencies for uploaded HTML pages |
my ($result,$save_err); |
my ($result,$save_err); |
|
my %updated = ( |
|
rewrites => \%rewrites, |
|
zombies => \%zombies, |
|
removefrommap => \%removefrommap, |
|
removeparam => \%removeparam, |
|
dbcopies => \%dbcopies, |
|
retitles => \%retitles, |
|
); |
|
my %info = ( |
|
newsubdir => \%newsubdir, |
|
params => \%params, |
|
before => \%before, |
|
after => \%after, |
|
); |
|
my %moves = ( |
|
copies => \%copies, |
|
docmoves => \%docmoves, |
|
mapmoves => \%mapmoves, |
|
); |
$result = |
$result = |
&apply_fixups($folder,$is_map,$prefixchg,$coursedom,$coursenum,$oldurl, |
&apply_fixups($folder,$is_map,$coursedom,$coursenum,$errors, |
$url,\%removefrommap,\%removeparam,\%rewrites,\%retitles, |
\%updated,\%info,\%moves,$prefixchg,$oldurl,$url,'paste'); |
\%copies,\%dbcopies,\%zombies,\%params,\%docmoves, |
|
\%mapmoves,\%newsubdir,$errors,\%before,\%after); |
|
if ($result eq 'ok') { |
if ($result eq 'ok') { |
if ($is_map) { |
if ($is_map) { |
my ($errtext,$fatal) = &mapread($coursenum,$coursedom, |
my ($errtext,$fatal) = &mapread($coursenum,$coursedom, |
Line 1180 sub contained_map_check {
|
Line 1229 sub contained_map_check {
|
$titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'}; |
$titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'}; |
} else { |
} else { |
if ($allmaps->{$ressrc}) { |
if ($allmaps->{$ressrc}) { |
$removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc; |
$removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc; |
} elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') { |
} elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') { |
$removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc; |
$removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc; |
} else { |
} else { |
Line 1204 sub contained_map_check {
|
Line 1253 sub contained_map_check {
|
return; |
return; |
} |
} |
|
|
sub reinit_role { |
|
my ($cdom,$cnum,$chome) = @_; |
|
my ($furl,$ferr) = &Apache::lonuserstate::readmap("$cdom/$cnum"); |
|
unless ($ferr) { |
|
&Apache::loncommon::update_content_constraints($cdom,$cnum,$chome,$cdom.'_'.$cnum); |
|
} |
|
return; |
|
} |
|
|
|
sub url_paste_fixups { |
sub url_paste_fixups { |
my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$allmaps,$rewrites,$retitles,$copies, |
my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$allmaps,$rewrites,$retitles,$copies, |
$dbcopies,$zombies,$params,$mapmoves,$mapchanges,$tomove,$newsubdir,$newurls) = @_; |
$dbcopies,$zombies,$params,$mapmoves,$mapchanges,$tomove,$newsubdir,$newurls) = @_; |
Line 1331 sub url_paste_fixups {
|
Line 1371 sub url_paste_fixups {
|
} |
} |
|
|
sub apply_fixups { |
sub apply_fixups { |
my ($folder,$is_map,$prefixchg,$cdom,$cnum,$oldurl,$url,$removefrommap, |
my ($folder,$is_map,$cdom,$cnum,$errors,$updated,$info,$moves,$prefixchg, |
$removeparam,$rewrites,$retitles,$copies,$dbcopies,$zombies,$params, |
$oldurl,$url,$caller) = @_; |
$docmoves,$mapmoves,$newsubdir,$errors,$before,$after) = @_; |
my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles, |
foreach my $key (keys(%{$copies}),keys(%{$docmoves})) { |
%params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves); |
|
if (ref($updated) eq 'HASH') { |
|
if (ref($updated->{'rewrites'}) eq 'HASH') { |
|
%rewrites = %{$updated->{'rewrites'}}; |
|
} |
|
if (ref($updated->{'zombies'}) eq 'HASH') { |
|
%zombies = %{$updated->{'zombies'}}; |
|
} |
|
if (ref($updated->{'removefrommap'}) eq 'HASH') { |
|
%removefrommap = %{$updated->{'removefrommap'}}; |
|
} |
|
if (ref($updated->{'removeparam'}) eq 'HASH') { |
|
%removeparam = %{$updated->{'removeparam'}}; |
|
} |
|
if (ref($updated->{'dbcopies'}) eq 'HASH') { |
|
%dbcopies = %{$updated->{'dbcopies'}}; |
|
} |
|
if (ref($updated->{'retitles'}) eq 'HASH') { |
|
%retitles = %{$updated->{'retitles'}}; |
|
} |
|
} |
|
if (ref($info) eq 'HASH') { |
|
if (ref($info->{'newsubdir'}) eq 'HASH') { |
|
%newsubdir = %{$info->{'newsubdir'}}; |
|
} |
|
if (ref($info->{'params'}) eq 'HASH') { |
|
%params = %{$info->{'params'}}; |
|
} |
|
if (ref($info->{'before'}) eq 'HASH') { |
|
%before = %{$info->{'before'}}; |
|
} |
|
if (ref($info->{'after'}) eq 'HASH') { |
|
%after = %{$info->{'after'}}; |
|
} |
|
} |
|
if (ref($moves) eq 'HASH') { |
|
if (ref($moves->{'copies'}) eq 'HASH') { |
|
%copies = %{$moves->{'copies'}}; |
|
} |
|
if (ref($moves->{'docmoves'}) eq 'HASH') { |
|
%docmoves = %{$moves->{'docmoves'}}; |
|
} |
|
if (ref($moves->{'mapmoves'}) eq 'HASH') { |
|
%mapmoves = %{$moves->{'mapmoves'}}; |
|
} |
|
} |
|
foreach my $key (keys(%copies),keys(%docmoves)) { |
my @allcopies; |
my @allcopies; |
if (ref($copies->{$key}) eq 'HASH') { |
if (exists($copies{$key})) { |
my %added; |
if (ref($copies{$key}) eq 'HASH') { |
foreach my $innerkey (keys(%{$copies->{$key}})) { |
my %added; |
if (($innerkey ne '') && (!$added{$innerkey})) { |
foreach my $innerkey (keys(%{$copies{$key}})) { |
push(@allcopies,$innerkey); |
if (($innerkey ne '') && (!$added{$innerkey})) { |
$added{$innerkey} = 1; |
push(@allcopies,$innerkey); |
|
$added{$innerkey} = 1; |
|
} |
} |
} |
|
undef(%added); |
} |
} |
undef(%added); |
|
} |
} |
if ($key eq $oldurl) { |
if ($key eq $oldurl) { |
if ((exists($docmoves->{$key}))) { |
if ((exists($docmoves{$key}))) { |
unless (grep(/^\Q$oldurl\E/,@allcopies)) { |
unless (grep(/^\Q$oldurl\E/,@allcopies)) { |
push(@allcopies,$oldurl); |
push(@allcopies,$oldurl); |
} |
} |
Line 1361 sub apply_fixups {
|
Line 1449 sub apply_fixups {
|
my $content = &Apache::lonnet::getfile($item); |
my $content = &Apache::lonnet::getfile($item); |
unless ($content eq '-1') { |
unless ($content eq '-1') { |
my $storefn; |
my $storefn; |
if (($key eq $oldurl) && (ref($docmoves) eq 'HASH') && (exists($docmoves->{$key}))) { |
if (($key eq $oldurl) && (exists($docmoves{$key}))) { |
$storefn = $docmoves->{$key}; |
$storefn = $docmoves{$key}; |
} else { |
} else { |
$storefn = $relpath; |
$storefn = $relpath; |
$storefn =~s{^/uploaded/$match_domain/$match_courseid/}{}; |
$storefn =~s{^/uploaded/$match_domain/$match_courseid/}{}; |
if ($prefixchg) { |
if ($prefixchg && $before{'doc'} && $after{'doc'}) { |
$storefn =~ s/^\Q$before->{'doc'}\E/$after->{'doc'}/; |
$storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/; |
} |
} |
if ($newsubdir->{$key}) { |
if ($newsubdir{$key}) { |
$storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir->{$key}#; |
$storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}#; |
} |
} |
} |
} |
©_dependencies($item,$storefn,$relpath,$errors,\$content); |
©_dependencies($item,$storefn,$relpath,$errors,\$content); |
Line 1378 sub apply_fixups {
|
Line 1466 sub apply_fixups {
|
&Apache::lonclonecourse::writefile($env{'request.course.id'}, |
&Apache::lonclonecourse::writefile($env{'request.course.id'}, |
$storefn.$fname,$content); |
$storefn.$fname,$content); |
if ($copyurl eq '/adm/notfound.html') { |
if ($copyurl eq '/adm/notfound.html') { |
if ((ref($docmoves) eq 'HASH') && (exists($docmoves->{$oldurl}))) { |
if (exists($docmoves{$oldurl})) { |
return &mt('Paste failed: an error occurred copying the file.'); |
return &mt('Paste failed: an error occurred copying the file.'); |
} elsif (ref($errors) eq 'HASH') { |
} elsif (ref($errors) eq 'HASH') { |
$errors->{$item} = 1; |
$errors->{$item} = 1; |
Line 1389 sub apply_fixups {
|
Line 1477 sub apply_fixups {
|
} |
} |
} |
} |
} |
} |
foreach my $key (keys(%{$mapmoves})) { |
foreach my $key (keys(%mapmoves)) { |
my $storefn=$key; |
my $storefn=$key; |
$storefn=~s{^/uploaded/$match_domain/$match_courseid/}{}; |
$storefn=~s{^/uploaded/$match_domain/$match_courseid/}{}; |
if ($prefixchg) { |
if ($prefixchg && $before{'map'} && $after{'map'}) { |
$storefn =~ s/^\Q$before->{'map'}\E/$after->{'map'}/; |
$storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/; |
} |
} |
if ($newsubdir->{$key}) { |
if ($newsubdir{$key}) { |
$storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir->{$key}/; |
$storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/; |
} |
} |
my $mapcontent = &Apache::lonnet::getfile($key); |
my $mapcontent = &Apache::lonnet::getfile($key); |
if ($mapcontent eq '-1') { |
if ($mapcontent eq '-1') { |
Line 1416 sub apply_fixups {
|
Line 1504 sub apply_fixups {
|
} |
} |
my %updates; |
my %updates; |
if ($is_map) { |
if ($is_map) { |
foreach my $key (keys(%{$rewrites})) { |
if (ref($updated) eq 'HASH') { |
$updates{$key} = 1; |
foreach my $type (keys(%{$updated})) { |
} |
if (ref($updated->{$type}) eq 'HASH') { |
foreach my $key (keys(%{$zombies})) { |
foreach my $key (keys(%{$updated->{$type}})) { |
$updates{$key} = 1; |
$updates{$key} = 1; |
} |
} |
foreach my $key (keys(%{$removefrommap})) { |
} |
$updates{$key} = 1; |
} |
} |
|
foreach my $key (keys(%{$removeparam})) { |
|
$updates{$key} = 1; |
|
} |
|
foreach my $key (keys(%{$dbcopies})) { |
|
$updates{$key} = 1; |
|
} |
|
foreach my $key (keys(%{$retitles})) { |
|
$updates{$key} = 1; |
|
} |
} |
foreach my $key (keys(%updates)) { |
foreach my $key (keys(%updates)) { |
my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb); |
my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb); |
if (ref($rewrites->{$key}) eq 'HASH') { |
if (ref($rewrites{$key}) eq 'HASH') { |
%torewrite = %{$rewrites->{$key}}; |
%torewrite = %{$rewrites{$key}}; |
} |
} |
if (ref($retitles->{$key}) eq 'HASH') { |
if (ref($retitles{$key}) eq 'HASH') { |
%toretitle = %{$retitles->{$key}}; |
%toretitle = %{$retitles{$key}}; |
} |
} |
if (ref($removefrommap->{$key}) eq 'HASH') { |
if (ref($removefrommap{$key}) eq 'HASH') { |
%toremove = %{$removefrommap->{$key}}; |
%toremove = %{$removefrommap{$key}}; |
} |
} |
if (ref($removeparam->{$key}) eq 'HASH') { |
if (ref($removeparam{$key}) eq 'HASH') { |
%remparam = %{$removeparam->{$key}}; |
%remparam = %{$removeparam{$key}}; |
} |
} |
if (ref($zombies->{$key}) eq 'HASH') { |
if (ref($zombies{$key}) eq 'HASH') { |
%zombie = %{$zombies->{$key}}; |
%zombie = %{$zombies{$key}}; |
} |
} |
if (ref($dbcopies->{$key}) eq 'HASH') { |
if (ref($dbcopies{$key}) eq 'HASH') { |
foreach my $item (keys(%{$dbcopies->{$key}})) { |
foreach my $item (keys(%{$dbcopies{$key}})) { |
$newdb{$item} = &dbcopy($item); |
$newdb{$item} = &dbcopy($item); |
} |
} |
} |
} |
if (ref($params->{$key}) eq 'HASH') { |
if (ref($params{$key}) eq 'HASH') { |
%currparam = %{$params->{$key}}; |
%currparam = %{$params{$key}}; |
} |
} |
my ($errtext,$fatal) = &LONCAPA::map::mapread($key); |
my ($errtext,$fatal) = &LONCAPA::map::mapread($key); |
if ($fatal) { |
if ($fatal) { |
Line 1471 sub apply_fixups {
|
Line 1550 sub apply_fixups {
|
} |
} |
} |
} |
} |
} |
for (my $i=0; $i<@LONCAPA::map::resources; $i++) { |
for (my $i=0; $i<@LONCAPA::map::order; $i++) { |
if (defined($LONCAPA::map::resources[$i])) { |
my $idx = $LONCAPA::map::order[$i]; |
|
if (defined($LONCAPA::map::resources[$idx])) { |
my $changed; |
my $changed; |
my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$i]); |
my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]); |
if ($toremove{$src} eq $i) { |
if ((exists($toremove{$idx})) && ($toremove{$idx} eq $src)) { |
splice(@LONCAPA::map::order,$i,1); |
splice(@LONCAPA::map::order,$i,1); |
if (ref($currparam{$i}) eq 'ARRAY') { |
if (ref($currparam{$idx}) eq 'ARRAY') { |
foreach my $name (@{$currparam{$i}}) { |
foreach my $name (@{$currparam{$idx}}) { |
&LONCAPA::map::delparameter($i,'parameter_'.$name); |
&LONCAPA::map::delparameter($idx,'parameter_'.$name); |
} |
} |
} |
} |
next; |
next; |
} |
} |
my $origsrc = $src; |
my $origsrc = $src; |
if ((exists($toretitle{$src})) && ($toretitle{$src} eq $i)) { |
if ((exists($toretitle{$src})) && ($toretitle{$src} eq $idx)) { |
if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) { |
if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) { |
$changed = 1; |
$changed = 1; |
} |
} |
} |
} |
if ((exists($torewrite{$src})) && ($torewrite{$src} eq $i)) { |
if ((exists($torewrite{$src})) && ($torewrite{$src} eq $idx)) { |
$src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/}; |
$src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/}; |
if ($origsrc =~ m{^/uploaded/}) { |
if ($origsrc =~ m{^/uploaded/}) { |
if ($prefixchg) { |
if ($prefixchg && $before{'map'} && $after{'map'}) { |
if ($src =~ /\.(page|sequence)$/) { |
if ($src =~ /\.(page|sequence)$/) { |
$src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before->{'map'}\E#$1$after->{'map'}#; |
$src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#; |
} else { |
} else { |
$src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before->{'doc'}\E#$1$after->{'doc'}#; |
$src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#; |
} |
} |
} |
} |
if ($newsubdir->{$origsrc}) { |
if ($newsubdir{$origsrc}) { |
if ($src =~ /\.(page|sequence)$/) { |
if ($src =~ /\.(page|sequence)$/) { |
$src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir->{$origsrc}#; |
$src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#; |
} else { |
} else { |
$src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir->{$origsrc}#; |
$src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$origsrc}#; |
} |
} |
} |
} |
} |
} |
Line 1514 sub apply_fixups {
|
Line 1594 sub apply_fixups {
|
$changed = 1; |
$changed = 1; |
} |
} |
if ($changed) { |
if ($changed) { |
$LONCAPA::map::resources[$i] = join(':',($title,$src,$ext,$type)); |
$LONCAPA::map::resources[$idx] = join(':',($title,$src,$ext,$type)); |
} |
} |
} |
} |
} |
} |
Line 1532 sub apply_fixups {
|
Line 1612 sub apply_fixups {
|
} else { |
} else { |
$storefn = $key; |
$storefn = $key; |
$storefn=~s{^/uploaded/$match_domain/$match_courseid/}{}; |
$storefn=~s{^/uploaded/$match_domain/$match_courseid/}{}; |
if ($prefixchg) { |
if ($prefixchg && $before{'map'} && $after{'map'}) { |
$storefn =~ s/^\Q$before->{'map'}\E/$after->{'map'}/; |
$storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/; |
} |
} |
if ($newsubdir->{$key}) { |
if ($newsubdir{$key}) { |
$storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir->{$key}/; |
$storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/; |
} |
} |
} |
} |
my $report; |
my $report; |
Line 1546 sub apply_fixups {
|
Line 1626 sub apply_fixups {
|
(my $outtext,$errtext) = |
(my $outtext,$errtext) = |
&LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report); |
&LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report); |
if ($errtext) { |
if ($errtext) { |
return &mt('Paste failed: an error occurred saving the folder or page.'); |
if ($caller eq 'paste') { |
|
return &mt('Paste failed: an error occurred saving the folder or page.'); |
|
} |
} |
} |
} |
} |
} |
} |
Line 1790 sub editor {
|
Line 1872 sub editor {
|
push(@imports, [$name, $url, $residx]); |
push(@imports, [$name, $url, $residx]); |
} |
} |
} |
} |
($errtext,$fatal)=&group_import($coursenum, $coursedom, $folder, |
($errtext,$fatal,my $fixuperrors) = |
$container,'londocs',@imports); |
&group_import($coursenum, $coursedom, $folder,$container, |
|
'londocs',@imports); |
return $errtext if ($fatal); |
return $errtext if ($fatal); |
|
if ($fixuperrors) { |
|
$r->print($fixuperrors); |
|
} |
} |
} |
# Loading a complete map |
# Loading a complete map |
if ($env{'form.loadmap'}) { |
if ($env{'form.loadmap'}) { |
Line 4843 Return hash with valid author names
|
Line 4929 Return hash with valid author names
|
|
|
=item contained_map_check() |
=item contained_map_check() |
|
|
=item reinit_role() |
|
|
|
=item url_paste_fixups() |
=item url_paste_fixups() |
|
|
=item apply_fixups() |
=item apply_fixups() |