--- loncom/interface/londocs.pm 2012/12/13 02:27:27 1.484.2.13
+++ loncom/interface/londocs.pm 2012/12/13 02:45:27 1.484.2.15
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.484.2.13 2012/12/13 02:27:27 raeburn Exp $
+# $Id: londocs.pm,v 1.484.2.15 2012/12/13 02:45:27 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]);
}
}
@@ -2467,13 +2479,14 @@ $form_common.'
EXTLNK
} else {
- my ($cfile,$home,$switchserver,$uploaded) =
- &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom);
+ my ($cfile,$home,$switchserver,$forceedit,$forceview) =
+ &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
if (($cfile ne '') && ($symb ne '')) {
my $jscall =
&Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
$switchserver,
- $uploaded,$symb);
+ $forceedit,
+ undef,$symb);
if ($jscall) {
$editlink = ' '.&mt('Edit').'';
@@ -2536,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 = '