From a94c056ed72a1c3e6925ec56fda6294968686d42 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 4 Sep 2012 21:45:57 +0100 Subject: [PATCH] wip --- mason/edit | 5 +++-- mason/save | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100755 mason/save diff --git a/mason/edit b/mason/edit index 5e60d09..60e8b9e 100755 --- a/mason/edit +++ b/mason/edit @@ -48,5 +48,6 @@ if (!$tx) { die "no such text $textid"; } - - + + + diff --git a/mason/save b/mason/save new file mode 100755 index 0000000..30cc47a --- /dev/null +++ b/mason/save @@ -0,0 +1,34 @@ +<%init> +use AwayMsg; +db_connect(); + +<%args> +$textid +$save => 0 +$cancel => 0 +$textid => undef + +<%perl> +if ($save) { + my $ins; + $dbh->do('BEGIN'); + if ($textid eq 'new') { + my $ntextq = $dbh->prepare("SELECT textid FROM texts". + " ORDER BY textid DESC LIMIT 1"); + $ntextq->execute(); + my $ntextrow = $ntextq->fetchrow_hashref(); + if ($ntextrow) { + $textid = $ntextrow->{'textid'} + 1; + } else { + $textid = 1; + } + } else { + my $dtextq = $dbh->prepare("DELETE FROM texts WHERE textid = ?"); + my $ndeleted = $dtextq->execute($textid); + if (!$ndeleted) { + + + + $ins = $dbh->prepare("INSERT INTO texts VALUES ( + $sth = $dbh-> +} -- 2.30.2