--- loncom/publisher/lonpublisher.pm 2004/06/11 02:27:27 1.171 +++ loncom/publisher/lonpublisher.pm 2004/06/11 20:11:06 1.172 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Publication Handler # -# $Id: lonpublisher.pm,v 1.171 2004/06/11 02:27:27 taceyjo1 Exp $ +# $Id: lonpublisher.pm,v 1.172 2004/06/11 20:11:06 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -801,49 +801,21 @@ sub store_metadata { &Apache::lonnet::logthis($error); return ($error,undef); } + my $dbh = &Apache::lonmysql::get_dbh(); if (($metadata{'obsolete'}) || ($metadata{'copyright'} eq 'priv') || ($metadata{'copyright'} eq 'custom')) { -# remove this entry - $status=&Apache::lonmysql::remove_from_table - ('metadata','url',$metadata{'url'}); + # remove this entry + $status=&LONCAPA::lonmetadata::delete_metadata($dbh,undef, + $metadata{'url'}); } else { -# store new data -# adjust some values to metadatadatabase (e.g., "usage" is a reserved word) - $metadata{'creationdate'}= - &Apache::lonmysql::sqltime($metadata{'creationdate'}); - $metadata{'lastrevisiondate'}= - &Apache::lonmysql::sqltime($metadata{'lastrevisiondate'}); - $metadata{'sequsage'}=$metadata{'usage'}; - $metadata{'sequsage_list'}=$metadata{'usage_list'}; - my %newmetadata=(); -# see if we have old entries - my @oldmeta=&Apache::lonmysql::get_rows('metadata', - "url LIKE BINARY '". - $metadata{'url'}."'"); - if ($#oldmeta==0) { -# yes, there is one old entry, transfer to newmetadata - %newmetadata=&LONCAPA::lonmetadata::metadata_col_to_hash(@{$oldmeta[0]}); -# remove old entry - $status=&Apache::lonmysql::remove_from_table - ('metadata','url',$metadata{'url'}); - } elsif ($#oldmeta>0) { -# more than one entry fit - how did that happen? - $error='Error occured retrieving old values in '. - 'metadata table in LON-CAPA database: '.$#oldmeta. - ' matches'; - &Apache::lonnet::logthis($error); - return ($error,undef); - } -# store new data on top of it - foreach (keys %metadata) { - $newmetadata{$_}=$metadata{$_}; - } - $status = &Apache::lonmysql::store_row('metadata',\%newmetadata); + $status = &LONCAPA::lonmetadata::update_metadata($dbh,undef, + \%metadata); } - if (! defined($status)) { + if (defined($status) && $status ne '') { $error='Error occured storing new values in '. 'metadata table in LON-CAPA database'; &Apache::lonnet::logthis($error); + &Apache::lonnet::logthis($status); return ($error,undef); } return (undef,$status);