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 | 2 | class ClassCategoryController extends AbstractController |
|
35 | { |
||
36 | public function index(Application $app, Request $request, $class_name_id, $id = null) |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
37 | { |
||
38 | 2 | // |
|
39 | $ClassName = $app['eccube.repository.class_name']->find($class_name_id); |
||
40 | if (!$ClassName) { |
||
41 | 2 | throw new NotFoundHttpException('商品規格が存在しません'); |
|
42 | } |
||
43 | if ($id) { |
||
44 | $TargetClassCategory = $app['eccube.repository.class_category']->find($id); |
||
45 | if (!$TargetClassCategory || $TargetClassCategory->getClassName() != $ClassName) { |
||
46 | throw new NotFoundHttpException('商品規格が存在しません'); |
||
47 | } |
||
48 | } else { |
||
49 | 1 | $TargetClassCategory = new \Eccube\Entity\ClassCategory(); |
|
50 | $TargetClassCategory->setClassName($ClassName); |
||
51 | } |
||
52 | |||
53 | // |
||
54 | $builder = $app['form.factory'] |
||
55 | ->createBuilder('admin_class_category', $TargetClassCategory); |
||
56 | |||
57 | $event = new EventArgs( |
||
58 | array( |
||
59 | 'builder' => $builder, |
||
60 | 'ClassName' => $ClassName, |
||
61 | 'TargetClassCategory' => $TargetClassCategory, |
||
62 | ), |
||
63 | $request |
||
64 | ); |
||
65 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_PRODUCT_CLASS_CATEGORY_INDEX_INITIALIZE, $event); |
||
66 | |||
67 | $form = $builder->getForm(); |
||
68 | |||
69 | if ($request->getMethod() === 'POST') { |
||
70 | $form->handleRequest($request); |
||
71 | if ($form->isValid()) { |
||
72 | log_info('規格分類登録開始', array($id)); |
||
73 | 2 | $status = $app['eccube.repository.class_category']->save($TargetClassCategory); |
|
74 | 2 | ||
75 | if ($status) { |
||
76 | |||
77 | log_info('規格分類登録完了', array($id)); |
||
78 | |||
79 | 2 | $event = new EventArgs( |
|
80 | array( |
||
81 | 1 | 'form' => $form, |
|
82 | 'ClassName' => $ClassName, |
||
83 | 'TargetClassCategory' => $TargetClassCategory, |
||
84 | ), |
||
85 | $request |
||
86 | 1 | ); |
|
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 | 1 | } |
|
97 | 1 | } |
|
98 | 1 | ||
99 | 1 | $ClassCategories = $app['eccube.repository.class_category']->getList($ClassName); |
|
100 | |||
101 | 1 | return $app->render('Product/class_category.twig', array( |
|
102 | 'form' => $form->createView(), |
||
103 | 'ClassName' => $ClassName, |
||
104 | 'ClassCategories' => $ClassCategories, |
||
105 | 'TargetClassCategory' => $TargetClassCategory, |
||
106 | 1 | )); |
|
107 | } |
||
108 | |||
109 | public function delete(Application $app, Request $request, $class_name_id, $id) |
||
0 ignored issues
–
show
|
|||
110 | 1 | { |
|
111 | $this->isTokenValid($app); |
||
112 | |||
113 | $ClassName = $app['eccube.repository.class_name']->find($class_name_id); |
||
114 | 1 | if (!$ClassName) { |
|
115 | throw new NotFoundHttpException('商品規格が存在しません'); |
||
116 | } |
||
117 | |||
118 | log_info('規格分類削除開始', array($id)); |
||
119 | |||
120 | $TargetClassCategory = $app['eccube.repository.class_category']->find($id); |
||
121 | 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 | $num = $app['eccube.repository.product_class']->createQueryBuilder('pc') |
||
127 | ->select('count(pc.id)') |
||
128 | ->where('pc.ClassCategory1 = :id OR pc.ClassCategory2 = :id') |
||
129 | ->setParameter('id',$id) |
||
130 | ->getQuery() |
||
131 | ->getSingleScalarResult(); |
||
132 | if ($num > 0) { |
||
133 | $app->addError('admin.class_category.delete.hasproduct', 'admin'); |
||
134 | } else { |
||
135 | $status = $app['eccube.repository.class_category']->delete($TargetClassCategory); |
||
136 | |||
137 | if ($status === true) { |
||
138 | |||
139 | log_info('規格分類削除完了', array($id)); |
||
140 | |||
141 | $event = new EventArgs( |
||
142 | array( |
||
143 | 'ClassName' => $ClassName, |
||
144 | 'TargetClassCategory' => $TargetClassCategory, |
||
145 | ), |
||
146 | $request |
||
147 | ); |
||
148 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_PRODUCT_CLASS_CATEGORY_DELETE_COMPLETE, $event); |
||
149 | |||
150 | $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 | 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) |
|
0 ignored issues
–
show
|
|||
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; |
||
0 ignored issues
–
show
|
|||
174 | } |
||
175 | } |
||
176 |