--- loncom/publisher/lonpublisher.pm 2006/05/30 12:47:41 1.209
+++ loncom/publisher/lonpublisher.pm 2007/01/10 20:23:21 1.216
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.209 2006/05/30 12:47:41 www Exp $
+# $Id: lonpublisher.pm,v 1.216 2007/01/10 20:23:21 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -129,8 +129,7 @@ use Apache::loncfile;
use LONCAPA::lonmetadata;
use Apache::lonmsg;
use vars qw(%metadatafields %metadatakeys);
-use lib '/home/httpd/lib/perl/';
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
my %addid;
@@ -281,9 +280,8 @@ sub metaread {
sub coursedependencies {
my $url=&Apache::lonnet::declutter(shift);
$url=~s/\.meta$//;
- my ($adomain,$aauthor)=($url=~/^(\w+)\/(\w+)\//);
- my $regexp=$url;
- $regexp=~s/(\W)/\\$1/g;
+ my ($adomain,$aauthor)=($url=~ m{^($match_domain)/($match_username)/});
+ my $regexp=quotemeta($url);
$regexp='___'.$regexp.'___course';
my %evaldata=&Apache::lonnet::dump('nohist_resevaldata',$adomain,
$aauthor,$regexp);
@@ -497,7 +495,7 @@ sub get_subscribed_hosts {
my $srcf=$2;
opendir(DIR,$1);
while ($filename=readdir(DIR)) {
- if ($filename=~/\Q$srcf\E\.(\w+)$/) {
+ if ($filename=~/\Q$srcf\E\.($match_lonid)$/) {
my $subhost=$1;
if (($subhost ne 'meta' && $subhost ne 'subscription' &&
$subhost ne 'tmp') &&
@@ -511,7 +509,7 @@ sub get_subscribed_hosts {
if ( $sh=Apache::File->new("$target.subscription") ) {
&Apache::lonnet::logthis("opened $target.subscription");
while (my $subline=<$sh>) {
- if ($subline =~ /(^\w+):/) {
+ if ($subline =~ /^($match_lonid):/) {
if ($1 ne $Apache::lonnet::perlvar{'lonHostID'}) {
push(@subscribed,$1);
}
@@ -846,7 +844,7 @@ sub store_metadata {
$status=&LONCAPA::lonmetadata::delete_metadata($dbh,undef,
$metadata{'url'});
} else {
- $status = &LONCAPA::lonmetadata::update_metadata($dbh,undef,
+ $status = &LONCAPA::lonmetadata::update_metadata($dbh,undef,undef,
\%metadata);
}
if (defined($status) && $status ne '') {
@@ -856,7 +854,7 @@ sub store_metadata {
&Apache::lonnet::logthis($status);
return ($error,undef);
}
- return (undef,$status);
+ return (undef,'success');
}
@@ -942,7 +940,7 @@ sub publish {
return (''.&mt('No write permission to user directory, FAIL').'',1);
}
print $logfile
-"\n\n================= Publish ".localtime()." Phase One ================\n".$env{'user.name'}.'@'.$env{'user.domain'}."\n";
+"\n\n================= Publish ".localtime()." Phase One ================\n".$env{'user.name'}.':'.$env{'user.domain'}."\n";
if (($style eq 'ssi') || ($style eq 'rat') || ($style eq 'prv')) {
# ------------------------------------------------------- This needs processing
@@ -987,7 +985,7 @@ sub publish {
my %temphash=(&Apache::lonnet::declutter($target).'___'.
&Apache::lonnet::declutter($thisdep).'___usage'
=> time);
- $thisdep=~/^\/res\/(\w+)\/(\w+)\//;
+ $thisdep=~m{^/res/($match_domain)/($match_username)/};
if ((defined($1)) && (defined($2))) {
&Apache::lonnet::put('nohist_resevaldata',\%temphash,
$1,$2);
@@ -1036,7 +1034,7 @@ sub publish {
$env{'environment.generation'};
$metadatafields{'author'}=~s/\s+/ /g;
$metadatafields{'author'}=~s/\s+$//;
- $metadatafields{'owner'}=$cuname.'@'.$cudom;
+ $metadatafields{'owner'}=$cuname.':'.$cudom;
# ------------------------------------------------ Check out directory hierachy
@@ -1439,7 +1437,7 @@ sub phasetwo {
return 0;
}
print $logfile
- "\n================= Publish ".localtime()." Phase Two ================\n".$env{'user.name'}.'@'.$env{'user.domain'}."\n";
+ "\n================= Publish ".localtime()." Phase Two ================\n".$env{'user.name'}.':'.$env{'user.domain'}."\n";
%metadatafields=();
%metadatakeys=();
@@ -1467,9 +1465,10 @@ sub phasetwo {
$metadatafields{'obsoletereplacement'}=
$env{'form.obsoletereplacement'};
$metadatafields{'dependencies'}=$env{'form.dependencies'};
- $metadatafields{'modifyinguser'}=$env{'user.name'}.'@'.
+ $metadatafields{'modifyinguser'}=$env{'user.name'}.':'.
$env{'user.domain'};
- $metadatafields{'authorspace'}=$cuname.'@'.$cudom;
+ $metadatafields{'authorspace'}=$cuname.':'.$cudom;
+ $metadatafields{'domain'}=$cudom;
my $allkeywords=$env{'form.addkey'};
if (exists($env{'form.keywords'})) {
@@ -1668,7 +1667,7 @@ sub phasetwo {
unless ($batch) {
my $thissrc=$source;
- $thissrc=~s/^\/home\/(\w+)\/public_html/\/priv\/$1/;
+ $thissrc=~s{^/home/($match_username)/public_html}{/priv/$1};
my $thissrcdir=$thissrc;
$thissrcdir=~s/\/[^\/]+$/\//;
@@ -1820,10 +1819,16 @@ sub publishdirectory {
# previously published, modified now
$publishthis=1;
}
+ my $meta_cmtime = (stat($fn.'/'.$filename.'.meta'))[9];
+ my $meta_rmtime = (stat($resdir.'/'.$filename.'.meta'))[9];
+ if ( $meta_rmtime<$meta_cmtime ) {
+ $publishthis=1;
+ }
} else {
# never published
$publishthis=1;
}
+
if ($publishthis) {
&batchpublish($r,$fn.'/'.$filename,$resdir.'/'.$filename);
} else {
@@ -1987,8 +1992,8 @@ sub handler {
return HTTP_NOT_ACCEPTABLE;
}
- $fn=~s/^http\:\/\/[^\/]+//;
- $fn=~s/^\/\~(\w+)/\/home\/$1\/public_html/;
+ $fn=~s{^http://[^/]+}{};
+ $fn=~s{^/~($match_username)}{/home/$1/public_html};
my $targetdir='';
$docroot=$r->dir_config('lonDocRoot');
@@ -2041,7 +2046,7 @@ sub handler {
my $js='';
- $r->print(&Apache::loncommon::start_page('Resource Publication'));
+ $r->print(&Apache::loncommon::start_page('Resource Publication',$js));
my $thisfn=$fn;