private function _postProcess()
 {
     // Dismiss Addons rating
     if (isset($_GET['dismissRating'])) {
         $this->_html = '';
         self::_cleanBuffer();
         if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) {
             Configuration::updateGlobalValue('PM_' . self::$_module_prefix . '_DISMISS_RATING', 1);
         } else {
             Configuration::updateValue('PM_' . self::$_module_prefix . '_DISMISS_RATING', 1);
         }
         die;
     }
     $this->saveConfig();
     $this->saveAdvancedConfig();
     if (isset($_GET['displayPreview'])) {
         $this->_html = '';
         $this->displayPreview();
         self::_cleanBuffer();
         echo $this->_html;
         die;
     } elseif (Tools::getValue('activeMaintenance')) {
         echo $this->_postProcessMaintenance(self::$_module_prefix);
         die;
     } elseif (Tools::getValue('actionColumn') == 'get_select_columns') {
         $id_menu = Tools::getValue('id_menu', false);
         if (!$id_menu) {
             die;
         }
         $columns = AdvancedTopMenuColumnClass::getMenuColumsByIdMenu((int) $id_menu, $this->_cookie->id_lang, false);
         $column_selected = Tools::getValue('column_selected', false);
         $this->_smarty->assign(array('columns' => $columns, 'column_selected' => $column_selected, 'objADTM' => new PM_AdvancedTopMenu()));
         self::_cleanBuffer();
         $this->_smarty->display(dirname(__FILE__) . '/column_select.tpl');
         die;
     } elseif (Tools::getValue('actionColumn') == 'get_select_columnsWrap') {
         $id_menu = Tools::getValue('id_menu', false);
         if (!$id_menu) {
             die;
         }
         $columnsWrap = AdvancedTopMenuColumnWrapClass::getMenuColumnsWrap((int) $id_menu, $this->_cookie->id_lang, false);
         $columnWrap_selected = Tools::getValue('columnWrap_selected', false);
         $this->_smarty->assign(array('columnsWrap' => $columnsWrap, 'columnWrap_selected' => $columnWrap_selected));
         self::_cleanBuffer();
         $this->_smarty->display(dirname(__FILE__) . '/columnwrap_select.tpl');
         die;
     } elseif (isset($_GET['columnElementsPosition'])) {
         $order = $_GET['columnElementsPosition'] ? explode(',', $_GET['columnElementsPosition']) : array();
         foreach ($order as $position => $id_element) {
             $row = array('position' => intval($position));
             Db::getInstance()->AutoExecute(_DB_PREFIX_ . 'pm_advancedtopmenu_elements', $row, 'UPDATE', 'id_element =' . intval($id_element));
         }
         $this->clearCache();
         self::_cleanBuffer();
         echo $this->l('Save');
         die;
     } elseif (isset($_GET['menuPosition'])) {
         $order = $_GET['menuPosition'] ? explode(',', $_GET['menuPosition']) : array();
         foreach ($order as $position => $id_menu) {
             if (!trim($id_menu)) {
                 continue;
             }
             $row = array('position' => intval($position));
             Db::getInstance()->AutoExecute(_DB_PREFIX_ . 'pm_advancedtopmenu', $row, 'UPDATE', 'id_menu =' . intval($id_menu));
         }
         $this->clearCache();
         self::_cleanBuffer();
         echo $this->l('Save');
         die;
     } elseif (isset($_GET['columnPosition'])) {
         $order = $_GET['columnPosition'] ? explode(',', $_GET['columnPosition']) : array();
         foreach ($order as $position => $id_column) {
             if (!trim($id_column)) {
                 continue;
             }
             $row = array('position' => intval($position));
             Db::getInstance()->AutoExecute(_DB_PREFIX_ . 'pm_advancedtopmenu_columns', $row, 'UPDATE', 'id_column =' . intval($id_column));
         }
         $this->clearCache();
         self::_cleanBuffer();
         echo $this->l('Save');
         die;
     } elseif (isset($_GET['columnWrapPosition'])) {
         $order = $_GET['columnWrapPosition'] ? explode(',', $_GET['columnWrapPosition']) : array();
         foreach ($order as $position => $id_wrap) {
             if (!trim($id_wrap)) {
                 continue;
             }
             $row = array('position' => intval($position));
             Db::getInstance()->AutoExecute(_DB_PREFIX_ . 'pm_advancedtopmenu_columns_wrap', $row, 'UPDATE', 'id_wrap =' . intval($id_wrap));
         }
         $this->clearCache();
         self::_cleanBuffer();
         echo $this->l('Save');
         die;
     } elseif (Tools::getValue('activeMenu') && Tools::getValue('id_menu')) {
         $return = '';
         $ObjAdvancedTopMenuClass = new AdvancedTopMenuClass(Tools::getValue('id_menu'));
         $ObjAdvancedTopMenuClass->active = $ObjAdvancedTopMenuClass->active ? 0 : 1;
         if ($ObjAdvancedTopMenuClass->save()) {
             $return .= '$("#imgActiveMenu' . $ObjAdvancedTopMenuClass->id . '").attr("src","../img/admin/' . ($ObjAdvancedTopMenuClass->active ? 'enabled' : 'disabled') . '.gif");';
             $return .= 'show_info("activemenu","' . $this->l('Save') . '");';
         } else {
             $return .= 'show_info("activemenu","' . $this->l('Error during update menu') . '");';
         }
         $this->clearCache();
         self::_cleanBuffer();
         echo $return;
         die;
     } elseif (Tools::getValue('activeColumnWrap') && Tools::getValue('id_wrap')) {
         $return = '';
         $ObjAdvancedTopMenuColumnWrapClass = new AdvancedTopMenuColumnWrapClass(Tools::getValue('id_wrap'));
         $ObjAdvancedTopMenuColumnWrapClass->active = $ObjAdvancedTopMenuColumnWrapClass->active ? 0 : 1;
         if ($ObjAdvancedTopMenuColumnWrapClass->save()) {
             $return .= '$("#imgActiveColumnWrap' . $ObjAdvancedTopMenuColumnWrapClass->id . '").attr("src","../img/admin/' . ($ObjAdvancedTopMenuColumnWrapClass->active ? 'enabled' : 'disabled') . '.gif");';
             $return .= 'show_info("activecolumnwrap","' . $this->l('Save') . '");';
         } else {
             $return .= 'show_info("activecolumnwrap","' . $this->l('Error during update column') . '");';
         }
         $this->clearCache();
         self::_cleanBuffer();
         echo $return;
         die;
     } elseif (Tools::getValue('activeColumn') && Tools::getValue('id_column')) {
         $return = '';
         $ObjAdvancedTopMenuColumnClass = new AdvancedTopMenuColumnClass(Tools::getValue('id_column'));
         $ObjAdvancedTopMenuColumnClass->active = $ObjAdvancedTopMenuColumnClass->active ? 0 : 1;
         if ($ObjAdvancedTopMenuColumnClass->save()) {
             $return .= '$("#imgActiveColumn' . $ObjAdvancedTopMenuColumnClass->id . '").attr("src","../img/admin/' . ($ObjAdvancedTopMenuColumnClass->active ? 'enabled' : 'disabled') . '.gif");';
             $return .= 'show_info("activegroup","' . $this->l('Save') . '");';
         } else {
             $return .= 'show_info("activegroup","' . $this->l('Error during update group') . '");';
         }
         $this->clearCache();
         self::_cleanBuffer();
         echo $return;
         die;
     } elseif (Tools::getValue('activeElement') && Tools::getValue('id_element')) {
         $return = '';
         $AdvancedTopMenuElementsClass = new AdvancedTopMenuElementsClass(Tools::getValue('id_element'));
         $AdvancedTopMenuElementsClass->active = $AdvancedTopMenuElementsClass->active ? 0 : 1;
         if ($AdvancedTopMenuElementsClass->save()) {
             $return .= '$("#imgActiveElement' . $AdvancedTopMenuElementsClass->id . '").attr("src","../img/admin/' . ($AdvancedTopMenuElementsClass->active ? 'enabled' : 'disabled') . '.gif");';
             $return .= 'show_info("activeelement","' . $this->l('Save') . '");';
         } else {
             $return .= 'show_info("activeelement","' . $this->l('Error during update element') . '");';
         }
         $this->clearCache();
         self::_cleanBuffer();
         echo $return;
         die;
     } elseif (Tools::getValue('deleteMenu') && Tools::getValue('id_menu')) {
         $ObjAdvancedTopMenuClass = new AdvancedTopMenuClass(Tools::getValue('id_menu'));
         if ($ObjAdvancedTopMenuClass->delete()) {
             $this->_html .= $this->displayConfirmation($this->l('Menu has been deleted'));
         } else {
             $this->errors[] = $this->l('Error during delete column');
         }
         $this->clearCache();
     } elseif (Tools::getValue('deleteColumnWrap') && Tools::getValue('id_wrap')) {
         $ObjAdvancedTopMenuColumnWrapClass = new AdvancedTopMenuColumnWrapClass(Tools::getValue('id_wrap'));
         if ($ObjAdvancedTopMenuColumnWrapClass->delete()) {
             $this->_html .= $this->displayConfirmation($this->l('Column has been deleted'));
         } else {
             $this->errors[] = $this->l('Error during delete column');
         }
         $this->clearCache();
     } elseif (Tools::getValue('deleteColumn') && Tools::getValue('id_column')) {
         $ObjAdvancedTopMenuColumnClass = new AdvancedTopMenuColumnClass(Tools::getValue('id_column'));
         if ($ObjAdvancedTopMenuColumnClass->delete()) {
             $this->_html .= $this->displayConfirmation($this->l('Group has been deleted'));
         } else {
             $this->errors[] = $this->l('Error during delete Group');
         }
         $this->clearCache();
     } elseif (Tools::getValue('deleteElement') && Tools::getValue('id_element')) {
         $AdvancedTopMenuElementsClass = new AdvancedTopMenuElementsClass(Tools::getValue('id_element'));
         if ($AdvancedTopMenuElementsClass->delete()) {
             $this->_html .= $this->displayConfirmation($this->l('Item has been deleted'));
         } else {
             $this->errors[] = $this->l('Error during delete item');
         }
         $this->clearCache();
     } elseif (Tools::getValue('getMenuForm')) {
         $ObjAdvancedTopMenuClass = false;
         if (Tools::getValue('editMenu') && Tools::getValue('id_menu')) {
             $ObjAdvancedTopMenuClass = new AdvancedTopMenuClass(Tools::getValue('id_menu'));
         }
         $cms = CMS::listCms(intval($this->_cookie->id_lang));
         $categories = Category::getCategories(intval($this->_cookie->id_lang), false);
         $manufacturer = Manufacturer::getManufacturers(false, $this->_cookie->id_lang, true);
         $supplier = Supplier::getSuppliers(false, $this->_cookie->id_lang, true);
         self::_cleanBuffer();
         if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) {
             $this->_html = '';
         }
         $this->displayMenuForm($cms, $categories, $manufacturer, $supplier, $ObjAdvancedTopMenuClass);
         $this->initColorPicker();
         $this->initTinyMce();
         echo $this->_html;
         die;
     } elseif (Tools::getValue('getColumnWrapForm')) {
         $ObjAdvancedTopMenuColumnWrapClass = false;
         if (Tools::getValue('editColumnWrap') && Tools::getValue('id_wrap')) {
             $ObjAdvancedTopMenuColumnWrapClass = new AdvancedTopMenuColumnWrapClass(Tools::getValue('id_wrap'));
         }
         $menus = AdvancedTopMenuClass::getMenus($this->_cookie->id_lang, false);
         self::_cleanBuffer();
         if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) {
             $this->_html = '';
         }
         $this->displayColumnWrapForm($menus, $ObjAdvancedTopMenuColumnWrapClass);
         $this->initColorPicker();
         $this->initTinyMce();
         echo $this->_html;
         die;
     } elseif (Tools::getValue('getColumnForm')) {
         $ObjAdvancedTopMenuColumnClass = false;
         if (Tools::getValue('editColumn') && Tools::getValue('id_column')) {
             $ObjAdvancedTopMenuColumnClass = new AdvancedTopMenuColumnClass(Tools::getValue('id_column'));
         }
         $cms = CMS::listCms(intval($this->_cookie->id_lang));
         $categories = Category::getCategories(intval($this->_cookie->id_lang), false);
         $manufacturer = Manufacturer::getManufacturers(false, $this->_cookie->id_lang, true);
         $supplier = Supplier::getSuppliers(false, $this->_cookie->id_lang, true);
         $menus = AdvancedTopMenuClass::getMenus($this->_cookie->id_lang, false);
         self::_cleanBuffer();
         if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) {
             $this->_html = '';
         }
         $this->displayColumnForm($menus, $cms, $categories, $manufacturer, $supplier, $ObjAdvancedTopMenuColumnClass);
         $this->initColorPicker();
         $this->initTinyMce();
         echo $this->_html;
         die;
     } elseif (Tools::getValue('getElementForm')) {
         $ObjAdvancedTopMenuElementsClass = false;
         if (Tools::getValue('editElement') && Tools::getValue('id_element')) {
             $ObjAdvancedTopMenuElementsClass = new AdvancedTopMenuElementsClass(Tools::getValue('id_element'));
         }
         $cms = CMS::listCms(intval($this->_cookie->id_lang));
         $categories = Category::getCategories(intval($this->_cookie->id_lang), false);
         $manufacturer = Manufacturer::getManufacturers(false, $this->_cookie->id_lang, true);
         $supplier = Supplier::getSuppliers(false, $this->_cookie->id_lang, true);
         $menus = AdvancedTopMenuClass::getMenus($this->_cookie->id_lang, false);
         self::_cleanBuffer();
         if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) {
             $this->_html = '';
         }
         $this->displayElementForm($menus, array(), $cms, $categories, $manufacturer, $supplier, $ObjAdvancedTopMenuElementsClass);
         $this->initColorPicker();
         echo $this->_html;
         die;
     } elseif (isset($_POST['submitMenu'])) {
         $this->_postProcessMenu();
         $this->clearCache();
     } elseif (isset($_POST['submitColumnWrap'])) {
         $this->_postProcessColumnWrap();
         $this->clearCache();
     } elseif (isset($_POST['submitColumn'])) {
         $this->_postProcessColumn();
         $this->clearCache();
     } elseif (isset($_POST['submitElement'])) {
         $this->_postProcessColumnElement();
         $this->clearCache();
     } elseif (isset($_POST['submitFastChangeColumn'])) {
         $id_column = Tools::getValue('id_column');
         $id_wrap = Tools::getValue('id_wrap');
         if ($id_wrap && $id_column) {
             $row = array('id_wrap' => intval($id_wrap));
             Db::getInstance()->AutoExecute(_DB_PREFIX_ . 'pm_advancedtopmenu_columns', $row, 'UPDATE', 'id_column =' . intval($id_column));
         }
         $this->clearCache();
     }
 }
 public function delete()
 {
     /* Get childs */
     $toDelete = array(intval($this->id));
     $toDelete = array_unique($toDelete);
     foreach ($toDelete as $id_column) {
         if (file_exists(_PS_ROOT_DIR_ . '/modules/pm_advancedtopmenu/column_icons/' . $id_column . '.' . ($this->image_type ? $this->image_type : 'jpg'))) {
             @unlink(_PS_ROOT_DIR_ . '/modules/pm_advancedtopmenu/column_icons/' . $id_column . '.' . ($this->image_type ? $this->image_type : 'jpg'));
         }
     }
     /* Delete its child from database */
     $list = sizeof($toDelete) > 1 ? implode(',', $toDelete) : intval($this->id);
     Db::getInstance()->Execute('DELETE FROM `' . _DB_PREFIX_ . 'pm_advancedtopmenu_columns` WHERE `id_column` IN (' . $list . ')');
     Db::getInstance()->Execute('DELETE FROM `' . _DB_PREFIX_ . 'pm_advancedtopmenu_columns_lang` WHERE `id_column` IN (' . $list . ')');
     $elements = AdvancedTopMenuElementsClass::getElementIds($list);
     foreach ($elements as $id_element) {
         $obj = new AdvancedTopMenuElementsClass($id_element);
         $obj->delete();
     }
     return true;
 }