'.(' 'x 4).
'
'.(' ' x2).
+ &mt('Copy to new folder').''.(' ' x2).
'
');
- if (($is_uploaded_map) && ($env{'docs.markedcopy_nested'})) {
+ &mt('Move old folder').'
');
+ if ($env{'docs.markedcopy_nested'}) {
$r->print('
'.&mt('Folder to paste contains sub-folders').
'
');
my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested'});
@@ -1037,19 +965,17 @@ sub do_paste_from_buffer {
}
if (($srcdom ne $coursedom) || ($srcnum ne $coursenum) || ($prefixchg) ||
(($newurl ne '') && ($newurl ne $url))) {
- unless (&url_paste_fixups($url,$folder,$prefixchg,$coursedom,
- $coursenum,$srcdom,$srcnum,$allmaps,
- \%rewrites,\%retitles,\%copies,\%dbcopies,
+ unless (&url_paste_fixups($url,$folder,$prefixchg,$coursedom,$coursenum,
+ $allmaps,\%rewrites,\%retitles,\%copies,\%dbcopies,
\%zombies,\%params,\%mapmoves,\%mapchanges,\%tomove,
\%newsubdir,\%newurls)) {
$mapmoves{$url} = 1;
}
$url = $newurl;
} elsif ($env{'docs.markedcopy_nested'}) {
- &url_paste_fixups($url,$folder,$prefixchg,$coursedom,$coursenum,
- $srcdom,$srcnum,$allmaps,\%rewrites,
+ &url_paste_fixups($url,$folder,$prefixchg,$coursedom,$coursenum,$allmaps,\%rewrites,
\%retitles,\%copies,\%dbcopies,\%zombies,\%params,\%mapmoves,
- \%mapchanges,\%tomove,\%newsubdir,\%newurls);
+ \%mapchanges,\%tomove,\%newsubdir,\%newurls);
}
} elsif ($url=~m {^/res/}) {
# published maps can only exists once, so remove it from paste buffer when done
@@ -1062,34 +988,22 @@ sub do_paste_from_buffer {
}
}
}
- my $lockerrors;
- if ($url=~ m{/(bulletinboard|smppg)$}) {
- my $prefix = $1;
- #need to copy the db contents to a new one, unless this is a move.
- my %info = (
- src => $url,
- cdom => $coursedom,
- cnum => $coursenum,
- );
- my (%lockerr,$msg);
- unless ($env{'form.docs.markedcopy_options'} eq 'move') {
- my ($newurl,$result,$errtext) =
- &dbcopy(\%info,$coursedom,$coursenum,\%lockerr);
- if ($result eq 'ok') {
- $url = $newurl;
+ if ($url=~ m{/smppg$}) {
+ my $db_name = &Apache::lonsimplepage::get_db_name($url);
+ if ($db_name =~ /^smppage_/) {
+ #simple pages, need to copy the db contents to a new one.
+ my %contents=&Apache::lonnet::dump($db_name,$coursedom,$coursenum);
+ my $now = time();
+ $db_name =~ s{_\d*$ }{_$now}x;
+ my $dbresult=&Apache::lonnet::put($db_name,\%contents,
+ $coursedom,$coursenum);
+ if ($dbresult eq 'ok') {
+ $url =~ s{/(\d*)/smppg$ }{/$now/smppg}x;
$title=&mt('Copy of').' '.$title;
} else {
- if ($prefix eq 'smppg') {
- $msg = &mt('Paste failed: An error occurred when copying the simple page.').' '.$errtext;
- } elsif ($prefix eq 'bulletinboard') {
- $msg = &mt('Paste failed: An error occurred when copying the bulletin board.').' '.$errtext;
- }
- return ($result,undef,[$msg],$lockerr{$prefix});
+ return (&mt('Paste failed: An error occurred when copying the simple page.'));
}
- if ($lockerr{$prefix}) {
- $lockerrors = $lockerr{$prefix};
- }
- }
+ }
}
$title = &LONCAPA::map::qtunescape($title);
my $ext='false';
@@ -1116,9 +1030,7 @@ sub do_paste_from_buffer {
if ($newdocsdir eq '') {
$newdocsdir = 'default';
}
- if (($prefixchg) ||
- ($srcdom ne $coursedom) || ($srcnum ne $coursenum) ||
- ($env{'form.docs.markedcopy_options'} ne 'move')) {
+ if (($prefixchg) || ($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
$url =
&Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath,
@@ -1155,15 +1067,14 @@ sub do_paste_from_buffer {
docmoves => \%docmoves,
mapmoves => \%mapmoves,
);
- ($result,my $msgsarray,my $lockerror) =
+ $result =
&apply_fixups($folder,$is_map,$coursedom,$coursenum,$errors,
\%updated,\%info,\%moves,$prefixchg,$oldurl,$url,'paste');
- $lockerrors .= $lockerror;
if ($result eq 'ok') {
if ($is_map) {
my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
$folder.'.'.$container);
- return ($errtext,$save_err,$msgsarray,$lockerrors) if ($fatal);
+ return $errtext if ($fatal);
if ($#LONCAPA::map::order<1) {
my $idx=&LONCAPA::map::getresidx();
@@ -1200,7 +1111,7 @@ sub do_paste_from_buffer {
&Apache::lonnet::delenv('docs.markedcopy_nested');
&Apache::lonnet::delenv('docs.markedcopy_nestednames');
}
- return ($result,$save_err,$msgsarray,$lockerrors);
+ return ($result,$save_err);
}
sub get_newmap_url {
@@ -1264,96 +1175,20 @@ sub get_newmap_url {
}
sub dbcopy {
- my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_;
- my ($url,$result,$errtext);
- my $url = $dbref->{'src'};
- if (ref($dbref) eq 'HASH') {
- if ($url =~ m{/(smppg|bulletinboard)$}) {
- my $prefix = $1;
- if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
- ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
- my $db_name;
- my $marker = (split(m{/},$url))[4];
- $marker=~s/\D//g;
- if ($dbref->{'src'} =~ m{/smppg$}) {
- $db_name =
- &Apache::lonsimplepage::get_db_name($url,$marker,
- $dbref->{'cdom'},
- $dbref->{'cnum'});
- } else {
- $db_name = 'bulletinpage_'.$marker;
- }
- my ($suffix,$freedlock,$error) =
- &Apache::lonnet::get_timebased_id($prefix,'num','templated',
- $coursedom,$coursenum,
- 'concat');
- if (!$suffix) {
- if ($prefix eq 'smppg') {
- $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);
- } else {
- $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a bulletin board [_1].',$url);
- }
- if ($error) {
- $errtext .= '
'.$error;
- }
- } else {
- #need to copy the db contents to a new one.
- my %contents=&Apache::lonnet::dump($db_name,
- $dbref->{'cdom'},
- $dbref->{'cnum'});
- if (exists($contents{'uploaded.photourl'})) {
- my $photo = $contents{'uploaded.photourl'};
- my ($subdir,$fname) =
- ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
- my $newphoto;
- if ($fname ne '') {
- my $content = &Apache::lonnet::getfile($photo);
- unless ($content eq '-1') {
- $env{'form.'.$suffix.'.photourl'} = $content;
- $newphoto =
- &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");
- delete($env{'form.'.$suffix.'.photourl'});
- }
- }
- if ($newphoto =~ m{^/uploaded/}) {
- $contents{'uploaded.photourl'} = $newphoto;
- }
- }
- $db_name =~ s{_\d*$ }{_$suffix}x;
- $result=&Apache::lonnet::put($db_name,\%contents,
- $coursedom,$coursenum);
- if ($result eq 'ok') {
- $url =~ s{/(\d*)/(smppg|bulletinboard)$}{/$suffix/$2}x;
- }
- }
- if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {
- $lockerrorsref->{$prefix} =
- ''.
- &mt('There was a problem removing a lockfile.');
- if ($prefix eq 'smppg') {
- $lockerrorsref->{$prefix} .=
- &mt('This will prevent creation of additional simple pages in this course.');
- } else {
- $lockerrorsref->{$prefix} .= &mt('This will prevent creation of additional bulletin boards in this course.');
- }
- $lockerrorsref->{$prefix} .= &mt('Please contact the domain coordinator for your LON-CAPA domain.').'
';
- }
- }
- } elsif ($url =~ m{/syllabus$}) {
- if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
- ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
- if (($dbref->{'cdom'} ne $coursedom) ||
- ($dbref->{'cnum'} ne $coursenum)) {
- my %contents=&Apache::lonnet::dump('syllabus',
- $dbref->{'cdom'},
- $dbref->{'cnum'});
- $result=&Apache::lonnet::put('syllabus',\%contents,
- $coursedom,$coursenum);
- }
- }
+ my ($url,$coursedom,$coursenum) = @_;
+ if ($url=~ m{/smppg$}) {
+ my $db_name = &Apache::lonsimplepage::get_db_name($url);
+ if ($db_name =~ /^smppage_/) {
+ #simple pages, need to copy the db contents to a new one.
+ my %contents=&Apache::lonnet::dump($db_name,$coursedom,$coursenum);
+ my $now = time();
+ $db_name =~ s{_\d*$ }{_$now}x;
+ my $result=&Apache::lonnet::put($db_name,\%contents,
+ $coursedom,$coursenum);
+ $url =~ s{/(\d*)/smppg$ }{/$now/smppg}x;
}
}
- return ($url,$result,$errtext);
+ return $url;
}
sub uniqueness_check {
@@ -1419,9 +1254,8 @@ sub contained_map_check {
}
sub url_paste_fixups {
- my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps,
- $rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves,
- $mapchanges,$tomove,$newsubdir,$newurls) = @_;
+ my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$allmaps,$rewrites,$retitles,$copies,
+ $dbcopies,$zombies,$params,$mapmoves,$mapchanges,$tomove,$newsubdir,$newurls) = @_;
my $checktitle;
if (($prefixchg) &&
($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) {
@@ -1448,13 +1282,13 @@ sub url_paste_fixups {
my $title = $token->[2]->{'title'};
if ($checktitle) {
if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
- $retitles->{$oldurl}{$id} = $ressrc;
+ $retitles->{$oldurl}{$ressrc} = $id;
}
}
next if ($token->[2]->{'type'} eq 'external');
if ($token->[2]->{'type'} eq 'zombie') {
next if ($skip);
- $zombies->{$oldurl}{$id} = $ressrc;
+ $zombies->{$oldurl}{$ressrc} = $id;
$changed = 1;
} elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
my $srcdom = $1;
@@ -1466,11 +1300,10 @@ sub url_paste_fixups {
my $prefix = $1;
$mapname = $prefix.$2;
if ($tomove->{$mapname}) {
- &url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,
- $srcdom,$srcnum,$allmaps,$rewrites,
- $retitles,$copies,$dbcopies,$zombies,
- $params,$mapmoves,$mapchanges,$tomove,
- $newsubdir,$newurls);
+ &url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,$allmaps,
+ $rewrites,$retitles,$copies,$dbcopies,$zombies,
+ $params,$mapmoves,$mapchanges,$tomove,$newsubdir,
+ $newurls);
next;
} else {
($newurl,my $error) =
@@ -1488,39 +1321,28 @@ sub url_paste_fixups {
($mapchanges->{$oldurl}) || (($newurl ne '') && ($newurl ne $oldurl))) {
if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
- $rewrites->{$oldurl}{$id} = $ressrc;
+ $rewrites->{$oldurl}{$ressrc} = $id;
$mapchanges->{$ressrc} = 1;
- unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,
- $cnum,$srcdom,$srcnum,$allmaps,
- $rewrites,$retitles,$copies,$dbcopies,
- $zombies,$params,$mapmoves,$mapchanges,
- $tomove,$newsubdir,$newurls)) {
+ unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,$allmaps,
+ $rewrites,$retitles,$copies,$dbcopies,$zombies,
+ $params,$mapmoves,$mapchanges,$tomove,$newsubdir,
+ $newurls)) {
$mapmoves->{$ressrc} = 1;
}
$changed = 1;
} else {
- $rewrites->{$oldurl}{$id} = $ressrc;
+ $rewrites->{$oldurl}{$ressrc} = $id;
$copies->{$oldurl}{$ressrc} = $id;
$changed = 1;
}
}
- } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/.+$}) {
+ } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/(.+)$}) {
next if ($skip);
my $srcdom = $1;
my $srcnum = $2;
if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
- $rewrites->{$oldurl}{$id} = $ressrc;
- $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
- $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
- $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
- $changed = 1;
- }
- } elsif ($ressrc =~ m{^/adm/$match_domain/$match_username/\d+/(smppg|bulletinboard)$}) {
- if (($fromcdom ne $cdom) || ($fromcnum ne $cnum) ||
- ($env{'form.docs.markedcopy_options'} ne 'move')) {
- $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
- $dbcopies->{$oldurl}{$id}{'cdom'} = $fromcdom;
- $dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum;
+ $rewrites->{$oldurl}{$ressrc} = $id;
+ $dbcopies->{$oldurl}{$ressrc} = $id;
$changed = 1;
}
} elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) {
@@ -1528,9 +1350,8 @@ sub url_paste_fixups {
my $srcdom = $1;
my $srcnum = $2;
if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
- $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
- $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
- $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
+ $rewrites->{$oldurl}{$ressrc} = $id;
+ $dbcopies->{$oldurl}{$ressrc} = $id;
$changed = 1;
}
}
@@ -1553,8 +1374,7 @@ sub apply_fixups {
my ($folder,$is_map,$cdom,$cnum,$errors,$updated,$info,$moves,$prefixchg,
$oldurl,$url,$caller) = @_;
my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles,
- %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs,
- %lockerrors,$lockmsg);
+ %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves);
if (ref($updated) eq 'HASH') {
if (ref($updated->{'rewrites'}) eq 'HASH') {
%rewrites = %{$updated->{'rewrites'}};
@@ -1616,7 +1436,7 @@ sub apply_fixups {
}
if ($key eq $oldurl) {
if ((exists($docmoves{$key}))) {
- unless (grep(/^\Q$oldurl\E$/,@allcopies)) {
+ unless (grep(/^\Q$oldurl\E/,@allcopies)) {
push(@allcopies,$oldurl);
}
}
@@ -1638,7 +1458,7 @@ sub apply_fixups {
$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}#;
}
}
©_dependencies($item,$storefn,$relpath,$errors,\$content);
@@ -1711,17 +1531,8 @@ sub apply_fixups {
%zombie = %{$zombies{$key}};
}
if (ref($dbcopies{$key}) eq 'HASH') {
- foreach my $idx (keys(%{$dbcopies{$key}})) {
- if (ref($dbcopies{$key}{$idx}) eq 'HASH') {
- my ($newurl,$result,$errtext) =
- &dbcopy($dbcopies{$key}{$idx},$cdom,$cnum,\%lockerrors);
- if ($result eq 'ok') {
- $newdb{$idx} = $newurl;
- } elsif (ref($errors) eq 'HASH') {
- $errors->{$key} = 1;
- }
- push(@msgs,$errtext);
- }
+ foreach my $item (keys(%{$dbcopies{$key}})) {
+ $newdb{$item} = &dbcopy($item);
}
}
if (ref($params{$key}) eq 'HASH') {
@@ -1729,12 +1540,12 @@ sub apply_fixups {
}
my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
if ($fatal) {
- return ($errtext);
+ return $errtext;
}
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{$i} eq $src) {
+ if ($zombie{$src} eq $i) {
undef($LONCAPA::map::zombies[$i]);
}
}
@@ -1754,12 +1565,12 @@ sub apply_fixups {
next;
}
my $origsrc = $src;
- if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
+ if ((exists($toretitle{$src})) && ($toretitle{$src} eq $idx)) {
if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
$changed = 1;
}
}
- if ((exists($torewrite{$idx})) && ($torewrite{$idx} eq $src)) {
+ if ((exists($torewrite{$src})) && ($torewrite{$src} eq $idx)) {
$src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
if ($origsrc =~ m{^/uploaded/}) {
if ($prefixchg && $before{'map'} && $after{'map'}) {
@@ -1769,17 +1580,17 @@ sub apply_fixups {
$src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
}
}
- if ($origsrc =~ /\.(page|sequence)$/) {
- if ($newsubdir{$origsrc}) {
+ if ($newsubdir{$origsrc}) {
+ if ($src =~ /\.(page|sequence)$/) {
$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;
- } elsif ($newdb{$idx} ne '') {
- $src = $newdb{$idx};
+ } elsif ($newdb{$src} ne '') {
+ $src = $newdb{$src};
$changed = 1;
}
if ($changed) {
@@ -1794,9 +1605,6 @@ sub apply_fixups {
}
}
}
- if (values(%lockerrors) > 0) {
- $lockmsg = join('
',values(%lockerrors));
- }
my $storefn;
if ($key eq $oldurl) {
$storefn = $url;
@@ -1819,12 +1627,12 @@ sub apply_fixups {
&LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
if ($errtext) {
if ($caller eq 'paste') {
- return (&mt('Paste failed: an error occurred saving the folder or page.'));
+ return &mt('Paste failed: an error occurred saving the folder or page.');
}
}
}
}
- return ('ok',\@msgs,$lockmsg);
+ return 'ok';
}
sub copy_dependencies {
@@ -2012,22 +1820,9 @@ sub editor {
if ($env{'form.pastemarked'}) {
my %paste_errors;
- my ($paste_res,$save_error,$pastemsgarray,$lockerror) =
+ my ($paste_res,$save_error) =
&do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
\%paste_errors);
- if (ref($pastemsgarray) eq 'ARRAY') {
- if (@{$pastemsgarray} > 0) {
-
- $r->print(''.
- join('
',@{$pastemsgarray}).
- '
');
- }
- }
- if ($lockerror) {
- $r->print(''.
- $lockerror.
- '
');
- }
if ($save_error ne '') {
return $save_error;
}
@@ -2061,10 +1856,10 @@ sub editor {
foreach my $item (split(/\&/,$env{'form.importdetail'})) {
if (defined($item)) {
my ($name,$url,$residx)=
- map { &unescape($_); } split(/\=/,$item);
- if ($url =~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
+ map {&unescape($_)} split(/\=/,$item);
+ if ($url=~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
my ($suffix,$errortxt,$locknotfreed) =
- &new_timebased_suffix($coursedom,$coursenum,'map',$1,$2);
+ &newmap_suffix($1,$2,$coursedom,$coursenum);
if ($locknotfreed) {
$r->print($locknotfreed);
}
@@ -2073,34 +1868,6 @@ sub editor {
} else {
return $errortxt;
}
- } elsif ($url =~ m{^/adm/$match_domain/$match_username/new/(smppg|bulletinboard)$}) {
- my $type = $1;
- my ($suffix,$errortxt,$locknotfreed) =
- &new_timebased_suffix($coursedom,$coursenum,$type);
- if ($locknotfreed) {
- $r->print($locknotfreed);
- }
- if ($suffix) {
- $url =~ s{^(/adm/$match_domain/$match_username)/new}{$1/$suffix};
- } else {
- return $errortxt;
- }
- } elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) {
- if ($supplementalflag) {
- next unless ($1 eq 'supplemental');
- if ($folder eq 'supplemental') {
- next unless ($2 eq 'default');
- } else {
- next unless ($folder eq 'supplemental_'.$2);
- }
- } else {
- next unless ($1 eq 'docs');
- if ($folder eq 'default') {
- next unless ($2 eq 'default');
- } else {
- next unless ($folder eq 'default_'.$2);
- }
- }
}
push(@imports, [$name, $url, $residx]);
}
@@ -2274,11 +2041,15 @@ sub process_file_upload {
$container='page';
}
($errtext,$fatal)=
- &mapread($coursenum,$coursedom,$folder.'.'.$container);
+ &mapread($coursenum,$coursedom,$folder.'.'.$container);
if ($#LONCAPA::map::order<1) {
$LONCAPA::map::order[0]=1;
$LONCAPA::map::resources[1]='';
}
+ if ($fatal) {
+ $$upload_output = ''.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'
';
+ return;
+ }
my $destination = 'docs/';
if ($folder =~ /^supplemental/) {
$destination = 'supplemental/';
@@ -2288,10 +2059,6 @@ sub process_file_upload {
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
$destination .= $2.'/';
}
- if ($fatal) {
- $$upload_output = ''.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'
';
- return;
- }
# this is for a course, not a user, so set context to coursedoc.
my $newidx=&LONCAPA::map::getresidx();
$destination .= $newidx;
@@ -2831,52 +2598,26 @@ ENDPARMS
return $line;
}
-sub new_timebased_suffix {
- my ($coursedom,$coursenum,$type,$area,$container) = @_;
- my ($prefix,$namespace,$idtype,$errtext,$locknotfreed);
- if ($type eq 'map') {
- $prefix = 'docs';
- if ($area eq 'supplemental') {
- $prefix = 'supp';
- }
- $prefix .= $container;
- $namespace = 'uploadedmaps';
- } else {
- $prefix = $type;
- $namespace = 'templated';
+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',$namespace,
+ &Apache::lonnet::get_timebased_id($prefix,'num','uploadedmaps',
$coursedom,$coursenum);
if (!$suffix) {
- if ($type eq 'map') {
- $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
- } elsif ($type eq 'smppg') {
- $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.');
- } else {
- $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new bulletin board.');
- }
+ $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.').' ';
- if ($type eq 'map') {
- &mt('This will prevent creation of additional folders or composite pages in this course.');
- } elsif ($type eq 'smppg') {
- $locknotfreed .=
- &mt('This will prevent creation of additional simple pages in this course.');
- } else {
- $locknotfreed .=
- &mt('This will prevent creation of additional bulletin boards in this course.');
- }
- $locknotfreed .=
- ' '.&mt('Please contact the domain coordinator for your LON-CAPA domain.').
- '
';
+ $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);
}
@@ -3417,6 +3158,7 @@ sub startContentScreen {
if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
$output .= ' '.&mt('Content Overview').' '."\n";
$output .= ' '.&mt('Content Search').' '."\n";
+ $output .= ' '.&mt('Content Index').' '."\n";
$output .= ''.&mt('Supplemental Content').'';
} else {
$output .= ' '.&mt('Content Editor').' '."\n";
@@ -3481,8 +3223,7 @@ sub handler {
'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
$help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
- $help{'Course Roster'} = &Apache::loncommon::help_open_topic('Docs_Course_Roster');
- $help{'Web Page'} = &Apache::loncommon::help_open_topic('Docs_Web_Page');
+
my $allowed;
# URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
@@ -3817,7 +3558,6 @@ sub handler {
'navc' => 'Table of Contents',
'sipa' => 'Simple Course Page',
'sipr' => 'Simple Problem',
- 'webp' => 'Blank Web Page (editable)',
'drbx' => 'Drop Box',
'scuf' => 'External Scores (handgrade, upload, clicker)',
'bull' => 'Discussion Board',
@@ -4070,6 +3810,7 @@ NAMFORM
NASOFORM
+
my $newrosterform=(<
@@ -4081,27 +3822,6 @@ NASOFORM
NROSTFORM
- my $newwebpage;
- if ($folder =~ /^default_?(\d*)$/) {
- $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
- if ($1) {
- $newwebpage .= $1;
- } else {
- $newwebpage .= 'default';
- }
- $newwebpage .= '/new.html';
- }
- my $newwebpageform =(<
-
- $pathitem
-
-
- $help{'Web Page'}
-
-NWEBFORM
-
-
my $specialdocumentsform;
my @specialdocumentsforma;
my $gradingform;
@@ -4160,7 +3880,6 @@ NGFFORM
{'
'=>$newsylform},
{'
'=>$newnavform},
{'
'=>$newsmppageform},
- {'
'=>$newwebpageform},
);
$specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
@@ -4298,34 +4017,12 @@ SNSFORM
SNAMFORM
- my $supwebpage;
- if ($folder =~ /^supplemental_?(\d*)$/) {
- $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
- if ($1) {
- $supwebpage .= $1;
- } else {
- $supwebpage .= 'default';
- }
- $supwebpage .= '/new.html';
- }
- my $supwebpageform =(<
-
- $pathitem
-
-
- $help{'Web Page'}
-
-SWEBFORM
-
my @specialdocs = (
{'
'
=>$supnewsylform},
{'
'
=>$supnewaboutmeform},
- {'
'=>$supwebpageform},
-
);
my @supimportdoc = (
{'
'
@@ -4680,6 +4377,7 @@ sub generate_edit_table {
sub editing_js {
my ($udom,$uname,$supplementalflag) = @_;
+ my $now = time();
my %lt = &Apache::lonlocal::texthash(
p_mnf => 'Name of New Folder',
t_mnf => 'New Folder',
@@ -4690,7 +4388,6 @@ sub editing_js {
p_msb => 'Title for the Problem',
p_mdb => 'Title for the Drop Box',
p_mbb => 'Title for the Discussion Board',
- p_mwp => 'Title for Web Page',
p_mab => "Enter user:domain for User's Personal Information Page",
p_mab2 => 'Personal Information Page of ',
p_mab_alrt1 => 'Not a valid user:domain',
@@ -4778,26 +4475,11 @@ function makesmppage() {
var title=prompt('$lt{"p_msp"}');
if (title) {
this.document.forms.newsmppg.importdetail.value=
- escape(title)+'=/adm/$udom/$uname/new/smppg';
+ escape(title)+'=/adm/$udom/$uname/$now/smppg';
this.document.forms.newsmppg.submit();
}
}
-function makewebpage(type) {
- var title=prompt('$lt{"p_mwp"}');
- var formname;
- if (type == 'supp') {
- formname = this.document.forms.supwebpage;
- } else {
- formname = this.document.forms.newwebpage;
- }
- if (title) {
- var webpage = formname.importdetail.value;
- formname.importdetail.value = escape(title)+'='+webpage;
- formname.submit();
- }
-}
-
function makesmpproblem() {
var title=prompt('$lt{"p_msb"}');
if (title) {
@@ -4820,7 +4502,7 @@ function makebulboard() {
var title=prompt('$lt{"p_mbb"}');
if (title) {
this.document.forms.newbul.importdetail.value=
- escape(title)+'=/adm/$udom/$uname/new/bulletinboard';
+ escape(title)+'=/adm/$udom/$uname/$now/bulletinboard';
this.document.forms.newbul.submit();
}
}