--- loncom/interface/londocs.pm 2012/11/08 20:51:40 1.503
+++ loncom/interface/londocs.pm 2012/11/11 17:37:17 1.504
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.503 2012/11/08 20:51:40 raeburn Exp $
+# $Id: londocs.pm,v 1.504 2012/11/11 17:37:17 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1828,6 +1828,18 @@ sub editor {
if (defined($item)) {
my ($name,$url,$residx)=
map {&unescape($_)} split(/\=/,$item);
+ if ($url=~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
+ my ($suffix,$errortxt,$locknotfreed) =
+ &newmap_suffix($1,$2,$coursedom,$coursenum);
+ if ($locknotfreed) {
+ $r->print($locknotfreed);
+ }
+ if ($suffix) {
+ $url =~ s/_new\./_$suffix./;
+ } else {
+ return $errortxt;
+ }
+ }
push(@imports, [$name, $url, $residx]);
}
}
@@ -2537,6 +2549,30 @@ ENDPARMS
return $line;
}
+sub newmap_suffix {
+ my ($area,$container,$coursedom,$coursenum) = @_;
+ my ($prefix,$idtype,$errtext,$locknotfreed);
+ $prefix = 'docs';
+ if ($area eq 'supplemental') {
+ $prefix = 'supp';
+ }
+ $prefix .= $container;
+ $idtype = 'concat';
+ my ($suffix,$freedlock,$error) =
+ &Apache::lonnet::get_timebased_id($prefix,'num','uploadedmaps',
+ $coursedom,$coursenum);
+ if (!$suffix) {
+ $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
+ if ($error) {
+ $errtext .= '
'.$error;
+ }
+ }
+ if ($freedlock ne 'ok') {
+ $locknotfreed = '