site/cgi-bin/modules/BSE/UI/SubAdmin.pm
site/cgi-bin/modules/BSE/UserReg.pm
site/cgi-bin/modules/BSE/Util/DynSort.pm
+site/cgi-bin/modules/BSE/Util/DynamicTags.pm
site/cgi-bin/modules/BSE/Util/Iterate.pm
site/cgi-bin/modules/BSE/Util/SQL.pm
site/cgi-bin/modules/BSE/Util/Secure.pm
-VERSION=0.15_22
+VERSION=0.15_23
DISTNAME=bse-$(VERSION)
DISTBUILD=$(DISTNAME)
DISTTAR=../$(DISTNAME).tar
[error settings]
title = Error
+dynamic = 0
[messages]
user/notyourorder = Order $1 isn't your order
use FindBin;
use lib "$FindBin::Bin/modules";
use Constants qw(:shop);
-use BSE::Cfg;
use BSE::Session;
use BSE::Mail;
use BSE::Template;
use BSE::Util::Tags;
-use SiteUsers;
-use CGI;
+use BSE::Request;
-my $cfg = BSE::Cfg->new;
+my $req = BSE::Request->new;
+my $cfg = $req->cfg;;
-my %session;
-BSE::Session->tie_it(\%session, $cfg);
-
-my $cgi = CGI->new;
+my $cgi = $req->cgi;
my $useremail = $cgi->param('email');
unless ($useremail) {
- if ($session{userid}) {
- my $user = SiteUsers->getBy(userId=>$session{userid});
+ my $user = $req->siteuser;
+ if ($user) {
$useremail = $user->{email};
}
}
my %acts;
%acts =
(
- BSE::Util::Tags->basic(\%acts, $cgi, $cfg),
+ $req->dyn_user_tags(),
product => sub { $product },
product_id => sub { $product_id },
email => sub { $useremail },
use strict;
use BSE::Util::Tags qw(tag_hash);
use BSE::Template;
+use DevHelp::HTML;
sub new {
my ($class, $req) = @_;
sub tags {
my ($self, $article) = @_;
-
+
+ $self->{req}->set_article(dynarticle => $article);
return
(
dynarticle => [ \&tag_hash, $article ],
- BSE::Util::Tags->basic({}, $self->{req}->cgi, $self->{req}->cfg),
+ $self->{req}->dyn_user_tags(),
);
}
package BSE::Dynamic::Seminar;
use strict;
-use base 'BSE::Dynamic::Product;
+use base 'BSE::Dynamic::Product';
use BSE::TB::Seminars;
sub get_real_article {
sub make_link {
my ($self, $article) = @_;
- my $urlbase = $self->{cfg}->entryVar('site', 'secureurl');
+# Modified by adrian
+ my $urlbase = '';
+ if ($self->{cfg}->entry('shop', 'secureurl_articles', 1)) {
+ $urlbase = $self->{cfg}->entryVar('site', 'secureurl');
+ }
+# end adrian
if ($article->is_dynamic) {
return "$urlbase/cgi-bin/page.pl?id=$article->{id}&title=".escape_uri($article->{title});
sub make_link {
my ($self, $article) = @_;
- my $urlbase = $self->{cfg}->entryVar('site', 'secureurl');
+# Modified by adrian
+ my $urlbase = '';
+ if ($self->{cfg}->entry('shop', 'secureurl_articles', 1)) {
+ $urlbase = $self->{cfg}->entryVar('site', 'secureurl');
+ }
+# end adrian
if ($article->is_dynamic) {
return "$urlbase/cgi-bin/page.pl?id=$article->{id}&title=".escape_uri($article->{title});
}
}
+sub dyn_user_tags {
+ my ($self) = @_;
+
+ require BSE::Util::DynamicTags;
+ return BSE::Util::DynamicTags->tags($self);
+}
+
sub DESTROY {
my ($self) = @_;
if ($self->{session}) {
}
}
+sub set_article {
+ my ($self, $name, $article) = @_;
+
+ if ($article) {
+ $self->{articles}{$name} = $article;
+ }
+ else {
+ delete $self->{articles}{$name};
+ }
+}
+
+sub get_article {
+ my ($self, $name) = @_;
+
+ exists $self->{articles}{$name}
+ or return;
+
+ my $article = $self->{articles}{$name};
+ if (ref $article eq 'SCALAR') {
+ $article = $$article;
+ }
+ $article
+ or return;
+
+ $article;
+}
+
1;
# returns a list of tags which display the cart details
sub shop_cart_tags {
- my ($acts, $cart, $cart_prods, $session, $q, $cfg, $stage) = @_;
+ my ($acts, $cart, $cart_prods, $req, $stage) = @_;
+ my $cfg = $req->cfg;
+ my $q = $req->cgi;
$cfg or confess "No config";
$cfg->isa("BSE::Cfg") or confess "Not a config";
my $item_index;
my $option_index;
my @options;
- my $user;
- if ($session->{userid}) {
- require 'SiteUsers.pm';
- $user = SiteUsers->getBy(userId=>$session->{userid});
- }
my $sem_session;
my $location;
my $item;
my $product;
return
(
- BSE::Util::Tags->basic($acts, $q, $cfg),
- ifUser => sub { $user },
- user => sub { CGI::escapeHTML($user ? $user->{$_[0]} : '') },
+ $req->dyn_user_tags(),
iterate_items_reset => sub { $item_index = -1 },
iterate_items =>
sub {
},
index => sub { $item_index },
total =>
- sub { total($cart, $cart_prods, $session->{custom}, $cfg, $stage) },
+ sub { total($cart, $cart_prods, $req->session->{custom}, $cfg, $stage) },
count => sub { scalar @$cart },
iterate_options_reset => sub { $option_index = -1 },
iterate_options => sub { ++$option_index < @options },
session => [ \&tag_session, \$item, \$sem_session ],
location => [ \&tag_location, \$item, \$location ],
custom_class($cfg)
- ->checkout_actions($acts, $cart, $cart_prods, $session->{custom}, $q, $cfg),
+ ->checkout_actions($acts, $cart, $cart_prods, $req->session->{custom}, $q, $cfg),
);
}
my %acts;
%acts =
(
- BSE::Util::Tags->basic(undef, $req->cgi, $req->cfg),
+ $req->dyn_user_tags(),
$class->_display_tags($user, $req->cfg),
);
crypt_passphrase => $Constants::SHOP_PASSPHRASE,
crypt_signing_id => $Constants::SHOP_SIGNING_ID,
crypt_content_type => 0,
+ autofill => 1,
);
sub _get_form {
maxdatemsg);
my @extra_cfg_names = grep /\S/ && !exists $std_cfg_names{$_},
split /,/, $extra_cfg_names;
+ my $user = $req->siteuser;
for my $name (keys %$fields) {
my $field = $fields->{$name};
$field->{name} = $name;
my $value = $cfg->entry($valid_section, "${name}_${cfg_name}");
defined $value and $field->{$cfg_name} = $value;
}
+
+ if ($form{autofill} && $user && exists $user->{$name}) {
+ $field->{default} = $user->{$name};
+ }
}
$form{validation} = $fields;
my $current_value;
%acts =
(
- BSE::Util::Tags->basic(\%acts, $req->cgi, $req->cfg),
+ $req->dyn_user_tags(),
error_img => [ \&tag_error_img, $req->cfg, $errors ],
$it->make_iterator(undef, 'field', 'fields', $form->{fields},
undef, undef, \$current_field),
}
}
+ $req->set_article(article=>$article);
my %acts;
%acts =
(
- BSE::Util::Tags->static(),
+ $req->dyn_user_tags(),
article => [ \&tag_hash, $article ],
image => [ \&tag_hash, $image ],
);
(
$cust_class->cart_actions(\%acts, \@cart, \@cart_prods, \%custom_state,
$req->cfg),
- shop_cart_tags(\%acts, \@items, \@cart_prods, $req->session, $req->cgi,
- $req->cfg, 'cart'),
+ shop_cart_tags(\%acts, \@items, \@cart_prods, $req, 'cart'),
basic_tags(\%acts),
msg => $msg,
);
my %acts;
%acts =
(
- shop_cart_tags(\%acts, \@items, \@cart_prods, $req->session, $req->cgi,
- $cfg, 'checkout'),
+ shop_cart_tags(\%acts, \@items, \@cart_prods, $req, 'checkout'),
basic_tags(\%acts),
message => $message,
msg => $message,
message => $msg,
msg => $msg,
order => [ \&tag_hash, $order_values ],
- shop_cart_tags(\%acts, \@items, \@products, $req->session, $req->cgi,
- $req->cfg, 'payment'),
+ shop_cart_tags(\%acts, \@items, \@products, $req, 'payment'),
ifMultPaymentTypes => @payment_types > 1,
checkedPayment => [ \&tag_checkedPayment, $payment, \%types_by_name ],
ifPayments => [ \&tag_ifPayments, \@payment_types, \%types_by_name ],
my @donttouch = qw(id userId password email confirmed confirmSecret waitingForConfirmation disabled flags affiliate_name previousLogon);
my %donttouch = map { $_, $_ } @donttouch;
-sub user_tags {
- my ($self, $acts, $session, $user) = @_;
-
- unless ($user) {
- my $userid = $session->{userid};
-
- if ($userid) {
- $user = SiteUsers->getBy(userId=>$userid);
- }
- }
-
- return
- (
- ifUser=>
- sub {
- if ($_[0]) {
- return $user->{$_[0]};
- }
- else {
- return $user;
- }
- },
- user => $user ? [ \&tag_hash, $user ] : '',
- );
-}
-
sub _refresh_userpage ($$) {
my ($cfg, $msg) = @_;
}
sub show_logon {
- my ($self, $session, $cgi, $cfg, $message) = @_;
+ my ($self, $req, $message) = @_;
+
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
my $nopassword = $cfg->entryBool('site users', 'nopassword', 0);
if ($nopassword) {
- return $self->nopassword($session, $cgi, $cfg);
+ return $self->nopassword($req);
}
$message ||= $cgi->param('message') || '';
my %acts;
%acts =
(
- BSE::Util::Tags->basic(\%acts, $cgi, $cfg),
- $self->user_tags(\%acts, $session),
+ $req->dyn_user_tags(),
message => sub { CGI::escapeHTML($message) },
);
}
sub logon {
- my ($self, $session, $cgi, $cfg) = @_;
+ my ($self, $req) = @_;
+
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
my $nopassword = $cfg->entryBool('site users', 'nopassword', 0);
if ($nopassword) {
- return $self->nopassword($session, $cgi, $cfg);
+ return $self->nopassword($req);
}
my $msgs = BSE::Message->new(cfg=>$cfg, section=>'user');
my $userid = $cgi->param('userid')
}
sub set_cookie {
- my ($self, $session, $cgi, $cfg) = @_;
+ my ($self, $req) = @_;
+
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
my $debug = $cfg->entryBool('debug', 'logon_cookies', 0);
my $msgs = BSE::Message->new(cfg=>$cfg, section=>'user');
}
sub logoff {
- my ($self, $session, $cgi, $cfg) = @_;
+ my ($self, $req) = @_;
+
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
my $nopassword = $cfg->entryBool('site users', 'nopassword', 0);
if ($nopassword) {
- return $self->nopassword($session, $cgi, $cfg);
+ return $self->nopassword($req);
}
my $msgs = BSE::Message->new(cfg=>$cfg, section=>'user');
}
sub show_register {
- my ($self, $session, $cgi, $cfg, $message, $errors) = @_;
+ my ($self, $req, $message, $errors) = @_;
+
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
my $user_register = $cfg->entryBool('site users', 'user_register', 1);
my $nopassword = $cfg->entryBool('site users', 'nopassword', 0);
my %acts;
%acts =
(
- BSE::Util::Tags->basic(\%acts, $cgi, $cfg),
- $self->user_tags(\%acts, $session),
+ $req->dyn_user_tags(),
old =>
sub {
my $value = $cgi->param($_[0]);
}
sub _get_user {
- my ($self, $session, $cgi, $cfg, $name) = @_;
+ my ($self, $req, $name) = @_;
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
my $nopassword = $cfg->entryBool('site users', 'nopassword', 0);
if ($nopassword) {
my $password;
return $custom->siteuser_auth($session, $cgi, $cfg);
}
else {
- my $userid = $session->{userid}
- or do { $self->show_logon($session, $cgi, $cfg); return };
- my $user = SiteUsers->getBy(userId=>$userid)
- or do { $self->show_logon($session, $cgi, $cfg); return };
+ my $user = $req->siteuser
+ or do { $self->show_logon($req); return };
$user->{disabled}
- and do { $self->show_logon($session, $cgi, $cfg, "Account disabled"); return };
+ and do { $self->show_logon($req, "Account disabled"); return };
return $user;
}
}
sub show_opts {
- my ($self, $session, $cgi, $cfg, $message, $errors) = @_;
+ my ($self, $req, $message, $errors) = @_;
- my $user = $self->_get_user($session, $cgi, $cfg, 'show_opts')
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
+
+ my $user = $self->_get_user($req, 'show_opts')
or return;
my @subs = grep $_->{visible}, BSE::SubscriptionTypes->all;
my @usersubs = BSE::SubscribedUsers->getBy(userId=>$user->{id});
my %acts;
%acts =
(
- BSE::Util::Tags->basic(\%acts, $cgi, $cfg),
- $self->user_tags(\%acts, $session, $user),
+ $req->dyn_user_tags(),
last =>
sub {
my $value = $cgi->param($_[0]);
}
sub saveopts {
- my ($self, $session, $cgi, $cfg) = @_;
+ my ($self, $req) = @_;
+
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
my $msgs = BSE::Message->new(cfg=>$cfg, section=>'user');
- my $user = $self->_get_user($session, $cgi, $cfg)
+ my $user = $self->_get_user($req)
or return;
my $nopassword = $cfg->entryBool('site users', 'nopassword', 0);
my %errors;
}
sub register {
- my ($self, $session, $cgi, $cfg) = @_;
+ my ($self, $req) = @_;
+
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
my $msgs = BSE::Message->new(cfg=>$cfg, section=>'user');
}
sub userpage {
- my ($self, $session, $cgi, $cfg, $message) = @_;
+ my ($self, $req, $message) = @_;
+
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
- my $user = $self->_get_user($session, $cgi, $cfg, 'userpage')
+ my $user = $self->_get_user($req, 'userpage')
or return;
require BSE::TB::Orders;
my @orders = sort { $b->{orderDate} cmp $a->{orderDate}
my $file_index;
%acts =
(
- BSE::Util::Tags->basic(\%acts, $cgi, $cfg),
- $self->user_tags(\%acts, $session, $user),
+ $req->dyn_user_tags(),
message => sub { CGI::escapeHTML($message) },
BSE::Util::Tags->make_iterator(\@orders, 'order', 'orders',
\$order_index),
}
sub req_orderdetail {
- my ($self, $session, $cgi, $cfg, $message) = @_;
+ my ($self, $req, $message) = @_;
+
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
- my $user = $self->_get_user($session, $cgi, $cfg, 'userpage')
+ my $user = $self->_get_user($req, 'userpage')
or return;
my $order_id = $cgi->param('id');
my $order;
my %acts;
%acts =
(
- BSE::Util::Tags->basic(\%acts, $cgi, $cfg),
+ $req->dyn_user_tags(),
order => [ \&tag_hash, $order ],
- $self->user_tags(\%acts, $session, $user),
message => sub { CGI::escapeHTML($message) },
$it->make_iterator
(undef, 'item', 'items', \@items, undef, undef, \$current_item),
}
sub download {
- my ($self, $session, $cgi, $cfg) = @_;
+ my ($self, $req) = @_;
+
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
my $msgs = BSE::Message->new(cfg=>$cfg, section=>'user');
- my $user = $self->_get_user($session, $cgi, $cfg, 'show_opts')
+ my $user = $self->_get_user($req, 'show_opts')
or return;
my $orderid = $cgi->param('order')
}
sub download_file {
- my ($self, $session, $cgi, $cfg) = @_;
+ my ($self, $req) = @_;
+
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
my $msgs = BSE::Message->new(cfg=>$cfg, section=>'user');
my $userid = $session->{userid};
}
sub show_lost_password {
- my ($self, $session, $cgi, $cfg, $message) = @_;
+ my ($self, $req, $message) = @_;
+
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
$message ||= $cgi->param('message') || '';
$message = escape_html($message);
my %acts;
%acts =
(
- BSE::Util::Tags->basic(\%acts, $cgi, $cfg),
+ $req->dyn_user_tags(),
message => $message,
- $self->user_tags(\%acts, $session, $user),
);
BSE::Template->show_page('user/lostpassword', $cfg, \%acts);
}
sub lost_password {
- my ($self, $session, $cgi, $cfg, $message) = @_;
+ my ($self, $req, $message) = @_;
+
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
my $msgs = BSE::Message->new(cfg=>$cfg, section=>'user');
my $userid = $cgi->param('userid');
}
sub subinfo {
- my ($self, $session, $cgi, $cfg) = @_;
+ my ($self, $req) = @_;
+
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
my $id = $cgi->param('id')
or return $self->show_opts($session, $cgi, $cfg, "No subscription id parameter");
}
sub nopassword {
- my ($self, $session, $cgi, $cfg) = @_;
+ my ($self, $req) = @_;
+
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
my %acts;
%acts =
}
sub blacklist {
- my ($self, $session, $cgi, $cfg) = @_;
+ my ($self, $req) = @_;
+
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
my $msgs = BSE::Message->new(cfg=>$cfg, section=>'user');
my $email = $cgi->param('blacklist')
}
sub confirm {
- my ($self, $session, $cgi, $cfg) = @_;
+ my ($self, $req) = @_;
+
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
my $msgs = BSE::Message->new(cfg=>$cfg, section=>'user');
my $secret = $cgi->param('confirm')
}
sub unsub {
- my ($self, $session, $cgi, $cfg) = @_;
+ my ($self, $req) = @_;
+
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
my $msgs = BSE::Message->new(cfg=>$cfg, section=>'user');
my $secret = $cgi->param('unsub')
}
sub req_image {
- my ($self, $session, $cgi, $cfg) = @_;
+ my ($self, $req) = @_;
+
+ my $cfg = $req->cfg;
+ my $cgi = $req->cgi;
+ my $session = $req->session;
my $u = $cgi->param('u');
my $i = $cgi->param('i');
--- /dev/null
+package BSE::Util::DynamicTags;
+use strict;
+use BSE::Util::Tags;
+use DevHelp::HTML;
+
+sub tags {
+ my ($class, $req) = @_;
+
+ return
+ (
+ BSE::Util::Tags->basic(undef, $req->cgi, $req->cfg),
+ user => [ \&tag_user, $req ],
+ ifUser => [ \&tag_ifUser, $req ],
+ ifUserCanSee => [ \&tag_ifUserCanSee, $req ],
+ );
+}
+
+sub tag_ifUser {
+ my ($req, $args) = @_;
+
+ my $user = $req->siteuser
+ or return '';
+ if ($args) {
+ return $user->{$args};
+ }
+ else {
+ return 1;
+ }
+}
+
+sub tag_user {
+ my ($req, $args) = @_;
+
+ my $siteuser = $req->siteuser
+ or return '';
+
+ exists $siteuser->{$args}
+ or return '';
+
+ escape_html($siteuser->{$args});
+}
+
+sub tag_ifUserCanSee {
+ my ($req, $args) = @_;
+
+ $args
+ or return 0;
+
+ my $article;
+ if ($args =~ /^\d+$/) {
+ $article = Articles->getByPkey($args);
+ }
+ else {
+ $article = $req->get_article($args);
+ }
+ $article
+ or return 0;
+
+ print STDERR "$args -> $article ($article->{id})\n";
+
+ $req->siteuser_has_access($article);
+}
+
+1;
my @images = Images->getBy('articleId', $article->{id});
my @unnamed_images = grep $_->{name} eq '', @images;
+ my @iter_images;
my $image_index = -1;
my $had_image_tags = 0;
my @files = sort { $b->{displayOrder} <=> $a->{displayOrder} }
},
# access to images, if any
- iterate_images_reset => sub { $image_index = -1 },
- iterate_images => sub { $had_image_tags = 1; ++$image_index < @unnamed_images },
+ iterate_images_reset =>
+ sub {
+ my ($arg) = @_;
+ $image_index = -1;
+ if ($arg eq 'all') {
+ @iter_images = @images;
+ }
+ elsif ($arg eq 'named') {
+ @iter_images = grep $_->{name} ne '', @images;
+ }
+ elsif ($arg =~ m!^named\s+/([^/]+)/$!) {
+ my $re = $1;
+ @iter_images = grep $_->{name} =~ /$re/i, @images;
+ }
+ else {
+ @iter_images = @unnamed_images;
+ }
+ },
+ iterate_images =>
+ sub { $had_image_tags = 1; ++$image_index < @iter_images },
image =>
sub {
my ($which, $align, $rest) = split ' ', $_[0], 3;
$im = $images[$which-1];
}
else {
- $im = $unnamed_images[$image_index];
+ $im = $iter_images[$image_index];
}
return $self->_format_image($im, $align, $rest);
$self->_format_image($im, $align, $rest);
},
ifImage => sub { $_[0] >= 1 && $_[0] <= @images },
- ifImages => sub { @images },
+ ifImages =>
+ sub {
+ my ($arg) = @_;
+ if ($arg eq 'all' or $arg eq '') {
+ return @images;
+ }
+ elsif ($arg eq 'named') {
+ return grep $_->{name} ne '', @images;
+ }
+ elsif ($arg =~ m!^named\s+/([^/]+)/$!) {
+ my $re = $1;
+ return grep $_->{name} =~ /$re/i, @images;
+ }
+ elsif ($arg eq 'unnamed') {
+ return @unnamed_images;
+ }
+ else {
+ return 0;
+ }
+ },
image_index => sub { $image_index },
BSE::Util::Tags->make_iterator(\@files, 'file', 'files'),
BSE::Util::Tags->make_iterator(\@stepkids, 'stepkid', 'stepkids'),
BSE::Util::Tags->make_iterator(\@allkids, 'allkid', 'allkids', \$allkids_index),
BSE::Util::Tags->make_iterator(\@stepparents, 'stepparent', 'stepparents'),
top => [ \&tag_top, $self, $article ],
- ifDynamic =>
- scalar(UNIVERSAL::isa($top, 'Article') ? $top->is_dynamic : 0),
+ ifDynamic => [ \&tag_ifDynamic, $self, $top ],
);
if ($abs_urls) {
return %acts;
}
+sub tag_ifDynamic {
+ my ($self, $top) = @_;
+
+ # this is to support pregenerated pages being handled as dynamic pages
+ $self->{force_dynamic} and return 1;
+
+ UNIVERSAL::isa($top, 'Article') ? $top->is_dynamic : 0;
+}
+
sub generate {
my ($self, $article, $articles) = @_;
=item iterator ... images
-Iterates over the images for the given article.
+Iterates over the unnamed images for the given article.
+
+=item iterator ... images all
+
+Iterates over all images for the article.
+
+=item iterator ... images named
+
+Iterates over the named images for the article.
+
+=item iterator ... images named /regexp/
+
+Iterates over images with names matching the given regular expression.
+Note that if the expression matches an empty string then unnamed
+images will be included.
=item image which field
=item ifImages
+=item ifImages all
+
Conditional tag, true if the article has any images.
+=item ifImages named
+
+Conditional tag, true if the article has any named images.
+
+=item ifImages named /regexp/
+
+Conditional tag, true if the article has any named images, where the
+name matches the regular expression.
+
+=item ifImages unnamed
+
+Conditional tag, true if the article has any unnamed images.
+
=item embed child
This has been made more general and been moved, see L<Generate/embed child>.
+=item ifDynamic
+
+Tests if the article is dynamically generated.
+
+=item top I<field>
+
+Toplevel article being generated. This is the page that any articles
+are being embedded in.
+
+=item iterator ... files
+
+Iterates over the files attached to the article, setting the file tag.
+
+=item file I<field>
+
+Information from the current file in the files iterator.
+
=back
=head2 Article attributes
(-1, -1, $SEARCH_TITLE, $SEARCH_TITLE_IMAGE, 0, $CGI_URI."/search.pl", 0, 1);
require 'Generate/Article.pm';
- my $gen = Generate::Article->new(cfg=>$cfg, top => \%article);
+ my $gen = Generate::Article->new(cfg=>$cfg, top => \%article,
+ force_dynamic => 1);
my %acts;
%acts = $gen->baseActs($articles, \%acts, \%article);
require 'Generate/Article.pm';
my $shop = $articles->getByPkey($SHOPID);
my $cfg = BSE::Cfg->new;
- my $gen = Generate::Article->new(cfg=>$cfg, top=>$shop);
+ my $gen = Generate::Article->new(cfg=>$cfg, top=>$shop, force_dynamic => 1);
for my $name (@pages) {
my %acts;
%acts = $gen->baseActs($articles, \%acts, $shop);
$article{$field} = $cfg->entryVar("$presets settings", $field);
}
}
+ # by default all of these are handled as dynamic, but it can be
+ # overidden, eg. the error template
+ my $dynamic = $cfg->entry("$presets settings", 'dynamic', 1);
my %acts;
- my $gen = Generate::Article->new(cfg=>$cfg, top=>\%article);
+ my $gen = Generate::Article->new(cfg=>$cfg, top=>\%article,
+ force_dynamic => $dynamic);
%acts = $gen->baseActs($articles, \%acts, \%article);
my $oldurl = $acts{url};
$acts{url} =
# -d:ptkdb
BEGIN { $ENV{DISPLAY} = '192.168.32.15:0.0' }
use strict;
-use CGI;
use FindBin;
use lib "$FindBin::Bin/modules";
use Articles;
use BSE::Template;
use DevHelp::HTML qw':default popup_menu';
use BSE::Util::Tags;
+use BSE::Request;
-my $cfg = BSE::Cfg->new;
+my $req = BSE::Request->new;
+my $cfg = $req->cfg;
my $results_per_page = 10;
my $dh = BSE::DB->single;
-my $cgi = CGI->new;
+my $cgi = $req->cgi;
my $words = $cgi->param('q');
my $section = $cgi->param('s');
my $date = $cgi->param('d');
my %acts;
%acts =
(
- BSE::Util::Tags->basic(\%acts, $cgi, $cfg),
+ $req->dyn_user_tags(),
iterate_results =>
sub {
++$result_seq;
# match against the pageTitle
$pageTitle = $articles[$article_index]{pageTitle};
$pageTitle =~ s!$words_re!<b>$1</b>!g or $pageTitle = '';
+ $req->set_article(result => $articles[$article_index]);
return 1;
}
else {
+ $req->set_article(result => undef);
+
return 0;
}
},
use FindBin;
use lib "$FindBin::Bin/modules";
use Constants;
-use BSE::Cfg;
use BSE::Session;
use BSE::UserReg;
-use CGI;
+use BSE::Request;
-my $cfg = BSE::Cfg->new;
-
-my %session;
-BSE::Session->tie_it(\%session, $cfg);
-
-# print STDERR "it's tied\n" if tied %session;
-# use Data::Dumper;
-# print STDERR Dumper \%session;
+my $req = BSE::Request->new;
my %actions =
(
a_orderdetail => 'req_orderdetail',
);
-my $cgi = CGI->new;
+my $cgi = $req->cgi;
my ($action) = grep $cgi->param($_) || $cgi->param("$_.x"), keys %actions;
-$action ||= 'show_logon';
+$action ||= 'userpage';
my $method = $actions{$action};
-BSE::UserReg->$method(\%session, $cgi, $cfg);
+BSE::UserReg->$method($req);
-untie %session;
=head1 CHANGES
+=head2 0.15_23
+
+=over
+
+=item *
+
+added [shop].secureurl_articles option. Patch by Adrian Oldham
+(http://www.visualthought.com.au/)
+
+=item *
+
+pregenerated templates used by various scripts are now generated as if
+they were dynamic articles, and the various scripts now make the
+dynamic article tags available. This is a complex change, so it may
+have introduced some problems.
+
+=item *
+
+the sidebar logon panel has been updated to generate serverside when
+the containing page is dynamic.
+
+=item *
+
+the t21gencat.t test script wasn't cleaning up properly after itself,
+leaving the database in an inconsistent state.
+
+=item *
+
+fmail.pl forms are now filled from the currently logged on siteuser by
+default. The field names must correspond to the siteuser field named
+for this to happen. Note: custom defquery_base variants will need to
+be updated to support this.
+
+=item *
+
+user.pl now attempts to display the userpage by default, instead of
+the logon form.
+
+=item *
+
+the images iterator (on articles) now accepts various options to
+filter the images iterated over. See templates.pod for details.
+
+=item *
+
+the ifImages conditions (on articles) now accepts various options to
+filter the images tested for. See templates.pod for details.
+
+=back
+
=head2 0.15_22
=over
Used by some templates to check if the shop is enabled. Set this to 1
to enable the shop, or 0 to disable it.
+=item secureurl_articles
+
+If this is false then shop articles will not use the secureurl as their
+baseurl. Default: True
+
=item register_if_files
If true the customer is required to register before checkout if there
=item *
+autofill - if this is non-zero then form values which match the names
+of siteuser fields are defaulted on the form with the values from the
+currently logged in user. Default: Enabled. To disable add:
+
+ autofill=0
+
+to the configuration area for your form.
+
+=item *
+
encrypt - if this is non-zero then the emailed form data is encrypted
using PGP or GPG as configured (see the crypt options below).
=item iterator ... images
-Iterates over the images for the given article.
+Iterates over the unnamed images for the given article.
+
+=item iterator ... images all
+
+Iterates over all images for the article.
+
+=item iterator ... images named
+
+Iterates over the named images for the article.
+
+=item iterator ... images named /regexp/
+
+Iterates over images with names matching the given regular expression.
+Note that if the expression matches an empty string then unnamed
+images will be included.
=item image which field
=item ifImages
+=item ifImages all
+
Conditional tag, true if the article has any images.
+=item ifImages named
+
+Conditional tag, true if the article has any named images.
+
+=item ifImages named /regexp/
+
+Conditional tag, true if the article has any named images, where the
+name matches the regular expression.
+
+=item ifImages unnamed
+
+Conditional tag, true if the article has any unnamed images.
+
+=item ifDynamic
+
+Tests if the article is dynamically generated.
+
+=item top I<field>
+
+Toplevel article being generated. This is the page that any articles
+are being embedded in.
+
+=item iterator ... files
+
+Iterates over the files attached to the article, setting the file tag.
+
+=item file I<field>
+
+Information from the current file in the files iterator.
+
=back
The following tags produce output only in admin mode.
<td>
<:switch:>
<:case Eq [field htmltype] "textarea":>
- <textarea name="<:field name:>" <:ifField width:>cols="<:field width:>"<:or:><:eif:> <:ifField height:>rows="<:field height:>"<:or:><:eif:> wrap="virtual"><:old [field name]:></textarea>
+ <textarea name="<:field name:>" <:ifField width:>cols="<:field width:>"<:or:><:eif:> <:ifField height:>rows="<:field height:>"<:or:><:eif:> wrap="virtual"><:old [field name] field default:></textarea>
<:case Eq [field htmltype] "password":>
<input type="password" name="<:field name:>" value="<:old [field name]:>" <:ifField width:>size="<:field width:>"<:or:><:eif:> />
<:case Eq [field htmltype] "select":>
<br />
<:iterator end values:>
<:case default:>
- <input type="text" name="<:field name:>" value="<:old [field name]:>" <:ifField width:>size="<:field width:>" <:or:><:eif:><:ifField maxlength:>maxlength="<:field maxlength:>"<:or:><:eif:> />
+ <input type="text" name="<:field name:>" value="<:old [field name] field default:>" <:ifField width:>size="<:field width:>" <:or:><:eif:><:ifField maxlength:>maxlength="<:field maxlength:>"<:or:><:eif:> />
<:endswitch:>
<:ifField notes:><:field notes:><:or:><:eif:>
</td>
<: iterator begin results:>
<dl>
<dt> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <b> <:resultSeq:>.
- </b></font> <a href="<:articleurl:>"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b><:result
- title:></b></font></a>
+ </b></font> <:ifUserCanSee result:><a href="<:articleurl:>"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b><:result
+ title:></b></font></a> <:or:><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b><:result
+ title:></b></font><:eif:>
<dd> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <:excerpt:></font>
<br>
<font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#808080">
-<:wrap base.tmpl:> <:embed start:><:if Cfg "site users" nopassword:>
-<!-- This form is not used when you have the nopassword option enabled -->
-<p><font face="Verdana, Arial, Helvetica, sans-serif" size="-2">Please use the URL from your confirmation email to access your
-details and subscription information.</font></p>
-<div align="center"><form action="/cgi-bin/user.pl" method="post"><input type="submit" name="show_register" value="Register" class="user-buttons" /></form></div>
-<:or Cfg:><:ifAdmin:>
+<:wrap base.tmpl:> <:embed start:><:ifAdmin:>
<table cellpadding="4" cellspacing="0" border="0">
<tr>
<td>
</td>
</tr>
</table>
-<:or:><:eif:>
+<:or:><:eif:><:if Cfg "site users" nopassword:>
+<!-- This form is not used when you have the nopassword option enabled -->
+<p><font face="Verdana, Arial, Helvetica, sans-serif" size="-2">Please use the URL from your confirmation email to access your
+details and subscription information.</font></p>
+<div align="center"><form action="/cgi-bin/user.pl" method="post"><input type="submit" name="show_register" value="Register" class="user-buttons" /></form></div>
+<:or Cfg:><:if Dynamic:>
+<:if User:>
+<form action="/cgi-bin/user.pl" method="post">
+<table><tr><td align="left"><input type="submit" name="userpage" value="User profile" class="user-buttons" /></td><td align="right"><input type="submit" name="logoff" value="Logoff" class="user-buttons" /></td></tr></table></form>
+<:or User:>
+<form action="/cgi-bin/user.pl" method="post">
+<table><tr><th><font face="Verdana, Arial, Helvetica, sans-serif" size="-2">Username:</font></th><td><input type="text" name="userid" size="10" /></td></tr>
+<tr><th><font face="Verdana, Arial, Helvetica, sans-serif" size="-2">Password:</font></th><td><input type="password" name="password" size="10" /></td></tr>
+<tr><td align="left"><input type="submit" name="logon" value="Logon" class="user-buttons" /></td><td align="right"><input type="submit" name="show_register" value="Register" class="user-buttons" /></td></tr></table></form>
+<:eif User:>
+<:or Dynamic:>
<div align="center">
<script language="JavaScript">
<!--
//-->
</script>
</div>
-<:eif Cfg:><:embed end:>
+<:eif Dynamic:><:eif Cfg:><:embed end:>
BSE::Admin::StepParents->del($parent, $parent);
for my $kid (reverse @kids) {
my $name = $kid->{title};
+ my $kidid = $kid->{id};
$kid->remove();
- ok(1, "removing kid $name");
+ ok(1, "removing kid $name ($kidid)");
}
$parent->remove();
ok(1, "removed parent");
#!perl -w
use strict;
use BSE::Test ();
-use Test::More tests=>69;
+use Test::More tests=>74;
use File::Spec;
use FindBin;
my $cgidir = File::Spec->catdir(BSE::Test::base_dir, 'cgi-bin');
BSE::Admin::StepParents->del($parent, $stepkid);
BSE::Admin::StepParents->del($parent, $stepprod);
-for my $kid (reverse @kids) {
+for my $kid (reverse @prods, $stepprod) {
+ my $name = $kid->{title};
+ $kid->remove();
+ ok(1, "removing product $name");
+}
+for my $kid (reverse @kids, $stepkid) {
my $name = $kid->{title};
$kid->remove();
ok(1, "removing kid $name");
default formmail validation.subject_width=40
-test form.fields=name,company,select,radio,check,multiselect
+test form.fields=email,name,company,select,radio,check,multiselect
test form.subject=Foo
test form.encrypt=1
test form.crypt_signing_id=
test form.email=tony@develop-help.com
test form.field_config=notes,required_if
test form.submit=Send the message
+test form.autofill=0
test form.require_logon=1
test form.logon_message=Yo Dude! Logon to submit this form!
test formmail validation.name_description=Your Name