X-Git-Url: http://git.indexdata.com/?p=irspy-moved-to-github.git;a=blobdiff_plain;f=web%2Fhtdocs%2Fdetails%2Fedit.mc;h=917c9f3f94cf438d6e17fdadf53af5ecd5f9ab2a;hp=ad724a0e428b39f585a120494045f4ad1832a7c5;hb=b7b5603afb2143500f0d347bd92a9ca723f55746;hpb=61d0705b4be65fc3c8482b84ee53e39c32c670f8 diff --git a/web/htdocs/details/edit.mc b/web/htdocs/details/edit.mc index ad724a0..917c9f3 100644 --- a/web/htdocs/details/edit.mc +++ b/web/htdocs/details/edit.mc @@ -1,16 +1,15 @@ -%# $Id: edit.mc,v 1.14 2006-11-16 12:16:32 mike Exp $ +%# $Id: edit.mc,v 1.17 2006-11-16 17:27:15 mike Exp $ <%args> $id => undef <%perl> my $conn = new ZOOM::Connection("localhost:3313/IR-Explain---1", 0, - user => "admin", password => "fruitbat"); + user => "admin", password => "fruitbat", + elementSetName => "zeerex"); my $rec = ''; if (defined $id && $id ne "") { - $conn->option(elementSetName => "zeerex"); - my $qid = $id; - $qid =~ s/"/\\"/g; - my $query = qq[rec.id="$qid"]; + # Existing record + my $query = 'rec.id="' . cql_quote($id) . '"'; my $rs = $conn->search(new ZOOM::Query::CQL($query)); my $n = $rs->size(); if ($n == 0) { @@ -18,6 +17,20 @@ if (defined $id && $id ne "") { } else { $rec = $rs->record(0); } + +} else { + # New record + my $host = $r->param("host"); + my $port = $r->param("port"); + my $dbname = $r->param("dbname"); + if (!defined $host || $host eq "" || + !defined $port || $port eq "" || + !defined $dbname || $dbname eq "") { + print qq[

You must specify host, port and database name.

\n]; + $r->param(update => 0); + } + + my $query = cql_target($host, $port, $dbname); } my $xc = irspy_xpath_context($rec); @@ -59,7 +72,7 @@ my @fields = my $nchanges = 0; my $update = $r->param("update"); -if (defined $update) { +if ($update) { # Update record with submitted data my %fieldsByKey = map { ( $_->[0], $_) } @fields; my %data; @@ -102,7 +115,7 @@ foreach my $ref (@fields) { % } % } elsif ($nlines) { - + % } else { % }