|
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\Admin\Setting\System; |
|
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 AuthorityController extends AbstractController |
|
|
|
|
|
|
34
|
|
|
{ |
|
35
|
|
|
|
|
36
|
7 |
|
public function index(Application $app, Request $request) |
|
|
|
|
|
|
37
|
|
|
{ |
|
38
|
7 |
|
$AuthorityRoles = $app['eccube.repository.authority_role']->findAllSort(); |
|
39
|
|
|
|
|
40
|
7 |
|
$builder = $app['form.factory']->createBuilder(); |
|
41
|
|
|
$builder |
|
42
|
7 |
|
->add('AuthorityRoles', 'collection', array( |
|
43
|
7 |
|
'type' => 'admin_authority_role', |
|
44
|
7 |
|
'allow_add' => true, |
|
45
|
7 |
|
'allow_delete' => true, |
|
46
|
7 |
|
'prototype' => true, |
|
47
|
7 |
|
'data' => $AuthorityRoles, |
|
48
|
7 |
|
)); |
|
49
|
|
|
|
|
50
|
7 |
|
$event = new EventArgs( |
|
51
|
|
|
array( |
|
52
|
7 |
|
'builder' => $builder, |
|
53
|
7 |
|
'AuthorityRoles' => $AuthorityRoles, |
|
54
|
7 |
|
), |
|
55
|
|
|
$request |
|
56
|
7 |
|
); |
|
57
|
7 |
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SYSTEM_AUTHORITY_INDEX_INITIALIZE, $event); |
|
58
|
|
|
|
|
59
|
7 |
|
$form = $builder->getForm(); |
|
60
|
|
|
|
|
61
|
7 |
|
if (count($AuthorityRoles) == 0) { |
|
62
|
|
|
// 1件もない場合、空行を追加 |
|
63
|
4 |
|
$form->get('AuthorityRoles')->add(uniqid(), 'admin_authority_role'); |
|
64
|
4 |
|
} |
|
65
|
|
|
|
|
66
|
|
|
|
|
67
|
7 |
|
if ('POST' === $request->getMethod()) { |
|
|
|
|
|
|
68
|
|
|
|
|
69
|
4 |
|
$form->handleRequest($request); |
|
70
|
|
|
|
|
71
|
4 |
|
if ($form->isValid()) { |
|
72
|
4 |
|
$data = $form->getData(); |
|
73
|
|
|
|
|
74
|
4 |
|
foreach ($AuthorityRoles as $AuthorityRole) { |
|
75
|
2 |
|
$app['orm.em']->remove($AuthorityRole); |
|
76
|
4 |
|
} |
|
77
|
|
|
|
|
78
|
4 |
|
foreach ($data['AuthorityRoles'] as $AuthorityRole) { |
|
79
|
4 |
|
$Authority = $AuthorityRole->getAuthority(); |
|
80
|
4 |
|
$denyUrl = $AuthorityRole->getDenyUrl(); |
|
81
|
4 |
|
if ($Authority && !empty($denyUrl)) { |
|
82
|
3 |
|
$app['orm.em']->persist($AuthorityRole); |
|
83
|
3 |
|
} else { |
|
84
|
1 |
|
$id = $AuthorityRole->getId(); |
|
85
|
1 |
|
if (!empty($id)) { |
|
86
|
1 |
|
$role = $app['eccube.repository.authority_role']->find($id); |
|
87
|
1 |
|
if ($role) { |
|
88
|
|
|
// 削除 |
|
89
|
1 |
|
$app['orm.em']->remove($AuthorityRole); |
|
90
|
1 |
|
} |
|
91
|
1 |
|
} |
|
92
|
|
|
} |
|
93
|
4 |
|
} |
|
94
|
4 |
|
$app['orm.em']->flush(); |
|
95
|
|
|
|
|
96
|
4 |
|
$event = new EventArgs( |
|
97
|
|
|
array( |
|
98
|
4 |
|
'form' => $form, |
|
99
|
4 |
|
'AuthorityRoles' => $AuthorityRoles, |
|
100
|
4 |
|
), |
|
101
|
|
|
$request |
|
102
|
4 |
|
); |
|
103
|
4 |
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SYSTEM_AUTHORITY_INDEX_COMPLETE, $event); |
|
104
|
|
|
|
|
105
|
4 |
|
$app->addSuccess('admin.system.authority.save.complete', 'admin'); |
|
106
|
|
|
|
|
107
|
4 |
|
return $app->redirect($app->url('admin_setting_system_authority')); |
|
108
|
|
|
|
|
|
|
|
|
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
4 |
|
return $app->render('Setting/System/authority.twig', array( |
|
113
|
4 |
|
'form' => $form->createView(), |
|
114
|
4 |
|
)); |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
|