--- loncom/publisher/lonpublisher.pm 2003/12/26 19:12:51 1.152
+++ loncom/publisher/lonpublisher.pm 2003/12/27 16:58:36 1.155
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.152 2003/12/26 19:12:51 www Exp $
+# $Id: lonpublisher.pm,v 1.155 2003/12/27 16:58:36 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -791,11 +791,41 @@ sub store_metadata {
('metadata','url',$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'});
- $status = &Apache::lonmysql::store_row('metadata',\%metadata);
+ &Apache::lonmysql::sqltime($metadata{'lastrevisiondate'});
+ $metadata{'sequsage'}=$metadata{'usage'};
+ $metadata{'sequsage_list'}=$metadata{'usage_list'};
+ my %newmetadata=();
+# retrieve current database column names
+ my @columns=&Apache::lonmysql::col_order('metadata');
+# see if we have old entries
+ my @oldmeta=&Apache::lonmysql::get_rows('metadata',
+ "url LIKE BINARY '".
+ $metadata{'url'}."'");
+ if ($#oldmeta==0) {
+# there is an old value
+ for (my $i=0; $i<=$#columns; $i++) {
+ $newmetadata{$columns[$i]}=$oldmeta[0]->[$i];
+ }
+# 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);
}
if (! defined($status)) {
$error='Error occured storing new values in '.
@@ -960,9 +990,6 @@ sub publish {
$metadatafields{'author'}=~s/\s+/ /g;
$metadatafields{'author'}=~s/\s+$//;
$metadatafields{'owner'}=$cuname.'@'.$cudom;
- $metadatafields{'modifyinguser'}=$ENV{'user.name'}.'@'.
- $ENV{'user.domain'};
- $metadatafields{'authorspace'}=$cuname.'@'.$cudom;
# ------------------------------------------------ Check out directory hierachy
@@ -1178,7 +1205,7 @@ END
$metadatafields{'creationdate'}=time;
}
$scrout.=&hiddenfield('creationdate',
- &Apache::loncommon::unsqltime($metadatafields{'creationdate'}));
+ &Apache::lonmysql::unsqltime($metadatafields{'creationdate'}));
$scrout.=&hiddenfield('lastrevisiondate',time);
@@ -1345,6 +1372,9 @@ sub phasetwo {
$metadatafields{'obsoletereplacement'}=
$ENV{'form.obsoletereplacement'};
$metadatafields{'dependencies'}=$ENV{'form.dependencies'};
+ $metadatafields{'modifyinguser'}=$ENV{'user.name'}.'@'.
+ $ENV{'user.domain'};
+ $metadatafields{'authorspace'}=$cuname.'@'.$cudom;
my $allkeywords=$ENV{'form.addkey'};
if (exists($ENV{'form.keywords'})) {