1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of EC-CUBE |
4
|
|
|
* |
5
|
|
|
* Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. |
6
|
|
|
* |
7
|
|
|
* http://www.lockon.co.jp/ |
8
|
|
|
* |
9
|
|
|
* This program is free software; you can redistribute it and/or |
10
|
|
|
* modify it under the terms of the GNU General Public License |
11
|
|
|
* as published by the Free Software Foundation; either version 2 |
12
|
|
|
* of the License, or (at your option) any later version. |
13
|
|
|
* |
14
|
|
|
* This program is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU General Public License for more details. |
18
|
|
|
* |
19
|
|
|
* You should have received a copy of the GNU General Public License |
20
|
|
|
* along with this program; if not, write to the Free Software |
21
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
namespace Eccube\Controller; |
26
|
|
|
|
27
|
|
|
use Eccube\Application; |
28
|
|
|
use Eccube\Common\Constant; |
29
|
|
|
use Eccube\Entity\Master\CustomerStatus; |
30
|
|
|
use Symfony\Component\HttpFoundation\Request; |
31
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
32
|
|
|
use Symfony\Component\HttpKernel\Exception as HttpException; |
33
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; |
34
|
|
|
|
35
|
|
|
class EntryController extends AbstractController |
|
|
|
|
36
|
|
|
{ |
37
|
|
|
|
38
|
|
|
/** |
|
|
|
|
39
|
|
|
* Index |
40
|
|
|
* |
41
|
|
|
* @param Application $app |
42
|
|
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse |
43
|
|
|
*/ |
44
|
5 |
|
public function index(Application $app, Request $request) |
45
|
|
|
{ |
46
|
|
|
/** @var $Customer \Eccube\Entity\Customer */ |
47
|
|
|
$Customer = $app['eccube.repository.customer']->newCustomer(); |
48
|
|
|
|
49
|
|
|
/* @var $builder \Symfony\Component\Form\FormBuilderInterface */ |
50
|
|
|
$builder = $app['form.factory']->createBuilder('entry', $Customer); |
51
|
|
|
|
52
|
|
|
/* @var $form \Symfony\Component\Form\FormInterface */ |
53
|
|
|
$form = $builder->getForm(); |
54
|
|
|
if ('POST' === $request->getMethod()) { |
55
|
|
|
$form->handleRequest($request); |
56
|
|
|
|
57
|
|
|
if ($form->isValid()) { |
58
|
3 |
|
switch ($request->get('mode')) { |
59
|
3 |
View Code Duplication |
case 'confirm': |
|
|
|
|
60
|
|
|
$builder->setAttribute('freeze', true); |
61
|
|
|
$form = $builder->getForm(); |
62
|
|
|
$form->handleRequest($request); |
63
|
|
|
|
64
|
1 |
|
return $app['twig']->render('Entry/confirm.twig', array( |
65
|
1 |
|
'form' => $form->createView(), |
66
|
|
|
)); |
67
|
|
|
break; |
|
|
|
|
68
|
|
|
|
69
|
2 |
|
case 'complete': |
70
|
|
|
$Customer->setSalt( |
71
|
|
|
$app['eccube.repository.customer'] |
72
|
|
|
->createSalt(5) |
73
|
|
|
); |
74
|
|
|
|
75
|
|
|
$Customer->setPassword( |
76
|
|
|
$app['eccube.repository.customer']->encryptPassword($app, $Customer) |
77
|
|
|
); |
78
|
|
|
|
79
|
|
|
$Customer->setSecretKey( |
80
|
|
|
$app['eccube.repository.customer']->getUniqueSecretKey($app) |
81
|
|
|
); |
82
|
|
|
|
83
|
|
|
$CustomerAddress = new \Eccube\Entity\CustomerAddress(); |
84
|
|
|
$CustomerAddress->setName01($Customer->getName01()) |
85
|
|
|
->setName02($Customer->getName02()) |
86
|
|
|
->setKana01($Customer->getKana01()) |
87
|
|
|
->setKana02($Customer->getKana02()) |
88
|
|
|
->setCompanyName($Customer->getCompanyName()) |
89
|
|
|
->setZip01($Customer->getZip01()) |
90
|
|
|
->setZip02($Customer->getZip02()) |
91
|
|
|
->setZipcode($Customer->getZip01() . $Customer->getZip02()) |
|
|
|
|
92
|
|
|
->setPref($Customer->getPref()) |
93
|
|
|
->setAddr01($Customer->getAddr01()) |
94
|
|
|
->setAddr02($Customer->getAddr02()) |
95
|
|
|
->setTel01($Customer->getTel01()) |
96
|
|
|
->setTel02($Customer->getTel02()) |
97
|
|
|
->setTel03($Customer->getTel03()) |
98
|
|
|
->setFax01($Customer->getFax01()) |
99
|
|
|
->setFax02($Customer->getFax02()) |
100
|
|
|
->setFax03($Customer->getFax03()) |
101
|
1 |
|
->setDelFlg(Constant::DISABLED) |
102
|
|
|
->setCustomer($Customer); |
103
|
|
|
|
104
|
|
|
$app['orm.em']->persist($Customer); |
105
|
|
|
$app['orm.em']->persist($CustomerAddress); |
106
|
|
|
$app['orm.em']->flush(); |
107
|
|
|
|
108
|
|
|
$activateUrl = $app->url('entry_activate', array('secret_key' => $Customer->getSecretKey())); |
109
|
|
|
|
110
|
|
|
/** @var $BaseInfo \Eccube\Entity\BaseInfo */ |
111
|
|
|
$BaseInfo = $app['eccube.repository.base_info']->get(); |
112
|
|
|
$activateFlg = $BaseInfo->getOptionCustomerActivate(); |
113
|
|
|
|
114
|
|
|
// 仮会員設定が有効な場合は、確認メールを送信し完了画面表示. |
115
|
1 |
|
if ($activateFlg) { |
116
|
|
|
|
117
|
|
|
// メール送信 |
118
|
|
|
$app['eccube.service.mail']->sendCustomerConfirmMail($Customer, $activateUrl); |
119
|
|
|
|
120
|
|
|
return $app->redirect($app->url('entry_complete')); |
121
|
|
|
|
122
|
|
|
// 仮会員設定が無効な場合は認証URLへ遷移させ、会員登録を完了させる. |
123
|
|
|
} else { |
124
|
|
|
return $app->redirect($activateUrl); |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|
130
|
3 |
|
return $app['view']->render('Entry/index.twig', array( |
131
|
3 |
|
'form' => $form->createView(), |
132
|
|
|
)); |
133
|
5 |
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Complete |
137
|
|
|
* |
138
|
|
|
* @param Application $app |
139
|
|
|
* @return mixed |
140
|
|
|
*/ |
141
|
1 |
|
public function complete(Application $app) |
142
|
|
|
{ |
143
|
1 |
|
return $app['view']->render('Entry/complete.twig', array( |
|
|
|
|
144
|
|
|
)); |
145
|
1 |
|
} |
146
|
|
|
|
147
|
|
|
/** |
|
|
|
|
148
|
|
|
* 会員のアクティベート(本会員化)を行う |
149
|
|
|
* |
150
|
|
|
* @param Application $app |
151
|
|
|
* @return mixed |
152
|
|
|
*/ |
153
|
3 |
|
public function activate(Application $app, Request $request, $secret_key) |
154
|
|
|
{ |
155
|
|
|
$errors = $app['validator']->validateValue($secret_key, array( |
|
|
|
|
156
|
|
|
new Assert\NotBlank(), |
157
|
|
|
new Assert\Regex(array( |
158
|
|
|
'pattern' => '/^[a-zA-Z0-9]+$/', |
159
|
|
|
)) |
160
|
3 |
|
) |
161
|
|
|
); |
|
|
|
|
162
|
|
|
|
163
|
|
|
if ($request->getMethod() === 'GET' && count($errors) === 0) { |
164
|
|
|
try { |
165
|
|
|
$Customer = $app['eccube.repository.customer'] |
166
|
|
|
->getNonActiveCustomerBySecretKey($secret_key); |
167
|
|
|
} catch (\Exception $e) { |
168
|
|
|
throw new HttpException\NotFoundHttpException('※ 既に会員登録が完了しているか、無効なURLです。'); |
169
|
2 |
|
} |
170
|
|
|
|
171
|
|
|
$CustomerStatus = $app['eccube.repository.customer_status']->find(CustomerStatus::ACTIVE); |
172
|
|
|
$Customer->setStatus($CustomerStatus); |
173
|
|
|
$Customer->setBuyTimes(0); |
174
|
|
|
$Customer->setBuyTotal(0); |
175
|
|
|
|
176
|
|
|
$app['orm.em']->persist($Customer); |
177
|
|
|
$app['orm.em']->flush(); |
178
|
|
|
|
179
|
|
|
// メール送信 |
180
|
|
|
$app['eccube.service.mail']->sendCustomerCompleteMail($Customer); |
181
|
|
|
|
182
|
|
|
// 本会員登録してログイン状態にする |
183
|
|
|
$token = new UsernamePasswordToken($Customer, null, 'customer', array('ROLE_USER')); |
184
|
|
|
$this->getSecurity($app)->setToken($token); |
185
|
|
|
|
186
|
|
|
return $app['view']->render('Entry/activate.twig'); |
187
|
|
|
} else { |
188
|
|
|
throw new HttpException\AccessDeniedHttpException('不正なアクセスです。'); |
189
|
|
|
} |
190
|
3 |
|
} |
191
|
|
|
} |
192
|
|
|
|