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
|
|
|
namespace Eccube\Controller\Admin\Setting\System; |
25
|
|
|
|
26
|
|
|
use Eccube\Application; |
27
|
|
|
use Eccube\Controller\AbstractController; |
28
|
|
|
use Eccube\Event\EccubeEvents; |
29
|
|
|
use Eccube\Event\EventArgs; |
30
|
|
|
use Symfony\Component\HttpFoundation\Request; |
31
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
32
|
|
|
|
33
|
|
|
class MemberController extends AbstractController |
|
|
|
|
34
|
|
|
{ |
35
|
6 |
|
public function __construct() |
|
|
|
|
36
|
|
|
{ |
37
|
6 |
|
} |
38
|
|
|
|
39
|
1 |
|
public function index(Application $app, Request $request) |
|
|
|
|
40
|
|
|
{ |
41
|
|
|
$Members = $app['eccube.repository.member']->findBy(array(), array('rank' => 'DESC')); |
42
|
|
|
|
43
|
|
|
$builder = $app['form.factory']->createBuilder(); |
44
|
|
|
|
45
|
|
|
$event = new EventArgs( |
46
|
|
|
array( |
47
|
|
|
'builder' => $builder, |
48
|
|
|
'Members' => $Members, |
49
|
1 |
|
), |
50
|
|
|
$request |
51
|
|
|
); |
52
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_MEMBER_INDEX_INITIALIZE, $event); |
53
|
|
|
|
54
|
|
|
$form = $builder->getForm(); |
55
|
|
|
|
56
|
1 |
|
return $app->render('Setting/System/member.twig', array( |
57
|
1 |
|
'form' => $form->createView(), |
58
|
|
|
'Members' => $Members, |
59
|
|
|
)); |
60
|
1 |
|
} |
61
|
|
|
|
62
|
2 |
|
public function edit(Application $app, Request $request, $id = null) |
|
|
|
|
63
|
|
|
{ |
64
|
2 |
|
$previous_password = null; |
65
|
2 |
|
if ($id) { |
66
|
|
|
$Member = $app['eccube.repository.member']->find($id); |
67
|
1 |
|
if (!$Member) { |
68
|
|
|
throw new NotFoundHttpException(); |
69
|
|
|
} |
70
|
|
|
$previous_password = $Member->getPassword(); |
71
|
|
|
$Member->setPassword($app['config']['default_password']); |
72
|
|
|
} else { |
73
|
|
|
$Member = new \Eccube\Entity\Member(); |
74
|
1 |
|
} |
75
|
|
|
|
76
|
|
|
$builder = $app['form.factory'] |
77
|
|
|
->createBuilder('admin_member', $Member); |
78
|
|
|
|
79
|
|
|
$event = new EventArgs( |
80
|
|
|
array( |
|
|
|
|
81
|
|
|
'builder' => $builder, |
82
|
|
|
'Member' => $Member |
83
|
2 |
|
), |
84
|
|
|
$request |
85
|
|
|
); |
86
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_MEMBER_EDIT_INITIALIZE, $event); |
87
|
|
|
|
88
|
|
|
$form = $builder->getForm(); |
89
|
|
|
|
90
|
|
|
if ('POST' === $request->getMethod()) { |
91
|
|
|
$form->handleRequest($request); |
92
|
|
|
if ($form->isValid()) { |
93
|
|
|
if (!is_null($previous_password) |
94
|
|
|
&& $Member->getpassword() === $app['config']['default_password']) { |
95
|
|
|
// 編集時にPWを変更していなければ |
96
|
|
|
// 変更前のパスワード(暗号化済み)をセット |
97
|
|
|
$Member->setPassword($previous_password); |
98
|
|
|
} else { |
99
|
|
|
$salt = $Member->getSalt(); |
100
|
|
|
if (!isset($salt)) { |
101
|
|
|
$salt = $app['eccube.repository.member']->createSalt(5); |
102
|
|
|
$Member->setSalt($salt); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
// 入力されたPWを暗号化してセット |
106
|
|
|
$password = $app['eccube.repository.member']->encryptPassword($Member); |
107
|
|
|
$Member->setPassword($password); |
108
|
|
|
} |
109
|
|
|
$status = $app['eccube.repository.member']->save($Member); |
110
|
|
|
|
111
|
|
|
if ($status) { |
112
|
|
|
$event = new EventArgs(array( |
|
|
|
|
113
|
|
|
'form' => $form, |
114
|
|
|
'Member' => $Member |
115
|
|
|
), |
116
|
|
|
$request |
117
|
|
|
); |
118
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_MEMBER_EDIT_COMPLETE, $event); |
119
|
|
|
|
120
|
|
|
$app->addSuccess('admin.member.save.complete', 'admin'); |
121
|
|
|
|
122
|
|
|
return $app->redirect($app->url('admin_setting_system_member')); |
123
|
|
|
} else { |
124
|
|
|
$app->addError('admin.member.save.error', 'admin'); |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|
129
|
2 |
|
return $app->render('Setting/System/member_edit.twig', array( |
130
|
2 |
|
'form' => $form->createView(), |
131
|
|
|
'Member' => $Member, |
132
|
|
|
)); |
133
|
|
|
|
134
|
2 |
|
} |
135
|
|
|
|
136
|
1 |
View Code Duplication |
public function up(Application $app, Request $request, $id) |
|
|
|
|
137
|
|
|
{ |
138
|
|
|
$this->isTokenValid($app); |
139
|
|
|
|
140
|
|
|
$TargetMember = $app['eccube.repository.member']->find($id); |
141
|
|
|
|
142
|
1 |
|
if (!$TargetMember) { |
143
|
|
|
throw new NotFoundHttpException(); |
144
|
|
|
} |
145
|
|
|
|
146
|
1 |
|
$status = false; |
147
|
|
|
if ('PUT' === $request->getMethod()) { |
148
|
|
|
$status = $app['eccube.repository.member']->up($TargetMember); |
149
|
|
|
} |
150
|
|
|
|
151
|
1 |
|
if ($status) { |
152
|
|
|
$app->addSuccess('admin.member.up.complete', 'admin'); |
153
|
|
|
} else { |
154
|
|
|
$app->addError('admin.member.up.error', 'admin'); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
return $app->redirect($app->url('admin_setting_system_member')); |
158
|
1 |
|
} |
159
|
|
|
|
160
|
1 |
View Code Duplication |
public function down(Application $app, Request $request, $id) |
|
|
|
|
161
|
|
|
{ |
162
|
|
|
$this->isTokenValid($app); |
163
|
|
|
|
164
|
|
|
$TargetMember = $app['eccube.repository.member']->find($id); |
165
|
|
|
|
166
|
1 |
|
if (!$TargetMember) { |
167
|
|
|
throw new NotFoundHttpException(); |
168
|
|
|
} |
169
|
|
|
|
170
|
1 |
|
$status = false; |
171
|
|
|
if ('PUT' === $request->getMethod()) { |
172
|
|
|
$status = $app['eccube.repository.member']->down($TargetMember); |
173
|
|
|
} |
174
|
|
|
|
175
|
1 |
|
if ($status) { |
176
|
|
|
$app->addSuccess('admin.member.down.complete', 'admin'); |
177
|
|
|
} else { |
178
|
|
|
$app->addError('admin.member.down.error', 'admin'); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
return $app->redirect($app->url('admin_setting_system_member')); |
182
|
1 |
|
} |
183
|
|
|
|
184
|
1 |
|
public function delete(Application $app, Request $request, $id) |
|
|
|
|
185
|
|
|
{ |
186
|
|
|
$this->isTokenValid($app); |
187
|
|
|
|
188
|
|
|
$TargetMember = $app['eccube.repository.member']->find($id); |
189
|
1 |
|
if (!$TargetMember) { |
190
|
|
|
$app->deleteMessage(); |
191
|
|
|
return $app->redirect($app->url('admin_setting_system_member')); |
|
|
|
|
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
$event = new EventArgs( |
195
|
|
|
array( |
|
|
|
|
196
|
|
|
'TargetMember' => $TargetMember |
197
|
1 |
|
), |
198
|
|
|
$request |
199
|
|
|
); |
200
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_MEMBER_DELETE_INITIALIZE, $event); |
201
|
|
|
|
202
|
|
|
$status = $app['eccube.repository.member']->delete($TargetMember); |
203
|
|
|
|
204
|
1 |
|
if ($status) { |
205
|
|
|
$app->addSuccess('admin.member.delete.complete', 'admin'); |
206
|
|
|
$event = new EventArgs( |
207
|
1 |
|
array(), |
208
|
|
|
$request |
209
|
|
|
); |
210
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_MEMBER_DELETE_COMPLETE, $event); |
211
|
|
|
} else { |
212
|
|
|
$app->addError('admin.member.delete.error', 'admin'); |
213
|
1 |
|
} |
214
|
|
|
|
215
|
|
|
return $app->redirect($app->url('admin_setting_system_member')); |
216
|
|
|
} |
217
|
|
|
} |