version 1.159, 2003/12/31 03:02:49
|
version 1.164, 2004/02/27 17:27:51
|
Line 204 sub metaeval {
|
Line 204 sub metaeval {
|
if ($newentry !~m|^/res|) { $newentry=$prefix.$newentry; } |
if ($newentry !~m|^/res|) { $newentry=$prefix.$newentry; } |
} |
} |
# actually store |
# actually store |
$metadatafields{$unikey}=$newentry; |
if ( $entry eq 'rule' && exists($metadatafields{$unikey})) { |
|
$metadatafields{$unikey}.=','.$newentry; |
|
} else { |
|
$metadatafields{$unikey}=$newentry; |
|
} |
} |
} |
} |
} |
} |
} |
Line 916 sub publish {
|
Line 920 sub publish {
|
$allowstr.="\n".'<allow src="'.$thisdep.'" />'; |
$allowstr.="\n".'<allow src="'.$thisdep.'" />'; |
} |
} |
$scrout.='<br />'; |
$scrout.='<br />'; |
unless ($thisdep=~/\*/) { |
if ($thisdep!~/\*/ && $thisdep!~m|^/adm/|) { |
$scrout.='<a href="'.$thisdep.'">'; |
$scrout.='<a href="'.$thisdep.'">'; |
} |
} |
$scrout.='<tt>'.$thisdep.'</tt>'; |
$scrout.='<tt>'.$thisdep.'</tt>'; |
unless ($thisdep=~/\*/) { |
if ($thisdep!~/\*/ && $thisdep!~m|^/adm/|) { |
$scrout.='</a>'; |
$scrout.='</a>'; |
if ( |
if ( |
&Apache::lonnet::getfile($Apache::lonnet::perlvar{'lonDocRoot'}.'/'. |
&Apache::lonnet::getfile($Apache::lonnet::perlvar{'lonDocRoot'}.'/'. |
Line 1017 sub publish {
|
Line 1021 sub publish {
|
} |
} |
|
|
} else { |
} else { |
# ------------------------------------------ See if anything new in file itself |
|
|
|
$allmeta=&parseformeta($source,$style); |
|
# ---------------------- Read previous metafile, remember parameters and stores |
# ---------------------- Read previous metafile, remember parameters and stores |
|
|
$scrout.=&metaread($logfile,$source.'.meta'); |
$scrout.=&metaread($logfile,$source.'.meta'); |
Line 1030 sub publish {
|
Line 1031 sub publish {
|
delete $metadatafields{$_}; |
delete $metadatafields{$_}; |
} |
} |
} |
} |
|
# ------------------------------------------ See if anything new in file itself |
|
|
|
$allmeta=&parseformeta($source,$style); |
|
|
} |
} |
|
|
|
|
Line 1697 sub publishdirectory {
|
Line 1702 sub publishdirectory {
|
} |
} |
closedir(DIR); |
closedir(DIR); |
} |
} |
|
|
|
######################################### |
|
# publish a default.meta file |
|
|
|
sub defaultmetapublish { |
|
my ($r,$fn,$cuname,$cudom)=@_; |
|
$fn=~s/^\/\~$cuname\//\/home\/$cuname\/public_html\//; |
|
unless (-e $fn) { |
|
return HTTP_NOT_FOUND; |
|
} |
|
my $target=$fn; |
|
$target=~s/^\/home\/$cuname\/public_html\//$Apache::lonnet::perlvar{'lonDocRoot'}\/res\/$cudom\/$cuname\//; |
|
|
|
|
|
&Apache::loncommon::content_type($r,'text/html'); |
|
$r->send_http_header; |
|
|
|
$r->print('<html><head><title>LON-CAPA Publishing</title></head>'); |
|
$r->print(&Apache::loncommon::bodytag('Catalog Information Publication')); |
|
|
|
# ---------------------------------------------------------------- Write Source |
|
my $copyfile=$target; |
|
|
|
my @parts=split(/\//,$copyfile); |
|
my $path="/$parts[1]/$parts[2]/$parts[3]/$parts[4]"; |
|
|
|
my $count; |
|
for ($count=5;$count<$#parts;$count++) { |
|
$path.="/$parts[$count]"; |
|
if ((-e $path)!=1) { |
|
$r->print('<p>'.&mt('Created directory').' '.$parts[$count].'</p>'); |
|
mkdir($path,0777); |
|
} |
|
} |
|
|
|
if (copy($fn,$copyfile)) { |
|
$r->print('<p>'.&mt('Copied source file').'</p>'); |
|
} else { |
|
return "<font color=\"red\">". |
|
&mt('Failed to copy source').", $!, ".&mt('FAIL')."</font>"; |
|
} |
|
|
|
# --------------------------------------------------- Send update notifications |
|
|
|
my @subscribed=&get_subscribed_hosts($target); |
|
foreach my $subhost (@subscribed) { |
|
$r->print('<p>'.&mt('Notifying host').' '.$subhost.':');$r->rflush; |
|
my $reply=&Apache::lonnet::critical('update:'.$target,$subhost); |
|
$r->print($reply.'</p><br />');$r->rflush; |
|
} |
|
# ------------------------------------------------------------------- Link back |
|
my $link=$fn; |
|
$link=~s/^\/home\/$cuname\/public_html\//\/priv\/$cuname\//; |
|
$r->print("<a href='$link'>".&mt('Back to Catalog Information').'</a>'); |
|
$r->print('</body></html>'); |
|
return OK; |
|
} |
######################################### |
######################################### |
|
|
=pod |
=pod |
Line 1754 sub handler {
|
Line 1816 sub handler {
|
# -------------------------------------------------------------- Check filename |
# -------------------------------------------------------------- Check filename |
|
|
my $fn=&Apache::lonnet::unescape($ENV{'form.filename'}); |
my $fn=&Apache::lonnet::unescape($ENV{'form.filename'}); |
|
|
|
($cuname,$cudom)= |
|
&Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain')); |
|
|
|
# special publication: default.meta file |
|
if ($fn=~/\/default.meta$/) { |
|
return &defaultmetapublish($r,$fn,$cuname,$cudom); |
|
} |
$fn=~s/\.meta$//; |
$fn=~s/\.meta$//; |
|
|
unless ($fn) { |
unless ($fn) { |
Line 1762 sub handler {
|
Line 1832 sub handler {
|
return HTTP_NOT_FOUND; |
return HTTP_NOT_FOUND; |
} |
} |
|
|
($cuname,$cudom)= |
|
&Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain')); |
|
unless (($cuname) && ($cudom)) { |
unless (($cuname) && ($cudom)) { |
$r->log_reason($cuname.' at '.$cudom. |
$r->log_reason($cuname.' at '.$cudom. |
' trying to publish file '.$ENV{'form.filename'}. |
' trying to publish file '.$ENV{'form.filename'}. |
Line 1772 sub handler {
|
Line 1840 sub handler {
|
return HTTP_NOT_ACCEPTABLE; |
return HTTP_NOT_ACCEPTABLE; |
} |
} |
|
|
unless (&Apache::lonnet::homeserver($cuname,$cudom) |
my $home=&Apache::lonnet::homeserver($cuname,$cudom); |
eq $r->dir_config('lonHostID')) { |
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. |
$r->log_reason($cuname.' at '.$cudom. |
' trying to publish file '.$ENV{'form.filename'}. |
' trying to publish file '.$ENV{'form.filename'}. |
' ('.$fn.') - not homeserver ('. |
' ('.$fn.') - not homeserver ('.$home.')', |
&Apache::lonnet::homeserver($cuname,$cudom).')', |
|
$r->filename); |
$r->filename); |
return HTTP_NOT_ACCEPTABLE; |
return HTTP_NOT_ACCEPTABLE; |
} |
} |