) {
+ if ($configline =~ /PerlSetVar/) {
+ my ($dummy,$varname,$varvalue)=split(/\s+/,$configline);
+ chomp($varvalue);
+ $perlvar{$varname}=$varvalue;
+ }
+ }
+ close(CONFIG);
+
+ my $warning;
my $dbh;
{
unless (
$dbh = DBI->connect("DBI:mysql:loncapa","www",$perlvar{'lonSqlAccess'},{ RaiseError =>0,PrintError=>0})
) {
- return 'Cannot connect to database!';
+ $warning='WARNING: Cannot connect to '.
+ 'database!';
+ }
+ else {
+ my %sqldatafields;
+ $sqldatafields{'url'}=$distarget;
+ my $sth=$dbh->prepare(
+ 'delete from metadata where url like binary'.
+ '"'.$sqldatafields{'url'}.'"');
+ $sth->execute();
+ map {my $field=$metadatafields{$_}; $field=~s/\"/\'\'/g;
+ $sqldatafields{$_}=$field;}
+ ('title','author','subject','keywords','notes','abstract',
+ 'mime','language','creationdate','lastrevisiondate','owner',
+ 'copyright');
+
+ $sth=$dbh->prepare('insert into metadata values ('.
+ '"'.delete($sqldatafields{'title'}).'"'.','.
+ '"'.delete($sqldatafields{'author'}).'"'.','.
+ '"'.delete($sqldatafields{'subject'}).'"'.','.
+ '"'.delete($sqldatafields{'url'}).'"'.','.
+ '"'.delete($sqldatafields{'keywords'}).'"'.','.
+ '"'.'current'.'"'.','.
+ '"'.delete($sqldatafields{'notes'}).'"'.','.
+ '"'.delete($sqldatafields{'abstract'}).'"'.','.
+ '"'.delete($sqldatafields{'mime'}).'"'.','.
+ '"'.delete($sqldatafields{'language'}).'"'.','.
+ '"'.
+ sqltime(delete($sqldatafields{'creationdate'}))
+ .'"'.','.
+ '"'.
+ sqltime(delete(
+ $sqldatafields{'lastrevisiondate'})).'"'.','.
+ '"'.delete($sqldatafields{'owner'}).'"'.','.
+ '"'.delete(
+ $sqldatafields{'copyright'}).'"'.')');
+ $sth->execute();
+ $dbh->disconnect;
+ $scrout.='Synchronized SQL metadata database';
+ print $logfile "\nSynchronized SQL metadata database";
}
}
- my %sqldatafields;
- $sqldatafields{'url'}=$distarget;
- $sth=$dbh->prepare("delete from metadata where url like binary \"".
- $sqldatafields{'url'}."\"");
- $sth->execute();
- map {my $field=$metadatafields{$_}; $field=~s/\"/\'\'/g;
- $sqldatafields{$_}=$field;}
- ('title','author','subject','keywords','notes','abstract',
- 'mime','language','creationdate','lastrevisiondate','owner','copyright');
-
- $sth=$dbh->prepare('insert into metadata values ('.
- '"'.delete($sqldatafields{'title'}).'"'.','.
- '"'.delete($sqldatafields{'author'}).'"'.','.
- '"'.delete($sqldatafields{'subject'}).'"'.','.
- '"'.delete($sqldatafields{'url'}).'"'.','.
- '"'.delete($sqldatafields{'keywords'}).'"'.','.
- '"'.'current'.'"'.','.
- '"'.delete($sqldatafields{'notes'}).'"'.','.
- '"'.delete($sqldatafields{'abstract'}).'"'.','.
- '"'.delete($sqldatafields{'mime'}).'"'.','.
- '"'.delete($sqldatafields{'language'}).'"'.','.
- '"'.delete($sqldatafields{'creationdate'}).'"'.','.
- '"'.delete($sqldatafields{'lastrevisiondate'}).'"'.','.
- '"'.delete($sqldatafields{'owner'}).'"'.','.
- '"'.delete($sqldatafields{'copyright'}).'"'.')');
- $sth->execute();
- $dbh->disconnect;
- $scrout.='
Synchronized SQL metadata database';
- print $logfile "\nSynchronized SQL metadata database";
# ----------------------------------------------------------- Copy old versions
@@ -681,7 +718,7 @@ if (-e $target) {
$thissrcdir=~s/\/[^\/]+$/\//;
- return $scrout.
+ return $warning.$scrout.
'
View Target'.
'Back to Source'.
'
Diffs with Current Version
');
+ }
# ------------ We are publishing from $thisfn to $thistarget with $thisembstyle
unless ($ENV{'form.phase'} eq 'two') {
- $r->print('
'.&publish($thisfn,$thistarget,$thisembstyle));
+ $r->print(
+ '
'.&publish($thisfn,$thistarget,$thisembstyle));
} else {
- $r->print('
'.&phasetwo($thisfn,$thistarget,$thisembstyle,$thisdistarget));
+ $r->print(
+ '
'.&phasetwo($thisfn,$thistarget,$thisembstyle,$thisdistarget));
}
}