--- loncom/publisher/lonpublisher.pm 2006/01/24 22:09:36 1.207 +++ loncom/publisher/lonpublisher.pm 2006/09/27 20:34:26 1.213 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Publication Handler # -# $Id: lonpublisher.pm,v 1.207 2006/01/24 22:09:36 albertel Exp $ +# $Id: lonpublisher.pm,v 1.213 2006/09/27 20:34:26 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -129,6 +129,9 @@ use Apache::loncfile; use LONCAPA::lonmetadata; use Apache::lonmsg; use vars qw(%metadatafields %metadatakeys); +use lib '/home/httpd/lib/perl/'; +use LONCAPA; + my %addid; my %nokey; @@ -843,7 +846,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 '') { @@ -853,7 +856,7 @@ sub store_metadata { &Apache::lonnet::logthis($status); return ($error,undef); } - return (undef,$status); + return (undef,'success'); } @@ -939,7 +942,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 @@ -1033,7 +1036,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 @@ -1168,7 +1171,7 @@ sub publish { '

'.($env{'form.makeobsolete'}?'':'').'

'. &hiddenfield('phase','two'). &hiddenfield('filename',$env{'form.filename'}). - &hiddenfield('allmeta',&Apache::lonnet::escape($allmeta)). + &hiddenfield('allmeta',&escape($allmeta)). &hiddenfield('dependencies',join(',',keys %allow)); unless ($env{'form.makeobsolete'}) { $intr_scrout.= @@ -1436,12 +1439,12 @@ 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=(); - &metaeval(&Apache::lonnet::unescape($env{'form.allmeta'})); + &metaeval(&unescape($env{'form.allmeta'})); $metadatafields{'title'}=$env{'form.title'}; $metadatafields{'author'}=$env{'form.author'}; @@ -1464,9 +1467,9 @@ 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; my $allkeywords=$env{'form.addkey'}; if (exists($env{'form.keywords'})) { @@ -1817,10 +1820,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 { @@ -1849,8 +1858,7 @@ sub defaultmetapublish { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; - $r->print('LON-CAPA Publishing'); - $r->print(&Apache::loncommon::bodytag('Catalog Information Publication')); + $r->print(&Apache::loncommon::start_page('Catalog Information Publication')); # ---------------------------------------------------------------- Write Source my $copyfile=$target; @@ -1886,7 +1894,7 @@ sub defaultmetapublish { my $link=$fn; $link=~s/^\/home\/$cuname\/public_html\//\/priv\/$cuname\//; $r->print("".&mt('Back to Catalog Information').''); - $r->print(''); + $r->print(&Apache::loncommon::end_page()); return OK; } ######################################### @@ -1948,7 +1956,7 @@ sub handler { @{$modified_urls}=(); # -------------------------------------------------------------- Check filename - my $fn=&Apache::lonnet::unescape($env{'form.filename'}); + my $fn=&unescape($env{'form.filename'}); ($cuname,$cudom)= &Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain')); @@ -2036,11 +2044,10 @@ sub handler { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; - my $js=&Apache::loncommon::browser_and_searcher_javascript(); - $r->print('LON-CAPA Publishing - '); - $r->print(&Apache::loncommon::bodytag('Resource Publication')); + my $js=''; + $r->print(&Apache::loncommon::start_page('Resource Publication',$js)); my $thisfn=$fn; @@ -2115,7 +2122,7 @@ ENDDIFF $r->print('
'); } } - $r->print(''); + $r->print(&Apache::loncommon::end_page()); return OK; }