-VERSION=0.14_08
+VERSION=0.14_09
DISTNAME=bse-$(VERSION)
DISTBUILD=$(DISTNAME)
DISTTAR=../$(DISTNAME).tar
refresh_to($req->url('logon'));
}
-sub tag_recipient_count {
+sub tag_list_recipient_count {
my ($subs, $subindex) = @_;
$$subindex >= 0 && $$subindex < @$subs
\$subindex),
BSE::Util::Tags->secure($req),
message => sub { CGI::escapeHTML($message) },
- recipient_count => [ \&tag_recipient_count, \@subs, \$subindex ],
+ recipient_count => [ \&tag_list_recipient_count, \@subs, \$subindex ],
);
BSE::Template->show_page('admin/subs/list', $cfg, \%acts);
}
my @all = grep($req->user_can('edit_add_child', $_)
|| $sub->{parentId} == $_->{id},
Articles->all());
- @all = grep
+ @all =
+ grep
{
my $type = ($_->{generator} =~ /(\w+)$/)[0] || 'Article';
$valid_types{$type} && $_->{id} != $shopid
} @all;
my %labels = map { $_->{id}, "$_->{title} ($_->{id})" } @all;
+ @all = sort { lc $labels{$a->{id}} cmp lc $labels{$b->{id}} } @all;
my @extras;
- if ($sub && !$old) {
- @extras = ( -default=>$sub->{parentId} );
+ unless ($old) {
+ if ($sub) {
+ @extras = ( -default=>$sub->{parentId} );
+ }
+ else {
+ # use the highest id, presuming the most recent article created
+ # was created to store subscriptions
+ my $max = -1;
+ $max < $_->{id} and $max = $_->{id} for @all;
+ @extras = ( -default=>$max );
+ }
}
return CGI::popup_menu(-name=>'parentId',
-values=> [ map $_->{id}, @all ],
BSE::Template->show_page('admin/subs/start_send', $cfg, \%acts);
}
+sub tag_recipient_count {
+ my ($sub, $rcount_cache) = @_;
+
+ defined $$rcount_cache or $$rcount_cache = $sub->recipient_count;
+
+ $$rcount_cache;
+}
+
sub send_form {
my ($q, $req, $cfg) = @_;
or return _refresh_list($q, $cfg, $msgs->(startnoid=>"No id supplied to be edited"));
my $sub = BSE::SubscriptionTypes->getByPkey($id)
or return _refresh_list($q, $cfg, $msgs->(startnosub=>"Cannot find record $id"));
+ my $count_cache;
my %acts;
%acts =
(
old => sub { CGI::escapeHTML(defined $sub->{$_[0]} ? $sub->{$_[0]} : '') },
template => sub { return _template_popup($cfg, $q, $sub, 0, $_[0]) },
parent=> sub { _parent_popup($req, $sub) },
+ recipient_count => [ \&tag_recipient_count, $sub, \$count_cache ],
);
BSE::Template->show_page('admin/subs/send_form', $cfg, \%acts);
}
my @recipients = $sub->recipients;
+ unless (@recipients) {
+ $callback->('error', undef, 'This subscription has no recipients, no action taken');
+ return;
+ }
+
my %article;
$sub->_send($cfg, $opts, $callback, \@recipients, \%article);
and next TRY;
$part =~ s#image\[([^\]\[]+)\]# $self->image($1) #ige
and next TRY;
- $part =~ s#class\[([^\]\[\|]+)\|([^\]\[]+)\]#<span class="$1">$2</span>#ig
+ $part =~ s#class\[([^\]\[\|]+)\|([^\]\[]+)\]#
+ _fix_spanned(qq/<span class="$1">/, "</span>", $2)#eig
and next TRY;
last;
}
print STDERR "** switch\n" if DEBUG;
my @cases = split /(?=<:\s*case\s)/gs, $content;
- shift @cases; # drop the loser at the front
+ shift @cases if @cases && $cases[0] !~ /<:\s*case\s/;
my $case;
while ($case = shift @cases) {
my ($cond, $data) = $case =~ /<:\s*case\s+(.*?):>(.*)/s;
=head1 CHANGES
+=head2 0.14_09
+
+=over
+
+=item *
+
+the <:switch:> template construct had required there be some text
+between "<:switch:>" and the first case, this is no longer necessary.
+You still might want to keep a newline there to make it easier to pick
+out cases
+
+=item *
+
+the list of possible archive parents for subscriptions is now sorted
+by title (#295) We now select the highest id article by default when
+creating a new subscription, presuming it was created to store an
+archive.
+
+=item *
+
+the <:recipient_count:> tag is now available on the subscription send
+form, and the Send link is now always available on the subscriptions
+list. (#269)
+
+=item *
+
+the subscription send action, if it somehow is submitted with no users
+subcribed, will no longer archive an article and update the most
+recent send date. This can happen if the last user unsubscribes while
+the administrator is composing their newsletter.
+
+=item *
+
+the class[] body text tag now nests correctly when spanning over
+paragraphs
+
+=back
+
=head2 0.14_08
=over
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-
- <title>Administration - Subscriptions Manager</title>
-
- <link rel="stylesheet" type="text/css" href="/css/admin.css" />
-
-</head>
-
-<body>
-
+<:wrap admin/xbase.tmpl title=>"Subscriptions List":>
<h1>Subscriptions List</h1>
<:ifMessage:><p><b><:message:></b></p><:or:><:eif:>
-<p>| <a href="/cgi-bin/admin/menu.pl">Admin menu</a> |</p>
+<p>| <a href="/cgi-bin/admin/menu.pl">Admin menu</a> |<:ifUserCan subs_add:>
+<a href="<:script:>?add=1">Add Subscription</a> |<:or:><:eif:></p>
<table border="0" cellspacing="0" cellpadding="0" bgcolor="#000000" class="table">
<tr>
<td align="center"><:recipient_count:></td>
<td nowrap> <:ifUserCan subs_edit:><a href="<:script:>?edit=1&id=<:subscription id:>"><b>Edit</b></a> <:or:><:eif:>
<:ifUserCan subs_delete:><a href="<:script:>?delconfirm=1&id=<:subscription id:>"><b>Delete</b></a> <:or:><:eif:>
- <:ifAnd [ifUserCan subs_send] [recipient_count]:><a href="<:script:>?start_send=1&id=<:subscription id:>"><b>Send</b></a> <:or:><:eif:>
+ <:ifUserCan subs_send:><a href="<:script:>?start_send=1&id=<:subscription id:>"><b>Send</b></a><:or:><:eif:>
</td>
</tr>
<:iterator end subscriptions:>
</td>
</tr>
</table>
-<:ifUserCan subs_add:>
-<form name="form1" method="post" action="<:script:>">
- <p><input type="submit" name="add" value="Add Subscription">
- </p>
-</form><:or:><:eif:>
-<p><font size="-1">BSE Release <:release:></font></p>
-</body>
-</html>
</tr>
</table>
<p>
- <input type="submit" name="send" value="Send Subscription">
- <:help subssend send:>
+ <:ifRecipient_count:><input type="submit" name="send" value="Send Subscription">
+ <:help subssend send:> <:or:><:eif:>
<:ifCfg subscriptions testing 1:> <input type="submit" name="send_test" value="Send Test">
<:help subssend sendtest:> <:or:><:eif:>
<input type="submit" name="html_preview" value="HTML Preview">
#!perl -w
# Basic tests for Squirrel::Template
use strict;
-use Test::More tests => 16;
+use Test::More tests => 17;
sub template_test($$$$;$);
$str = "DEF";
template_test($switch, "DEF", "switch def", \%acts, "both");
+ my $switch2 = <<IN;
+<:switch:><:case Eq [strref] "ABC":>ONE<:case Eq [strref] "XYZ":>TWO<:
+case default:>DEF<:endswitch:>
+IN
+ $str = "ABC";
+ template_test($switch2, "ONE", "switch without ignored", \%acts, "both");
+
template_test("<:with begin upper:>Alpha<:with end upper:>", "ALPHA", "with", \%acts);
template_test("<:include doesnt/exist optional:>", "", "optional include", \%acts);
template_test("<:include doesnt/exist:>", "** cannot find include doesnt/exist in path **", "failed include", \%acts);
#!perl -w
use strict;
-use Test::More tests => 37;
+use Test::More tests => 38;
sub format_test($$$;$);
my $gotmodule = require_ok('DevHelp::Formatter');
SKIP: {
- skip "couldn't load module", 35 unless $gotmodule;
+ skip "couldn't load module", 37 unless $gotmodule;
format_test <<IN, <<OUT, 'bold', 'both';
b[hello]
format_test 'image[foo]', '', 'image';
format_test 'class[xxx|yyy]', '<span class="xxx">yyy</span>', 'class';
+ format_test "class[xxx|yy\n\nzz]", <<EOS, 'class2', 'out';
+<span class="xxx">yy</span></p>
+<p><span class="xxx">zz</span>
+EOS
}
sub format_test ($$$;$) {