[LON-CAPA-cvs] cvs: loncom /publisher lonpublisher.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Fri, 11 Jun 2004 20:11:06 -0000
matthew Fri Jun 11 16:11:06 2004 EDT
Modified files:
/loncom/publisher lonpublisher.pm
Log:
&store_metadata now uses lonmetadata to do the heavy lifting.
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.171 loncom/publisher/lonpublisher.pm:1.172
--- loncom/publisher/lonpublisher.pm:1.171 Thu Jun 10 22:27:27 2004
+++ loncom/publisher/lonpublisher.pm Fri Jun 11 16:11:06 2004
@@ -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 @@
&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='<font color="red">Error occured retrieving old values in '.
- 'metadata table in LON-CAPA database: '.$#oldmeta.
- ' matches</font>';
- &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='<font color="red">Error occured storing new values in '.
'metadata table in LON-CAPA database</font>';
&Apache::lonnet::logthis($error);
+ &Apache::lonnet::logthis($status);
return ($error,undef);
}
return (undef,$status);