Tadashi Okoshi
slash****@users*****
2005年 11月 22日 (火) 21:10:45 JST
Index: affelio_farm/lib/AffelioFarm/App/Stage1.pm
diff -u affelio_farm/lib/AffelioFarm/App/Stage1.pm:1.1.1.1 affelio_farm/lib/AffelioFarm/App/Stage1.pm:1.2
--- affelio_farm/lib/AffelioFarm/App/Stage1.pm:1.1.1.1 Tue Oct 25 04:14:39 2005
+++ affelio_farm/lib/AffelioFarm/App/Stage1.pm Tue Nov 22 21:10:45 2005
@@ -4,6 +4,7 @@
use lib("../../../admin/skelton/affelio/extlib/");
use lib("../../../admin/skelton/affelio/lib/");
+ use Affelio::NetLib::Email;
use lib("../../../lib/");
use Affelio::misc::Debug;
@@ -22,26 +23,29 @@
my $cgi = shift;
my $farm = shift;
my $output_ref = shift;
+ my $kiosk_flag = shift;
my $wi = new Affelio::misc::WebInput();
my $mode2 = $wi->PTN_mode($cgi->url_param("mode2"));
if($mode2 eq "submit"){
- my $ret=submit($cgi, $farm, $output_ref);
+ my $ret=submit($cgi, $farm, $output_ref, $kiosk_flag);
if($ret < 0){
$output_ref->{system_message} = '<AF_M text="Invalid input!">';
$output_ref->{tmpl_file} = "/public/stage1.tmpl";
- return(show($cgi, $farm, $output_ref));
+ return(show($cgi, $farm, $output_ref, $kiosk_flag));
}else{
- $output_ref->{tmpl_file} = "/public/stage1_done.tmpl";
- return();
+ if($kiosk_flag){
+ return();
+ }else{
+ $output_ref->{tmpl_file} = "/public/stage1_done.tmpl";
+ return();
+ }
}
}else{
-
$output_ref->{tmpl_file} = "/public/stage1.tmpl";
- return(show($cgi, $farm, $output_ref));
-
+ return(show($cgi, $farm, $output_ref, $kiosk_flag));
}
@@ -54,6 +58,7 @@
my $cgi = shift;
my $farm = shift;
my $output_ref = shift;
+ my $kiosk_flag = shift;
my $wi = new Affelio::misc::WebInput;
####################################################
@@ -96,21 +101,28 @@
throw Affelio::exception::DBException($dbh->errstr);
}
- ####################################################
- #Send email
- open(MAIL, " | $farm->{config}->{system}->{sendmail_path} -t -f'Affelio Farm <$farm->{config}->{system}->{email_sender_to_user}>'");
- print MAIL "To: $email1\n";
- print MAIL "Subject: Confirmation from Affelio Farm\n\n";
-
- my $stage2url = "$farm->{config}->{site}->{script_web_root}/index.cgi?mode1=stage2&h=$hash&id=$email1";
- my $body = "Welcome to our Affelio Farm!\n";
- $body .= "Please click the following URL to continue registration!\n";
- $body .= "\n";
- $body .= $stage2url;
-
- print MAIL "$body\n";
- print MAIL "\n";
- close(MAIL);
+ if($kiosk_flag ==1){
+ ####################################################
+ #Kiosk mode
+ #no mail
+
+ $output_ref->{forwardto_URL} = "$farm->{config}->{site}->{script_web_root}/kiosk/index.cgi?mode1=stage2&h=$hash&id=$email1";
+
+ }else{
+ ####################################################
+ #Send email
+ my $to = $email1;
+ my $subject = "Welcome to Affelio Farm!";
+ my $stage2url = "$farm->{config}->{site}->{script_web_root}/index.cgi?mode1=stage2&h=$hash&id=$email1";
+
+ my $TMPL_FILE = "$farm->{config}->{site}->{script_fs_root}/admin/config/email_regist_tmp-" . $farm->{config}->{site}->{locale} . ".tmpl";
+ my $tmpl = new HTML::Template( filename => $TMPL_FILE,
+ die_on_bad_params => 0);
+ $tmpl->param(email => $email1);
+ $tmpl->param(stage2url => $stage2url);
+
+ Affelio::NetLib::Email::send_email($farm->{config}->{system}->{sendmail_path}, "$farm->{config}->{system}->{email_sender_to_user}", "Affelio Farm", $to, $subject, $farm->translate_templateL10N($tmpl->output));
+ };
return(1);
}
@@ -123,8 +135,15 @@
my $cgi = shift;
my $farm = shift;
my $output_ref = shift;
+ my $kiosk_flag = shift;
+
my $today = get_today();
+ if($kiosk_flag){
+ $output_ref->{available} = "true";
+ return();
+ }
+
if($farm->{config}->{farming}->{register_without_invitation} eq "no"){
$output_ref->{not_available} = "true";
debug_print("Public:Stage1:Show: public regist is NA");
Index: affelio_farm/lib/AffelioFarm/App/Stage5.pm
diff -u affelio_farm/lib/AffelioFarm/App/Stage5.pm:1.1.1.1 affelio_farm/lib/AffelioFarm/App/Stage5.pm:1.2
--- affelio_farm/lib/AffelioFarm/App/Stage5.pm:1.1.1.1 Tue Oct 25 04:14:39 2005
+++ affelio_farm/lib/AffelioFarm/App/Stage5.pm Tue Nov 22 21:10:45 2005
@@ -2,17 +2,19 @@
{
use strict;
use lib("../../../admin/skelton/affelio/extlib/");
+ use Error qw(:try);
use lib("../../../lib/");
use AffelioFarm::App::Routines qw(check_session);
use AffelioFarm::App::Admin::AccountManagement qw(create_account);
use lib("../../../admin/skelton/affelio/lib/");
+ use Affelio::NetLib::Email;
use Affelio::misc::Debug;
use Affelio::misc::Time;
use Affelio::misc::WebInput;
use Affelio::exception::InvalidInputException;
-
+ use Affelio::exception::Exception;
use Exporter;
@AffelioFarm::App::Stage5::ISA = "Exporter";
@@ -75,6 +77,10 @@
debug_print("Public:Stage5:submit [$in_account] [$in_password1] [$in_password2] [$in_email]");
+ ###########################
+ #Check input data
+ ###########################
+
#######
#Accout name check
if($cgi->param("account_name") eq ""){
@@ -83,7 +89,11 @@
}elsif ($in_account ne $cgi->param("account_name")){
$output_ref->{system_message} .= '<AF_M text="Invalid account name!"><BR>';
return(-1);
+ }elsif( (length($in_account) <3) || (length($in_account) > 10)){
+ $output_ref->{system_message} .= '<AF_M text="Invalid account name!"><BR>';
+ return(-1);
}
+
$output_ref->{account_name} = $cgi->param("account_name");
#######
@@ -139,22 +149,76 @@
return(-1);
}
- ################
+ ###########################
#create account
- ################
+ ###########################
my $ret ="";
try{
+ debug_print("Public:Stage5:submit create_account: ....");
$ret = create_account($farm, $in_account,
$in_password1, $in_email);
-
- $output_ref->{user_affelio_url} = $farm->{config}->{site}->{farm_web_root} . $in_account;
- return(1);
+ debug_print("Public:Stage5:submit create_account: done");
+ $output_ref->{user_affelio_url}
+ = $farm->{config}->{site}->{farm_web_root} . $in_account;
}catch Error with{
my $e= shift;
$output_ref->{system_message} = "Account creation failed: " . $e;
return(-1);
};
+
+ ###########################
+ #register to USER db
+ ###########################
+ try{
+ register_userdb($farm, $in_email, $in_account);
+ }catch Error with{
+ my $e= shift;
+ $output_ref->{system_message} = "USER db update failed: " . $e;
+ return(-1);
+ };
+
+ ###########################
+ #send email to user
+ ###########################
+ debug_print("Public:Stage5:submit Sending email....");
+ my $subject = "Your Affelio is created!";
+ my $TMPL_FILE = "$farm->{config}->{site}->{script_fs_root}/admin/config/email_regist_done-" . $farm->{config}->{site}->{locale} . ".tmpl";
+ my $tmpl = new HTML::Template( filename => $TMPL_FILE,
+ die_on_bad_params => 0);
+ $tmpl->param(username => $in_account);
+ $tmpl->param(password => $in_password1);
+ $tmpl->param(email => $in_email);
+ $tmpl->param(URL => $farm->{config}->{site}->{farm_web_root} . $in_account);
+ try{
+ Affelio::NetLib::Email::send_email($farm->{config}->{system}->{sendmail_path}, "$farm->{config}->{system}->{email_sender_to_user}", "Affelio Farm", $in_email, $subject, $farm->translate_templateL10N($tmpl->output));
+ }catch Error with{
+ my $e= shift;
+ $output_ref->{system_message} = "Account has been created. But notification email failed" . $e;
+ return(-1);
+ };
+ debug_print("Public:Stage5:submit Sending email....done");
+
+ ###########################
+ #send email to admin
+ ###########################
+ if($farm->{config}->{system}->{email_at_account_creation} eq "yes"){
+ my $subject = "New user to AffelioFarm: $in_account";
+ my $body = "New user : $in_account\n";
+ $body .= "Email : $in_email\n";
+ $body .= "in : $farm->{config}->{farming}->{farm_name}\n";
+
+ try{
+ Affelio::NetLib::Email::send_email($farm->{config}->{system}->{sendmail_path}, "$farm->{config}->{system}->{email_sender_to_admin}", "Affelio Farm", $farm->{config}->{system}->{admin_email}, $subject, $body);
+ }catch Error with{
+ my $e= shift;
+ $output_ref->{system_message} = "Account has been created. But notification email failed" . $e;
+ return(-1);
+ };
+ }
+
+
+ return(1);
}
@@ -175,6 +239,7 @@
return(1);
}
+
#######################################################################
#show_done
#######################################################################
@@ -185,6 +250,10 @@
return(1);
}
+
+ #######################################################################
+ #remove_session
+ #######################################################################
sub remove_session{
my $farm = shift;
my $hash = shift;
@@ -201,5 +270,31 @@
}
}
+
+ #######################################################################
+ #register_userdb
+ #######################################################################
+ sub register_userdb{
+ my $farm = shift;
+ my $email = shift;
+ my $account_name = shift;
+
+ my $ipaddr = $ENV{'REMOTE_ADDR'};
+ my $datetime = Affelio::misc::Time::get_timestamp();
+ my $dbh = $farm->open_db();
+ my $query = 'INSERT INTO users(datetime, email, ipaddr, account_name) values (?,?,?,?)';
+
+ my $sth;
+ eval{
+ $sth = $dbh->prepare($query);
+ $sth->execute($datetime, $email, $ipaddr, $account_name);
+ };
+ if($@){
+ throw Affelio::exception::DBException($dbh->errstr);
+ }
+ }
+
+
+
}
1;