-VERSION=0.14_06
+VERSION=0.14_07
DISTNAME=bse-$(VERSION)
DISTBUILD=$(DISTNAME)
DISTTAR=../$(DISTNAME).tar
disabled integer not null default 0,
+ flags varchar(80) not null default '',
+
primary key (id),
unique (userId)
);
address2=Second address line in configuration
address3=Third address line in configuration
enabled=1
+display_billAddress=Billing Address
+display_name1=First Name
+display_name2=Last Name
+display_address=Address
[level 1]
template=common/default.tmpl
add=>1,
);
-my @donttouch = qw(id userId password email confirmed confirmSecret waitingForConfirmation);
+my @donttouch = qw(id userId password email confirmed confirmSecret waitingForConfirmation flags); # flags is saved separately
my %donttouch = map { $_, $_ } @donttouch;
sub dispatch {
$class->$method($req);
}
+sub flags {
+ my ($cfg) = @_;
+
+ my %flags = $cfg->entriesCS('site user flags');
+
+ my @valid = grep /^\w+$/, keys %flags;
+
+ return map +{ id => $_, desc => $flags{$_} },
+ sort { lc($flags{$a}) cmp lc($flags{$b}) } @valid;
+}
+
sub req_list {
my ($class, $req, $msg) = @_;
return $cfg->entryBool('site users', "require_$args", 0);
}
+sub iter_flags {
+ my ($cfg) = @_;
+
+ flags($cfg);
+}
+
+sub tag_if_flag_set {
+ my ($flags, $arg, $acts, $funcname, $templater) = @_;
+
+ my @args = DevHelp::Tags->get_parms($arg, $acts, $templater);
+ @args or return;
+
+ return index($flags, $args[0]) >= 0;
+}
+
sub req_edit {
my ($class, $req, $msg, $errors) = @_;
my $siteuser = SiteUsers->getByPkey($id)
or return $class->req_list($req, "No such site user found");
+ my $it = BSE::Util::Iterate->new;
+
$errors ||= {};
if ($msg) {
$msg = escape_html($msg);
siteuser => [ \&tag_hash, $siteuser ],
error_img => [ \&tag_error_img, $req->cfg, $errors ],
ifRequired => [ \&tag_if_required, $req->cfg ],
+ $it->make_iterator([ \&iter_flags, $req->cfg], 'flag', 'flags'),
+ ifFlagSet => [ \&tag_if_flag_set, $siteuser->{flags} ],
);
my $template = 'admin/users/edit';
}
}
+ my @flags = flags($cfg);
+ my %flags = map { $_->{id} => 1 } @flags;
+ $user->{flags} = join('', grep exists $flags{$_}, $cgi->param('flags'))
+ if $cgi->param('saveFlags');
+
$user->{textOnlyMail} = 0
if $cgi->param('saveTextOnlyMail') && !defined $cgi->param('textOnlyMail');
$user->{keepAddress} = 0
use BSE::Util::Secure qw/make_secret/;
$user{password} = make_secret($cfg);
}
+ my @flags = flags($cfg);
+ my %flags = map { $_->{id} => 1 } @flags;
+ $user{flags} = join('', grep exists $flags{$_}, $cgi->param('flags'));
my $user;
eval {
'select * from site_users where userId = ?',
getSiteUserByPkey =>
'select * from site_users where id = ?',
- addSiteUser => 'insert site_users values(null,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
- replaceSiteUser => 'replace site_users values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
+ addSiteUser => 'insert site_users values(null,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
+ replaceSiteUser => 'replace site_users values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
'SiteUsers.removeSubscriptions'=>
'delete from subscribed_users where userId = ?',
'SiteUsers.removeSub'=>
return 1 if $req->user;
+ my $server_auth_admin = $cfg->entry('basic', 'server_auth', 0);
+
my $user;
require BSE::TB::AdminUsers;
- if ($ENV{REMOTE_USER}) {
+ if ($server_auth_admin && $ENV{REMOTE_USER}) {
($user) = BSE::TB::AdminUsers->getBy(logon => $ENV{REMOTE_USER});
}
if ($req->session->{adminuserid}) {
id => 0,
name => 'CC',
desc => 'Credit Card',
- require => [ qw/cardNumber cardExpiry/ ],
+ require => [ qw/cardNumber cardExpiry cardHolder cardType/ ],
},
1 => {
id => 1,
use constant MAX_UNACKED_CONF_MSGS => 3;
use constant MIN_UNACKED_CONF_GAP => 2 * 24 * 60 * 60;
-my @donttouch = qw(id userId password email confirmed confirmSecret waitingForConfirmation disabled);
+my @donttouch = qw(id userId password email confirmed confirmSecret waitingForConfirmation disabled flags);
my %donttouch = map { $_, $_ } @donttouch;
sub user_tags {
and next TRY;
$part =~ s#image\[([^\]\[]+)\]# $self->image($1) #ige
and next TRY;
+ $part =~ s#class\[([^\]\[\|]+)\|([^\]\[]+)\]#<span class="$1">$2</span>#ig
+ and next TRY;
last;
}
$part =~ s!(\n([ \r]*\n)*)!$1 eq "\n" ? "<br />\n" : "</p>\n<p>"!eg;
1+$$rindex;
}
+sub _iter_count {
+ my ($self, $rdata, $code, $loaded, $nocache,
+ $args, $acts, $name, $templater) = @_;
+
+ if (!$$loaded && !@$rdata && $code || $args || $nocache) {
+ my ($sub, @args) = $code;
+
+ if (ref $code eq 'ARRAY') {
+ ($sub, @args) = @$code;
+ }
+ @$rdata = $sub->(@args, $args, $acts, $name, $templater);
+ ++$$loaded unless $args;
+ }
+
+ scalar(@$rdata);
+}
+
sub make_iterator {
my ($self, $code, $single, $plural, $rdata, $rindex, $nocache) = @_;
prompt otherPrompt profession otherProfession previousLogon
billFirstName billLastName billStreet billSuburb billState
billPostCode billCountry instructions billTelephone billFacsimile
- billEmail adminNotes disabled/;
+ billEmail adminNotes disabled flags/;
}
sub removeSubscriptions {
push @required, @{$pay_types{$paymentType}{require}};
for my $field (@required) {
+ my $display = $cfg->entry('shop', "display_$field", $field);
defined(param($field)) && length(param($field))
- or return checkout("Field $field is required", 1);
+ or return checkout("Field $display is required", 1);
}
defined(param('email')) && param('email') =~ /.\@./
or return checkout("Please enter a valid email address", 1);
=head1 CHANGES
+=head2 0.14_07
+
+You will need to run upgrade_mysql.pl for this release.
+
+=over
+
+=item *
+
+checkoutfinal_base.tmpl now uses the new <:if Payment I<name>:> tags,
+and includes a payments customization shim.
+
+=item *
+
+shop.pl now uses [shop].display_I<field-name> to convert stored field
+names into display names for error messages.
+
+=item *
+
+cardType and cardHolder fields are now required fields for credit card
+payments
+
+=item *
+
+admin access control now requires that a configuration option to be
+set before it will accept admin user authentication information from
+the server (typically basic authentication.)
+
+=item *
+
+the class[I<classname>|I<text>] tag was lost when integrating the
+common tag handling code, added it back in (#284)
+
+=item *
+
+you can now define custom flags for site users, the flag value is a
+single letter or digit, case-sensitive. Add an entry like:
+
+ I<letter-or-digit>=I<description>
+
+to the [site user flags] section of the config file. For example:
+
+ a=Access to private area of the site
+ b=Accept orders on account
+
+You can check this on templates where the user is visible with the
+<:if Match:> tag:
+
+ <:ifMatch [siteuser flags] "b":>Accept orders on account<:or:><:eif:>
+
+=back
+
=head2 0.14_06
=over
If this is true then the user/group/permissions database is used to
control access to the system. Default: False.
+=item server_auth
+
+Set this to non-zero to enable authentication via server
+authentication (usually Basic Authentication.) You should normally
+set this if you set htusers below. Default: 0 (disabled)
+
=item htusers
This should be the path to a file to be updated with the list of users
If true, then the order is email to to_email, possibly with credit
card information included. Default: $SHOP_EMAIL_ORDER.
+=item display_I<field>
+
+Used to translate the stored order field name into a presentation name
+suitable for error messages.
+
=back
=head2 [fields]
</td>
<td bgcolor="#FFFFFF" valign="top"><:help editsiteuser adminNotes:> <:error_img adminNotes:></td>
</tr>
+<:if Flags:>
+ <tr>
+ <th bgcolor="#FFFFFF" align="left" valign="top">Flags: </th>
+ <td bgcolor="#FFFFFF">
+ <:iterator begin flags:>
+ <input type="checkbox" name="flags" value="<:flag id:>" /> <:flag desc:>
+ <:iterator separator flags:>
+ <br />
+ <:iterator end flags:>
+ </td>
+ <td bgcolor="#FFFFFF" valign="top"><:help editsiteuser flags:> <:error_img adminNotes:></td>
+ </tr>
+<:or Flags:><:eif Flags:>
<tr>
<td bgcolor="#FFFFFF" colspan="3" align="right">
<input type="submit" name="a_add" value=" Add User " />
</td>
<td bgcolor="#FFFFFF" valign="top"><:help editsiteuser adminNotes:> <:error_img adminNotes:></td>
</tr>
+<:if Flags:>
+ <tr>
+ <th bgcolor="#FFFFFF" align="left" valign="top">Flags: </th>
+ <td bgcolor="#FFFFFF"> <input type="hidden" name="saveFlags" value="1" />
+ <:iterator begin flags:>
+ <input type="checkbox" name="flags" value="<:flag id:>" <:ifFlagSet [flag id]:>checked="checked" <:or:><:eif:>/> <:flag desc:>
+ <:iterator separator flags:>
+ <br />
+ <:iterator end flags:>
+ </td>
+ <td bgcolor="#FFFFFF" valign="top"><:help editsiteuser flags:> <:error_img adminNotes:></td>
+ </tr>
+<:or Flags:><:eif Flags:>
<:if UserCan siteuser_changepw:>
<:if Cfg "site users" nopassword:><:or Cfg:>
<tr>
<input type="Text" name="billCountry" size=20 value="<:old billCountry:>">
*</font></td>
</tr>
+ <tr>
+ <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> Email:</font></td>
+ <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
+ <input type="Text" name="billEmail" size=20 value="<:old billEmail:>">
+ *</font></td>
+ </tr>
+ <tr>
+ <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> Telephone:</font></td>
+ <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
+ <input type="Text" name="billTelephone" size=20 value="<:old billTelephone:>">
+ *</font></td>
+ </tr>
+ <tr>
+ <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> Facsimile:</font></td>
+ <td> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
+ <input type="Text" name="billFacsimile" size=20 value="<:old billFacsimile:>">
+ *</font></td>
+ </tr>
</table>
<p> </p>
<:or Cgi:>
<p> The <:siteName:> store is run on a secure encrypted server, your details are
safe with us.<br>
</p>
-<:if CCPayment:><:or CCPayment:><:eif CCPayment:>
-<:if ChequePayment:>
+<:if Payment CC:><:or Payment:><:eif Payment:>
+<:if Payment Cheque:>
<p>Please send your cheque to:</p>
<ul><:cfg shop address1 |h:><br>
<:cfg shop address2 |h:><br>
<:cfg shop address3 |h:></ul>
-<:or ChequePayment:><:eif ChequePayment:>
-<:if CallMePayment:>
+<:or Payment:><:eif Payment:>
+<:if Payment CallMe:>
<p>We will call you to arrange payment.</p>
-<:or CallMePayment:><:eif CallMePayment:>
-
+<:or Payment:><:eif Payment:>
+<:include custom/checkout_final_payments.include optional:>
</font>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
#!perl -w
use strict;
-use Test::More tests => 36;
+use Test::More tests => 37;
sub format_test($$$;$);
<table width="80" height="10" border="0" bgcolor="#FF0000" cellpadding="0" cellspacing="0"><tr><td><img src="/images/trans_pixel.gif" width="1" height="1" alt="" /></td></tr></table>
OUT
format_test 'image[foo]', '', 'image';
+
+ format_test 'class[xxx|yyy]', '<span class="xxx">yyy</span>', 'class';
}
sub format_test ($$$;$) {
dealer.bsb=999999
dealer.accountno=77777777
+shop.display_facsimile=Fax Number
+site user flags.a=Access to private pages
+tandb custom.siteuser_include_flag=a