public function postProcess() { if ($id_tab = intval(Tools::getValue('id_tab')) and $direction = Tools::getValue('move') and Validate::isLoadedObject($tab = new Tab($id_tab))) { global $currentIndex; if ($tab->move($direction)) { Tools::redirectAdmin($currentIndex . '&token=' . $this->token); } } else { if (!Tools::getValue('position')) { $_POST['position'] = Tab::getNbTabs(Tools::getValue('id_parent')); } parent::postProcess(); } }
public function postProcess() { /* PrestaShop demo mode */ if (_PS_MODE_DEMO_) { $this->_errors[] = Tools::displayError('This functionnality has been disabled.'); return; } /* PrestaShop demo mode*/ if ($id_tab = (int) Tools::getValue('id_tab') and $direction = Tools::getValue('move') and Validate::isLoadedObject($tab = new Tab($id_tab))) { global $currentIndex; if ($tab->move($direction)) { Tools::redirectAdmin($currentIndex . '&token=' . $this->token); } } else { if (!Tools::getValue('position')) { $_POST['position'] = Tab::getNbTabs(Tools::getValue('id_parent')); } parent::postProcess(); } }
public function install() { //create log file SceauLogger::insertLogSceau(__METHOD__ . " : " . __LINE__, "Création du fichier de log"); /** database tables creation * */ $sqlfile = dirname(__FILE__) . '/install.sql'; if (!file_exists($sqlfile) || !($sql = Tools::file_get_contents($sqlfile))) { return false; } $sql = str_replace('PREFIX_', _DB_PREFIX_, $sql); $sql = str_replace('SCEAU_ORDER_TABLE_NAME', self::SCEAU_ORDER_TABLE_NAME, $sql); $sql = str_replace('SCEAU_STATE_TABLE_NAME', self::SCEAU_STATE_TABLE_NAME, $sql); $queries = preg_split("/;\\s*[\r\n]+/", $sql); foreach ($queries as $query) { if (!Db::getInstance()->Execute(trim($query))) { SceauLogger::insertLogSceau(__METHOD__ . " : " . __LINE__, "Installation failed, database creation failed : " . Db::getInstance()->getMsgError()); return false; } } //Sceau order statuses insertion foreach ($this->_fianetsceau_order_statuses as $id => $label) { $sql = "INSERT INTO `" . _DB_PREFIX_ . self::SCEAU_STATE_TABLE_NAME . "` (`id_fianetsceau_state`,`label`) VALUES ('" . (int) $id . "','" . pSQL((string) $label) . "')"; $insert = Db::getInstance()->execute($sql); if (!$insert) { SceauLogger::insertLogSceau(__METHOD__ . " : " . __LINE__, "Insertion state {$id}.{$label} échouée : " . Db::getInstance()->getMsgError()); } } //tabs creation $tab_admin_id_order = Tab::getIdFromClassName('AdminOrders'); //AdminSceauController registration $tab_controller_main = new Tab(); $tab_controller_main->active = 1; $tab_controller_main->class_name = "AdminSceau"; foreach (Language::getLanguages() as $language) { $tab_controller_main->name[$language['id_lang']] = "Sceau de Confiance"; } $tab_controller_main->id_parent = $tab_admin_id_order; $tab_controller_main->module = $this->name; $tab_controller_main->add(); $tab_controller_main->move($this->getNewLastPosition(0)); //Hook register return parent::install() && $this->registerHook('newOrder') && $this->registerHook('paymentConfirm') && $this->registerHook('adminOrder') && $this->registerHook('backOfficeHeader') && $this->registerHook('top') && $this->registerHook('footer') && $this->registerHook('leftColumn') && $this->registerHook('rightColumn'); }
public function install() { CertissimLogger::insertLog(__METHOD__ . " : " . __LINE__, "Génération du fichier log"); /** database tables creation * */ $sqlfile = dirname(__FILE__) . '/install.sql'; if (!file_exists($sqlfile) || !($sql = file_get_contents($sqlfile))) { return false; } $sql = str_replace('PREFIX_', _DB_PREFIX_, $sql); $queries = preg_split("/;\\s*[\r\n]+/", $sql); foreach ($queries as $query) { if (!Db::getInstance()->Execute(trim($query))) { CertissimLogger::insertLog(__METHOD__ . " : " . __LINE__, "Install impossible, génération base échouée : " . Db::getInstance()->getMsgError()); return false; } } //Certissim order stats insertion foreach ($this->_certissim_states as $id => $label) { $sql = "INSERT INTO `" . _DB_PREFIX_ . self::CERTISSIM_STATE_TABLE_NAME . "` (`id_certissim_state`,`label`) VALUES ('" . (int) $id . "','" . (string) $label . "')"; $insert = Db::getInstance()->execute($sql); if (!$insert) { CertissimLogger::insertLog(__METHOD__ . " : " . __LINE__, "Insertion state {$id}.{$label} échouée : " . Db::getInstance()->getMsgError()); } } $tab_admin_order_id = Tab::getIdFromClassName('AdminOrders'); //AdminCertissimController registration $tab_controller_main = new Tab(); $tab_controller_main->active = 1; $tab_controller_main->class_name = "AdminCertissim"; foreach (Language::getLanguages() as $language) { $tab_controller_main->name[$language['id_lang']] = "Certissim"; } $tab_controller_main->id_parent = $tab_admin_order_id; $tab_controller_main->module = $this->name; $tab_controller_main->add(); $tab_controller_main->move($this->getNewLastPosition(0)); return parent::install() && $this->registerHook('newOrder') && $this->registerHook('paymentConfirm') && $this->registerHook('adminOrder') && $this->registerHook('backOfficeHeader'); }
public function postProcess() { /* PrestaShop demo mode */ if (_PS_MODE_DEMO_) { $this->errors[] = Tools::displayError('This functionality has been disabled.'); return; } /* PrestaShop demo mode*/ if (($id_tab = (int) Tools::getValue('id_tab')) && ($direction = Tools::getValue('move')) && Validate::isLoadedObject($tab = new Tab($id_tab))) { if ($tab->move($direction)) { Tools::redirectAdmin(self::$currentIndex . '&token=' . $this->token); } } elseif (Tools::getValue('position') && !Tools::isSubmit('submitAdd' . $this->table)) { if ($this->tabAccess['edit'] !== '1') { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } elseif (!Validate::isLoadedObject($object = new Tab((int) Tools::getValue($this->identifier)))) { $this->errors[] = Tools::displayError('An error occurred while updating the status for an object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)'); } if (!$object->updatePosition((int) Tools::getValue('way'), (int) Tools::getValue('position'))) { $this->errors[] = Tools::displayError('Failed to update the position.'); } else { Tools::redirectAdmin(self::$currentIndex . '&conf=5&token=' . Tools::getAdminTokenLite('AdminTabs')); } } elseif (Tools::isSubmit('submitAdd' . $this->table) && Tools::getValue('id_tab') === Tools::getValue('id_parent')) { $this->errors[] = Tools::displayError('You can\'t put this menu inside itself. '); } elseif (Tools::isSubmit('submitAdd' . $this->table) && ($id_parent = (int) Tools::getValue('id_parent'))) { $this->redirect_after = self::$currentIndex . '&id_' . $this->table . '=' . $id_parent . '&details' . $this->table . '&conf=4&token=' . $this->token; } elseif (isset($_GET['details' . $this->table]) && is_array($this->bulk_actions)) { $submit_bulk_actions = array_merge(array('enableSelection' => array('text' => $this->l('Enable selection'), 'icon' => 'icon-power-off text-success'), 'disableSelection' => array('text' => $this->l('Disable selection'), 'icon' => 'icon-power-off text-danger')), $this->bulk_actions); foreach ($submit_bulk_actions as $bulk_action => $params) { if (Tools::isSubmit('submitBulk' . $bulk_action . $this->table) || Tools::isSubmit('submitBulk' . $bulk_action)) { if ($this->tabAccess['edit'] === '1') { $this->action = 'bulk' . $bulk_action; $this->boxes = Tools::getValue($this->list_id . 'Box'); } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } break; } elseif (Tools::isSubmit('submitBulk')) { if ($this->tabAccess['edit'] === '1') { $this->action = 'bulk' . Tools::getValue('select_submitBulk'); $this->boxes = Tools::getValue($this->list_id . 'Box'); } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } break; } } } else { // Temporary add the position depend of the selection of the parent category if (!Tools::isSubmit('id_tab')) { // @todo Review $_POST['position'] = Tab::getNbTabs(Tools::getValue('id_parent')); } } if (!count($this->errors)) { parent::postProcess(); } }
public function postProcess() { /* PrestaShop demo mode */ if (_PS_MODE_DEMO_) { $this->errors[] = Tools::displayError('This functionality has been disabled.'); return; } /* PrestaShop demo mode*/ if (($id_tab = (int) Tools::getValue('id_tab')) && ($direction = Tools::getValue('move')) && Validate::isLoadedObject($tab = new Tab($id_tab))) { if ($tab->move($direction)) { Tools::redirectAdmin(self::$currentIndex . '&token=' . $this->token); } } elseif (Tools::getValue('position') && !Tools::isSubmit('submitAdd' . $this->table)) { if ($this->tabAccess['edit'] !== '1') { $this->errors[] = Tools::displayError('You do not have permission to edit here.'); } elseif (!Validate::isLoadedObject($object = new Tab((int) Tools::getValue($this->identifier)))) { $this->errors[] = Tools::displayError('An error occurred while updating status for object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)'); } if (!$object->updatePosition((int) Tools::getValue('way'), (int) Tools::getValue('position'))) { $this->errors[] = Tools::displayError('Failed to update the position.'); } else { Tools::redirectAdmin(self::$currentIndex . '&conf=5&token=' . Tools::getAdminTokenLite('AdminTabs')); } } elseif (Tools::isSubmit('submitAddtab') && Tools::getValue('id_tab') === Tools::getValue('id_parent')) { $this->errors[] = Tools::displayError('You can\'t put this menu in itself'); } else { // Temporary add the position depend of the selection of the parent category if (!Tools::isSubmit('id_tab')) { // @todo Review $_POST['position'] = Tab::getNbTabs(Tools::getValue('id_parent')); } } if (!count($this->errors)) { parent::postProcess(); } }