public function initProcess() { if (Tools::isSubmit('submitAddproductAndStay') || Tools::isSubmit('submitAddproduct')) { $this->id_object = (int) Tools::getValue('id_product'); $this->object = new Product($this->id_object); if ($this->isTabSubmitted('Informations') && $this->object->is_virtual && (int) Tools::getValue('type_product') != 2) { if ($id_product_download = (int) ProductDownload::getIdFromIdProduct($this->id_object)) { $product_download = new ProductDownload($id_product_download); if (!$product_download->deleteFile($id_product_download)) { $this->errors[] = Tools::displayError('Cannot delete file'); } } } } if (Tools::getValue('deleteVirtualProduct')) { if ($this->tabAccess['delete'] === '1') { $this->action = 'deleteVirtualProduct'; } else { $this->errors[] = Tools::displayError('You do not have permission to delete this.'); } } elseif (Tools::isSubmit('submitAddProductAndPreview')) { $this->display = 'edit'; $this->action = 'save'; if (Tools::getValue('id_product')) { $this->id_object = Tools::getValue('id_product'); $this->object = new Product((int) Tools::getValue('id_product')); } } elseif (Tools::isSubmit('submitAttachments')) { if ($this->tabAccess['edit'] === '1') { $this->action = 'attachments'; $this->tab_display = 'attachments'; } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } } elseif (Tools::getIsset('duplicate' . $this->table)) { if ($this->tabAccess['add'] === '1') { $this->action = 'duplicate'; } else { $this->errors[] = Tools::displayError('You do not have permission to add this.'); } } elseif (Tools::getValue('id_image') && Tools::getValue('ajax')) { if ($this->tabAccess['edit'] === '1') { $this->action = 'image'; } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } } elseif (Tools::isSubmit('submitProductAttribute')) { if ($this->tabAccess['edit'] === '1') { $this->action = 'productAttribute'; } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } } elseif (Tools::isSubmit('submitFeatures') || Tools::isSubmit('submitFeaturesAndStay')) { if ($this->tabAccess['edit'] === '1') { $this->action = 'features'; } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } } elseif (Tools::isSubmit('submitPricesModification')) { if ($this->tabAccess['add'] === '1') { $this->action = 'pricesModification'; } else { $this->errors[] = Tools::displayError('You do not have permission to add this.'); } } elseif (Tools::isSubmit('deleteSpecificPrice')) { if ($this->tabAccess['delete'] === '1') { $this->action = 'deleteSpecificPrice'; } else { $this->errors[] = Tools::displayError('You do not have permission to delete this.'); } } elseif (Tools::isSubmit('submitSpecificPricePriorities')) { if ($this->tabAccess['edit'] === '1') { $this->action = 'specificPricePriorities'; $this->tab_display = 'prices'; } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } } elseif (Tools::isSubmit('submitCustomizationConfiguration')) { if ($this->tabAccess['edit'] === '1') { $this->action = 'customizationConfiguration'; $this->tab_display = 'customization'; $this->display = 'edit'; } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } } elseif (Tools::isSubmit('submitProductCustomization')) { if ($this->tabAccess['edit'] === '1') { $this->action = 'productCustomization'; $this->tab_display = 'customization'; $this->display = 'edit'; } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } } elseif (Tools::isSubmit('id_product')) { $post_max_size = Tools::getMaxUploadSize(Configuration::get('PS_LIMIT_UPLOAD_FILE_VALUE') * 1024 * 1024); if ($post_max_size && isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH'] && $_SERVER['CONTENT_LENGTH'] > $post_max_size) { $this->errors[] = sprintf(Tools::displayError('The uploaded file exceeds the "Maximum size for a downloadable product" set in preferences (%1$dMB) or the post_max_size/ directive in php.ini (%2$dMB).'), number_format(Configuration::get('PS_LIMIT_UPLOAD_FILE_VALUE')), $post_max_size / 1024 / 1024); } } if (!$this->action) { parent::initProcess(); } else { $this->id_object = (int) Tools::getValue($this->identifier); } if (isset($this->available_tabs[Tools::getValue('key_tab')])) { $this->tab_display = Tools::getValue('key_tab'); } if (!$this->tab_display && $this->action) { if (in_array($this->action, array_keys($this->available_tabs))) { $this->tab_display = $this->action; } } if (!$this->tab_display) { if (in_array($this->default_tab, $this->available_tabs)) { $this->tab_display = $this->default_tab; } else { $this->tab_display = key($this->available_tabs); } } }