This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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\Product; |
||
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 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
||
33 | |||
34 | class ClassCategoryController extends AbstractController |
||
35 | { |
||
36 | 4 | public function index(Application $app, Request $request, $class_name_id, $id = null) |
|
37 | { |
||
38 | // |
||
39 | 4 | $ClassName = $app['eccube.repository.class_name']->find($class_name_id); |
|
40 | 4 | if (!$ClassName) { |
|
41 | throw new NotFoundHttpException('商品規格が存在しません'); |
||
42 | } |
||
43 | 4 | if ($id) { |
|
44 | 2 | $TargetClassCategory = $app['eccube.repository.class_category']->find($id); |
|
45 | 2 | if (!$TargetClassCategory || $TargetClassCategory->getClassName() != $ClassName) { |
|
46 | 2 | throw new NotFoundHttpException('商品規格が存在しません'); |
|
47 | } |
||
48 | } else { |
||
49 | 2 | $TargetClassCategory = new \Eccube\Entity\ClassCategory(); |
|
50 | 2 | $TargetClassCategory->setClassName($ClassName); |
|
51 | } |
||
52 | |||
53 | // |
||
54 | 4 | $builder = $app['form.factory'] |
|
55 | 4 | ->createBuilder('admin_class_category', $TargetClassCategory); |
|
56 | |||
57 | 4 | $event = new EventArgs( |
|
58 | array( |
||
59 | 4 | 'builder' => $builder, |
|
60 | 4 | 'ClassName' => $ClassName, |
|
61 | 4 | 'TargetClassCategory' => $TargetClassCategory, |
|
62 | ), |
||
63 | $request |
||
64 | ); |
||
65 | 4 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_PRODUCT_CLASS_CATEGORY_INDEX_INITIALIZE, $event); |
|
66 | |||
67 | 4 | $form = $builder->getForm(); |
|
68 | |||
69 | 4 | if ($request->getMethod() === 'POST') { |
|
70 | $form->handleRequest($request); |
||
71 | if ($form->isValid()) { |
||
72 | log_info('規格分類登録開始', array($id)); |
||
73 | $status = $app['eccube.repository.class_category']->save($TargetClassCategory); |
||
74 | |||
75 | if ($status) { |
||
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
76 | |||
77 | log_info('規格分類登録完了', array($id)); |
||
78 | |||
79 | $event = new EventArgs( |
||
80 | array( |
||
81 | 'form' => $form, |
||
82 | 'ClassName' => $ClassName, |
||
83 | 'TargetClassCategory' => $TargetClassCategory, |
||
84 | ), |
||
85 | $request |
||
86 | ); |
||
87 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_PRODUCT_CLASS_CATEGORY_INDEX_COMPLETE, $event); |
||
88 | |||
89 | $app->addSuccess('admin.class_category.save.complete', 'admin'); |
||
90 | |||
91 | return $app->redirect($app->url('admin_product_class_category', array('class_name_id' => $ClassName->getId()))); |
||
92 | } else { |
||
93 | log_info('規格分類登録エラー', array($id)); |
||
94 | $app->addError('admin.class_category.save.error', 'admin'); |
||
95 | } |
||
96 | } |
||
97 | } |
||
98 | |||
99 | 4 | $ClassCategories = $app['eccube.repository.class_category']->getList($ClassName); |
|
100 | |||
101 | 4 | return $app->render('Product/class_category.twig', array( |
|
102 | 4 | 'form' => $form->createView(), |
|
103 | 4 | 'ClassName' => $ClassName, |
|
104 | 4 | 'ClassCategories' => $ClassCategories, |
|
105 | 4 | 'TargetClassCategory' => $TargetClassCategory, |
|
106 | )); |
||
107 | } |
||
108 | |||
109 | 2 | public function delete(Application $app, Request $request, $class_name_id, $id) |
|
110 | { |
||
111 | 2 | $this->isTokenValid($app); |
|
112 | |||
113 | 2 | $ClassName = $app['eccube.repository.class_name']->find($class_name_id); |
|
114 | 2 | if (!$ClassName) { |
|
115 | throw new NotFoundHttpException('商品規格が存在しません'); |
||
116 | } |
||
117 | |||
118 | 2 | log_info('規格分類削除開始', array($id)); |
|
119 | |||
120 | 2 | $TargetClassCategory = $app['eccube.repository.class_category']->find($id); |
|
121 | 2 | if (!$TargetClassCategory || $TargetClassCategory->getClassName() != $ClassName) { |
|
122 | $app->deleteMessage(); |
||
123 | return $app->redirect($app->url('admin_product_class_category', array('class_name_id' => $ClassName->getId()))); |
||
124 | } |
||
125 | |||
126 | 2 | $num = $app['eccube.repository.product_class']->createQueryBuilder('pc') |
|
127 | 2 | ->select('count(pc.id)') |
|
128 | 2 | ->where('pc.ClassCategory1 = :id OR pc.ClassCategory2 = :id') |
|
129 | 2 | ->setParameter('id',$id) |
|
130 | 2 | ->getQuery() |
|
131 | 2 | ->getSingleScalarResult(); |
|
132 | 2 | if ($num > 0) { |
|
133 | $app->addError('admin.class_category.delete.hasproduct', 'admin'); |
||
134 | } else { |
||
135 | 2 | $status = $app['eccube.repository.class_category']->delete($TargetClassCategory); |
|
136 | |||
137 | 2 | View Code Duplication | if ($status === true) { |
138 | |||
139 | 2 | log_info('規格分類削除完了', array($id)); |
|
140 | |||
141 | 2 | $event = new EventArgs( |
|
142 | array( |
||
143 | 2 | 'ClassName' => $ClassName, |
|
144 | 2 | 'TargetClassCategory' => $TargetClassCategory, |
|
145 | ), |
||
146 | $request |
||
147 | ); |
||
148 | 2 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_PRODUCT_CLASS_CATEGORY_DELETE_COMPLETE, $event); |
|
149 | |||
150 | 2 | $app->addSuccess('admin.class_category.delete.complete', 'admin'); |
|
151 | } else { |
||
152 | log_info('規格分類削除エラー', array($id)); |
||
153 | |||
154 | $app->addError('admin.class_category.delete.error', 'admin'); |
||
155 | } |
||
156 | } |
||
157 | |||
158 | 2 | return $app->redirect($app->url('admin_product_class_category', array('class_name_id' => $ClassName->getId()))); |
|
159 | } |
||
160 | |||
161 | View Code Duplication | public function moveRank(Application $app, Request $request) |
|
162 | { |
||
163 | if ($request->isXmlHttpRequest()) { |
||
164 | $ranks = $request->request->all(); |
||
165 | foreach ($ranks as $categoryId => $rank) { |
||
166 | $ClassCategory = $app['eccube.repository.class_category'] |
||
167 | ->find($categoryId); |
||
168 | $ClassCategory->setRank($rank); |
||
169 | $app['orm.em']->persist($ClassCategory); |
||
170 | } |
||
171 | $app['orm.em']->flush(); |
||
172 | } |
||
173 | return true; |
||
174 | } |
||
175 | } |
||
176 |