--- loncom/publisher/lonpublisher.pm 2003/12/22 22:09:06 1.149 +++ loncom/publisher/lonpublisher.pm 2003/12/27 14:42:57 1.154 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Publication Handler # -# $Id: lonpublisher.pm,v 1.149 2003/12/22 22:09:06 www Exp $ +# $Id: lonpublisher.pm,v 1.154 2003/12/27 14:42:57 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -767,7 +767,7 @@ Returns: (error,status). error is undef ######################################### ######################################### sub store_metadata { - my %metadata = %{shift()}; + my %metadata = @_; my $error; # Determine if the table exists my $status = &Apache::lonmysql::check_table('metadata'); @@ -784,17 +784,19 @@ sub store_metadata { &Apache::lonnet::logthis($error); return ($error,undef); } - # Remove old value from table - $status = &Apache::lonmysql::remove_from_table - ('metadata','url',$metadata{'url'}); - if (! defined($status)) { - $error = 'Error when removing old values from '. - 'metadata table in LON-CAPA database.'; - &Apache::lonnet::logthis($error); - return ($error,undef); + if (($metadata{'obsolete'}) || ($metadata{'copyright'} eq 'priv') || + ($metadata{'copyright'} eq 'custom')) { +# remove this entry + $status=&Apache::lonmysql::remove_from_table + ('metadata','url',$metadata{'url'}); + } else { +# store new data + $metadata{'creationdate'}= + &Apache::lonmysql::sqltime($metadata{'creationdate'}); + $metadata{'lastrevisiondate'}= + &Apache::lonmysql::sqltime($metadata{'lastrevisiondate'}); + $status = &Apache::lonmysql::store_row('metadata',\%metadata); } - # Store data in table. - $status = &Apache::lonmysql::store_row('metadata',\%metadata); if (! defined($status)) { $error='Error occured storing new values in '. 'metadata table in LON-CAPA database'; @@ -958,9 +960,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 @@ -1144,6 +1143,21 @@ END $source=~/\.(\w+)$/; + + $scrout.= + "\n
". + uc(&mt('Lowest Grade Level:')). + "
". + uc(&mt('Highest Grade Level:')). + "
'.&mt('Synchronized SQL metadata database').'
'); - print $logfile "\nSynchronized SQL metadata database"; - } else { - $r->print($error); - print $logfile "\n".$error; - } + + my ($error,$success) = &store_metadata(%metadatafields); + if ($success) { + $r->print(''.&mt('Synchronized SQL metadata database').'
'); + print $logfile "\nSynchronized SQL metadata database"; } else { - $r->print(''. - &mt('Private Publication - did not synchronize database').'
'); - print $logfile "\nPrivate: Did not synchronize data into ". - "SQL metadata database"; + $r->print($error); + print $logfile "\n".$error; } + # ----------------------------------------------------------- Copy old versions if (-e $target) {