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\Setting\Shop; |
||
26 | |||
27 | use Doctrine\ORM\EntityManager; |
||
28 | use Eccube\Application; |
||
29 | use Eccube\Controller\AbstractController; |
||
30 | use Eccube\Event\EccubeEvents; |
||
31 | use Eccube\Event\EventArgs; |
||
32 | use Symfony\Component\Form\Form; |
||
33 | use Symfony\Component\Form\FormError; |
||
34 | use Symfony\Component\HttpFoundation\Request; |
||
35 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
||
36 | |||
37 | class TaxRuleController extends AbstractController |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
38 | { |
||
39 | |||
40 | /** |
||
41 | * 税率設定の初期表示・登録 |
||
42 | * |
||
43 | * @param Application $app |
||
44 | * @param Request $request |
||
45 | 2 | * @param null $id |
|
46 | * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response |
||
47 | 2 | */ |
|
48 | public function index(Application $app, Request $request, $id = null) |
||
49 | 2 | { |
|
50 | $TargetTaxRule = null; |
||
51 | |||
52 | if ($id == null) { |
||
53 | $TargetTaxRule = $app['eccube.repository.tax_rule']->newTaxRule(); |
||
54 | } else { |
||
55 | $TargetTaxRule = $app['eccube.repository.tax_rule']->find($id); |
||
56 | 1 | if (is_null($TargetTaxRule)) { |
|
57 | throw new NotFoundHttpException(); |
||
58 | } |
||
59 | } |
||
60 | |||
61 | /** @var $BaseInfo \Eccube\Entity\BaseInfo */ |
||
62 | $BaseInfo = $app['eccube.repository.base_info']->get(); |
||
63 | |||
64 | $builder = $app['form.factory'] |
||
65 | 2 | ->createBuilder('tax_rule', $TargetTaxRule); |
|
66 | |||
67 | $builder |
||
68 | ->get('option_product_tax_rule') |
||
69 | ->setData($BaseInfo->getOptionProductTaxRule()); |
||
70 | |||
71 | if ($TargetTaxRule->isDefaultTaxRule()) { |
||
72 | // 基本税率設定は適用日時の変更は行わない |
||
73 | $builder = $builder->remove('apply_date'); |
||
74 | } |
||
75 | |||
76 | $event = new EventArgs( |
||
77 | array( |
||
78 | 'builder' => $builder, |
||
79 | 'BaseInfo' => $BaseInfo, |
||
80 | 'TargetTaxRule' => $TargetTaxRule, |
||
81 | ), |
||
82 | $request |
||
83 | ); |
||
84 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_TAX_RULE_INDEX_INITIALIZE, $event); |
||
85 | |||
86 | /* @var $form \Symfony\Component\Form\FormInterface */ |
||
87 | $form = $builder->getForm(); |
||
88 | |||
89 | View Code Duplication | if ('POST' === $request->getMethod()) { |
|
90 | $form->handleRequest($request); |
||
91 | 2 | if ($this->isValid($app['orm.em'], $form)) { |
|
92 | $app['orm.em']->persist($TargetTaxRule); |
||
93 | |||
94 | 2 | $app['orm.em']->flush(); |
|
95 | |||
96 | 2 | $event = new EventArgs( |
|
97 | array( |
||
98 | 'form' => $form, |
||
99 | 'BaseInfo' => $BaseInfo, |
||
100 | 'TargetTaxRule' => $TargetTaxRule, |
||
101 | ), |
||
102 | $request |
||
103 | ); |
||
104 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_TAX_RULE_INDEX_COMPLETE, $event); |
||
105 | 1 | ||
106 | $app->addSuccess('admin.shop.tax.save.complete', 'admin'); |
||
107 | |||
108 | return $app->redirect($app->url('admin_setting_shop_tax')); |
||
109 | } |
||
110 | 1 | } |
|
111 | |||
112 | // 共通税率一覧 |
||
113 | $TaxRules = $app['eccube.repository.tax_rule']->getList(); |
||
114 | |||
115 | return $app->render('Setting/Shop/tax_rule.twig', array( |
||
116 | 'TargetTaxRule' => $TargetTaxRule, |
||
117 | 'TaxRules' => $TaxRules, |
||
118 | 'form' => $form->createView(), |
||
119 | )); |
||
120 | } |
||
121 | 1 | ||
122 | /** |
||
0 ignored issues
–
show
|
|||
123 | * 税率設定の削除 |
||
124 | * |
||
125 | * @param Application $app |
||
126 | * @param Request $request |
||
127 | * @param $id |
||
128 | * @return \Symfony\Component\HttpFoundation\RedirectResponse |
||
129 | */ |
||
130 | public function delete(Application $app, Request $request, $id) |
||
131 | { |
||
132 | $this->isTokenValid($app); |
||
133 | |||
134 | $TargetTaxRule = $app['eccube.repository.tax_rule']->find($id); |
||
135 | if (!$TargetTaxRule) { |
||
136 | $app->deleteMessage(); |
||
137 | return $app->redirect($app->url('admin_setting_shop_tax')); |
||
138 | } |
||
139 | |||
140 | if (!$TargetTaxRule->isDefaultTaxRule()) { |
||
141 | $app['eccube.repository.tax_rule']->delete($TargetTaxRule); |
||
142 | |||
143 | $event = new EventArgs( |
||
144 | array( |
||
145 | 'TargetTaxRule' => $TargetTaxRule, |
||
146 | ), |
||
147 | $request |
||
148 | ); |
||
149 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_TAX_RULE_DELETE_COMPLETE, $event); |
||
150 | |||
151 | $app->addSuccess('admin.shop.tax.delete.complete', 'admin'); |
||
152 | } |
||
153 | |||
154 | return $app->redirect($app->url('admin_setting_shop_tax')); |
||
155 | } |
||
156 | |||
157 | /** |
||
158 | * 軽減税率の有効/無効設定 |
||
159 | * |
||
160 | * @param Application $app |
||
161 | * @param Request $request |
||
162 | * @return \Symfony\Component\HttpFoundation\RedirectResponse |
||
163 | */ |
||
164 | public function editParameter(Application $app, Request $request) |
||
165 | { |
||
166 | $builder = $app['form.factory'] |
||
167 | ->createBuilder('tax_rule'); |
||
168 | |||
169 | $event = new EventArgs( |
||
170 | array( |
||
171 | 'builder' => $builder, |
||
172 | ), |
||
173 | $request |
||
174 | ); |
||
175 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_TAX_RULE_EDIT_PARAMETER_INITIALIZE, $event); |
||
176 | |||
177 | $form = $builder->getForm(); |
||
178 | |||
179 | View Code Duplication | if ('POST' === $request->getMethod()) { |
|
180 | $form->handleRequest($request); |
||
181 | |||
182 | // 軽減税率設定の項目のみ処理する |
||
183 | $optionForm = $form->get('option_product_tax_rule'); |
||
184 | if ($optionForm->isValid()) { |
||
185 | /** @var $BaseInfo \Eccube\Entity\BaseInfo */ |
||
186 | $BaseInfo = $app['eccube.repository.base_info']->get(); |
||
187 | $BaseInfo->setOptionProductTaxRule($optionForm->getData()); |
||
188 | |||
189 | $app['orm.em']->flush(); |
||
190 | |||
191 | $event = new EventArgs( |
||
192 | array( |
||
193 | 'form' => $form, |
||
194 | 'BaseInfo' => $BaseInfo, |
||
195 | ), |
||
196 | $request |
||
197 | ); |
||
198 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_TAX_RULE_EDIT_PARAMETER_COMPLETE, $event); |
||
199 | |||
200 | $app->addSuccess('admin.shop.tax.save.complete', 'admin'); |
||
201 | } |
||
202 | } |
||
203 | |||
204 | return $app->redirect($app->url('admin_setting_shop_tax')); |
||
205 | } |
||
206 | |||
207 | protected function isValid(EntityManager $em, Form $form) |
||
208 | { |
||
209 | if (!$form->isValid()) { |
||
210 | return false; |
||
211 | } |
||
212 | /** |
||
213 | * 同一日時のエラーチェック. |
||
214 | */ |
||
215 | /** @var $TargetTaxRule \Eccube\Entity\TaxRule */ |
||
216 | $TargetTaxRule = $form->getData(); |
||
217 | $parameters = array(); |
||
218 | $parameters['apply_date'] = $TargetTaxRule->getApplyDate(); |
||
219 | $qb = $em |
||
220 | ->getRepository('Eccube\Entity\TaxRule') |
||
221 | ->createQueryBuilder('t') |
||
222 | ->select('count(t.id)') |
||
223 | ->where('t.apply_date = :apply_date'); |
||
224 | // 編集時は, 編集対象をのぞいて検索. |
||
225 | if ($TargetTaxRule->getId()) { |
||
226 | $qb->andWhere('t.id <> :id'); |
||
227 | $parameters['id'] = $TargetTaxRule->getId(); |
||
228 | } |
||
229 | $qb->setParameters($parameters); |
||
230 | $count = $qb |
||
231 | ->getQuery() |
||
232 | ->getSingleScalarResult(); |
||
233 | // 同じ適用日時の登録データがあればエラーとする. |
||
234 | if ($count > 0) { |
||
235 | $form['apply_date']->addError(new FormError('既に同じ適用日時で登録されています。')); |
||
236 | |||
237 | return false; |
||
238 | } |
||
239 | |||
240 | return true; |
||
241 | } |
||
242 | } |
||
243 |