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();
     }
 }
Exemple #3
0
 public function addAdminTab()
 {
     $id_parent = Tab::getIdFromClassName('AdminParentOrders');
     $adminTab = new Tab();
     $languages = Language::getLanguages(true);
     $adminTab->name = array();
     foreach ($languages as $lang) {
         $adminTab->name[$lang['id_lang']] = 'fr' == $lang['iso_code'] ? 'Carte des commandes' : 'Order map';
     }
     $adminTab->class_name = 'AdminMappa';
     $adminTab->module = $this->name;
     $adminTab->id_parent = $id_parent;
     $adminTab->active = true;
     $adminTab->position = Tab::getNbTabs($id_parent);
     if (!$adminTab->save()) {
         return false;
     }
     Configuration::updateValue('ADMIN_TAB_MODULE_MAPPA', $adminTab->id);
     return true;
 }
Exemple #4
0
    public function move($direction)
    {
        $nb_tabs = Tab::getNbTabs($this->id_parent);
        if ($direction != 'l' && $direction != 'r') {
            return false;
        }
        if ($nb_tabs <= 1) {
            return false;
        }
        if ($direction == 'l' && $this->position <= 1) {
            return false;
        }
        if ($direction == 'r' && $this->position >= $nb_tabs) {
            return false;
        }
        $new_position = $direction == 'l' ? $this->position - 1 : $this->position + 1;
        Db::getInstance()->execute('
			UPDATE `' . _DB_PREFIX_ . 'tab` t
			SET position = ' . (int) $this->position . '
			WHERE id_parent = ' . (int) $this->id_parent . '
				AND position = ' . (int) $new_position);
        $this->position = $new_position;
        return $this->update();
    }
 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();
     }
 }