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\Mypage; |
26
|
|
|
|
27
|
|
|
use Eccube\Application; |
28
|
|
|
use Eccube\Controller\AbstractController; |
29
|
|
|
use Eccube\Event\EccubeEvents; |
30
|
|
|
use Eccube\Event\EventArgs; |
31
|
|
|
use Symfony\Component\HttpFoundation\Request; |
32
|
|
|
|
33
|
|
|
class ChangeController extends AbstractController |
34
|
|
|
{ |
35
|
|
|
/** |
36
|
|
|
* 会員情報編集画面. |
37
|
|
|
* |
38
|
|
|
* @param Application $app |
39
|
|
|
* @param Request $request |
|
|
|
|
40
|
|
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response |
41
|
|
|
*/ |
42
|
8 |
|
public function index(Application $app, Request $request) |
43
|
|
|
{ |
44
|
8 |
|
$Customer = $app->user(); |
45
|
8 |
|
$LoginCustomer = clone $Customer; |
46
|
8 |
|
$app['orm.em']->detach($LoginCustomer); |
47
|
|
|
|
48
|
8 |
|
$previous_password = $Customer->getPassword(); |
49
|
8 |
|
$Customer->setPassword($app['config']['default_password']); |
50
|
|
|
|
51
|
|
|
/* @var $builder \Symfony\Component\Form\FormBuilderInterface */ |
52
|
8 |
|
$builder = $app['form.factory']->createBuilder('entry', $Customer); |
53
|
|
|
|
54
|
8 |
|
$event = new EventArgs( |
55
|
|
|
array( |
56
|
8 |
|
'builder' => $builder, |
57
|
8 |
|
'Customer' => $Customer, |
58
|
|
|
), |
59
|
|
|
$request |
60
|
|
|
); |
61
|
8 |
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_MYPAGE_CHANGE_INDEX_INITIALIZE, $event); |
62
|
|
|
|
63
|
|
|
/* @var $form \Symfony\Component\Form\FormInterface */ |
64
|
8 |
|
$form = $builder->getForm(); |
65
|
8 |
|
$form->handleRequest($request); |
66
|
|
|
|
67
|
8 |
|
if ($form->isSubmitted() && $form->isValid()) { |
|
|
|
|
68
|
|
|
|
69
|
4 |
|
log_info('会員編集開始'); |
70
|
|
|
|
71
|
4 |
View Code Duplication |
if ($Customer->getPassword() === $app['config']['default_password']) { |
72
|
2 |
|
$Customer->setPassword($previous_password); |
73
|
|
|
} else { |
74
|
2 |
|
if ($Customer->getSalt() === null) { |
75
|
|
|
$Customer->setSalt($app['eccube.repository.customer']->createSalt(5)); |
76
|
|
|
} |
77
|
2 |
|
$Customer->setPassword( |
78
|
2 |
|
$app['eccube.repository.customer']->encryptPassword($app, $Customer) |
79
|
|
|
); |
80
|
|
|
} |
81
|
4 |
|
$app['orm.em']->flush(); |
82
|
|
|
|
83
|
4 |
|
log_info('会員編集完了'); |
84
|
|
|
|
85
|
4 |
|
$event = new EventArgs( |
86
|
|
|
array( |
87
|
4 |
|
'form' => $form, |
88
|
4 |
|
'Customer' => $Customer, |
89
|
|
|
), |
90
|
|
|
$request |
91
|
|
|
); |
92
|
4 |
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_MYPAGE_CHANGE_INDEX_COMPLETE, $event); |
93
|
|
|
|
94
|
4 |
|
return $app->redirect($app->url('mypage_change_complete')); |
95
|
|
|
} |
96
|
|
|
|
97
|
4 |
|
$app['security']->getToken()->setUser($LoginCustomer); |
98
|
|
|
|
99
|
4 |
|
return $app->render('Mypage/change.twig', array( |
100
|
4 |
|
'form' => $form->createView(), |
101
|
|
|
)); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* 会員情報編集完了画面. |
106
|
|
|
* |
107
|
|
|
* @param Application $app |
108
|
|
|
* @param Request $request |
|
|
|
|
109
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
110
|
|
|
*/ |
111
|
2 |
|
public function complete(Application $app, Request $request) |
112
|
|
|
{ |
113
|
2 |
|
return $app->render('Mypage/change_complete.twig'); |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|