--- loncom/interface/londocs.pm 2012/11/08 20:51:40 1.503 +++ loncom/interface/londocs.pm 2012/11/14 00:18:53 1.506 @@ -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.506 2012/11/14 00:18:53 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]); } } @@ -1949,7 +1961,7 @@ sub editor { &Apache::lonhtmlcommon::add_item_funclist( ''. - ''.$funcname.''. + ''.$funcname.''. ''.$funcname.''). &Apache::lonhtmlcommon::end_funclist())); } @@ -2151,9 +2163,13 @@ sub entryline { $esc_path=&escape($env{'form.pagepath'}); $path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"'); } + my $isexternal; if (!$supplementalflag && $residx) { my $currurl = $url; $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/}; + if ($currurl =~ m{^/adm/wrapper/ext/}) { + $isexternal = 1; + } my $path = 'uploaded/'. $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. $env{'course.'.$env{'request.course.id'}.'.num'}.'/'; @@ -2269,8 +2285,8 @@ sub entryline { |/aboutme$ |/navmaps$ |/bulletinboard$ - |\.html$ - |^/adm/wrapper/ext)}x)) { + |\.html$)}x) + || $isexternal) { $skip_confirm = 1; } @@ -2537,6 +2553,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 = '
'.&mt('There was a problem removing a lockfile. This will prevent creation of additional folders or composite pages in this course. Please contact the domain coordinator for your LON-CAPA domain.').'
'; + } + return ($suffix,$errtext,$locknotfreed); +} + =pod =item tiehash() @@ -3736,10 +3776,8 @@ HIDDENFORM } else { #$postexec='self.close();'; } - my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. - '.sequence'; - my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. - '.page'; + my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence'; + my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page'; my $container='sequence'; if ($env{'form.pagepath'}) { $container='page'; @@ -3965,8 +4003,7 @@ unless ($env{'form.pagepath'}) { $env{'form.pagepath'} = ''; if ($allowed) { my $folderseq= - '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time. - '.sequence'; + '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence'; my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');