X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=nj-awaymsg.git;a=blobdiff_plain;f=mason%2Fedit;h=96124131d93a83a3e464d4c9c702650882cad3b2;hp=7869cc814c4cc6526c0aec599e2efd881d48223a;hb=dc799127a0e7b0599248dd9669652aeb4af59454;hpb=1f01b365b07c5952ec878a4ca0d4b69f2ed14f80 diff --git a/mason/edit b/mason/edit index 7869cc8..9612413 100755 --- a/mason/edit +++ b/mason/edit @@ -1,6 +1,7 @@ <%init> use AwayMsg; db_connect(); +www_begin($r,$m); <%args> @@ -14,7 +15,7 @@ my $textid; if (defined $create) { } else { foreach my $k (keys %ARGS) { - if ($k =~ m/^t(\d{0,7})$/) { + if ($k =~ m/^t_(\d{0,7})$/) { $textid= $1; last; } @@ -22,21 +23,52 @@ if (defined $create) { die unless defined $textid; } -my $sth = $dbh->prepare("SELECT * FROM texts WHERE textid=?"); -$sth->execute($textid); -my $tx = $sth->fetchrow_hashref();# +my $tx; + +if ($ARGS{'create'}) { + my $date = `date --iso-8601=minutes`; chomp $date or die; + $tx = { desc => "Message created $date", + subject => "Away from my email", + textid => "new", + text => "" }; +} else { + my $sth = $dbh->prepare("SELECT * FROM texts WHERE textid=?"); + $sth->execute($textid); + $tx = $sth->fetchrow_hashref();# +} + +my $usedq = $dbh->prepare(<execute(); if (!$tx) { die "no such text $textid"; } - -Editing - <% $tx->{'desc'} |h %> - Email "out of office" setup - -

Edit "<% $tx->{'desc'} |h %>"

+<& htmlhead, subpage => "Edit \"$tx->{'desc'}\"" &>
<&| txtable, tx => $tx, inputs => 1 &> -TXTABLE CONTENT + - - + +% while (my $row = $usedq->fetchrow_hashref()) { + + +% } +
Use for <% $row->{'emailaddr'} |h %>{'emailaddr'}) %> +% if (!$create && $row->{'textid'} eq $textid) { + checked>(currently using this message) +% } elsif (defined $row->{'textid'}) { + >(currently using another message "<% $row->{'desc'} |h %>") +% } else { + > +% } +

+ + +