chiark / gitweb /
wip login/logout handling
[nj-awaymsg.git] / mason / main
1 <%init>
2 use AwayMsg;
3 db_connect();
4 www_begin($r,$m);
5 my ($sth,$row,$sthi,$rowi);
6 </%init>
7 <%shared>
8 our ($cgi,$ar);
9 </%shared>
10 <&htmlhead, subpage => 'Overview' &>
11
12 <h2>Email addresses and their configuration</h2>
13 <%perl>
14 $sth = $dbh->prepare(<<END);
15     SELECT *
16      FROM        config
17        LEFT JOIN addresses USING (emailaddr)
18        LEFT JOIN texts     USING (textid)
19      ORDER BY emailaddr
20 END
21 $sth->execute();
22 </%perl>
23 <table rules="all">
24 <tr>
25 <td>Address</td>
26 <td>Status</td>
27 <td>Which message?</td>
28 </tr><tr>
29 % while (my $row= $sth->fetchrow_hashref()) {
30 <tr>
31 <td><% $row->{'emailaddr'} |h %></td>
32 %     if (defined $row->{'textid'}) {
33 <td>active</td>
34 <td><% $row->{'desc'} |h %></td>
35 %     } else {
36 <td>inactive</td>
37 <td></td>
38 %     }
39 </tr>
40 % }
41 </table>
42
43 <hr>
44 <h2>Outbound messages</h2>
45 <%perl>
46 $sth = $dbh->prepare("SELECT * FROM texts ORDER BY textid");
47 $sthi = $dbh->prepare(<<END);
48     SELECT * FROM addresses
49      WHERE textid = ?
50      ORDER BY emailaddr
51 END
52 $sth->execute();
53 </%perl>
54 % while (my $row= $sth->fetchrow_hashref()) {
55 <form action="<% $ENV{'URL'} %>/edit" method="POST">
56 <% $ar->secret_hidden_html() %>
57 <h3>Message "<% $row->{'desc'} |h %>"</h3>
58
59 <&| txtable, tx => $row &>
60 %    $sthi->execute($row->{'textid'});
61 %    my $anyused = 0;
62 %    while (my $rowi= $sthi->fetchrow_hashref()) {
63 <tr><td>Used for:</td><td><% $rowi->{'emailaddr'} |h %></td></tr>
64 %        $anyused++;
65 %    }
66 %    if ($anyused) {
67 <tr><td colspan=2>Not currently in use</td></tr>
68 %    }
69 </&>
70 <pre>
71 <% $row->{'text'} |h %>
72 </pre>
73
74 <input type="submit" name="t_<% $row->{'textid'} %>"
75    value="Edit or configure this message">
76 <hr>
77 % }
78 <h3>Add new message</h3>
79 <input type="submit" name="create"
80    value="Start adding new message">
81 </form>