--- loncom/interface/loncommon.pm 2012/07/06 22:46:06 1.1085 +++ loncom/interface/loncommon.pm 2012/07/07 21:58:14 1.1086 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1085 2012/07/06 22:46:06 raeburn Exp $ +# $Id: loncommon.pm,v 1.1086 2012/07/07 21:58:14 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -11207,6 +11207,7 @@ sub process_extracted_files { my (%referrer,%orphaned,%todelete,%todeletedir,%newdest,%newseqid); if ($numitems) { for (my $i=1; $i<=$numitems; $i++) { + next if ($env{'form.archive_'.$i} eq 'dependency'); my $path = $env{'form.archive_content_'.$i}; if ($path =~ /^\Q$pathtocheck\E/) { if ($env{'form.archive_'.$i} eq 'discard') { @@ -11298,84 +11299,90 @@ sub process_extracted_files { } } } - } elsif ($env{'form.archive_'.$i} eq 'dependency') { - my ($title) = ($path =~ m{/([^/]+)$}); - $referrer{$i} = $env{'form.archive_dependent_on_'.$i}; - if ($env{'form.archive_'.$referrer{$i}} eq 'display') { - if (ref($dirorder{$i}) eq 'ARRAY') { - my ($itemidx,$fullpath,$relpath); + } + } else { + $warning .= &mt('Item extracted from archive: [_1] has unexpected path.',$path).'
'; + } + } + for (my $i=1; $i<=$numitems; $i++) { + next unless ($env{'form.archive_'.$i} eq 'dependency'); + my $path = $env{'form.archive_content_'.$i}; + if ($path =~ /^\Q$pathtocheck\E/) { + my ($title) = ($path =~ m{/([^/]+)$}); + $referrer{$i} = $env{'form.archive_dependent_on_'.$i}; + if ($env{'form.archive_'.$referrer{$i}} eq 'display') { + if (ref($dirorder{$i}) eq 'ARRAY') { + my ($itemidx,$fullpath,$relpath); + if (ref($dirorder{$referrer{$i}}) eq 'ARRAY') { + my $container = $dirorder{$referrer{$i}}->[-1]; for (my $j=0; $j<@{$dirorder{$i}}; $j++) { - if (ref($dirorder{$referrer{$i}}) eq 'ARRAY') { - my $container = $dirorder{$referrer{$i}}->[-1]; - for (my $j=0; $j<@{$dirorder{$i}}; $j++) { - if ($dirorder{$i}->[$j] eq $container) { - $itemidx = $j; - } - } + if ($dirorder{$i}->[$j] eq $container) { + $itemidx = $j; } } - if ($itemidx ne '') { - if (grep(/^\Q$referrer{$i}\E$/,@archdirs)) { - if ($mapinner{$referrer{$i}}) { - $fullpath = "$prefix$dir/$docstype/$mapinner{$referrer{$i}}"; - for (my $j=$itemidx; $j<@{$dirorder{$i}}; $j++) { - if (grep(/^\Q$dirorder{$i}->[$j]\E$/,@archdirs)) { - unless (defined($newseqid{$dirorder{$i}->[$j]})) { - $fullpath .= '/'.$titles{$dirorder{$i}->[$j]}; - $relpath .= '/'.$titles{$dirorder{$i}->[$j]}; - if (!-e $fullpath) { - mkdir($fullpath,0755); - } - } - } else { - last; - } - } - } - } elsif ($newdest{$referrer{$i}}) { - $fullpath = $newdest{$referrer{$i}}; - for (my $j=$itemidx; $j<@{$dirorder{$i}}; $j++) { - if ($env{'form.archive_'.$dirorder{$i}->[$j]} eq 'discard') { - $orphaned{$i} = $env{'form.archive_'.$dirorder{$i}->[$j]}; - last; - } elsif (grep(/^\Q$dirorder{$i}->[$j]\E$/,@archdirs)) { - unless (defined($newseqid{$dirorder{$i}->[$j]})) { - $fullpath .= '/'.$titles{$dirorder{$i}->[$j]}; - $relpath .= '/'.$titles{$dirorder{$i}->[$j]}; - if (!-e $fullpath) { - mkdir($fullpath,0755); - } + } + if ($itemidx eq '') { + $itemidx = 0; + } + if (grep(/^\Q$referrer{$i}\E$/,@archdirs)) { + if ($mapinner{$referrer{$i}}) { + $fullpath = "$prefix$dir/$docstype/$mapinner{$referrer{$i}}"; + for (my $j=$itemidx; $j<@{$dirorder{$i}}; $j++) { + if (grep(/^\Q$dirorder{$i}->[$j]\E$/,@archdirs)) { + unless (defined($newseqid{$dirorder{$i}->[$j]})) { + $fullpath .= '/'.$titles{$dirorder{$i}->[$j]}; + $relpath .= '/'.$titles{$dirorder{$i}->[$j]}; + if (!-e $fullpath) { + mkdir($fullpath,0755); } - } else { - last; } + } else { + last; } } - if ($fullpath ne '') { - if (-e "$prefix$path") { - system("mv $prefix$path $fullpath/$title"); - } - if (-e "$fullpath/$title") { - my $showpath; - if ($relpath ne '') { - $showpath = "$relpath/$title"; - } else { - $showpath = "/$title"; - } - $result .= '
  • '.&mt('[_1] included as a dependency',$showpath).'
  • '."\n"; - } - unless ($ishome) { - my $fetch = "$fullpath/$title"; - $fetch =~ s/^\Q$prefix$dir\E//; - $prompttofetch{$fetch} = 1; + } + } elsif ($newdest{$referrer{$i}}) { + $fullpath = $newdest{$referrer{$i}}; + for (my $j=$itemidx; $j<@{$dirorder{$i}}; $j++) { + if ($env{'form.archive_'.$dirorder{$i}->[$j]} eq 'discard') { + $orphaned{$i} = $env{'form.archive_'.$dirorder{$i}->[$j]}; + last; + } elsif (grep(/^\Q$dirorder{$i}->[$j]\E$/,@archdirs)) { + unless (defined($newseqid{$dirorder{$i}->[$j]})) { + $fullpath .= '/'.$titles{$dirorder{$i}->[$j]}; + $relpath .= '/'.$titles{$dirorder{$i}->[$j]}; + if (!-e $fullpath) { + mkdir($fullpath,0755); + } } + } else { + last; } } } - } elsif ($env{'form.archive_'.$referrer{$i}} eq 'discard') { - $warning .= &mt('[_1] is a dependency of [_2], which was discarded.', - $path,$env{'form.archive_content_'.$referrer{$i}}).'
    '; + if ($fullpath ne '') { + if (-e "$prefix$path") { + system("mv $prefix$path $fullpath/$title"); + } + if (-e "$fullpath/$title") { + my $showpath; + if ($relpath ne '') { + $showpath = "$relpath/$title"; + } else { + $showpath = "/$title"; + } + $result .= '
  • '.&mt('[_1] included as a dependency',$showpath).'
  • '."\n"; + } + unless ($ishome) { + my $fetch = "$fullpath/$title"; + $fetch =~ s/^\Q$prefix$dir\E//; + $prompttofetch{$fetch} = 1; + } + } } + } elsif ($env{'form.archive_'.$referrer{$i}} eq 'discard') { + $warning .= &mt('[_1] is a dependency of [_2], which was discarded.', + $path,$env{'form.archive_content_'.$referrer{$i}}).'
    '; } } else { $warning .= &mt('Item extracted from archive: [_1] has unexpected path.',$path).'
    ';