[LON-CAPA-cvs] cvs: loncom /interface londocs.pm

raeburn raeburn at source.lon-capa.org
Mon Jan 14 15:32:05 EST 2013


raeburn		Mon Jan 14 20:32:05 2013 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  - Pasting folders from paste buffer.
    - For zombies, rewrites and retitles use unique ID for resource in map as
      hash key instead of resource URL, in case the same item is used more than
      once in a particular map.
    - For files uploaded to a course (e.g., HTML files) fix rewriting of path
      to resource in map which contains it, when folder is pasted between 
      courses.  
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.531 loncom/interface/londocs.pm:1.532
--- loncom/interface/londocs.pm:1.531	Thu Jan 10 17:10:30 2013
+++ loncom/interface/londocs.pm	Mon Jan 14 20:32:04 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.531 2013/01/10 17:10:30 raeburn Exp $
+# $Id: londocs.pm,v 1.532 2013/01/14 20:32:04 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1282,13 +1282,13 @@
             my $title = $token->[2]->{'title'};
             if ($checktitle) {
                 if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
-                    $retitles->{$oldurl}{$ressrc} = $id;
+                    $retitles->{$oldurl}{$id} = $ressrc;
                 }
             }
             next if ($token->[2]->{'type'} eq 'external');
             if ($token->[2]->{'type'} eq 'zombie') {
                 next if ($skip);  
-                $zombies->{$oldurl}{$ressrc} = $id;
+                $zombies->{$oldurl}{$id} = $ressrc;
                 $changed = 1;
             } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
                 my $srcdom = $1;
@@ -1321,7 +1321,7 @@
                     ($mapchanges->{$oldurl}) || (($newurl ne '') && ($newurl ne $oldurl))) {
                    
                     if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
-                        $rewrites->{$oldurl}{$ressrc} = $id;
+                        $rewrites->{$oldurl}{$id} = $ressrc;
                         $mapchanges->{$ressrc} = 1;
                         unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,$allmaps,
                                                   $rewrites,$retitles,$copies,$dbcopies,$zombies,
@@ -1331,7 +1331,7 @@
                         }
                         $changed = 1;
                     } else {
-                        $rewrites->{$oldurl}{$ressrc} = $id;
+                        $rewrites->{$oldurl}{$id} = $ressrc;
                         $copies->{$oldurl}{$ressrc} = $id;
                         $changed = 1;
                     }
@@ -1341,7 +1341,7 @@
                 my $srcdom = $1;
                 my $srcnum = $2;
                 if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
-                    $rewrites->{$oldurl}{$ressrc} = $id;
+                    $rewrites->{$oldurl}{$id} = $ressrc;
                     $dbcopies->{$oldurl}{$ressrc} = $id;
                     $changed = 1;
                 }
@@ -1350,7 +1350,7 @@
                 my $srcdom = $1;
                 my $srcnum = $2;
                 if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
-                    $rewrites->{$oldurl}{$ressrc} = $id;
+                    $rewrites->{$oldurl}{$id} = $ressrc;
                     $dbcopies->{$oldurl}{$ressrc} = $id;
                     $changed = 1;
                 }
@@ -1436,7 +1436,7 @@
         }
         if ($key eq $oldurl) {
             if ((exists($docmoves{$key}))) {
-                unless (grep(/^\Q$oldurl\E/, at allcopies)) {
+                unless (grep(/^\Q$oldurl\E$/, at allcopies)) {
                     push(@allcopies,$oldurl);
                 }
             }
@@ -1458,7 +1458,7 @@
                                 $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
                             }
                             if ($newsubdir{$key}) {
-                                $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}#;
+                                $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}/#;
                             }
                         }
                         &copy_dependencies($item,$storefn,$relpath,$errors,\$content);
@@ -1545,7 +1545,7 @@
             for (my $i=0; $i<@LONCAPA::map::zombies; $i++) {
                 if (defined($LONCAPA::map::zombies[$i])) {
                     my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::zombies[$i]);
-                    if ($zombie{$src} eq $i) {
+                    if ($zombie{$i} eq $src) {
                         undef($LONCAPA::map::zombies[$i]);
                     }
                 }
@@ -1565,12 +1565,12 @@
                         next;
                     }
                     my $origsrc = $src;
-                    if ((exists($toretitle{$src})) && ($toretitle{$src} eq $idx)) {
+                    if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
                         if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
                             $changed = 1;
                         }
                     }
-                    if ((exists($torewrite{$src})) && ($torewrite{$src} eq $idx)) {
+                    if ((exists($torewrite{$idx})) && ($torewrite{$idx} eq $src)) {
                         $src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
                         if ($origsrc =~ m{^/uploaded/}) {
                             if ($prefixchg && $before{'map'} && $after{'map'}) {
@@ -1580,12 +1580,12 @@
                                     $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
                                 }
                             }
-                            if ($newsubdir{$origsrc}) {
-                                if ($src =~ /\.(page|sequence)$/) {
+                            if ($origsrc =~ /\.(page|sequence)$/) {
+                                if ($newsubdir{$origsrc}) {
                                     $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#;
-                                } else {
-                                    $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$origsrc}#;
                                 }
+                            } elsif ($newsubdir{$key}) {
+                                $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$key}#;
                             }
                         }
                         $changed = 1;




More information about the LON-CAPA-cvs mailing list