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.
1 | <?php |
||
2 | /* |
||
3 | You may not change or alter any portion of this comment or credits |
||
4 | of supporting developers from this source code or any supporting source code |
||
5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
6 | |||
7 | This program is distributed in the hope that it will be useful, |
||
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
10 | */ |
||
11 | |||
12 | /** |
||
13 | * oledrion |
||
14 | * |
||
15 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
16 | * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
||
17 | * @author Hervé Thouzard (http://www.herve-thouzard.com/) |
||
18 | */ |
||
19 | |||
20 | use XoopsModules\Oledrion; |
||
21 | use XoopsModules\Oledrion\Constants; |
||
22 | |||
23 | /** |
||
24 | * Gestion des réductions (dans l'administration) |
||
25 | */ |
||
26 | if (!defined('OLEDRION_ADMIN')) { |
||
27 | exit(); |
||
28 | } |
||
29 | |||
30 | switch ($action) { |
||
31 | // **************************************************************************************************************** |
||
32 | case 'default': // Gestion des réductions |
||
33 | |||
34 | // **************************************************************************************************************** |
||
35 | xoops_cp_header(); |
||
36 | $adminObject = \Xmf\Module\Admin::getInstance(); |
||
37 | $adminObject->displayNavigation('index.php?op=discounts'); |
||
38 | |||
39 | $form = "<form method='post' action='$baseurl' name='frmadddiscount' id='frmadddiscount'><input type='hidden' name='op' id='op' value='discounts'><input type='hidden' name='action' id='action' value='add'><input type='submit' name='btngo' id='btngo' value='" |
||
40 | . _AM_OLEDRION_ADD_ITEM |
||
41 | . "'></form>"; |
||
42 | echo $form; |
||
43 | // Oledrion\Utility::htitle(_MI_OLEDRION_ADMENU6, 4); |
||
44 | |||
45 | $discounts = []; |
||
46 | $itemsCount = 0; |
||
47 | $class = ''; |
||
48 | $start = \Xmf\Request::getInt('start', 0, 'GET'); |
||
49 | |||
50 | $itemsCount = $discountsHandler->getCount(); // Recherche du nombre total de réductions |
||
51 | if ($itemsCount > $limit) { |
||
52 | $pagenav = new \XoopsPageNav($itemsCount, $limit, $start, 'start', 'op=discounts'); |
||
53 | } |
||
54 | |||
55 | $criteria = new \Criteria('disc_id', 0, '<>'); |
||
56 | $criteria->setLimit($limit); |
||
57 | $criteria->setStart($start); |
||
58 | $discounts = $discountsHandler->getObjects($criteria); |
||
59 | |||
60 | echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'>"; |
||
61 | echo "<tr><th align='center'>" . _AM_OLEDRION_ID . "</th><th align='center'>" . _TITLE . "</th><th align='center'>" . _AM_OLEDRION_ACTION . '</th></tr>'; |
||
62 | foreach ($discounts as $item) { |
||
63 | $class = ('even' === $class) ? 'odd' : 'even'; |
||
64 | $id = $item->getVar('disc_id'); |
||
65 | $actions = []; |
||
66 | $actions[] = "<a href='$baseurl?op=discounts&action=edit&id=" . $id . "' title='" . _OLEDRION_EDIT . "'>" . $icons['edit'] . '</a>'; |
||
67 | $actions[] = "<a href='$baseurl?op=discounts&action=delete&id=" . $id . "' title='" . _OLEDRION_DELETE . "'" . $conf_msg . '>' . $icons['delete'] . '</a>'; |
||
68 | $actions[] = "<a href='$baseurl?op=discounts&action=copy&id=" . $id . "' title='" . _OLEDRION_DUPLICATE_DISCOUNT . "'>" . $icons['copy'] . '</a>'; |
||
69 | echo "<tr class='" . $class . "'>\n"; |
||
70 | echo '<td>' . $id . "</td><td align='center'>" . $item->getVar('disc_title') . "</td><td align='center'>" . implode(' ', $actions) . "</td>\n"; |
||
71 | echo "<tr>\n"; |
||
72 | } |
||
73 | $class = ('even' === $class) ? 'odd' : 'even'; |
||
74 | echo "<tr class='" . $class . "'>\n"; |
||
75 | echo "<td colspan='3' align='center'>" . $form . "</td>\n"; |
||
76 | echo "</tr>\n"; |
||
77 | echo '</table>'; |
||
78 | if (isset($pagenav) && is_object($pagenav)) { |
||
79 | echo "<div align='right'>" . $pagenav->renderNav() . '</div>'; |
||
80 | } |
||
81 | $oledrion_reductions = new Oledrion\Reductions(); |
||
82 | |||
83 | require_once OLEDRION_ADMIN_PATH . 'admin_footer.php'; |
||
84 | |||
85 | break; |
||
86 | // **************************************************************************************************************** |
||
87 | case 'add': // Ajout d'une promotion |
||
88 | |||
89 | case 'edit': // Edition d'une promo |
||
90 | |||
91 | // **************************************************************************************************************** |
||
92 | |||
93 | xoops_cp_header(); |
||
94 | //oledrion_adminMenu(7); |
||
95 | if ('edit' === $action) { |
||
96 | $title = _AM_OLEDRION_EDIT_DISCOUNT; |
||
97 | $id = \Xmf\Request::getInt('id', 0, 'GET'); |
||
98 | if (empty($id)) { |
||
99 | Oledrion\Utility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5); |
||
100 | } |
||
101 | // Item exits ? |
||
102 | $item = null; |
||
103 | $item = $discountsHandler->get($id); |
||
104 | if (!is_object($item)) { |
||
105 | Oledrion\Utility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl, 5); |
||
106 | } |
||
107 | $edit = true; |
||
108 | $label_submit = _AM_OLEDRION_MODIFY; |
||
109 | } else { |
||
110 | $title = _AM_OLEDRION_ADD_DSICOUNT; |
||
111 | $item = $discountsHandler->create(true); |
||
112 | $label_submit = _AM_OLEDRION_ADD; |
||
113 | $edit = false; |
||
114 | } |
||
115 | |||
116 | require_once XOOPS_ROOT_PATH . '/class/template.php'; |
||
117 | global $xoopsTpl; |
||
118 | // $xoopsTpl = new \XoopsTpl(); |
||
119 | $xoopsTpl->assign('formTitle', $title); |
||
120 | $xoopsTpl->assign('action', 'edit'); |
||
121 | $xoopsTpl->assign('baseurl', $baseurl); |
||
122 | $xoopsTpl->assign('label_submit', $label_submit); |
||
123 | $discountForTemplate = $item->toArray(); |
||
124 | $discountForTemplate['disc_pediod_checked'] = $item->getVar('disc_date_from') > 0 && $item->getVar('disc_date_to') > 0 ? 'checked' : ''; |
||
125 | |||
126 | $disc_date_from = new \XoopsFormTextDateSelect(_AM_OLEDRION_DISCOUNT_PERFROM, 'disc_date_from', 15, $item->getVar('disc_date_from')); |
||
127 | $discountForTemplate['disc_date_from'] = $disc_date_from->render(); |
||
128 | $disc_date_to = new \XoopsFormTextDateSelect(_AM_OLEDRION_DISCOUNT_PERTO, 'disc_date_to', 15, $item->getVar('disc_date_to')); |
||
129 | $discountForTemplate['disc_date_to'] = $disc_date_to->render(); |
||
130 | |||
131 | $reductionType0 = $reductionType1 = $reductionType2 = ''; |
||
132 | $checked = 'checked'; |
||
133 | |||
134 | switch ($item->getVar('disc_price_type')) { |
||
135 | case Constants::OLEDRION_DISCOUNT_PRICE_TYPE0: |
||
136 | |||
137 | $reductionType0 = $checked; |
||
138 | |||
139 | break; |
||
140 | case Constants::OLEDRION_DISCOUNT_PRICE_TYPE1: |
||
141 | |||
142 | $reductionType1 = $checked; |
||
143 | |||
144 | break; |
||
145 | case Constants::OLEDRION_DISCOUNT_PRICE_TYPE2: |
||
146 | |||
147 | $reductionType2 = $checked; |
||
148 | |||
149 | break; |
||
150 | } |
||
151 | $discountForTemplate['disc_price_type_checked0'] = $reductionType0; |
||
152 | $discountForTemplate['disc_price_type_checked1'] = $reductionType1; |
||
153 | $discountForTemplate['disc_price_type_checked2'] = $reductionType2; |
||
154 | // **** |
||
155 | $disc_price_amount_type1 = $disc_price_amount_type2 = ''; |
||
156 | if (Constants::OLEDRION_DISCOUNT_PRICE_REDUCE_PERCENT == $item->getVar('disc_price_amount_type')) { |
||
157 | $disc_price_amount_type1 = $checked; |
||
158 | } elseif (Constants::OLEDRION_DISCOUNT_PRICE_REDUCE_MONEY == $item->getVar('disc_price_amount_type')) { |
||
159 | $disc_price_amount_type2 = $checked; |
||
160 | } |
||
161 | $discountForTemplate['disc_price_amount_type_checked1'] = $disc_price_amount_type1; |
||
162 | $discountForTemplate['disc_price_amount_type_checked2'] = $disc_price_amount_type2; |
||
163 | // **** |
||
164 | $disc_price_amount_on_checked1 = $disc_price_amount_on_checked2 = ''; |
||
165 | if (Constants::OLEDRION_DISCOUNT_PRICE_AMOUNT_ON_PRODUCT == $item->getVar('disc_price_amount_on')) { |
||
166 | $disc_price_amount_on_checked1 = $checked; |
||
167 | } elseif (Constants::OLEDRION_DISCOUNT_PRICE_AMOUNT_ON_CART == $item->getVar('disc_price_amount_on')) { |
||
168 | $disc_price_amount_on_checked2 = $checked; |
||
169 | } |
||
170 | $discountForTemplate['disc_price_amount_on_checked1'] = $disc_price_amount_on_checked1; |
||
171 | $discountForTemplate['disc_price_amount_on_checked2'] = $disc_price_amount_on_checked2; |
||
172 | // **** |
||
173 | $disc_price_case_checked1 = $disc_price_case_checked2 = $disc_price_case_checked3 = $disc_price_case_checked4 = ''; |
||
174 | switch ($item->getVar('disc_price_case')) { |
||
175 | case Constants::OLEDRION_DISCOUNT_PRICE_CASE_ALL: |
||
176 | |||
177 | $disc_price_case_checked1 = $checked; |
||
178 | |||
179 | break; |
||
180 | case Constants::OLEDRION_DISCOUNT_PRICE_CASE_FIRST_BUY: |
||
181 | |||
182 | $disc_price_case_checked2 = $checked; |
||
183 | |||
184 | break; |
||
185 | case Constants::OLEDRION_DISCOUNT_PRICE_CASE_PRODUCT_NEVER: |
||
186 | |||
187 | $disc_price_case_checked3 = $checked; |
||
188 | |||
189 | break; |
||
190 | case Constants::OLEDRION_DISCOUNT_PRICE_CASE_QTY_IS: |
||
191 | |||
192 | $disc_price_case_checked4 = $checked; |
||
193 | |||
194 | break; |
||
195 | } |
||
196 | $discountForTemplate['disc_price_case_checked1'] = $disc_price_case_checked1; |
||
197 | $discountForTemplate['disc_price_case_checked2'] = $disc_price_case_checked2; |
||
198 | $discountForTemplate['disc_price_case_checked3'] = $disc_price_case_checked3; |
||
199 | $discountForTemplate['disc_price_case_checked4'] = $disc_price_case_checked4; |
||
200 | |||
201 | // **** |
||
202 | $quantityConditions = [ |
||
203 | Constants::OLEDRION_DISCOUNT_PRICE_QTY_COND1 => Constants::OLEDRION_DISCOUNT_PRICE_QTY_COND1_TEXT, |
||
204 | Constants::OLEDRION_DISCOUNT_PRICE_QTY_COND2 => Constants::OLEDRION_DISCOUNT_PRICE_QTY_COND2_TEXT, |
||
205 | Constants::OLEDRION_DISCOUNT_PRICE_QTY_COND3 => Constants::OLEDRION_DISCOUNT_PRICE_QTY_COND3_TEXT, |
||
206 | Constants::OLEDRION_DISCOUNT_PRICE_QTY_COND4 => Constants::OLEDRION_DISCOUNT_PRICE_QTY_COND4_TEXT, |
||
207 | Constants::OLEDRION_DISCOUNT_PRICE_QTY_COND5 => Constants::OLEDRION_DISCOUNT_PRICE_QTY_COND5_TEXT, |
||
208 | ]; |
||
209 | $xoopsTpl->assign('disc_price_case_qty_cond_options', $quantityConditions); |
||
210 | $xoopsTpl->assign('disc_price_case_qty_cond_selected', $item->getVar('disc_price_case_qty_cond')); |
||
211 | |||
212 | // **** Réductions sur les frais de port **** |
||
213 | $disc_shipping_type_checked1 = $disc_shipping_type_checked2 = $disc_shipping_type_checked3 = $disc_shipping_type_checked4 = ''; |
||
214 | switch ($item->getVar('disc_shipping_type')) { |
||
215 | case Constants::OLEDRION_DISCOUNT_SHIPPING_TYPE1: |
||
216 | |||
217 | $disc_shipping_type_checked1 = $checked; |
||
218 | |||
219 | break; |
||
220 | case Constants::OLEDRION_DISCOUNT_SHIPPING_TYPE2: |
||
221 | |||
222 | $disc_shipping_type_checked2 = $checked; |
||
223 | |||
224 | break; |
||
225 | case Constants::OLEDRION_DISCOUNT_SHIPPING_TYPE3: |
||
226 | |||
227 | $disc_shipping_type_checked3 = $checked; |
||
228 | |||
229 | break; |
||
230 | case Constants::OLEDRION_DISCOUNT_SHIPPING_TYPE4: |
||
231 | |||
232 | $disc_shipping_type_checked4 = $checked; |
||
233 | |||
234 | break; |
||
235 | } |
||
236 | $discountForTemplate['disc_shipping_type_checked1'] = $disc_shipping_type_checked1; |
||
237 | $discountForTemplate['disc_shipping_type_checked2'] = $disc_shipping_type_checked2; |
||
238 | $discountForTemplate['disc_shipping_type_checked3'] = $disc_shipping_type_checked3; |
||
239 | $discountForTemplate['disc_shipping_type_checked4'] = $disc_shipping_type_checked4; |
||
240 | |||
241 | // Groupes |
||
242 | $xoopsTpl->assign('disc_groups_selected', $item->getVar('disc_group')); |
||
243 | /** @var \XoopsMemberHandler $memberHandler */ |
||
244 | $memberHandler = xoops_getHandler('member'); |
||
245 | $groups = $memberHandler->getGroupList(); |
||
246 | $groups[0] = _ALL; |
||
247 | ksort($groups); |
||
248 | $xoopsTpl->assign('disc_groups_options', $groups); |
||
249 | |||
250 | // Catégories |
||
251 | $categories = $categoryHandler->getAllCategories(new Oledrion\Parameters()); |
||
252 | $mytree = new Oledrion\XoopsObjectTree($categories, 'cat_cid', 'cat_pid'); |
||
253 | |||
254 | $categoriesSelect0 = $mytree->makeSelectElement('disc_cat_cid', 'cat_title', '-', $item->getVar('disc_cat_cid'), true, 0, '', ''); |
||
255 | $categoriesSelect = $categoriesSelect0->render(); |
||
256 | $discountForTemplate['disc_cat_cid_select'] = $categoriesSelect; |
||
257 | |||
258 | // Fabricants |
||
259 | $vendors = $vendorsHandler->getList(); |
||
260 | $vendors[0] = _ALL; |
||
261 | ksort($vendors); |
||
262 | |||
263 | $xoopsTpl->assign('disc_vendor_id_options', $vendors); |
||
264 | $xoopsTpl->assign('disc_vendor_id_selected', $item->getVar('disc_vendor_id')); |
||
265 | |||
266 | // Catégorie |
||
267 | $xoopsTpl->assign('disc_cat_cid_options', $categoriesSelect); |
||
268 | |||
269 | // Produits |
||
270 | $products = $productsHandler->getList(); |
||
271 | $products[0] = _ALL; |
||
272 | ksort($products); |
||
273 | $xoopsTpl->assign('disc_product_id_options', $products); |
||
274 | $xoopsTpl->assign('disc_product_id_selected', $item->getVar('disc_product_id')); |
||
275 | |||
276 | $productsSelect = $productsHandler->productSelector(new Oledrion\Parameters([ |
||
277 | 'caption' => _AM_OLEDRION_DISCOUNT_PRODUCT, |
||
278 | 'name' => 'disc_product_id', |
||
279 | 'value' => $item->getVar('disc_product_id'), |
||
280 | 'size' => 1, |
||
281 | 'multiple' => false, |
||
282 | 'values' => null, |
||
283 | 'showAll' => true, |
||
284 | 'sort' => 'product_title', |
||
285 | 'order' => 'ASC', |
||
286 | 'formName' => 'frmdiscount', |
||
287 | 'description' => _AM_OLEDRION_DISCOUNT_HELP1, |
||
288 | 'withNull' => _ALL, |
||
289 | ])); |
||
290 | $xoopsTpl->assign('disc_product_id', $productsSelect->render()); |
||
291 | |||
292 | $xoopsTpl->assign('discount', $discountForTemplate); |
||
293 | $xoopsTpl->assign('currencyName', Oledrion\Utility::getModuleOption('money_short')); |
||
294 | //$editor = Oledrion\Utility::getWysiwygForm(_AM_OLEDRION_DISCOUNT_DESCR, 'disc_description', $item->getVar('disc_description','e'), 15, 60, 'description_hidden'); |
||
295 | //$xoopsTpl->assign('editor', $editor->render()); |
||
296 | |||
297 | $xoopsTpl->display('db:oledrion_admin_discounts.tpl'); |
||
298 | require_once OLEDRION_ADMIN_PATH . 'admin_footer.php'; |
||
299 | |||
300 | break; |
||
301 | // **************************************************************************************************************** |
||
302 | case 'copy': // Duplication d'une réduction |
||
303 | |||
304 | // **************************************************************************************************************** |
||
305 | xoops_cp_header(); |
||
306 | $id = \Xmf\Request::getInt('id', 0, 'GET'); |
||
307 | if (empty($id)) { |
||
308 | Oledrion\Utility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5); |
||
309 | } |
||
310 | $opRedirect = 'discounts'; |
||
311 | $item = null; |
||
312 | $item = $discountsHandler->get($id); |
||
313 | if (is_object($item)) { |
||
314 | $newDiscount = $item->xoopsClone(); |
||
315 | if (OLEDRION_DUPLICATED_PLACE === 'right') { |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
316 | $newDiscount->setVar('disc_title', xoops_trim($item->getVar('disc_title')) . ' ' . _AM_OLEDRION_DUPLICATED); |
||
317 | } else { |
||
318 | $newDiscount->setVar('disc_title', _AM_OLEDRION_DUPLICATED . ' ' . xoops_trim($item->getVar('disc_title'))); |
||
319 | } |
||
320 | $newDiscount->setVar('disc_id', 0); |
||
321 | $newDiscount->setNew(); |
||
322 | $res = $discountsHandler->insert($newDiscount, true); |
||
323 | if ($res) { |
||
324 | Oledrion\Utility::updateCache(); |
||
325 | Oledrion\Utility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2); |
||
326 | } else { |
||
327 | Oledrion\Utility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5); |
||
328 | } |
||
329 | } else { |
||
330 | Oledrion\Utility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5); |
||
331 | } |
||
332 | |||
333 | break; |
||
334 | // **************************************************************************************************************** |
||
335 | case 'saveedit': // Enregistrement d'une réduction après modification ou ajout |
||
336 | |||
337 | // **************************************************************************************************************** |
||
338 | xoops_cp_header(); |
||
339 | $id = \Xmf\Request::getInt('disc_id', 0, 'POST'); |
||
340 | if (!empty($id)) { |
||
341 | $edit = true; |
||
342 | $item = $discountsHandler->get($id); |
||
343 | if (!is_object($item)) { |
||
344 | Oledrion\Utility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl, 5); |
||
345 | } |
||
346 | $item->unsetNew(); |
||
347 | } else { |
||
348 | $item = $discountsHandler->create(true); |
||
349 | } |
||
350 | $opRedirect = 'discounts'; |
||
351 | $item->setVars($_POST); |
||
352 | if (\Xmf\Request::hasVar('disc_pediod', 'POST') && 1 == \Xmf\Request::getInt('disc_pediod', 0, 'POST')) { |
||
353 | $item->setVar('disc_date_from', strtotime($_POST['disc_date_from'])); |
||
354 | $item->setVar('disc_date_to', strtotime($_POST['disc_date_to'])); |
||
355 | } else { |
||
356 | $item->setVar('disc_date_from', 0); |
||
357 | $item->setVar('disc_date_to', 0); |
||
358 | } |
||
359 | $res = $discountsHandler->insert($item); |
||
360 | if ($res) { |
||
361 | Oledrion\Utility::updateCache(); |
||
362 | Oledrion\Utility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2); |
||
363 | } else { |
||
364 | Oledrion\Utility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5); |
||
365 | } |
||
366 | |||
367 | break; |
||
368 | // **************************************************************************************************************** |
||
369 | case 'delete': // Suppression d'une réduction |
||
370 | |||
371 | // **************************************************************************************************************** |
||
372 | xoops_cp_header(); |
||
373 | $id = \Xmf\Request::getInt('id', 0, 'GET'); |
||
374 | if (empty($id)) { |
||
375 | Oledrion\Utility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5); |
||
376 | } |
||
377 | $opRedirect = 'discounts'; |
||
378 | $item = $discountsHandler->get($id); |
||
379 | if (is_object($item)) { |
||
380 | $res = $discountsHandler->delete($item, true); |
||
381 | if ($res) { |
||
382 | Oledrion\Utility::updateCache(); |
||
383 | Oledrion\Utility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2); |
||
384 | } else { |
||
385 | Oledrion\Utility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5); |
||
386 | } |
||
387 | } else { |
||
388 | Oledrion\Utility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5); |
||
389 | } |
||
390 | |||
391 | break; |
||
392 | } |
||
393 |