version 1.266, 2010/05/27 18:27:43
|
version 1.281, 2013/01/15 18:21:31
|
Line 66 invocation by F<loncapa_apache.conf>:
|
Line 66 invocation by F<loncapa_apache.conf>:
|
|
|
=head1 OVERVIEW |
=head1 OVERVIEW |
|
|
Authors can only write-access the C</~authorname/> space. They can |
Authors can only write-access the C</priv/domain/authorname/> space. |
copy resources into the resource area through the publication step, |
They can copy resources into the resource area through the |
and move them back through a recover step. Authors do not have direct |
publication step, and move them back through a recover step. |
write-access to their resource space. |
Authors do not have direct write-access to their resource space. |
|
|
During the publication step, several events will be |
During the publication step, several events will be |
triggered. Metadata is gathered, where a wizard manages default |
triggered. Metadata is gathered, where a wizard manages default |
Line 121 use HTML::LCParser;
|
Line 121 use HTML::LCParser;
|
use HTML::Entities; |
use HTML::Entities; |
use Encode::Encoder; |
use Encode::Encoder; |
use Apache::lonxml; |
use Apache::lonxml; |
use Apache::loncacc; |
|
use DBI; |
use DBI; |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::loncommon(); |
use Apache::loncommon(); |
Line 266 sub metaread {
|
Line 265 sub metaread {
|
my ($logfile,$fn,$prefix)=@_; |
my ($logfile,$fn,$prefix)=@_; |
unless (-e $fn) { |
unless (-e $fn) { |
print($logfile 'No file '.$fn."\n"); |
print($logfile 'No file '.$fn."\n"); |
return '<div><b>' |
return '<p class="LC_warning">' |
.&mt('No file: [_1]' |
.&mt('No file: [_1]',&Apache::loncfile::display($fn)) |
,'</b> <tt>'.&Apache::loncfile::display($fn).'</tt></div>'); |
.'</p>'; |
} |
} |
print($logfile 'Processing '.$fn."\n"); |
print($logfile 'Processing '.$fn."\n"); |
my $metastring; |
my $metastring; |
Line 277 sub metaread {
|
Line 276 sub metaread {
|
$metastring=join('',<$metafh>); |
$metastring=join('',<$metafh>); |
} |
} |
&metaeval($metastring,$prefix); |
&metaeval($metastring,$prefix); |
return '<div><b>' |
return '<p class="LC_info">' |
.&mt('Processed file: [_1]' |
.&mt('Processed file: [_1]',&Apache::loncfile::display($fn)) |
,'</b> <tt>'.&Apache::loncfile::display($fn).'</tt></div>'); |
.'</p>'; |
} |
} |
|
|
######################################### |
######################################### |
Line 1017 sub publish {
|
Line 1016 sub publish {
|
$outdep.= ' - <span class="LC_error">'.&mt('Currently not available'). |
$outdep.= ' - <span class="LC_error">'.&mt('Currently not available'). |
'</span>'; |
'</span>'; |
} else { |
} else { |
|
# |
|
# Store the fact that the dependency has been used by the target file |
|
# Unfortunately, usage is erroneously named sequsage in lonmeta.pm |
|
# The translation happens in lonmetadata.pm |
|
# |
my %temphash=(&Apache::lonnet::declutter($target).'___'. |
my %temphash=(&Apache::lonnet::declutter($target).'___'. |
&Apache::lonnet::declutter($thisdep).'___usage' |
&Apache::lonnet::declutter($thisdep).'___usage' |
=> time); |
=> time); |
Line 1080 sub publish {
|
Line 1084 sub publish {
|
# ------------------------------------------------ Check out directory hierachy |
# ------------------------------------------------ Check out directory hierachy |
|
|
my $thisdisfn=$source; |
my $thisdisfn=$source; |
$thisdisfn=~s/^\/home\/\Q$cuname\E\///; |
|
|
|
my @urlparts=split(/\//,$thisdisfn); |
$thisdisfn=~s/^\Q$docroot\E\/priv\/\Q$cudom\E\/\Q$cuname\E\///; |
|
my @urlparts=('.',split(/\//,$thisdisfn)); |
$#urlparts--; |
$#urlparts--; |
|
|
my $currentpath='/home/'.$cuname.'/'; |
my $currentpath=$docroot.'/priv/'.$cudom.'/'.$cuname.'/'; |
|
|
my $prefix='../'x($#urlparts); |
my $prefix='../'x($#urlparts); |
foreach (@urlparts) { |
foreach my $subdir (@urlparts) { |
$currentpath.=$_.'/'; |
$currentpath.=$subdir.'/'; |
$scrout.=&metaread($logfile,$currentpath.'default.meta',$prefix); |
$scrout.=&metaread($logfile,$currentpath.'default.meta',$prefix); |
$prefix=~s|^\.\./||; |
$prefix=~s|^\.\./||; |
} |
} |
Line 1121 sub publish {
|
Line 1125 sub publish {
|
# ------------------------------------------------------------- Save some stuff |
# ------------------------------------------------------------- Save some stuff |
my %savemeta=(); |
my %savemeta=(); |
foreach ('title') { |
foreach ('title') { |
$savemeta{$_}=$metadatafields{$_}; |
if ($metadatafields{$_}) { $savemeta{$_}=$metadatafields{$_}; } |
} |
} |
# ------------------------------------------ See if anything new in file itself |
# ------------------------------------------ See if anything new in file itself |
|
|
Line 1223 sub publish {
|
Line 1227 sub publish {
|
my $intr_scrout.='<br />' |
my $intr_scrout.='<br />' |
.'<form name="pubform" action="/adm/publish" method="post">'; |
.'<form name="pubform" action="/adm/publish" method="post">'; |
unless ($env{'form.makeobsolete'}) { |
unless ($env{'form.makeobsolete'}) { |
my $thissrc=$source; |
|
$thissrc=~s{^/home/($match_username)/public_html}{/priv/$1}; |
|
$intr_scrout.='<p class="LC_warning">' |
$intr_scrout.='<p class="LC_warning">' |
.&mt('Searching for your resource will be based on the following metadata. Please provide as much data as possible.') |
.&mt('Searching for your resource will be based on the following metadata. Please provide as much data as possible.') |
.'</p>' |
.'</p>' |
.'<p><input type="submit" value="' |
.'<p><input type="submit" value="' |
.&mt('Finalize Publication') |
.&mt('Finalize Publication') |
.'" /> <a href="'.$thissrc.'">'.&mt('Cancel').'</a></p>'; |
.'" /> <a href="'.&Apache::loncfile::url($source).'">'.&mt('Cancel').'</a></p>'; |
} |
} |
$intr_scrout.=&Apache::lonhtmlcommon::start_pick_box(); |
$intr_scrout.=&Apache::lonhtmlcommon::start_pick_box(); |
$intr_scrout.= |
$intr_scrout.= |
Line 1767 sub phasetwo {
|
Line 1769 sub phasetwo {
|
|
|
# ------------------------------------------------ Provide link to new resource |
# ------------------------------------------------ Provide link to new resource |
unless ($batch) { |
unless ($batch) { |
my $thissrc=$source; |
|
$thissrc=~s{^/home/($match_username)/public_html}{/priv/$1}; |
|
|
|
|
my $thissrc=&Apache::loncfile::url($source); |
my $thissrcdir=$thissrc; |
my $thissrcdir=$thissrc; |
$thissrcdir=~s/\/[^\/]+$/\//; |
$thissrcdir=~s/\/[^\/]+$/\//; |
|
|
Line 1839 sub batchpublish {
|
Line 1840 sub batchpublish {
|
my %oldenv=%env; |
my %oldenv=%env; |
$srcfile=~s/\/+/\//g; |
$srcfile=~s/\/+/\//g; |
$targetfile=~s/\/+/\//g; |
$targetfile=~s/\/+/\//g; |
my $thisdisfn=$srcfile; |
|
$thisdisfn=~s/\/home\/korte\/public_html\///; |
|
$srcfile=~s/\/+/\//g; |
$srcfile=~s/\/+/\//g; |
|
|
my $docroot=$r->dir_config('lonDocRoot'); |
my $docroot=$r->dir_config('lonDocRoot'); |
Line 1857 sub batchpublish {
|
Line 1856 sub batchpublish {
|
my $thisembstyle=&Apache::loncommon::fileembstyle($thistype); |
my $thisembstyle=&Apache::loncommon::fileembstyle($thistype); |
|
|
$r->print('<h2>' |
$r->print('<h2>' |
.&mt('Publishing [_1]' |
.&mt('Publishing [_1]',&Apache::loncfile::display($srcfile)) |
,'<span class="LC_filename">'.$thisdisfn.'</span>') |
|
.'</h2>' |
.'</h2>' |
); |
); |
|
|
Line 1884 sub publishdirectory {
|
Line 1882 sub publishdirectory {
|
my ($r,$fn,$thisdisfn)=@_; |
my ($r,$fn,$thisdisfn)=@_; |
$fn=~s/\/+/\//g; |
$fn=~s/\/+/\//g; |
$thisdisfn=~s/\/+/\//g; |
$thisdisfn=~s/\/+/\//g; |
my $resdir= |
my $thisdisresdir=$thisdisfn; |
$Apache::lonnet::perlvar{'lonDocRoot'}.'/res/'.$cudom.'/'.$cuname.'/'. |
$thisdisresdir=~s/^\/priv\//\/res\//; |
$thisdisfn; |
my $resdir = $r->dir_config('lonDocRoot').$thisdisresdir; |
$r->print(&Apache::lonhtmlcommon::start_pick_box() |
$r->print(&Apache::lonhtmlcommon::start_pick_box() |
.&Apache::lonhtmlcommon::row_title(&mt('Directory')) |
.&Apache::lonhtmlcommon::row_title(&mt('Directory')) |
.'<span class="LC_filename">'.$thisdisfn.'</span>' |
.'<span class="LC_filename">'.$thisdisfn.'</span>' |
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_title(&mt('Target')) |
.&Apache::lonhtmlcommon::row_title(&mt('Target')) |
.'<span class="LC_filename">'.$resdir.'</span>' |
.'<span class="LC_filename">'.$thisdisresdir.'</span>' |
); |
); |
|
|
my $dirptr=16384; # Mask indicating a directory in stat.cmode. |
my $dirptr=16384; # Mask indicating a directory in stat.cmode. |
Line 1931 sub publishdirectory {
|
Line 1929 sub publishdirectory {
|
if ($filename=~/\.(\w+)$/) { $extension=$1; } |
if ($filename=~/\.(\w+)$/) { $extension=$1; } |
if ($cmode&$dirptr) { |
if ($cmode&$dirptr) { |
if (($filename!~/^\./) && ($env{'form.pubrec'})) { |
if (($filename!~/^\./) && ($env{'form.pubrec'})) { |
&publishdirectory($r,$fn.'/'.$filename,$thisdisfn.'/'.$filename); |
&publishdirectory($r,$docroot.$fn.'/'.$filename,$thisdisfn.'/'.$filename); |
} |
} |
} elsif ((&Apache::loncommon::fileembstyle($extension) ne 'hdn') && |
} elsif ((&Apache::loncommon::fileembstyle($extension) ne 'hdn') && |
($filename!~/^[\#\.]/) && ($filename!~/\~$/)) { |
($filename!~/^[\#\.]/) && ($filename!~/\~$/)) { |
Line 1973 sub publishdirectory {
|
Line 1971 sub publishdirectory {
|
|
|
sub defaultmetapublish { |
sub defaultmetapublish { |
my ($r,$fn,$cuname,$cudom)=@_; |
my ($r,$fn,$cuname,$cudom)=@_; |
$fn=~s/^\/\~$cuname\//\/home\/$cuname\/public_html\//; |
|
unless (-e $fn) { |
unless (-e $fn) { |
return HTTP_NOT_FOUND; |
return HTTP_NOT_FOUND; |
} |
} |
my $target=$fn; |
my $target=$fn; |
$target=~s/^\/home\/$cuname\/public_html\//$Apache::lonnet::perlvar{'lonDocRoot'}\/res\/$cudom\/$cuname\//; |
$target=~s/^\Q$Apache::lonnet::perlvar{'lonDocRoot'}\E\/priv\//\Q$Apache::lonnet::perlvar{'lonDocRoot'}\E\/res\//; |
|
|
|
|
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
Line 2021 sub defaultmetapublish {
|
Line 2018 sub defaultmetapublish {
|
$r->print($reply.'</p><br />');$r->rflush; |
$r->print($reply.'</p><br />');$r->rflush; |
} |
} |
# ------------------------------------------------------------------- Link back |
# ------------------------------------------------------------------- Link back |
my $link=$fn; |
$r->print("<a href='".&Apache::loncfile::display($fn)."'>".&mt('Back to Metadata').'</a>'); |
$link=~s/^\/home\/$cuname\/public_html\//\/priv\/$cuname\//; |
|
$r->print("<a href='$link'>".&mt('Back to Metadata').'</a>'); |
|
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
return OK; |
return OK; |
} |
} |
Line 2087 sub handler {
|
Line 2082 sub handler {
|
# -------------------------------------------------------------- Check filename |
# -------------------------------------------------------------- Check filename |
|
|
my $fn=&unescape($env{'form.filename'}); |
my $fn=&unescape($env{'form.filename'}); |
|
($cuname,$cudom)=&Apache::lonnet::constructaccess($fn); |
|
# ----------------------------------------------------- Do we have permissions? |
|
unless (($cuname) && ($cudom)) { |
|
$r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}. |
|
' trying to publish file '.$env{'form.filename'}. |
|
' - not authorized', |
|
$r->filename); |
|
return HTTP_NOT_ACCEPTABLE; |
|
} |
|
# ----------------------------------------------------------------- Get docroot |
|
$docroot=$r->dir_config('lonDocRoot'); |
|
|
($cuname,$cudom)= |
|
&Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain')); |
|
|
|
# special publication: default.meta file |
# special publication: default.meta file |
if ($fn=~/\/default.meta$/) { |
if ($fn=~/\/default.meta$/) { |
return &defaultmetapublish($r,$fn,$cuname,$cudom); |
return &defaultmetapublish($r,$fn,$cuname,$cudom); |
} |
} |
$fn=~s/\.meta$//; |
$fn=~s/\.meta$//; |
|
|
|
# sanity test on the filename |
|
|
unless ($fn) { |
unless ($fn) { |
$r->log_reason($cuname.' at '.$cudom. |
$r->log_reason($cuname.' at '.$cudom. |
' trying to publish empty filename', $r->filename); |
' trying to publish empty filename', $r->filename); |
return HTTP_NOT_FOUND; |
return HTTP_NOT_FOUND; |
} |
} |
|
|
unless (($cuname) && ($cudom)) { |
unless (-e $docroot.$fn) { |
$r->log_reason($cuname.' at '.$cudom. |
|
' trying to publish file '.$env{'form.filename'}. |
|
' ('.$fn.') - not authorized', |
|
$r->filename); |
|
return HTTP_NOT_ACCEPTABLE; |
|
} |
|
|
|
my $home=&Apache::lonnet::homeserver($cuname,$cudom); |
|
my $allowed=0; |
|
my @ids=&Apache::lonnet::current_machine_ids(); |
|
foreach my $id (@ids) { if ($id eq $home) { $allowed = 1; } } |
|
unless ($allowed) { |
|
$r->log_reason($cuname.' at '.$cudom. |
|
' trying to publish file '.$env{'form.filename'}. |
|
' ('.$fn.') - not homeserver ('.$home.')', |
|
$r->filename); |
|
return HTTP_NOT_ACCEPTABLE; |
|
} |
|
|
|
$fn=~s{^http://[^/]+}{}; |
|
$fn=~s{^/~($match_username)}{/home/$1/public_html}; |
|
|
|
my $targetdir=''; |
|
$docroot=$r->dir_config('lonDocRoot'); |
|
if ($1 ne $cuname) { |
|
$r->log_reason($cuname.' at '.$cudom. |
|
' trying to publish unowned file '. |
|
$env{'form.filename'}.' ('.$fn.')', |
|
$r->filename); |
|
return HTTP_NOT_ACCEPTABLE; |
|
} else { |
|
$targetdir=$docroot.'/res/'.$cudom; |
|
} |
|
|
|
|
|
unless (-e $fn) { |
|
$r->log_reason($cuname.' at '.$cudom. |
$r->log_reason($cuname.' at '.$cudom. |
' trying to publish non-existing file '. |
' trying to publish non-existing file '. |
$env{'form.filename'}.' ('.$fn.')', |
$env{'form.filename'}.' ('.$fn.')', |
Line 2178 sub handler {
|
Line 2148 sub handler {
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::add_breadcrumb({ |
&Apache::lonhtmlcommon::add_breadcrumb({ |
'text' => 'Construction Space', |
'text' => 'Construction Space', |
'href' => &Apache::loncommon::authorspace(), |
'href' => &Apache::loncommon::authorspace($fn), |
}); |
}); |
&Apache::lonhtmlcommon::add_breadcrumb({ |
&Apache::lonhtmlcommon::add_breadcrumb({ |
'text' => 'Resource Publication', |
'text' => 'Resource Publication', |
Line 2191 sub handler {
|
Line 2161 sub handler {
|
$r->print(&Apache::loncommon::start_page('Resource Publication',$js) |
$r->print(&Apache::loncommon::start_page('Resource Publication',$js) |
.&Apache::lonhtmlcommon::breadcrumbs() |
.&Apache::lonhtmlcommon::breadcrumbs() |
.&Apache::loncommon::head_subbox( |
.&Apache::loncommon::head_subbox( |
&Apache::loncommon::CSTR_pageheader()) # FIXME crumbs broken? |
&Apache::loncommon::CSTR_pageheader($docroot.$fn)) |
); |
); |
|
|
|
my $thisdisfn=&HTML::Entities::encode($fn,'<>&"'); |
my $thisfn=$fn; |
my $thistarget=$fn; |
|
$thistarget=~s/^\/priv\//\/res\//; |
my $thistarget=$thisfn; |
my $thisdistarget=&HTML::Entities::encode($thistarget,'<>&"'); |
|
|
$thistarget=~s/^\/home/$targetdir/; |
|
$thistarget=~s/\/public\_html//; |
|
|
|
my $thisdistarget=$thistarget; |
|
$thisdistarget=~s/^\Q$docroot\E//; |
|
|
|
my $thisdisfn=$thisfn; |
|
$thisdisfn=~s/^\/home\/\Q$cuname\E\/public_html\///; |
|
|
|
if ($fn=~/\/$/) { |
if ($fn=~/\/$/) { |
# -------------------------------------------------------- This is a directory |
# -------------------------------------------------------- This is a directory |
&publishdirectory($r,$fn,$thisdisfn); |
&publishdirectory($r,$docroot.$fn,$thisdisfn); |
$r->print('<hr /><a href="/priv/' |
$r->print('<hr /><a href="'.$thisdisfn.'">'.&mt('Return to Directory').'</a>'); |
.$cuname.'/'.$thisdisfn |
|
.'">'.&mt('Return to Directory').'</a>'); |
|
|
|
|
|
} else { |
} else { |
# ---------------------- Evaluate individual file, and then output information. |
# ---------------------- Evaluate individual file, and then output information. |
$thisfn=~/\.(\w+)$/; |
$fn=~/\.(\w+)$/; |
my $thistype=$1; |
my $thistype=$1; |
my $thisembstyle=&Apache::loncommon::fileembstyle($thistype); |
my $thisembstyle=&Apache::loncommon::fileembstyle($thistype); |
if ($thistype eq 'page') { $thisembstyle = 'rat'; } |
if ($thistype eq 'page') { $thisembstyle = 'rat'; } |
Line 2242 sub handler {
|
Line 2199 sub handler {
|
.'<tt>' |
.'<tt>' |
); |
); |
$r->print(<<ENDCAPTION); |
$r->print(<<ENDCAPTION); |
<a href='javascript:void(window.open("/~$cuname/$thisdisfn","cat","height=300,width=500,scrollbars=1,resizable=1,menubar=0,location=1"))'> |
<a href='javascript:void(window.open("$thisdisfn","cat","height=300,width=500,scrollbars=1,resizable=1,menubar=0,location=1"))'> |
$thisdisfn</a> |
$thisdisfn</a> |
ENDCAPTION |
ENDCAPTION |
$r->print('</tt>' |
$r->print('</tt>' |
Line 2265 ENDCAPTION
|
Line 2222 ENDCAPTION
|
$r->print(&Apache::lonhtmlcommon::row_closure() |
$r->print(&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_title(&mt('Diffs'))); |
.&Apache::lonhtmlcommon::row_title(&mt('Diffs'))); |
$r->print(<<ENDDIFF); |
$r->print(<<ENDDIFF); |
<a href='javascript:void(window.open("/adm/diff?filename=/~$cuname/$thisdisfn&versiontwo=priv","cat","height=300,width=500,scrollbars=1,resizable=1,menubar=0,location=1"))'> |
<a href='javascript:void(window.open("/adm/diff?filename=$thisdisfn&versiontwo=priv","cat","height=300,width=500,scrollbars=1,resizable=1,menubar=0,location=1"))'> |
ENDDIFF |
ENDDIFF |
$r->print(&mt('Diffs with Current Version').'</a>'); |
$r->print(&mt('Diffs with Current Version').'</a>'); |
} |
} |
Line 2274 ENDDIFF
|
Line 2231 ENDDIFF
|
.&Apache::lonhtmlcommon::end_pick_box() |
.&Apache::lonhtmlcommon::end_pick_box() |
); |
); |
|
|
# ------------------ Publishing from $thisfn to $thistarget with $thisembstyle. |
# ---------------------- Publishing from $fn to $thistarget with $thisembstyle. |
|
|
unless ($env{'form.phase'} eq 'two') { |
unless ($env{'form.phase'} eq 'two') { |
# ---------------------------------------------------------- Parse for problems |
# ---------------------------------------------------------- Parse for problems |
my ($warningcount,$errorcount); |
my ($warningcount,$errorcount); |
if ($thisembstyle eq 'ssi') { |
if ($thisembstyle eq 'ssi') { |
($warningcount,$errorcount)=&checkonthis($r,$thisfn); |
($warningcount,$errorcount)=&checkonthis($r,$fn); |
} |
} |
unless ($errorcount) { |
unless ($errorcount) { |
my ($outstring,$error)= |
my ($outstring,$error)= |
&publish($thisfn,$thistarget,$thisembstyle); |
&publish($docroot.$fn,$docroot.$thistarget,$thisembstyle); |
$r->print($outstring); |
$r->print($outstring); |
} else { |
} else { |
$r->print('<h3 class="LC_error">'. |
$r->print('<h3 class="LC_error">'. |
Line 2292 ENDDIFF
|
Line 2249 ENDDIFF
|
'</h3>'); |
'</h3>'); |
} |
} |
} else { |
} else { |
&phasetwo($r,$thisfn,$thistarget,$thisembstyle,$thisdistarget); |
&phasetwo($r,$docroot.$fn,$docroot.$thistarget,$thisembstyle,$thisdistarget); |
} |
} |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |