--- loncom/publisher/lonpublisher.pm 2004/05/21 20:21:32 1.170
+++ loncom/publisher/lonpublisher.pm 2004/10/11 17:40:46 1.180
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.170 2004/05/21 20:21:32 www Exp $
+# $Id: lonpublisher.pm,v 1.180 2004/10/11 17:40:46 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -199,7 +199,8 @@ sub metaeval {
}
}
my $newentry=$parser->get_text('/'.$entry);
- if ($entry eq 'customdistributionfile') {
+ if (($entry eq 'customdistributionfile') ||
+ ($entry eq 'sourcerights')) {
$newentry=~s/^\s*//;
if ($newentry !~m|^/res|) { $newentry=$prefix.$newentry; }
}
@@ -328,6 +329,21 @@ sub textfield {
'';
}
+sub text_with_browse_field {
+ my ($title,$name,$value,$restriction)=@_;
+ $value=~s/^\s+//gs;
+ $value=~s/\s+$//gs;
+ $value=~s/\s+/ /gs;
+ $title=&mt($title);
+ $ENV{'form.'.$name}=$value;
+ return "\n
$title:".
+ "
".
+ ''.
+ 'Select '.
+ 'Search';
+
+}
+
sub hiddenfield {
my ($name,$value)=@_;
$ENV{'form.'.$name}=$value;
@@ -471,7 +487,8 @@ sub get_subscribed_hosts {
while ($filename=readdir(DIR)) {
if ($filename=~/\Q$srcf\E\.(\w+)$/) {
my $subhost=$1;
- if (($subhost ne 'meta' && $subhost ne 'subscription') &&
+ if (($subhost ne 'meta' && $subhost ne 'subscription' &&
+ $subhost ne 'tmp') &&
($subhost ne $Apache::lonnet::perlvar{'lonHostID'})) {
push(@subscribed,$subhost);
}
@@ -582,11 +599,11 @@ sub get_all_text_unbalanced {
} elsif ($token->[0] eq 'E') {
$result.=$token->[2];
}
- if ($result =~ /(.*)\Q$tag\E(.*)/s) {
+ if ($result =~ /\Q$tag\E/s) {
+ ($result,my $redo)=$result =~ /(.*)\Q$tag\E(.*)/is;
#&Apache::lonnet::logthis('Got a winner with leftovers ::'.$2);
#&Apache::lonnet::logthis('Result is :'.$1);
- $result=$1;
- my $redo=$tag.$2;
+ $redo=$tag.$redo;
push (@$pars,HTML::LCParser->new(\$redo));
$$pars[-1]->xml_mode('1');
last;
@@ -801,49 +818,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);
@@ -956,7 +945,7 @@ sub publish {
}
}
}
- $outstring=~s/\n*(\<\/[^\>]+\>)\s*$/$allowstr\n$1\n/s;
+ $outstring=~s/\n*(\<\/[^\>]+\>[^<]*)$/$allowstr\n$1\n/s;
# ------------------------------------------------------------- Write modified.
@@ -1158,7 +1147,7 @@ END
my $colcount=0;
foreach (sort keys %keywords) {
- $keywordout.='
';
+ $keywordout.=' />'.$_.'';
if ($colcount>10) {
$keywordout.="
\n";
$colcount=0;
@@ -1233,11 +1222,20 @@ END
$intr_scrout.=&textfield('Publisher/Owner','owner',
$metadatafields{'owner'});
-# -------------------------------------------------- Correct copyright for rat.
+# ---------------------------------------------- Retrofix for unused copyright
+ if ($metadatafields{'copyright'} eq 'free') {
+ $metadatafields{'copyright'}='default';
+ $metadatafields{'sourceavail'}='open';
+ }
+# ------------------------------------------------ Dial in reasonable defaults
my $defaultoption=$metadatafields{'copyright'};
unless ($defaultoption) { $defaultoption='default'; }
+ my $defaultsourceoption=$metadatafields{'sourceavail'};
+ unless ($defaultsourceoption) { $defaultsourceoption='closed'; }
unless ($style eq 'prv') {
+# -------------------------------------------------- Correct copyright for rat.
if ($style eq 'rat') {
+# -------------------------------------- Retrofix for non-applicable copyright
if ($metadatafields{'copyright'} eq 'public') {
delete $metadatafields{'copyright'};
$defaultoption='default';
@@ -1246,33 +1244,35 @@ END
$defaultoption,
\&Apache::loncommon::copyrightdescription,
(grep !/^public$/,(&Apache::loncommon::copyrightids)));
- } else {
- $intr_scrout.=&selectbox('Copyright/Distribution','copyright',
- $defaultoption,
- \&Apache::loncommon::copyrightdescription,
- (&Apache::loncommon::copyrightids));
- }
-
- my $copyright_help =
- Apache::loncommon::help_open_topic('Publishing_Copyright');
- $intr_scrout =~ s/DISTRIBUTION:/'DISTRIBUTION: ' . $copyright_help/ge;
- $intr_scrout.=&textfield('Custom Distribution File','customdistributionfile',
- $metadatafields{'customdistributionfile'}).
- $copyright_help;
- my $uctitle=&mt('Obsolete');
- $intr_scrout.=
- "\n