'.(' ' 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('
');
my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested'});
@@ -1006,23 +895,30 @@ sub do_paste_from_buffer {
%dbcopies,%zombies,%params,%docmoves,%mapmoves,%newsubdir,%newurls);
$oldurl = $url;
if ($is_map) {
+ if ($folder =~ /^default/) {
+ my $lastchange = &Apache::lonnet::get_coursechange($coursedom,$coursenum);
+ if ($lastchange > $env{'request.course.tied'}) {
+ &reinit_role($coursedom,$coursenum,$env{"course.$env{'request.course.id'}.home"});
+ }
+ }
# If pasting a map, check if map contains other maps
- my ($allmaps,%hierarchy,%titles);
- $allmaps = {};
+ my (%allmaps,%hierarchy,%titles);
if ($folder =~ /^default/) {
- $allmaps =
- &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
- $env{"course.$env{'request.course.id'}.home"},
- $env{'request.course.id'});
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ if (defined($navmap)) {
+ foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_map() },1,0,1)) {
+ $allmaps{$res->src()} = 1;
+ }
+ }
}
&contained_map_check($url,$folder,\%removefrommap,\%removeparam,
- \%addedmaps,\%hierarchy,\%titles,$allmaps);
+ \%addedmaps,\%hierarchy,\%titles,\%allmaps);
if ($url=~ m{^/uploaded/}) {
my $newurl;
unless ($env{'form.docs.markedcopy_options'} eq 'move') {
($newurl,my $error) =
&get_newmap_url($url,$folder,$prefixchg,$coursedom,$coursenum,
- $srcdom,$srcnum,\$title,$allmaps,\%newurls);
+ $srcdom,$srcnum,\$title,\%allmaps,\%newurls);
if ($error) {
return ($error);
}
@@ -1037,59 +933,45 @@ 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
&Apache::lonnet::delenv('docs.markedcopy');
# if pasting published map (main content are only) check map is not already in course
if ($folder =~ /^default/) {
- if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) {
+ if ($allmaps{$url}) {
return (&mt('Paste failed: only one instance of a particular published sequence or page is allowed within each course.'));
}
}
}
}
- 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 +998,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,
@@ -1136,34 +1016,16 @@ sub do_paste_from_buffer {
}
# Apply any changes to maps, or copy dependencies for uploaded HTML pages
my ($result,$save_err);
- my %updated = (
- rewrites => \%rewrites,
- zombies => \%zombies,
- removefrommap => \%removefrommap,
- removeparam => \%removeparam,
- dbcopies => \%dbcopies,
- retitles => \%retitles,
- );
- my %info = (
- newsubdir => \%newsubdir,
- params => \%params,
- before => \%before,
- after => \%after,
- );
- my %moves = (
- copies => \%copies,
- docmoves => \%docmoves,
- mapmoves => \%mapmoves,
- );
- ($result,my $msgsarray,my $lockerror) =
- &apply_fixups($folder,$is_map,$coursedom,$coursenum,$errors,
- \%updated,\%info,\%moves,$prefixchg,$oldurl,$url,'paste');
- $lockerrors .= $lockerror;
+ $result =
+ &apply_fixups($folder,$is_map,$prefixchg,$coursedom,$coursenum,$oldurl,
+ $url,\%removefrommap,\%removeparam,\%rewrites,\%retitles,
+ \%copies,\%dbcopies,\%zombies,\%params,\%docmoves,
+ \%mapmoves,\%newsubdir,$errors,\%before,\%after);
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 +1062,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 +1126,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 {
@@ -1394,7 +1180,7 @@ sub contained_map_check {
$titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'};
} else {
if ($allmaps->{$ressrc}) {
- $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
+ $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
} elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
$removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
} else {
@@ -1418,10 +1204,18 @@ sub contained_map_check {
return;
}
+sub reinit_role {
+ my ($cdom,$cnum,$chome) = @_;
+ my ($furl,$ferr) = &Apache::lonuserstate::readmap("$cdom/$cnum");
+ unless ($ferr) {
+ &Apache::loncommon::update_content_constraints($cdom,$cnum,$chome,$cdom.'_'.$cnum);
+ }
+ return;
+}
+
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 +1242,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 +1260,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 +1281,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 +1310,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;
}
}
@@ -1550,73 +1331,24 @@ sub url_paste_fixups {
}
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);
- if (ref($updated) eq 'HASH') {
- if (ref($updated->{'rewrites'}) eq 'HASH') {
- %rewrites = %{$updated->{'rewrites'}};
- }
- if (ref($updated->{'zombies'}) eq 'HASH') {
- %zombies = %{$updated->{'zombies'}};
- }
- if (ref($updated->{'removefrommap'}) eq 'HASH') {
- %removefrommap = %{$updated->{'removefrommap'}};
- }
- if (ref($updated->{'removeparam'}) eq 'HASH') {
- %removeparam = %{$updated->{'removeparam'}};
- }
- if (ref($updated->{'dbcopies'}) eq 'HASH') {
- %dbcopies = %{$updated->{'dbcopies'}};
- }
- if (ref($updated->{'retitles'}) eq 'HASH') {
- %retitles = %{$updated->{'retitles'}};
- }
- }
- if (ref($info) eq 'HASH') {
- if (ref($info->{'newsubdir'}) eq 'HASH') {
- %newsubdir = %{$info->{'newsubdir'}};
- }
- if (ref($info->{'params'}) eq 'HASH') {
- %params = %{$info->{'params'}};
- }
- if (ref($info->{'before'}) eq 'HASH') {
- %before = %{$info->{'before'}};
- }
- if (ref($info->{'after'}) eq 'HASH') {
- %after = %{$info->{'after'}};
- }
- }
- if (ref($moves) eq 'HASH') {
- if (ref($moves->{'copies'}) eq 'HASH') {
- %copies = %{$moves->{'copies'}};
- }
- if (ref($moves->{'docmoves'}) eq 'HASH') {
- %docmoves = %{$moves->{'docmoves'}};
- }
- if (ref($moves->{'mapmoves'}) eq 'HASH') {
- %mapmoves = %{$moves->{'mapmoves'}};
- }
- }
- foreach my $key (keys(%copies),keys(%docmoves)) {
+ my ($folder,$is_map,$prefixchg,$cdom,$cnum,$oldurl,$url,$removefrommap,
+ $removeparam,$rewrites,$retitles,$copies,$dbcopies,$zombies,$params,
+ $docmoves,$mapmoves,$newsubdir,$errors,$before,$after) = @_;
+ foreach my $key (keys(%{$copies}),keys(%{$docmoves})) {
my @allcopies;
- if (exists($copies{$key})) {
- if (ref($copies{$key}) eq 'HASH') {
- my %added;
- foreach my $innerkey (keys(%{$copies{$key}})) {
- if (($innerkey ne '') && (!$added{$innerkey})) {
- push(@allcopies,$innerkey);
- $added{$innerkey} = 1;
- }
+ if (ref($copies->{$key}) eq 'HASH') {
+ my %added;
+ foreach my $innerkey (keys(%{$copies->{$key}})) {
+ if (($innerkey ne '') && (!$added{$innerkey})) {
+ push(@allcopies,$innerkey);
+ $added{$innerkey} = 1;
}
- undef(%added);
}
+ undef(%added);
}
if ($key eq $oldurl) {
- if ((exists($docmoves{$key}))) {
- unless (grep(/^\Q$oldurl\E$/,@allcopies)) {
+ if ((exists($docmoves->{$key}))) {
+ unless (grep(/^\Q$oldurl\E/,@allcopies)) {
push(@allcopies,$oldurl);
}
}
@@ -1629,16 +1361,16 @@ sub apply_fixups {
my $content = &Apache::lonnet::getfile($item);
unless ($content eq '-1') {
my $storefn;
- if (($key eq $oldurl) && (exists($docmoves{$key}))) {
- $storefn = $docmoves{$key};
+ if (($key eq $oldurl) && (ref($docmoves) eq 'HASH') && (exists($docmoves->{$key}))) {
+ $storefn = $docmoves->{$key};
} else {
$storefn = $relpath;
$storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
- if ($prefixchg && $before{'doc'} && $after{'doc'}) {
- $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
+ if ($prefixchg) {
+ $storefn =~ s/^\Q$before->{'doc'}\E/$after->{'doc'}/;
}
- if ($newsubdir{$key}) {
- $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}/#;
+ if ($newsubdir->{$key}) {
+ $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir->{$key}#;
}
}
©_dependencies($item,$storefn,$relpath,$errors,\$content);
@@ -1646,7 +1378,7 @@ sub apply_fixups {
&Apache::lonclonecourse::writefile($env{'request.course.id'},
$storefn.$fname,$content);
if ($copyurl eq '/adm/notfound.html') {
- if (exists($docmoves{$oldurl})) {
+ if ((ref($docmoves) eq 'HASH') && (exists($docmoves->{$oldurl}))) {
return &mt('Paste failed: an error occurred copying the file.');
} elsif (ref($errors) eq 'HASH') {
$errors->{$item} = 1;
@@ -1657,14 +1389,14 @@ sub apply_fixups {
}
}
}
- foreach my $key (keys(%mapmoves)) {
+ foreach my $key (keys(%{$mapmoves})) {
my $storefn=$key;
$storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
- if ($prefixchg && $before{'map'} && $after{'map'}) {
- $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
+ if ($prefixchg) {
+ $storefn =~ s/^\Q$before->{'map'}\E/$after->{'map'}/;
}
- if ($newsubdir{$key}) {
- $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
+ if ($newsubdir->{$key}) {
+ $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir->{$key}/;
}
my $mapcontent = &Apache::lonnet::getfile($key);
if ($mapcontent eq '-1') {
@@ -1684,106 +1416,105 @@ sub apply_fixups {
}
my %updates;
if ($is_map) {
- if (ref($updated) eq 'HASH') {
- foreach my $type (keys(%{$updated})) {
- if (ref($updated->{$type}) eq 'HASH') {
- foreach my $key (keys(%{$updated->{$type}})) {
- $updates{$key} = 1;
- }
- }
- }
+ foreach my $key (keys(%{$rewrites})) {
+ $updates{$key} = 1;
+ }
+ foreach my $key (keys(%{$zombies})) {
+ $updates{$key} = 1;
+ }
+ foreach my $key (keys(%{$removefrommap})) {
+ $updates{$key} = 1;
+ }
+ foreach my $key (keys(%{$removeparam})) {
+ $updates{$key} = 1;
+ }
+ foreach my $key (keys(%{$dbcopies})) {
+ $updates{$key} = 1;
+ }
+ foreach my $key (keys(%{$retitles})) {
+ $updates{$key} = 1;
}
foreach my $key (keys(%updates)) {
my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
- if (ref($rewrites{$key}) eq 'HASH') {
- %torewrite = %{$rewrites{$key}};
+ if (ref($rewrites->{$key}) eq 'HASH') {
+ %torewrite = %{$rewrites->{$key}};
}
- if (ref($retitles{$key}) eq 'HASH') {
- %toretitle = %{$retitles{$key}};
+ if (ref($retitles->{$key}) eq 'HASH') {
+ %toretitle = %{$retitles->{$key}};
}
- if (ref($removefrommap{$key}) eq 'HASH') {
- %toremove = %{$removefrommap{$key}};
+ if (ref($removefrommap->{$key}) eq 'HASH') {
+ %toremove = %{$removefrommap->{$key}};
}
- if (ref($removeparam{$key}) eq 'HASH') {
- %remparam = %{$removeparam{$key}};
- }
- if (ref($zombies{$key}) eq 'HASH') {
- %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);
- }
+ if (ref($removeparam->{$key}) eq 'HASH') {
+ %remparam = %{$removeparam->{$key}};
+ }
+ if (ref($zombies->{$key}) eq 'HASH') {
+ %zombie = %{$zombies->{$key}};
+ }
+ if (ref($dbcopies->{$key}) eq 'HASH') {
+ foreach my $item (keys(%{$dbcopies->{$key}})) {
+ $newdb{$item} = &dbcopy($item);
}
}
- if (ref($params{$key}) eq 'HASH') {
- %currparam = %{$params{$key}};
+ if (ref($params->{$key}) eq 'HASH') {
+ %currparam = %{$params->{$key}};
}
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]);
}
}
}
- for (my $i=0; $i<@LONCAPA::map::order; $i++) {
- my $idx = $LONCAPA::map::order[$i];
- if (defined($LONCAPA::map::resources[$idx])) {
+ for (my $i=0; $i<@LONCAPA::map::resources; $i++) {
+ if (defined($LONCAPA::map::resources[$i])) {
my $changed;
- my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]);
- if ((exists($toremove{$idx})) && ($toremove{$idx} eq $src)) {
+ my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$i]);
+ if ($toremove{$src} eq $i) {
splice(@LONCAPA::map::order,$i,1);
- if (ref($currparam{$idx}) eq 'ARRAY') {
- foreach my $name (@{$currparam{$idx}}) {
- &LONCAPA::map::delparameter($idx,'parameter_'.$name);
+ if (ref($currparam{$i}) eq 'ARRAY') {
+ foreach my $name (@{$currparam{$i}}) {
+ &LONCAPA::map::delparameter($i,'parameter_'.$name);
}
}
next;
}
my $origsrc = $src;
- if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
+ if ((exists($toretitle{$src})) && ($toretitle{$src} eq $i)) {
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 $i)) {
$src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
if ($origsrc =~ m{^/uploaded/}) {
- if ($prefixchg && $before{'map'} && $after{'map'}) {
+ if ($prefixchg) {
if ($src =~ /\.(page|sequence)$/) {
- $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#;
+ $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before->{'map'}\E#$1$after->{'map'}#;
} else {
- $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
+ $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before->{'doc'}\E#$1$after->{'doc'}#;
}
}
- if ($origsrc =~ /\.(page|sequence)$/) {
- if ($newsubdir{$origsrc}) {
- $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$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) {
- $LONCAPA::map::resources[$idx] = join(':',($title,$src,$ext,$type));
+ $LONCAPA::map::resources[$i] = join(':',($title,$src,$ext,$type));
}
}
}
@@ -1794,9 +1525,6 @@ sub apply_fixups {
}
}
}
- if (values(%lockerrors) > 0) {
- $lockmsg = join(' ',values(%lockerrors));
- }
my $storefn;
if ($key eq $oldurl) {
$storefn = $url;
@@ -1804,27 +1532,25 @@ sub apply_fixups {
} else {
$storefn = $key;
$storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
- if ($prefixchg && $before{'map'} && $after{'map'}) {
- $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
+ if ($prefixchg) {
+ $storefn =~ s/^\Q$before->{'map'}\E/$after->{'map'}/;
}
- if ($newsubdir{$key}) {
- $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
+ if ($newsubdir->{$key}) {
+ $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir->{$key}/;
}
}
my $report;
if ($folder !~ /^supplemental/) {
$report = 1;
}
- (my $outtext,$errtext) =
+ my ($outtext,$errtext) =
&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 {
@@ -1889,93 +1615,23 @@ my %parameter_type = ( 'randompick'
my $valid_parameters_re = join('|',keys(%parameter_type));
# set parameters
sub update_parameter {
- if ($env{'form.changeparms'} eq 'all') {
- my (@allidx,@allmapidx,%allchecked,%currchecked);
- %allchecked = (
- 'hiddenresource' => {},
- 'encrypturl' => {},
- 'randompick' => {},
- 'randomorder' => {},
- );
- foreach my $which (keys(%allchecked)) {
- $env{'form.all'.$which} =~ s/,$//;
- if ($which eq 'randompick') {
- foreach my $item (split(/,/,$env{'form.all'.$which})) {
- my ($res,$value) = split(/:/,$item);
- if ($value =~ /^\d+$/) {
- $allchecked{$which}{$res} = $value;
- }
- }
- } else {
- map { $allchecked{$which}{$_} = 1; } split(/,/,$env{'form.all'.$which});
- }
- }
- my $haschanges = 0;
- foreach my $res (@LONCAPA::map::order) {
- my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
- $name=&LONCAPA::map::qtescape($name);
- $url=&LONCAPA::map::qtescape($url);
- next unless ($name && $url);
- my $is_map;
- if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
- $is_map = 1;
- }
- foreach my $which (keys(%allchecked)) {
- if (($which eq 'randompick' || $which eq 'randomorder')) {
- next if (!$is_map);
- }
- my $oldvalue = 0;
- my $newvalue = 0;
- if ($allchecked{$which}{$res}) {
- $newvalue = $allchecked{$which}{$res};
- }
- my $current = (&LONCAPA::map::getparameter($res,'parameter_'.$which))[0];
- if ($which eq 'randompick') {
- if ($current =~ /^(\d+)$/) {
- $oldvalue = $1;
- }
- } else {
- if ($current =~ /^yes$/i) {
- $oldvalue = 1;
- }
- }
- if ($oldvalue ne $newvalue) {
- $haschanges = 1;
- if ($newvalue) {
- my $storeval = 'yes';
- if ($which eq 'randompick') {
- $storeval = $newvalue;
- }
- &LONCAPA::map::storeparameter($res,'parameter_'.$which,
- $storeval,
- $parameter_type{$which});
- &remember_parms($res,$which,'set',$storeval);
- } elsif ($oldvalue) {
- &LONCAPA::map::delparameter($res,'parameter_'.$which);
- &remember_parms($res,$which,'del');
- }
- }
- }
- }
- return $haschanges;
- } else {
- return 0 if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
- my $which = $env{'form.changeparms'};
- my $idx = $env{'form.setparms'};
- if ($env{'form.'.$which.'_'.$idx}) {
- my $value = ($which eq 'randompick') ? $env{'form.rpicknum_'.$idx}
- : 'yes';
- &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $value,
- $parameter_type{$which});
- &remember_parms($idx,$which,'set',$value);
- } else {
- &LONCAPA::map::delparameter($idx,'parameter_'.$which);
+ return 0 if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
- &remember_parms($idx,$which,'del');
- }
- return 1;
+ my $which = $env{'form.changeparms'};
+ my $idx = $env{'form.setparms'};
+ if ($env{'form.'.$which.'_'.$idx}) {
+ my $value = ($which eq 'randompick') ? $env{'form.'.$which.'_'.$idx}
+ : 'yes';
+ &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $value,
+ $parameter_type{$which});
+ &remember_parms($idx,$which,'set',$value);
+ } else {
+ &LONCAPA::map::delparameter($idx,'parameter_'.$which);
+
+ &remember_parms($idx,$which,'del');
}
+ return 1;
}
@@ -2038,11 +1694,7 @@ sub editor {
$container = 'sequence';
}
- my $jumpto;
-
- unless ($supplementalflag) {
- $jumpto = "'uploaded/$coursedom/$coursenum/$folder.$container'";
- }
+ my $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
unless ($allowed) {
$randompick = -1;
@@ -2082,22 +1734,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;
}
@@ -2131,10 +1770,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);
}
@@ -2143,45 +1782,13 @@ 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]);
}
}
- ($errtext,$fatal,my $fixuperrors) =
- &group_import($coursenum, $coursedom, $folder,$container,
- 'londocs',@imports);
+ ($errtext,$fatal)=&group_import($coursenum, $coursedom, $folder,
+ $container,'londocs',@imports);
return $errtext if ($fatal);
- if ($fixuperrors) {
- $r->print($fixuperrors);
- }
}
# Loading a complete map
if ($env{'form.loadmap'}) {
@@ -2237,7 +1844,7 @@ sub editor {
$r->print('');
}
- my ($to_show,$output,@allidx,@allmapidx);
+ my ($to_show,$output);
&Apache::loncommon::start_data_table_count(); #setup a row counter
foreach my $res (@LONCAPA::map::order) {
@@ -2246,10 +1853,6 @@ sub editor {
$url=&LONCAPA::map::qtescape($url);
unless ($name) { $name=(split(/\//,$url))[-1]; }
unless ($name) { $idx++; next; }
- push(@allidx,$res);
- if ($url =~ m{/uploaded/.+\.(page|sequence)$}) {
- push(@allmapidx,$res);
- }
$output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
$coursenum,$coursedom,$crstype,
$pathitem,$supplementalflag,$container);
@@ -2264,7 +1867,7 @@ sub editor {
'Navigation_Screen',undef,'RAT')
.''.&mt('Tools:').' '
.'
$rand_pick_text
@@ -2945,52 +2508,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);
}
@@ -3531,6 +3068,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";
@@ -3595,8 +3133,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.
@@ -3674,33 +3211,23 @@ sub handler {
# Do we directly jump somewhere?
- if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
+ if ($env{'form.command'} eq 'direct') {
+ my ($mapurl,$id,$resurl);
if ($env{'form.symb'} ne '') {
$env{'form.folderpath'}=
&Apache::loncommon::symb_to_docspath($env{'form.symb'});
- &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
- $env{'form.command'}.'_'.$env{'form.symb'}});
} elsif ($env{'form.supppath'} ne '') {
$env{'form.folderpath'}=$env{'form.supppath'};
- &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
- $env{'form.command'}.'_'.$env{'form.supppath'}});
}
} elsif ($env{'form.command'} eq 'editdocs') {
- $env{'form.folderpath'} = 'default&'.
- &Apache::lonhtmlcommon::entity_encode('Main Course Content').
- ':::::';
- &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
+ $env{'form.folderpath'} = 'default&'.
+ &Apache::lonhtmlcommon::entity_encode('Main Course Content').
+ ':::::';
} elsif ($env{'form.command'} eq 'editsupp') {
- $env{'form.folderpath'} = 'supplemental&'.
+ $env{'form.folderpath'} = 'default&'.
&Apache::lonhtmlcommon::entity_encode('Supplemental Content');
- &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
- } elsif ($env{'form.command'} eq 'contents') {
- &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
- } elsif ($env{'form.command'} eq 'home') {
- &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
}
-
# Where do we store these for when we come back?
my $stored_folderpath='docs_folderpath';
if ($supplementalflag) {
@@ -3711,9 +3238,6 @@ sub handler {
if ((!$env{'form.folderpath'}) && $allowed) {
&Apache::loncommon::restore_course_settings($stored_folderpath,
{'folderpath' => 'scalar'});
- unless (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
- undef($env{'form.folderpath'});
- }
}
# If we are not allowed to make changes, all we can see are supplemental docs
@@ -3916,6 +3440,9 @@ sub handler {
} elsif ((!$showdoc) && (!$uploadphase)) {
# -----------------------------------------------------------------------------
my %lt=&Apache::lonlocal::texthash(
+ 'uplm' => 'Upload a new main '.lc($crstype).' document',
+ 'upls' => 'Upload a new supplemental '.lc($crstype).' document',
+ 'impp' => 'Import a document',
'copm' => 'All documents out of a published map into this folder',
'upfi' => 'Upload File',
'upld' => 'Import Content',
@@ -3925,20 +3452,21 @@ sub handler {
'impm' => 'Import from Assembled Map',
'selm' => 'Select Map',
'load' => 'Load Map',
+ 'reco' => 'Recover Deleted Documents',
'newf' => 'New Folder',
'newp' => 'New Composite Page',
+ 'extr' => 'External Resource',
'syll' => 'Syllabus',
'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',
'mypi' => 'My Personal Information Page',
'grpo' => 'Group Portfolio',
'rost' => 'Course Roster',
- 'abou' => 'Personal Information Page for a User',
+ 'abou' => 'Personal Information Page for a User',
'imsf' => 'IMS Import',
'imsl' => 'Import IMS package',
'cms' => 'Origin of IMS package',
@@ -3946,6 +3474,9 @@ sub handler {
'file' => 'File',
'title' => 'Title',
'comment' => 'Comment',
+ 'url' => 'URL',
+ 'prev' => 'Preview',
+ 'lnk' => 'Add Link',
'parse' => 'Upload embedded images/multimedia files if HTML file',
);
# -----------------------------------------------------------------------------
@@ -4184,6 +3715,7 @@ NAMFORM
NASOFORM
+
my $newrosterform=(<
@@ -4195,27 +3727,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;
@@ -4274,7 +3785,6 @@ NGFFORM
{' '=>$newsylform},
{' '=>$newnavform},
{' '=>$newsmppageform},
- {' '=>$newwebpageform},
);
$specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
@@ -4412,34 +3922,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 = (
{' '
@@ -4729,15 +4217,15 @@ sub generate_edit_table {
my $form;
my $activetab;
my $active;
- if (($env{'form.active'} ne '') && ($env{'form.active'} ne 'aa')) {
+ if($env{'form.active'} ne ''){
$activetab = $env{'form.active'};
}
my $backicon = $iconpath.'clickhere.gif';
- my $backtext = &mt('Exit Editor');
+ my $backtext = &mt('Exit');
$form = ''.
'
'."\n".
''.
- ''.
+ ' '.
' '.$backtext.' '."\n".
''.
@@ -4794,6 +4282,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',
@@ -4804,7 +4293,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',
@@ -4833,25 +4321,9 @@ sub editing_js {
my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents%3A%3A%3A%3A%3A';
my $toplevelsupp = &supplemental_base();
- my $backtourl;
- if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
- my $caller = $1;
- if ($caller =~ /^supplemental/) {
- $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
- } else {
- my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
- $res = &Apache::lonnet::clutter($res);
- if (&Apache::lonnet::is_on_map($res)) {
- $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($res),'<>&"').'?symb='.
- &HTML::Entities::encode($caller,'<>&"');
- }
- }
- } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
- $backtourl = '/adm/menu';
- } elsif ($supplementalflag) {
+ my $backtourl = '/adm/navmaps';
+ if ($supplementalflag) {
$backtourl = '/adm/supplemental';
- } else {
- $backtourl = '/adm/navmaps';
}
my $fieldsets = "'ext','doc'";
@@ -4892,26 +4364,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) {
@@ -4934,7 +4391,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();
}
}
@@ -5040,154 +4497,34 @@ this.document.forms.renameform.submit();
}
function updatePick(targetform,index,caller) {
- var pickitem;
- var picknumitem;
- var picknumtext;
- if (index == 'all') {
- pickitem = document.getElementById('randompickall');
- picknumitem = document.getElementById('rpicknumall');
- picknumtext = document.getElementById('rpicktextall');
- } else {
- pickitem = document.getElementById('randompick_'+index);
- picknumitem = document.getElementById('rpicknum_'+index);
- picknumtext = document.getElementById('randompicknum_'+index);
- }
+ var pickitem = document.getElementById('rpick_'+index);
+ var picknumitem = document.getElementById('rpicknum_'+index);
if (pickitem.checked) {
var picknum=prompt('$lt{"rpck"}',picknumitem.value);
if (picknum == '' || picknum == null) {
if (caller == 'check') {
pickitem.checked=false;
- if (index == 'all') {
- picknumtext.innerHTML = '';
- if (caller == 'link') {
- propagateState(targetform,'rpicknum');
- }
- } else {
- checkForSubmit(targetform,'randompick');
- }
+ return;
}
} else {
picknum.toString();
var regexdigit=/^\\d+\$/;
if (regexdigit.test(picknum)) {
picknumitem.value = picknum;
- if (index == 'all') {
- picknumtext.innerHTML = ' '+picknum+' ';
- if (caller == 'link') {
- propagateState(targetform,'rpicknum');
- }
- } else {
- picknumtext.innerHTML = ' '+picknum+' ';
- checkForSubmit(targetform,'randompick');
- }
+ targetform.changeparms.value='randompick';
+ targetform.submit();
} else {
if (caller == 'check') {
- if (index == 'all') {
- picknumtext.innerHTML = '';
- if (caller == 'link') {
- propagateState(targetform,'rpicknum');
- }
- } else {
- pickitem.checked=false;
- checkForSubmit(targetform,'randompick');
- }
+ pickitem.checked=false;
}
return;
}
}
} else {
- picknumitem.value = '';
- picknumtext.innerHTML = '';
- if (index == 'all') {
- if (caller == 'link') {
- propagateState(targetform,'rpicknum');
- }
- } else {
- checkForSubmit(targetform,'randompick');
- }
- }
-}
-
-function propagateState(form,param) {
- if (document.getElementById(param+'all')) {
- var setcheck = 0;
- var rpick = 0;
- if (param == 'rpicknum') {
- if (document.getElementById('randompickall')) {
- if (document.getElementById('randompickall').checked) {
- if (document.getElementById('rpicknumall')) {
- rpick = document.getElementById('rpicknumall').value;
- }
- }
- }
- } else {
- if (document.getElementById(param+'all').checked) {
- setcheck = 1;
- }
- }
- if ((param == 'encrypturl') || (param == 'hiddenresource')) {
- var allidxlist = form.allidx.value;
- if (allidxlist != '') {
- var allidxs = allidxlist.split(',');
- if (allidxs.length > 1) {
- for (var i=0; i 1) {
- for (var i=0; i 0) {
- document.getElementById('randompicknum_'+allmapidxs[i]).innerHTML = ': '+rpick+' ';
- } else {
- document.getElementById('randompicknum_'+allmapidxs[i]).innerHTML = '';
- }
- }
- }
- } else {
- if (setcheck == 1) {
- document.getElementById(param+'_'+allmapidxs[i]).checked = true;
- } else {
- document.getElementById(param+'_'+allmapidxs[i]).checked = false;
- }
- }
- }
- }
- }
- }
- }
- }
- return;
-}
-
-function checkForSubmit(targetform,param) {
- if (document.togglemultchecks.showmultpick.length) {
- for (var i=0; i 1) {
- for (var i=0; i