--- loncom/publisher/lonpublisher.pm 2003/12/22 21:57:25 1.148 +++ loncom/publisher/lonpublisher.pm 2003/12/31 03:02:49 1.159 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Publication Handler # -# $Id: lonpublisher.pm,v 1.148 2003/12/22 21:57:25 albertel Exp $ +# $Id: lonpublisher.pm,v 1.159 2003/12/31 03:02:49 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -25,24 +25,6 @@ # # http://www.lon-capa.org/ # -# -# (TeX Content Handler -# -# 05/29/00,05/30,10/11 Gerd Kortemeyer) -# -# 11/28,11/29,11/30,12/01,12/02,12/04,12/23 Gerd Kortemeyer -# 03/23 Guy Albertelli -# 03/24,03/29,04/03 Gerd Kortemeyer -# 05/03,05/05,05/07 Gerd Kortemeyer -# 06/23,08/07,08/11,8/13,8/17,8/18,8/24,9/26,10/16 Gerd Kortemeyer -# 12/04,12/05 Guy Albertelli -# 12/05 Gerd Kortemeyer -# 12/05 Guy Albertelli -# 12/06,12/07 Gerd Kortemeyer -# 12/25 Gerd Kortemeyer -# YEAR=2002 -# 1/17 Gerd Kortemeyer -# ### ############################################################################### @@ -144,6 +126,8 @@ use Apache::loncommon(); use Apache::lonmysql; use Apache::lonlocal; use Apache::loncfile; +use Apache::lonmeta; +use Apache::lonmsg; use vars qw(%metadatafields %metadatakeys); my %addid; @@ -219,9 +203,8 @@ sub metaeval { $newentry=~s/^\s*//; if ($newentry !~m|^/res|) { $newentry=$prefix.$newentry; } } - unless ($metadatafields{$unikey}=~/\w/) { - $metadatafields{$unikey}=$newentry; - } +# actually store + $metadatafields{$unikey}=$newentry; } } } @@ -335,8 +318,7 @@ sub textfield { $value=~s/\s+$//gs; $value=~s/\s+/ /gs; $title=&mt($title); - my $uctitle=uc($title); - return "\n
$uctitle:".
+ return "\n $title:".
" $uctitle:".
+ my $selout="\n $title:".
' ".&mt('ABSTRACT').":".
+ "\n ".&mt('Abstract').":".
" ".
+ &mt('Lowest Grade Level').':'.
+ " ".
+ &mt('Highest Grade Level').':'.
+ " $uctitle:".
' '.&mt('No valid custom distribution rights file specified, FAIL').
+ '
".
'';
}
@@ -349,9 +331,8 @@ sub hiddenfield {
sub selectbox {
my ($title,$name,$value,$functionref,@idlist)=@_;
$title=&mt($title);
- my $uctitle=uc($title);
$value=(split(/\s*,\s*/,$value))[-1];
- my $selout="\n
';
- &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
+# 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=&Apache::lonmeta::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);
}
- # 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';
@@ -977,14 +986,7 @@ 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;
-# ----------------------------------------------------------- Parse file itself
-# read %metadatafields from file itself
-
- $allmeta=&parseformeta($source,$style);
# ------------------------------------------------ Check out directory hierachy
my $thisdisfn=$source;
@@ -1001,6 +1003,10 @@ sub publish {
$scrout.=&metaread($logfile,$currentpath.'default.meta',$prefix);
$prefix=~s|^\.\./||;
}
+# ----------------------------------------------------------- Parse file itself
+# read %metadatafields from file itself
+
+ $allmeta=&parseformeta($source,$style);
# ------------------- Clear out parameters and stores (there should not be any)
@@ -1011,6 +1017,9 @@ sub publish {
}
} else {
+# ------------------------------------------ See if anything new in file itself
+
+ $allmeta=&parseformeta($source,$style);
# ---------------------- Read previous metafile, remember parameters and stores
$scrout.=&metaread($logfile,$source.'.meta');
@@ -1021,9 +1030,6 @@ sub publish {
delete $metadatafields{$_};
}
}
-# ------------------------------------------ See if anything new in file itself
-
- $allmeta=&parseformeta($source,$style);
}
@@ -1105,7 +1111,7 @@ sub publish {
# --------------------------------------------------- Scan content for keywords
my $keywords_help = Apache::loncommon::help_open_topic("Publishing_Keywords");
- my $KEYWORDS=&mt('KEYWORDS');
+ my $KEYWORDS=&mt('Keywords');
my $CheckAll=&mt('check all');
my $UncheckAll=&mt('uncheck all');
my $keywordout=<<"END";
@@ -1156,13 +1162,28 @@ END
$scrout.=&textfield('Notes','notes',$metadatafields{'notes'});
$scrout.=
- "\n
".
'
".
+ &Apache::loncommon::select_level_form($metadatafields{'lowestgradelevel'},'lowestgradelevel').
+ "\n
".
+ &Apache::loncommon::select_level_form($metadatafields{'highestgradelevel'},'highestgradelevel').
+ &textfield('Standards','standards',$metadatafields{'standards'});
+
+
+
+
$scrout.=&hiddenfield('mime',$1);
my $defaultlanguage=$metadatafields{'language'};
@@ -1180,7 +1201,7 @@ END
$metadatafields{'creationdate'}=time;
}
$scrout.=&hiddenfield('creationdate',
- &Apache::loncommon::unsqltime($metadatafields{'creationdate'}));
+ &Apache::lonmysql::unsqltime($metadatafields{'creationdate'}));
$scrout.=&hiddenfield('lastrevisiondate',time);
@@ -1214,7 +1235,7 @@ END
$scrout.=&textfield('Custom Distribution File','customdistributionfile',
$metadatafields{'customdistributionfile'}).
$copyright_help;
- my $uctitle=uc(&mt('Obsolete'));
+ my $uctitle=&mt('Obsolete');
$scrout.=
"\n
'.&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; } +# --------------------------------------------- Delete author resource messages + my $delresult=&Apache::lonmsg::del_url_author_res_msg($target); + $r->print(''.&mt('Removing error messages:').' '.$delresult.'
'); + print $logfile "\nRemoving error messages: $delresult"; # ----------------------------------------------------------- Copy old versions if (-e $target) { @@ -1562,6 +1596,7 @@ sub phasetwo { '">'. &mt('Back to Source Directory').''); } + return ''.&mt('Done').'
'; } ######################################### @@ -1616,8 +1651,8 @@ sub publishdirectory { my $resdir= $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/'.$cudom.'/'.$cuname.'/'. $thisdisfn; - $r->print('