version 1.488, 2012/06/30 23:11:11
|
version 1.489, 2012/07/05 21:33:39
|
Line 438 sub docs_change_log {
|
Line 438 sub docs_change_log {
|
'</script>'."\n"; |
'</script>'."\n"; |
$r->print(&Apache::loncommon::start_page('Content Change Log',$js)); |
$r->print(&Apache::loncommon::start_page('Content Change Log',$js)); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Change Log')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Change Log')); |
$r->print(&startContentScreen('docs')); |
$r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs'))); |
my %orderhash; |
my %orderhash; |
my $container='sequence'; |
my $container='sequence'; |
my $pathitem; |
my $pathitem; |
Line 457 sub docs_change_log {
|
Line 457 sub docs_change_log {
|
my $jumpto = $readfile; |
my $jumpto = $readfile; |
$jumpto =~ s{^/}{}; |
$jumpto =~ s{^/}{}; |
my $tid = 1; |
my $tid = 1; |
|
if ($supplementalflag) { |
|
$tid = 2; |
|
} |
my ($breadcrumbtrail) = &breadcrumbs($allowed,$crstype); |
my ($breadcrumbtrail) = &breadcrumbs($allowed,$crstype); |
$r->print($breadcrumbtrail. |
$r->print($breadcrumbtrail. |
&generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto, |
&generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto, |
Line 729 sub do_paste_from_buffer {
|
Line 732 sub do_paste_from_buffer {
|
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}); |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}); |
my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}); |
my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}); |
# Maps need to be copied first |
# Maps need to be copied first |
my ($oldurl,%removefrommap,%addedmaps,%rewrites,%copies,%dbcopies,%zombies,%params); |
my ($oldurl,%removefrommap,%addedmaps,%rewrites,%copies,%dbcopies,%zombies,%params, |
|
%moves,$srcdom,$srcnum); |
|
$oldurl = $url; |
if ($url=~/\.(page|sequence)$/) { |
if ($url=~/\.(page|sequence)$/) { |
# If pasting a map, check if map contains other maps |
# If pasting a map, check if map contains other maps |
&contained_map_check($url,$folder,\%removefrommap,\%addedmaps); |
&contained_map_check($url,$folder,\%removefrommap,\%addedmaps); |
Line 770 sub do_paste_from_buffer {
|
Line 775 sub do_paste_from_buffer {
|
} |
} |
if ($is_unique) { |
if ($is_unique) { |
if ($path =~ m{^/uploaded/($match_domain)/($match_courseid)/$}) { |
if ($path =~ m{^/uploaded/($match_domain)/($match_courseid)/$}) { |
my $srcdom = $1; |
$srcdom = $1; |
my $srcnum = $2; |
$srcnum = $2; |
if (($srcdom ne $coursedom) && ($srcnum ne $coursenum)) { |
if (($1 ne $coursedom) && ($2 ne $coursenum)) { |
if (&Apache::lonnet::allowed('mdc',$srcdom.'_'.$srcnum)) { |
my $srcdom = $1; |
|
my $srcnum = $2; |
|
if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) { |
&url_paste_fixups($oldid,$ext,$coursedom,$coursenum, |
&url_paste_fixups($oldid,$ext,$coursedom,$coursenum, |
\%allmaps, \%rewrites,\%copies,\%dbcopies,\%zombies,\%params); |
\%allmaps, \%rewrites,\%copies,\%dbcopies,\%zombies,\%params); |
} else { |
} else { |
Line 808 sub do_paste_from_buffer {
|
Line 815 sub do_paste_from_buffer {
|
return &mt('Paste failed: only one instance of a particular published sequence or page is allowed within each course.'); |
return &mt('Paste failed: only one instance of a particular published sequence or page is allowed within each course.'); |
} |
} |
} |
} |
|
} elsif ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/}) { |
|
if (($1 ne $coursedom) || ($2 ne $coursenum)) { |
|
$srcdom = $1; |
|
$srcnum = $2; |
|
unless ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) { |
|
return &mt('Paste failed: Item is from a different course which you do not have rights to edit'); |
|
} |
|
} |
} |
} |
if ($url=~ m{/smppg$}) { |
if ($url=~ m{/smppg$}) { |
my $db_name = &Apache::lonsimplepage::get_db_name($url); |
my $db_name = &Apache::lonsimplepage::get_db_name($url); |
Line 822 sub do_paste_from_buffer {
|
Line 837 sub do_paste_from_buffer {
|
$title=&mt('Copy of').' '.$title; |
$title=&mt('Copy of').' '.$title; |
} |
} |
} |
} |
|
my ($relpath,$oldprefix,$prefixchg); |
|
if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(.+)$}) { |
|
$oldprefix = $1; |
|
$relpath = $2; |
|
if (($folder =~ /^supplemental/) && ($oldprefix eq 'docs')) { |
|
$prefixchg = 1; |
|
} elsif (($folder =~ /^default/) && ($oldprefix eq 'supplemental')) { |
|
$prefixchg = 1; |
|
} |
|
} |
$title = &LONCAPA::map::qtunescape($title); |
$title = &LONCAPA::map::qtunescape($title); |
my $ext='false'; |
my $ext='false'; |
if ($url=~m{^http(|s)://}) { $ext='true'; } |
if ($url=~m{^http(|s)://}) { $ext='true'; } |
$url = &LONCAPA::map::qtunescape($url); |
$url = &LONCAPA::map::qtunescape($url); |
# Now insert the URL at the bottom |
# Now insert the URL at the bottom |
my $newidx = &LONCAPA::map::getresidx($url); |
my $newidx = &LONCAPA::map::getresidx($url); |
my $relpath; |
|
if (($folder =~ /^supplemental/) && |
|
($url =~ m{^/uploaded/$coursedom/$coursenum/docs/(.+)})) { |
|
$relpath = $1; |
|
} elsif (($folder =~ /^default/) && |
|
($url =~ m{^/uploaded/$coursedom/$coursenum/supplemental/(.+)})) { |
|
$relpath = $1; |
|
} |
|
if ($relpath ne '') { |
if ($relpath ne '') { |
my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$}); |
my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$}); |
my ($newloc,$newsubdir) = ($folder =~ /^(default|supplemental)_?(\d*)/); |
my ($newloc,$newsubdir) = ($folder =~ /^(default|supplemental)_?(\d*)/); |
Line 846 sub do_paste_from_buffer {
|
Line 863 sub do_paste_from_buffer {
|
if ($newsubdir eq '') { |
if ($newsubdir eq '') { |
$newsubdir = 'default'; |
$newsubdir = 'default'; |
} |
} |
my $newpath = "$newprefix/$newsubdir/$newidx/$rem"; |
if (($prefixchg) || ($srcdom ne '') && ($srcnum ne '')) { |
$url = |
my $newpath = "$newprefix/$newsubdir/$newidx/$rem"; |
&Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath, |
$url = |
&Apache::lonnet::getfile($url)); |
&Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath, |
if ($url eq '/adm/notfound.html') { |
&Apache::lonnet::getfile($oldurl)); |
return &mt('Paste failed: an error occurred saving the file.'); |
if ($url eq '/adm/notfound.html') { |
|
return &mt('Paste failed: an error occurred saving the file.'); |
|
} else { |
|
my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$}); |
|
$newsubpath =~ s{/+$}{/}; |
|
$moves{$oldurl} = $newsubpath; |
|
} |
} |
} |
} |
} |
my $noparams = 0; |
my $noparams = 0; |
if ((ref($params{$oldurl}) eq 'HASH') && ($relpath ne '') && ($folder =~ /^supplemental/)) { |
if ((ref($params{$oldurl}) eq 'HASH') && ($relpath ne '') && ($folder =~ /^supplemental/)) { |
$noparams = 1; |
$noparams = 1; |
} |
} |
&apply_fixups($coursedom,$coursenum,$oldurl,$url,$noparams,\%rewrites,\%copies,\%dbcopies,\%zombies,\%params); |
&apply_fixups($coursedom,$coursenum,$oldurl,$url,$noparams,\%rewrites,\%copies, |
|
\%dbcopies,\%zombies,\%params,\%moves); |
if ($env{'docs.markedcopy_supplemental'}) { |
if ($env{'docs.markedcopy_supplemental'}) { |
if ($folder =~ /^supplemental/) { |
if ($folder =~ /^supplemental/) { |
$title = $env{'docs.markedcopy_supplemental'}; |
$title = $env{'docs.markedcopy_supplemental'}; |
Line 978 sub url_paste_fixups {
|
Line 1002 sub url_paste_fixups {
|
$rewrites->{$oldurl}{$ressrc} = $id; |
$rewrites->{$oldurl}{$ressrc} = $id; |
&url_paste_fixups($ressrc,$3,$cdom,$cnum,$allmaps,$rewrites,$copies,$dbcopies,$zombies,$params); |
&url_paste_fixups($ressrc,$3,$cdom,$cnum,$allmaps,$rewrites,$copies,$dbcopies,$zombies,$params); |
} else { |
} else { |
|
$rewrites->{$oldurl}{$ressrc} = $id; |
$copies->{$oldurl}{$ressrc} = $id; |
$copies->{$oldurl}{$ressrc} = $id; |
} |
} |
} |
} |
Line 1011 sub url_paste_fixups {
|
Line 1036 sub url_paste_fixups {
|
} |
} |
|
|
sub apply_fixups { |
sub apply_fixups { |
my ($cdom,$cnum,$oldurl,$url,$noparams,$rewrites,$copies,$dbcopies,$zombies,$params) = @_; |
my ($cdom,$cnum,$oldurl,$url,$noparams,$rewrites,$copies,$dbcopies,$zombies,$params, |
|
$moves) = @_; |
my (%newdb,%newdoc); |
my (%newdb,%newdoc); |
if (ref($dbcopies->{$oldurl}) eq 'HASH') { |
if (ref($dbcopies->{$oldurl}) eq 'HASH') { |
foreach my $item (keys(%{$dbcopies->{$oldurl}})) { |
foreach my $item (keys(%{$dbcopies->{$oldurl}})) { |
$newdb{$item} = &dbcopy($item); |
$newdb{$item} = &dbcopy($item); |
} |
} |
} |
} |
|
my @allcopies; |
if (ref($copies->{$oldurl}) eq 'HASH') { |
if (ref($copies->{$oldurl}) eq 'HASH') { |
foreach my $item (keys(%{$copies->{$oldurl}})) { |
push(@allcopies,keys(%{$copies->{$oldurl}})); |
|
} |
|
if ((ref($moves) eq 'HASH') && (exists($moves->{$oldurl}))) { |
|
push(@allcopies,$oldurl); |
|
} |
|
if (@allcopies > 0) { |
|
foreach my $item (@allcopies) { |
my $content = &Apache::lonnet::getfile($item); |
my $content = &Apache::lonnet::getfile($item); |
my $newcontent; |
|
unless ($content eq '-1') { |
unless ($content eq '-1') { |
my $mm = new File::MMagic; |
my $mm = new File::MMagic; |
my $mimetype = $mm->checktype_contents($content); |
my $mimetype = $mm->checktype_contents($content); |
if ($mimetype eq 'text/html') { |
if ($mimetype eq 'text/html') { |
my (%allfiles,%codebase,$state); |
my (%allfiles,%codebase,$state); |
my ($embedded,$num,$delnum) = |
if (&Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,\$content) eq 'ok') { |
&Apache::loncommon::ask_for_embedded_content( |
my ($numexisting,$numpathchanges,$existing); |
'/adm/dependencies',$state,\%allfiles,\%codebase, |
(undef,$numexisting,$numpathchanges,$existing) = |
{'error_on_invalid_names' => 1, |
&Apache::loncommon::ask_for_embedded_content( |
'ignore_remote_references' => 1, |
'/adm/coursedocs',$state,\%allfiles,\%codebase, |
'docs_url' => $oldurl}); |
{'error_on_invalid_names' => 1, |
if ($embedded) { |
'ignore_remote_references' => 1, |
#FIXME Need to check for dependencies and copy and update refs. |
'docs_url' => $oldurl, |
|
'context' => 'paste'}); |
|
if ($numexisting > 0) { |
|
if (ref($existing) eq 'HASH') { |
|
my ($relpath) = ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(?:default|\d+)/.*/)[^/]+$}); |
|
foreach my $dep (keys(%{$existing})) { |
|
$dep =~ s{^\Q$relpath\E}{}; |
|
my $depfile = $relpath.$dep; |
|
my $depstorefn; |
|
if ((ref($copies->{$oldurl}) eq 'HASH') && |
|
($copies->{$oldurl}{$item})) { |
|
$depstorefn = $relpath; |
|
$depstorefn =~s{^/\w+/$match_domain/$match_courseid/}{}; |
|
} elsif ((ref($moves) eq 'HASH') && |
|
(exists($moves->{$oldurl}))) { |
|
$depstorefn = $moves->{$oldurl}; |
|
} |
|
$depstorefn .= $dep; |
|
my $depcontent = &Apache::lonnet::getfile($depfile); |
|
unless ($depcontent eq '-1') { |
|
&Apache::lonclonecourse::writefile($env{'request.course.id'},$depstorefn,$depcontent); |
|
} |
|
} |
|
} |
|
} |
} |
} |
$newcontent = $content; |
|
} else { |
|
$newcontent = $content; |
|
} |
} |
my $storefn=$item; |
my $storefn=$item; |
$storefn=~s{^/\w+/$match_domain/$match_courseid/}{}; |
unless (exists($moves->{$oldurl})) { |
$newdoc{$item} = &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,$newcontent); |
$storefn=~s{^/\w+/$match_domain/$match_courseid/}{}; |
|
$newdoc{$item} = &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,$content); |
|
} |
} |
} |
} |
} |
} |
} |