Nickbur /
Sunrise-CMS
| 1 | <?php |
||
| 2 | |||
| 3 | /* Divine CMS - Open source CMS for widespread use. |
||
| 4 | Copyright (c) 2019 Mykola Burakov ([email protected]) |
||
| 5 | |||
| 6 | See SOURCE.txt for other and additional information. |
||
| 7 | |||
| 8 | This file is part of Divine CMS. |
||
| 9 | |||
| 10 | This program is free software: you can redistribute it and/or modify |
||
| 11 | it under the terms of the GNU General Public License as published by |
||
| 12 | the Free Software Foundation, either version 3 of the License, or |
||
| 13 | (at your option) any later version. |
||
| 14 | |||
| 15 | This program is distributed in the hope that it will be useful, |
||
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 18 | GNU General Public License for more details. |
||
| 19 | |||
| 20 | You should have received a copy of the GNU General Public License |
||
| 21 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
||
| 22 | |||
| 23 | class ControllerDesignBenefit extends \Divine\Engine\Core\Controller |
||
|
0 ignored issues
–
show
|
|||
| 24 | { |
||
| 25 | private $error = array(); |
||
| 26 | |||
| 27 | public function index() |
||
|
0 ignored issues
–
show
|
|||
| 28 | { |
||
| 29 | $this->language->load('design/benefit'); |
||
| 30 | |||
| 31 | $this->document->setTitle($this->language->get('heading_title')); |
||
| 32 | |||
| 33 | $this->load->model('design/benefit'); |
||
| 34 | |||
| 35 | $this->getList(); |
||
| 36 | } |
||
| 37 | |||
| 38 | public function add() |
||
| 39 | { |
||
| 40 | $this->language->load('design/benefit'); |
||
| 41 | |||
| 42 | $this->document->setTitle($this->language->get('heading_title')); |
||
| 43 | |||
| 44 | $this->load->model('design/benefit'); |
||
| 45 | |||
| 46 | if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) { |
||
| 47 | $this->model_design_benefit->addBenefit($this->request->post); |
||
| 48 | |||
| 49 | $this->session->data['success'] = $this->language->get('text_success'); |
||
| 50 | |||
| 51 | $url = ''; |
||
| 52 | |||
| 53 | if (isset($this->request->get['sort'])) { |
||
| 54 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 55 | } |
||
| 56 | |||
| 57 | if (isset($this->request->get['order'])) { |
||
| 58 | $url .= '&order=' . $this->request->get['order']; |
||
| 59 | } |
||
| 60 | |||
| 61 | if (isset($this->request->get['page'])) { |
||
| 62 | $url .= '&page=' . $this->request->get['page']; |
||
| 63 | } |
||
| 64 | |||
| 65 | $this->response->redirect($this->url->link('design/benefit', 'token=' . $this->session->data['token'] . $url, true)); |
||
| 66 | } |
||
| 67 | |||
| 68 | $this->getForm(); |
||
| 69 | } |
||
| 70 | |||
| 71 | public function edit() |
||
| 72 | { |
||
| 73 | $this->language->load('design/benefit'); |
||
| 74 | |||
| 75 | $this->document->setTitle($this->language->get('heading_title')); |
||
| 76 | |||
| 77 | $this->load->model('design/benefit'); |
||
| 78 | |||
| 79 | if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) { |
||
| 80 | $this->model_design_benefit->editBenefit($this->request->get['benefit_id'], $this->request->post); |
||
| 81 | |||
| 82 | $this->session->data['success'] = $this->language->get('text_success'); |
||
| 83 | |||
| 84 | $url = ''; |
||
| 85 | |||
| 86 | if (isset($this->request->get['sort'])) { |
||
| 87 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 88 | } |
||
| 89 | |||
| 90 | if (isset($this->request->get['order'])) { |
||
| 91 | $url .= '&order=' . $this->request->get['order']; |
||
| 92 | } |
||
| 93 | |||
| 94 | if (isset($this->request->get['page'])) { |
||
| 95 | $url .= '&page=' . $this->request->get['page']; |
||
| 96 | } |
||
| 97 | |||
| 98 | $this->response->redirect($this->url->link('design/benefit', 'token=' . $this->session->data['token'] . $url, true)); |
||
| 99 | } |
||
| 100 | |||
| 101 | $this->getForm(); |
||
| 102 | } |
||
| 103 | |||
| 104 | public function delete() |
||
| 105 | { |
||
| 106 | $this->language->load('design/benefit'); |
||
| 107 | |||
| 108 | $this->document->setTitle($this->language->get('heading_title')); |
||
| 109 | |||
| 110 | $this->load->model('design/benefit'); |
||
| 111 | |||
| 112 | if (isset($this->request->post['selected']) && $this->validateDelete()) { |
||
| 113 | foreach ($this->request->post['selected'] as $benefit_id) { |
||
| 114 | $this->model_design_benefit->deleteBenefit($benefit_id); |
||
| 115 | } |
||
| 116 | |||
| 117 | $this->session->data['success'] = $this->language->get('text_success'); |
||
| 118 | |||
| 119 | $url = ''; |
||
| 120 | |||
| 121 | if (isset($this->request->get['sort'])) { |
||
| 122 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 123 | } |
||
| 124 | |||
| 125 | if (isset($this->request->get['order'])) { |
||
| 126 | $url .= '&order=' . $this->request->get['order']; |
||
| 127 | } |
||
| 128 | |||
| 129 | if (isset($this->request->get['page'])) { |
||
| 130 | $url .= '&page=' . $this->request->get['page']; |
||
| 131 | } |
||
| 132 | |||
| 133 | $this->response->redirect($this->url->link('design/benefit', 'token=' . $this->session->data['token'] . $url, true)); |
||
| 134 | } |
||
| 135 | |||
| 136 | $this->getList(); |
||
| 137 | } |
||
| 138 | |||
| 139 | protected function getList() |
||
| 140 | { |
||
| 141 | if (isset($this->request->get['sort'])) { |
||
| 142 | $sort = $this->request->get['sort']; |
||
| 143 | } else { |
||
| 144 | $sort = 'name'; |
||
| 145 | } |
||
| 146 | |||
| 147 | if (isset($this->request->get['order'])) { |
||
| 148 | $order = $this->request->get['order']; |
||
| 149 | } else { |
||
| 150 | $order = 'ASC'; |
||
| 151 | } |
||
| 152 | |||
| 153 | if (isset($this->request->get['page'])) { |
||
| 154 | $page = $this->request->get['page']; |
||
| 155 | } else { |
||
| 156 | $page = 1; |
||
| 157 | } |
||
| 158 | |||
| 159 | $url = ''; |
||
| 160 | |||
| 161 | if (isset($this->request->get['sort'])) { |
||
| 162 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 163 | } |
||
| 164 | |||
| 165 | if (isset($this->request->get['order'])) { |
||
| 166 | $url .= '&order=' . $this->request->get['order']; |
||
| 167 | } |
||
| 168 | |||
| 169 | if (isset($this->request->get['page'])) { |
||
| 170 | $url .= '&page=' . $this->request->get['page']; |
||
| 171 | } |
||
| 172 | |||
| 173 | $data['breadcrumbs'] = array(); |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 174 | |||
| 175 | $data['breadcrumbs'][] = array( |
||
| 176 | 'text' => $this->language->get('text_home'), |
||
| 177 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true), |
||
| 178 | 'separator' => false |
||
| 179 | ); |
||
| 180 | |||
| 181 | $data['breadcrumbs'][] = array( |
||
| 182 | 'text' => $this->language->get('heading_title'), |
||
| 183 | 'href' => $this->url->link('design/benefit', 'token=' . $this->session->data['token'] . $url, true), |
||
| 184 | 'separator' => ' :: ' |
||
| 185 | ); |
||
| 186 | |||
| 187 | $data['add'] = $this->url->link('design/benefit/add', 'token=' . $this->session->data['token'] . $url, true); |
||
| 188 | $data['delete'] = $this->url->link('design/benefit/delete', 'token=' . $this->session->data['token'] . $url, true); |
||
| 189 | |||
| 190 | $data['benefits'] = array(); |
||
| 191 | |||
| 192 | $filter_data = array( |
||
| 193 | 'sort' => $sort, |
||
| 194 | 'order' => $order, |
||
| 195 | 'start' => ($page - 1) * $this->config->get('config_limit_admin'), |
||
| 196 | 'limit' => $this->config->get('config_limit_admin') |
||
| 197 | ); |
||
| 198 | |||
| 199 | $benefit_total = $this->model_design_benefit->getTotalBenefits(); |
||
| 200 | |||
| 201 | $results = $this->model_design_benefit->getBenefits($filter_data); |
||
| 202 | |||
| 203 | |||
| 204 | |||
| 205 | foreach ($results as $result) { |
||
| 206 | if ($result['image'] && file_exists($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $result['image'])) { |
||
| 207 | $image = '/public_html/assets/images/' . $result['image']; |
||
| 208 | } else { |
||
| 209 | $image = '/public_html/assets/images/no_image.png'; |
||
| 210 | } |
||
| 211 | |||
| 212 | $data['benefits'][] = array( |
||
| 213 | 'benefit_id' => $result['benefit_id'], |
||
| 214 | 'name' => $result['name'], |
||
| 215 | 'status' => ($result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled')), |
||
| 216 | 'edit' => $this->url->link('design/benefit/edit', 'token=' . $this->session->data['token'] . '&benefit_id=' . $result['benefit_id'] . $url, true), |
||
| 217 | 'image' => $image, |
||
| 218 | ); |
||
| 219 | } |
||
| 220 | |||
| 221 | $data['heading_title'] = $this->language->get('heading_title'); |
||
| 222 | |||
| 223 | $data['text_list'] = $this->language->get('text_list'); |
||
| 224 | $data['text_no_results'] = $this->language->get('text_no_results'); |
||
| 225 | $data['text_confirm'] = $this->language->get('text_confirm'); |
||
| 226 | |||
| 227 | $data['column_image'] = $this->language->get('column_image'); |
||
| 228 | $data['column_name'] = $this->language->get('column_name'); |
||
| 229 | $data['column_status'] = $this->language->get('column_status'); |
||
| 230 | $data['column_action'] = $this->language->get('column_action'); |
||
| 231 | |||
| 232 | $data['button_add'] = $this->language->get('button_add'); |
||
| 233 | $data['button_edit'] = $this->language->get('button_edit'); |
||
| 234 | $data['button_delete'] = $this->language->get('button_delete'); |
||
| 235 | |||
| 236 | |||
| 237 | |||
| 238 | if (isset($this->error['warning'])) { |
||
| 239 | $data['error_warning'] = $this->error['warning']; |
||
| 240 | } else { |
||
| 241 | $data['error_warning'] = ''; |
||
| 242 | } |
||
| 243 | |||
| 244 | if (isset($this->session->data['success'])) { |
||
| 245 | $data['success'] = $this->session->data['success']; |
||
| 246 | |||
| 247 | unset($this->session->data['success']); |
||
| 248 | } else { |
||
| 249 | $data['success'] = ''; |
||
| 250 | } |
||
| 251 | |||
| 252 | if (isset($this->request->post['selected'])) { |
||
| 253 | $data['selected'] = (array)$this->request->post['selected']; |
||
| 254 | } else { |
||
| 255 | $data['selected'] = array(); |
||
| 256 | } |
||
| 257 | |||
| 258 | $url = ''; |
||
| 259 | |||
| 260 | if ($order == 'ASC') { |
||
| 261 | $url .= '&order=DESC'; |
||
| 262 | } else { |
||
| 263 | $url .= '&order=ASC'; |
||
| 264 | } |
||
| 265 | |||
| 266 | if (isset($this->request->get['page'])) { |
||
| 267 | $url .= '&page=' . $this->request->get['page']; |
||
| 268 | } |
||
| 269 | |||
| 270 | $data['sort_name'] = $this->url->link('design/benefit', 'token=' . $this->session->data['token'] . '&sort=name' . $url, true); |
||
| 271 | $data['sort_status'] = $this->url->link('design/benefit', 'token=' . $this->session->data['token'] . '&sort=status' . $url, true); |
||
| 272 | |||
| 273 | $url = ''; |
||
| 274 | |||
| 275 | if (isset($this->request->get['sort'])) { |
||
| 276 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 277 | } |
||
| 278 | |||
| 279 | if (isset($this->request->get['order'])) { |
||
| 280 | $url .= '&order=' . $this->request->get['order']; |
||
| 281 | } |
||
| 282 | |||
| 283 | $pagination = new \Divine\Engine\Library\Pagination(); |
||
| 284 | $pagination->total = $benefit_total; |
||
| 285 | $pagination->page = $page; |
||
| 286 | $pagination->limit = $this->config->get('config_limit_admin'); |
||
| 287 | $pagination->url = $this->url->link('design/benefit', 'token=' . $this->session->data['token'] . $url . '&page={page}', true); |
||
| 288 | |||
| 289 | $data['pagination'] = $pagination->render(); |
||
| 290 | |||
| 291 | $data['results'] = sprintf($this->language->get('text_pagination'), ($benefit_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($benefit_total - $this->config->get('config_limit_admin'))) ? $benefit_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $benefit_total, ceil($benefit_total / $this->config->get('config_limit_admin'))); |
||
| 292 | |||
| 293 | $data['sort'] = $sort; |
||
| 294 | $data['order'] = $order; |
||
| 295 | |||
| 296 | $data['header'] = $this->load->controller('common/header'); |
||
| 297 | $data['column'] = $this->load->controller('common/column_left'); |
||
| 298 | $data['footer'] = $this->load->controller('common/footer'); |
||
| 299 | |||
| 300 | $this->response->setOutput($this->load->view('design/benefit_list', $data)); |
||
| 301 | } |
||
| 302 | |||
| 303 | protected function getForm() |
||
| 304 | { |
||
| 305 | $data['heading_title'] = $this->language->get('heading_title'); |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 306 | |||
| 307 | $data['text_form'] = !isset($this->request->get['benefit_id']) ? $this->language->get('text_add') : $this->language->get('text_edit'); |
||
| 308 | $data['text_enabled'] = $this->language->get('text_enabled'); |
||
| 309 | $data['text_disabled'] = $this->language->get('text_disabled'); |
||
| 310 | $data['text_default'] = $this->language->get('text_default'); |
||
| 311 | $data['text_image_manager'] = $this->language->get('text_image_manager'); |
||
| 312 | $data['text_browse'] = $this->language->get('text_browse'); |
||
| 313 | $data['text_clear'] = $this->language->get('text_clear'); |
||
| 314 | $data['text_type_benefit'] = $this->language->get('text_type_benefit'); |
||
| 315 | $data['text_type_gift'] = $this->language->get('text_type_gift'); |
||
| 316 | |||
| 317 | $data['entry_name'] = $this->language->get('entry_name'); |
||
| 318 | $data['entry_image'] = $this->language->get('entry_image'); |
||
| 319 | $data['entry_link'] = $this->language->get('entry_link'); |
||
| 320 | $data['entry_status'] = $this->language->get('entry_status'); |
||
| 321 | $data['entry_type'] = $this->language->get('entry_type'); |
||
| 322 | $data['entry_description'] = $this->language->get('entry_description'); |
||
| 323 | |||
| 324 | $data['button_save'] = $this->language->get('button_save'); |
||
| 325 | $data['button_cancel'] = $this->language->get('button_cancel'); |
||
| 326 | $data['button_remove'] = $this->language->get('button_remove'); |
||
| 327 | |||
| 328 | if (isset($this->error['warning'])) { |
||
| 329 | $data['error_warning'] = $this->error['warning']; |
||
| 330 | } else { |
||
| 331 | $data['error_warning'] = ''; |
||
| 332 | } |
||
| 333 | |||
| 334 | if (isset($this->error['name'])) { |
||
| 335 | $data['error_name'] = $this->error['name']; |
||
| 336 | } else { |
||
| 337 | $data['error_name'] = ''; |
||
| 338 | } |
||
| 339 | |||
| 340 | $url = ''; |
||
| 341 | |||
| 342 | if (isset($this->request->get['sort'])) { |
||
| 343 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 344 | } |
||
| 345 | |||
| 346 | if (isset($this->request->get['order'])) { |
||
| 347 | $url .= '&order=' . $this->request->get['order']; |
||
| 348 | } |
||
| 349 | |||
| 350 | if (isset($this->request->get['page'])) { |
||
| 351 | $url .= '&page=' . $this->request->get['page']; |
||
| 352 | } |
||
| 353 | |||
| 354 | $data['breadcrumbs'] = array(); |
||
| 355 | |||
| 356 | $data['breadcrumbs'][] = array( |
||
| 357 | 'text' => $this->language->get('text_home'), |
||
| 358 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true), |
||
| 359 | 'separator' => false |
||
| 360 | ); |
||
| 361 | |||
| 362 | $data['breadcrumbs'][] = array( |
||
| 363 | 'text' => $this->language->get('heading_title'), |
||
| 364 | 'href' => $this->url->link('design/benefit', 'token=' . $this->session->data['token'] . $url, true), |
||
| 365 | 'separator' => ' :: ' |
||
| 366 | ); |
||
| 367 | |||
| 368 | if (!isset($this->request->get['benefit_id'])) { |
||
| 369 | $data['action'] = $this->url->link('design/benefit/add', 'token=' . $this->session->data['token'] . $url, true); |
||
| 370 | } else { |
||
| 371 | $data['action'] = $this->url->link('design/benefit/edit', 'token=' . $this->session->data['token'] . '&benefit_id=' . $this->request->get['benefit_id'] . $url, true); |
||
| 372 | } |
||
| 373 | |||
| 374 | $data['cancel'] = $this->url->link('design/benefit', 'token=' . $this->session->data['token'] . $url, true); |
||
| 375 | |||
| 376 | if (isset($this->request->get['benefit_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) { |
||
| 377 | $benefit_info = $this->model_design_benefit->getBenefit($this->request->get['benefit_id']); |
||
| 378 | } |
||
| 379 | |||
| 380 | $data['token'] = $this->session->data['token']; |
||
| 381 | |||
| 382 | |||
| 383 | $this->load->model('localisation/language'); |
||
| 384 | |||
| 385 | $data['languages'] = $this->model_localisation_language->getLanguages(); |
||
| 386 | |||
| 387 | if (isset($this->request->post['benefit_description'])) { |
||
| 388 | $data['benefit_description'] = $this->request->post['benefit_description']; |
||
| 389 | } elseif (isset($this->request->get['benefit_id'])) { |
||
| 390 | $data['benefit_description'] = $this->model_design_benefit->getBenefitDescriptions($this->request->get['benefit_id']); |
||
| 391 | } else { |
||
| 392 | $data['benefit_description'] = array(); |
||
| 393 | } |
||
| 394 | |||
| 395 | |||
| 396 | if (isset($this->request->post['name'])) { |
||
| 397 | $data['name'] = $this->request->post['name']; |
||
| 398 | } elseif (!empty($benefit_info)) { |
||
| 399 | $data['name'] = $benefit_info['name']; |
||
| 400 | } else { |
||
| 401 | $data['name'] = ''; |
||
| 402 | } |
||
| 403 | |||
| 404 | if (isset($this->request->post['status'])) { |
||
| 405 | $data['status'] = $this->request->post['status']; |
||
| 406 | } elseif (!empty($benefit_info)) { |
||
| 407 | $data['status'] = $benefit_info['status']; |
||
| 408 | } else { |
||
| 409 | $data['status'] = true; |
||
| 410 | } |
||
| 411 | |||
| 412 | if (isset($this->request->post['type'])) { |
||
| 413 | $data['type'] = $this->request->post['type']; |
||
| 414 | } elseif (!empty($benefit_info)) { |
||
| 415 | $data['type'] = $benefit_info['type']; |
||
| 416 | } else { |
||
| 417 | $data['type'] = true; |
||
| 418 | } |
||
| 419 | |||
| 420 | if (isset($this->request->post['link'])) { |
||
| 421 | $data['link'] = $this->request->post['link']; |
||
| 422 | } elseif (!empty($benefit_info)) { |
||
| 423 | $data['link'] = $benefit_info['link']; |
||
| 424 | } else { |
||
| 425 | $data['link'] = ''; |
||
| 426 | } |
||
| 427 | |||
| 428 | if (isset($this->request->post['image'])) { |
||
| 429 | $data['image'] = $this->request->post['image']; |
||
| 430 | } elseif (!empty($benefit_info)) { |
||
| 431 | $data['image'] = $benefit_info['image']; |
||
| 432 | } else { |
||
| 433 | $data['image'] = ''; |
||
| 434 | } |
||
| 435 | |||
| 436 | |||
| 437 | |||
| 438 | if (isset($this->request->post['image']) && file_exists($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $this->request->post['image'])) { |
||
| 439 | $data['thumb'] = '/public_html/assets/images/' . $this->request->post['image']; |
||
| 440 | } elseif (!empty($benefit_info) && $benefit_info['image'] && file_exists($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $benefit_info['image'])) { |
||
| 441 | $data['thumb'] = '/public_html/assets/images/' . $benefit_info['image']; |
||
| 442 | } else { |
||
| 443 | $data['thumb'] = '/public_html/assets/images/no_image.png'; |
||
| 444 | } |
||
| 445 | |||
| 446 | $data['placeholder'] = '/public_html/assets/images/no_image.png'; |
||
| 447 | |||
| 448 | $data['header'] = $this->load->controller('common/header'); |
||
| 449 | $data['column'] = $this->load->controller('common/column_left'); |
||
| 450 | $data['footer'] = $this->load->controller('common/footer'); |
||
| 451 | |||
| 452 | $this->response->setOutput($this->load->view('design/benefit_form', $data)); |
||
| 453 | } |
||
| 454 | |||
| 455 | protected function validateForm() |
||
| 456 | { |
||
| 457 | if (!$this->user->hasPermission('modify', 'design/benefit')) { |
||
| 458 | $this->error['warning'] = $this->language->get('error_permission'); |
||
| 459 | } |
||
| 460 | |||
| 461 | if ((\voku\helper\UTF8::strlen($this->request->post['name']) < 3) || (\voku\helper\UTF8::strlen($this->request->post['name']) > 64)) { |
||
| 462 | $this->error['name'] = $this->language->get('error_name'); |
||
| 463 | } |
||
| 464 | |||
| 465 | if (!$this->error) { |
||
|
0 ignored issues
–
show
The expression
$this->error of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using Loading history...
|
|||
| 466 | return true; |
||
| 467 | } else { |
||
| 468 | return false; |
||
| 469 | } |
||
| 470 | } |
||
| 471 | |||
| 472 | protected function validateDelete() |
||
| 473 | { |
||
| 474 | if (!$this->user->hasPermission('modify', 'design/benefit')) { |
||
| 475 | $this->error['warning'] = $this->language->get('error_permission'); |
||
| 476 | } |
||
| 477 | |||
| 478 | if (isset($this->request->post['selected'])) { |
||
| 479 | $selected = implode(',', $this->request->post['selected']); |
||
| 480 | |||
| 481 | $count = $this->model_design_benefit->validateDelete($selected); |
||
| 482 | |||
| 483 | if ($count) { |
||
| 484 | $this->error['warning'] = sprintf($this->language->get('error_product'), $count); |
||
| 485 | }; |
||
| 486 | } |
||
| 487 | |||
| 488 | |||
| 489 | if (!$this->error) { |
||
|
0 ignored issues
–
show
The expression
$this->error of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using Loading history...
|
|||
| 490 | return true; |
||
| 491 | } else { |
||
| 492 | return false; |
||
| 493 | } |
||
| 494 | } |
||
| 495 | } |
||
| 496 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.