% $m->comp('SELF:form_helpers') %>
<%perl>
if ($m->session->{loggedin}) {
$m->redirect("/account/");
}
my $email = $ARGS{l_email}||$m->session->{'l_email'};
my $user = $ARGS{l_user}||$m->session->{l_user};
my $first = $ARGS{l_first}||$m->session->{l_first};
my $last = $ARGS{l_last}||$m->session->{l_last};
if ($ARGS{submit}) {
$m->comp('SELF:process_submit', %ARGS);
}
%perl>
%# {{{
<%method process_submit>
<%perl>
my $created = 0;
my %errors = ();
my $message = '';
my @reqFields = qw( l_user l_first l_last l_pass l_pass_repeat l_email country );
my $l6contact = ($ARGS{'list_id'} eq "on")?"yes":"no";
if ( $m->comp("/func/setting", name => "humancheck_honeypot_newaccount_active" ) ) {
# This field better be empty...
if ( $ARGS{hcdata} ) {
$errors{'captcha'} .= "Sorry, You're not a human.
";
}
}
if ( $m->comp("/func/setting", name => "humancheck_iptime_newaccount_active" ) ) {
# this form has been loaded for more than an hour, they're not human:
if ( time - $m->session->{human_time} > 60*60 ) {
$errors{'captcha'} .= "Sorry, we don't think you're a human.
";
}
# form submitted from a different IP than it was served to.
if ( $m->session->{human_ip} ne $ENV{REMOTE_ADDR} ) {
$errors{'captcha'} .= "Sorry, you are trying something bad.
";
}
}
#passwords match?
if ($ARGS{'l_pass'} ne $ARGS{'l_pass_repeat'}) {
$errors{'l_pass'} = "Your passwords don't match.";
}
#shout "ERRORS: ",\%errors
# if scalar(%errors);
# Add User if no errors
if ( not scalar keys %errors ) {
my $sourceRef = 'WEB_SIMPLE';
my $country = $ARGS{country};
if ($country eq '') {
$country = uc($REQ->geo_country);
$country = $dbi->get('code from countries where code = ?', $country);
}
$country ||= 'US';
my $user = new L6::User dbi => $dbi;
$user->create(
user => $ARGS{'l_user'},
first => $ARGS{'l_first'},
last => $ARGS{'l_last'},
country => $country,
password => $ARGS{'l_pass'},
session_id => $m->session->{'_session_id'},
email => $ARGS{'l_email'},
l6Contact => $l6contact,
optout_email => $ARGS{list_id}?0:1
);
unless ( $user->error ) {
$created = 1;
my $langs_id = $dbi->get('langs_id
from sites_languages sl
left join languages l
on l.id = sl.languages_id
where sl.sites_id = ?
order by sl.priority
asc limit 1', $m->session->{sites_id});
$user->set(langs_id => $langs_id);
$user->lists_replace( qw(1 33 34 35 36 ) ) if $ARGS{list_id};
# send notify email
my $mailer = new L6::User::Message user => $user;
my $message_ref = 'new_l6_account';
$mailer->create(messages_ref => $message_ref, brand => 'line6');
$mailer->send ( fill_vars => {
updateaccounturl => $CONF{'L6C_URL'} . "/account/index.html",
forgoturl => $CONF{'L6C_URL'} . "/account/forgot.html?user=$ARGS{'user'}"});
$message = sprintf("%s
", $m->interp->apply_escapes('account_created','x'));;
if ($mailer->error) {
$message .= 'However we did experience a problem sending your confirmation email. If you would like
to request an email with your account information be sent you can do so
from our account recovery page.';
}
}
else {
$message = "There was some problem, please contact customer support.
".
$user->error_full . "
";
}
}
# Log in the new account
############################
if ($created ) {
$ARGS{'action'} = 'login';
$ARGS{'done'} = $m->session->{'loginReturnPage'}||"/account/";
$m->comp("/func/login_handle.cp", %ARGS);
$m->redirect("/account/");
}
elsif (keys %errors || $message ne '') { #errors processing request
$m->comp('/common/alert.cp', errors => \%errors, message => $message);
}
%perl>
%method>
%# }}}
%# {{{ method form_helpers
<%method form_helpers>
%method>
%# }}}
<%once>
use Digest::MD5 qw(md5_hex);
%once>