--- loncom/interface/londocs.pm 2012/10/31 12:54:13 1.501
+++ 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.501 2012/10/31 12:54:13 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(
''.
- ''.
+ '
'.
'').
&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;
}
@@ -2467,13 +2483,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 +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 = '