X-Git-Url: http://git.indexdata.com/?p=irspy-moved-to-github.git;a=blobdiff_plain;f=web%2Fhtdocs%2Fdetails%2Fedit.mc;h=92b5fa2c607b02d7879e65c4504771f51890cf70;hp=917c9f3f94cf438d6e17fdadf53af5ecd5f9ab2a;hb=f710bbf2da2d0478be71ca49425aa70be89c26d2;hpb=713149feeca669b0bf5702f55a89cd681a648f1e diff --git a/web/htdocs/details/edit.mc b/web/htdocs/details/edit.mc index 917c9f3..92b5fa2 100644 --- a/web/htdocs/details/edit.mc +++ b/web/htdocs/details/edit.mc @@ -1,4 +1,4 @@ -%# $Id: edit.mc,v 1.17 2006-11-16 17:27:15 mike Exp $ +%# $Id: edit.mc,v 1.19 2006-11-16 17:52:06 mike Exp $ <%args> $id => undef @@ -11,11 +11,10 @@ if (defined $id && $id ne "") { # 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) { - $id = undef; - } else { + if ($rs->size() > 0) { $rec = $rs->record(0); + } else { + $id = undef; } } else { @@ -26,11 +25,21 @@ if (defined $id && $id ne "") { if (!defined $host || $host eq "" || !defined $port || $port eq "" || !defined $dbname || $dbname eq "") { - print qq[

You must specify host, port and database name.

\n]; + print qq[

+You must specify host, port and database name.

\n]; $r->param(update => 0); + } else { + my $query = cql_target($host, $port, $dbname); + my $rs = $conn->search(new ZOOM::Query::CQL($query)); + if ($rs->size() > 0) { + my $fakeid = xml_encode(uri_escape("$host:$port/$dbname")); + print qq[

+There is already +a record +for this host, port and database name. +

\n]; + } } - - my $query = cql_target($host, $port, $dbname); } my $xc = irspy_xpath_context($rec); @@ -72,7 +81,7 @@ my @fields = my $nchanges = 0; my $update = $r->param("update"); -if ($update) { + # Update record with submitted data my %fieldsByKey = map { ( $_->[0], $_) } @fields; my %data; @@ -80,8 +89,10 @@ if ($update) { next if grep { $key eq $_ } qw(id update new copy); $data{$key} = $r->param($key); } + my $mynchanges = modify_xml_document($xc, \%fieldsByKey, \%data); - $nchanges = modify_xml_document($xc, \%fieldsByKey, \%data); +if ($update) { + $nchanges = $mynchanges; if ($nchanges) { ### Set e:metaInfo/e:dateModified }