chiark / gitweb /
database editing etc. works
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 12 Sep 2012 21:06:04 +0000 (22:06 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 12 Sep 2012 21:06:04 +0000 (22:06 +0100)
mason/main
mason/save

index 03a01d9..a9bc72e 100755 (executable)
@@ -54,8 +54,13 @@ $sth->execute();
 
 <&| txtable, tx => $row &>
 %    $sthi->execute($row->{'textid'});
+%    my $anyused = 0;
 %    while (my $rowi= $sthi->fetchrow_hashref()) {
 <tr><td>Used for:</td><td><% $rowi->{'emailaddr'} |h %></td></tr>
+%        $anyused++;
+%    }
+%    if ($anyused) {
+<tr><td colspan=2>Not currently in use</td></tr>
 %    }
 </&>
 <pre>
index cedd05b..c749084 100755 (executable)
@@ -48,12 +48,15 @@ $dinsertq->execute($textid, $desc, $subject, $text);
 my $tdeleteq = $dbh->prepare("DELETE FROM addresses WHERE textid = ?");
 $tdeleteq->execute($textid);
 
+my $odeleteq = $dbh->prepare("DELETE FROM addresses WHERE emailaddr = ?");
+
 my $tinsertq = $dbh->prepare("INSERT INTO addresses (emailaddr, textid)".
                             " VALUES (?,?)");
 my $tlistq = $dbh->prepare("SELECT * FROM config");
 $tlistq->execute();
 while (my $row = $tlistq->fetchrow_hashref()) {
     if ($ARGS{"u_".hquote($row->{'emailaddr'})}) {
+       $odeleteq->execute($row->{'emailaddr'});
        $tinsertq->execute($row->{'emailaddr'}, $textid);
     }
 }