public static function saveModule() { $module = new VerticalMegaMenus(); $shopId = Context::getContext()->shop->id; $languages = $module->getAllLanguage(); $response = new stdClass(); $itemId = intval($_POST['moduleId']); $db = DB::getInstance(); $names = $_POST['module_titles']; $position = intval($_POST['position']); $position_name = Hook::getNameById($position); $layout = Tools::getValue('moduleLayout', 'default'); $showCount = intval($_POST['showCount']); if ($itemId == 0) { $maxOrdering = $db->getValue("Select MAX(ordering) From " . _DB_PREFIX_ . "verticalmegamenus_modules Where `position` = " . $position); if ($maxOrdering > 0) { $maxOrdering++; } else { $maxOrdering = 1; } if ($db->execute("Insert Into " . _DB_PREFIX_ . "verticalmegamenus_modules (`id_shop`, `position`, `position_name`, `layout`, `ordering`, `status`, `show_count_item`) Values ('" . $shopId . "', '" . $position . "', '{$position_name}', '" . $layout . "', '" . $maxOrdering . "', '1', '" . $showCount . "')")) { $insertId = $db->Insert_ID(); if ($languages) { $insertDatas = array(); foreach ($languages as $index => $language) { $insertDatas[] = array('module_id' => $insertId, 'id_lang' => $language->id, 'id_shop' => $shopId, 'name' => $db->escape($names[$index])); } if ($insertDatas) { $db->insert('verticalmegamenus_module_lang', $insertDatas); } } $response->status = '1'; $response->msg = $module->ajaxTranslate('Add new Module Success!'); } else { $response->status = '0'; $response->msg = $module->ajaxTranslate('Add new Module not Success!'); } } else { $item = $db->getRow("Select * From " . _DB_PREFIX_ . "verticalmegamenus_modules Where id = " . $itemId); $db->execute("Update " . _DB_PREFIX_ . "verticalmegamenus_modules Set `id_shop`='" . $shopId . "', `position` = '" . $position . "', `position_name`='{$position_name}', `layout`='" . $layout . "', `show_count_item` = '" . $showCount . "' Where id = " . $itemId); if ($languages) { $insertDatas = array(); foreach ($languages as $index => $language) { $check = DB::getInstance()->getValue("Select module_id From " . _DB_PREFIX_ . "verticalmegamenus_module_lang Where module_id = {$itemId} AND id_lang = " . $language->id . " AND id_shop = " . $shopId); if ($check) { $db->execute("Update " . _DB_PREFIX_ . "verticalmegamenus_module_lang Set `name` = '" . $db->escape($names[$index]) . "' Where `module_id` = " . $itemId . " AND `id_lang` = " . $language->id . " AND `id_shop` = " . $shopId); } else { $insertDatas[] = array('module_id' => $itemId, 'id_lang' => $language->id, 'id_shop' => $shopId, 'name' => $db->escape($names[$index])); } } if ($insertDatas) { $db->insert('verticalmegamenus_module_lang', $insertDatas); } } $response->status = '1'; $response->msg = $module->ajaxTranslate('Update Module Success!'); } $module->clearCache(); die(Tools::jsonEncode($response)); }
public function postProcess() { if (Tools::isSubmit('submit' . $this->className)) { if (!$this->manageLinkList()) { return false; } $hook_name = Hook::getNameById(Tools::getValue('id_hook')); if (!Hook::isModuleRegisteredOnHook($this->module, $hook_name, $this->context->shop->id)) { Hook::registerHook($this->module, $hook_name); } $this->module->_clearCache($this->module->templateFile); Tools::redirectAdmin($this->context->link->getAdminLink('Admin' . $this->name)); } elseif (Tools::isSubmit('delete' . $this->className)) { if (!$this->deleteLinkList()) { return false; } $this->module->_clearCache($this->module->templateFile); Tools::redirectAdmin($this->context->link->getAdminLink('Admin' . $this->name)); } return parent::postProcess(); }
public function hookactionModuleRegisterHookAfter($params) { $module = $params['object']; $current_theme = Theme::getThemeInfo($this->context->shop->id_theme); if (!$this->IsOvicThemes($current_theme['theme_name'])) { return; } if ($module->name != $this->name) { $hook_name = $params['hook_name']; if ($hook_name && Validate::isHookName($hook_name)) { $id_hook = Hook::getIdByName($hook_name); $hook_name = Hook::getNameById($id_hook); // get full hookname //order possition hook $id_hook_header = Hook::getIdByName('Header'); if ($id_hook && $id_hook === $id_hook_header) { $this->changeHeaderPosition(); } if (in_array($hook_name, self::$OptionHookAssign)) { $this->backupModuleHook($id_hook, 'hook_module', 'ovic_backup_hook_module', true); } elseif (in_array($hook_name, self::getHookexecuteList())) { $this->backupModuleHook($id_hook, 'hook_module', 'ovic_backup_hook_module', false); } else { return; } $id_shop = (int) $this->context->shop->id; $current_id_option = Configuration::get('OVIC_CURRENT_OPTION', null, null, $id_shop); $current_option = new Options($current_id_option); $moduleHook = array(); $moduleHook[] = $module->name; $moduleHook[] = $hook_name; if ($current_option && Validate::isLoadedObject($current_option)) { //insert module to current option $HookedModulesArr = self::getModulesHook($current_option->theme, $current_option->alias, $hook_name); $HookedModulesArr = Tools::jsonDecode($HookedModulesArr['modules'], true); if (!is_array($HookedModulesArr)) { $HookedModulesArr = array(); } $key = array_search($moduleHook, $HookedModulesArr); if ($key && !array_key_exists($key, $HookedModulesArr)) { $HookedModulesArr[] = $moduleHook; self::registerHookModule($current_option, $hook_name, Tools::jsonEncode($HookedModulesArr), $id_shop); } } $pagelist = Meta::getMetas(); $sidebarPages = array(); $theme = new Theme((int) $this->context->shop->id_theme); if ($hook_name == 'displayLeftColumn' || $hook_name == 'displayRightColumn') { foreach ($pagelist as $page) { if ($hook_name == 'displayLeftColumn' && $theme->hasLeftColumn($page['page'])) { $HookedModulesArr = self::getSideBarModulesByPage($page['page'], 'left', false); if (!is_array($HookedModulesArr)) { $HookedModulesArr = array(); } $key = array_search($moduleHook, $HookedModulesArr); if ($key && !array_key_exists($key, $HookedModulesArr)) { $HookedModulesArr[] = $moduleHook; self::registerSidebarModule($page['page'], 'left', Tools::jsonEncode($HookedModulesArr), $id_shop); } } if ($hook_name == 'displayRightColumn' && $theme->hasRightColumn($page['page'])) { $HookedModulesArr = self::getSideBarModulesByPage($page['page'], 'right', false); if (!is_array($HookedModulesArr)) { $HookedModulesArr = array(); } $key = array_search($moduleHook, $HookedModulesArr); if ($key && !array_key_exists($key, $HookedModulesArr)) { $HookedModulesArr[] = $moduleHook; self::registerSidebarModule($page['page'], 'right', Tools::jsonEncode($HookedModulesArr), $id_shop); } } } } } } }
/** * Unregister module from hook * * @param mixed $id_hook Hook id (can be a hook name since 1.5.0) * @param array $shop_list List of shop * @return boolean result */ public function unregisterHook($hook_id, $shop_list = null) { // Get hook id if a name is given as argument if (!is_numeric($hook_id)) { $hook_name = (int) $hook_id; // Retrocompatibility $hook_id = Hook::getIdByName($hook_id); if (!$hook_id) { return false; } } else { $hook_name = Hook::getNameById((int) $hook_id); } Hook::exec('actionModuleUnRegisterHookBefore', array('object' => $this, 'hook_name' => $hook_name)); // Unregister module on hook by id $sql = 'DELETE FROM `' . _DB_PREFIX_ . 'hook_module` WHERE `id_module` = ' . (int) $this->id . ' AND `id_hook` = ' . (int) $hook_id . ($shop_list ? ' AND `id_shop` IN(' . implode(', ', $shop_list) . ')' : ''); $result = Db::getInstance()->execute($sql); // Clean modules position $this->cleanPositions($hook_id, $shop_list); Hook::exec('actionModuleUnRegisterHookAfter', array('object' => $this, 'hook_name' => $hook_name)); return $result; }
/** * Change hook execute off module */ public function ajaxProcessChangeModuleHook() { $result = array(); $id_hook = (int) Tools::getValue('id_hook'); $hookname = Hook::getNameById($id_hook); $id_option = (int) Tools::getValue('id_option'); $option = new Options($id_option); $id_hookexec = (int) Tools::getValue('id_hookexec'); $hookexec_name = Hook::getNameById($id_hookexec); $old_hook = (int) Tools::getValue('old_hook'); $id_module = (int) Tools::getValue('id_module'); if ($option && Validate::isLoadedObject($option) && $id_module && Validate::isUnsignedId($id_module) && $hookname && Validate::isHookName($hookname) && $hookexec_name && Validate::isHookName($hookexec_name)) { $result['status'] = true; $moduleObject = Module::getInstanceById($id_module); $HookedModulesArr = OvicLayoutControl::getModulesHook($option->theme, $option->alias, $hookname); $HookedModulesArr = Tools::jsonDecode($HookedModulesArr['modules'], true); if (!is_array($HookedModulesArr)) { $result['status'] = false; } if ($result['status']) { $moduleHook = array(); $moduleHook[] = $moduleObject->name; $moduleHook[] = Hook::getNameById($old_hook); $key = array_search($moduleHook, $HookedModulesArr); $result['test'] = $key; if (array_key_exists($key, $HookedModulesArr)) { $moduleHook[1] = $hookexec_name; $HookedModulesArr[$key] = $moduleHook; $result['status'] = OvicLayoutControl::registerHookModule($option, $hookname, Tools::jsonEncode($HookedModulesArr), $this->context->shop->id); $result['moduleinfo'] = $moduleObject->name . '-' . $hookexec_name; } } } die(Tools::jsonEncode($result)); }
/** * remove a module from a hook */ public function ajaxProcessremoveModuleHook() { $result = array(); $hookname = Tools::getValue('hookname'); $id_option = (int) Tools::getValue('id_option'); $id_hookexec = (int) Tools::getValue('id_hookexec'); $hookexec_name = Hook::getNameById($id_hookexec); $id_module = (int) Tools::getValue('id_module'); if ($id_module && Validate::isUnsignedId($id_module) && $hookname && Validate::isHookName($hookname) && $hookexec_name && Validate::isHookName($hookexec_name)) { $moduleObject = Module::getInstanceById($id_module); $HookedModulesArr = OvicLayoutControl::getModulesHook($id_option, $hookname); $HookedModulesArr = Tools::jsonDecode($HookedModulesArr['modules'], true); $HookedModulesArr = array_values($HookedModulesArr); $moduleHook = array(); $moduleHook[] = $moduleObject->name; $moduleHook[] = $hookexec_name; if ($HookedModulesArr && is_array($HookedModulesArr) && sizeof($HookedModulesArr)) { $key = array_search($moduleHook, $HookedModulesArr); unset($HookedModulesArr[$key]); } $HookedModulesArr = array_values($HookedModulesArr); $result['status'] = OvicLayoutControl::registerHookModule($id_option, $hookname, Tools::jsonEncode($HookedModulesArr), $this->context->shop->id); $result['msg'] = $this->l('Successful deletion'); //$this->displayError } Tools::clearCache(); die(Tools::jsonEncode($result)); }
public function getPositionOptions($selected = 0) { $positionOptions = ''; $items = DB::getInstance()->executeS("Select id_hook From " . _DB_PREFIX_ . "hook_module Where id_module = " . $this->id); if ($items) { foreach ($items as $item) { if ($selected == $item['id_hook']) { $positionOptions .= '<option selected="selected" value="' . $item['id_hook'] . '">' . Hook::getNameById($item['id_hook']) . '</option>'; } else { $positionOptions .= '<option value="' . $item['id_hook'] . '">' . Hook::getNameById($item['id_hook']) . '</option>'; } } } return $positionOptions; }
/** * Change hook execute off module */ public function ajaxProcessChangeModuleHook() { $result = array(); $pagemeta = Tools::getValue('pagemeta'); $hookcolumn = Tools::getValue('hookcolumn'); $id_hookexec = (int) Tools::getValue('id_hookexec'); $hookexec_name = Hook::getNameById($id_hookexec); $old_hook = (int) Tools::getValue('old_hook'); $id_module = (int) Tools::getValue('id_module'); if ($id_module && Validate::isUnsignedId($id_module) && $hookexec_name && Validate::isHookName($hookexec_name)) { $result['status'] = true; $moduleObject = Module::getInstanceById($id_module); $HookedModulesArr = OvicLayoutControl::getSideBarModulesByPage($pagemeta, $hookcolumn, false); if (!is_array($HookedModulesArr)) { $result['status'] = false; } if ($result['status']) { $moduleHook = array(); $moduleHook[] = $moduleObject->name; $moduleHook[] = Hook::getNameById($old_hook); $key = array_search($moduleHook, $HookedModulesArr); if (array_key_exists($key, $HookedModulesArr)) { $moduleHook[1] = $hookexec_name; $HookedModulesArr[$key] = $moduleHook; $result['status'] = OvicLayoutControl::registerSidebarModule($pagemeta, $hookcolumn, Tools::jsonEncode($HookedModulesArr), $this->context->shop->id); $result['moduleinfo'] = $moduleObject->name . '-' . $hookexec_name; } } } Tools::clearCache(); die(Tools::jsonEncode($result)); }
static function saveGroup() { $db = DB::getInstance(); $module = new OvicCustomTags(); $module->clearCache(); $shopId = Context::getContext()->shop->id; $languages = $module->getAllLanguages(); $itemId = Tools::getValue('groupId'); $names = Tools::getValue('names', array()); $position = intval($_POST['position']); $position_name = Hook::getNameById($position); $arrParams = array('background' => Tools::getValue('background', '#82A3CC'), 'color' => Tools::getValue('color', '#ffffff')); $params = json_encode($arrParams); $response = new stdClass(); if ($itemId == 0) { $maxOrdering = $db->getValue("Select MAX(ordering) From " . _DB_PREFIX_ . "ovic_custom_tags_groups Where `position` = " . $position); if ($maxOrdering > 0) { $maxOrdering++; } else { $maxOrdering = 1; } if ($db->execute("Insert Into " . _DB_PREFIX_ . "ovic_custom_tags_groups (`id_shop`, `position`, `position_name`, `status`, `params`, `ordering`) Values ('" . $shopId . "', '{$position}', '{$position_name}', '1', '{$params}', '{$maxOrdering}')")) { $insertId = $db->Insert_ID(); if ($languages) { $arrInsert = array(); foreach ($languages as $index => $language) { $arrInsert[] = array('groupId' => $insertId, 'id_lang' => $language->id, 'id_shop' => $shopId, 'name' => $db->escape($names[$index])); } if ($arrInsert) { $db->insert('ovic_custom_tags_group_lang', $arrInsert); } } $response->status = 1; $response->msg = 'Add new Group Success!'; } else { $response->status = 0; $response->msg = 'Error: Add new Group Failed!'; } } else { $item = $db->getRow("Select * From " . _DB_PREFIX_ . "ovic_custom_tags_groups Where id = " . $itemId); if ($item) { $db->execute("Update " . _DB_PREFIX_ . "ovic_custom_tags_groups Set `params`='{$params}', `position` = '{$position}', `position_name`='{$position_name}' Where id = " . $itemId); $arrInsert = array(); foreach ($languages as $index => $language) { $check = $db->getValue("Select groupId From " . _DB_PREFIX_ . "ovic_custom_tags_group_lang Where groupId = " . $itemId . " AND id_lang = " . $language->id . " AND id_shop = " . $shopId); if ($check) { $db->execute("Update " . _DB_PREFIX_ . "ovic_custom_tags_group_lang Set `name`='" . $db->escape($names[$index]) . "' Where `groupId` = '" . $itemId . "' AND `id_lang` = '" . $language->id . "' AND `id_shop` = '" . $shopId . "'"); } else { $arrInsert[] = array('groupId' => $itemId, 'id_lang' => $language->id, 'id_shop' => $shopId, 'name' => $db->escape($names[$index])); } } if ($arrInsert) { $db->insert('ovic_custom_tags_group_lang', $arrInsert); } $response->status = 1; $response->msg = 'Update Group success!'; } else { $response->status = 1; $response->msg = 'Error: Not isset Group.'; } } die(Tools::jsonEncode($response)); }
public function hookactionModuleRegisterHookAfter($params) { $module = $params['object']; if ($module->name != $this->name) { $hook_name = $params['hook_name']; if ($hook_name && Validate::isHookName($hook_name)) { $id_hook = Hook::getIdByName($hook_name); $hook_name = Hook::getNameById($id_hook); if (in_array($hook_name, self::$OptionHookAssign)) { $this->backupModuleHook($id_hook, 'hook_module', 'ovic_backup_hook_module', true); } elseif (in_array($hook_name, self::getHookexecuteList())) { $this->backupModuleHook($id_hook, 'hook_module', 'ovic_backup_hook_module', false); } $id_shop = $this->context->shop->id; $current_id_option = Configuration::get('OVIC_CURRENT_OPTION'); $moduleHook = array(); $moduleHook[] = $module->name; $moduleHook[] = $hook_name; if ($current_id_option && Validate::isUnsignedId($current_id_option)) { //insert module to current option $HookedModulesArr = self::getModulesHook($current_id_option, $hook_name); $HookedModulesArr = Tools::jsonDecode($HookedModulesArr['modules'], true); if (!is_array($HookedModulesArr)) { $HookedModulesArr = array(); } $key = array_search($moduleHook, $HookedModulesArr); if (!array_key_exists($key, $HookedModulesArr)) { $HookedModulesArr[] = $moduleHook; self::registerHookModule($current_id_option, $hook_name, Tools::jsonEncode($HookedModulesArr), $this->context->shop->id); } } $pagelist = Meta::getMetas(); $sidebarPages = array(); $theme = new Theme((int) $this->context->shop->id_theme); if ($hook_name == 'displayLeftColumn' || $hook_name == 'displayRightColumn') { foreach ($pagelist as $page) { if ($hook_name == 'displayLeftColumn' && $theme->hasLeftColumn($page['page'])) { $HookedModulesArr = self::getSideBarModulesByPage($page['page'], 'left', false); $HookedModulesArr[] = $moduleHook; self::registerSidebarModule($page['page'], 'left', Tools::jsonEncode($HookedModulesArr), $this->context->shop->id); } if ($hook_name == 'displayRightColumn' && $theme->hasRightColumn($page['page'])) { $HookedModulesArr = self::getSideBarModulesByPage($page['page'], 'right', false); $HookedModulesArr[] = $moduleHook; self::registerSidebarModule($page['page'], 'right', Tools::jsonEncode($HookedModulesArr), $this->context->shop->id); } } } } } }
public function getAllModule() { $langId = Context::getContext()->language->id; $shopId = Context::getContext()->shop->id; $items = DB::getInstance()->executeS("Select * From " . _DB_PREFIX_ . "flexiblebrand_modules Where id_shop = '" . $shopId . "' Order By position, ordering"); $html = ''; if ($items) { foreach ($items as $item) { $itemLang = $this->getModuleByLang($item['id'], $langId, $shopId); if ($item['status'] == "1") { $status = '<a title="Enabled" class="list-action-enable action-enabled lik-module-status" item-id="' . $item['id'] . '" value="' . $item['status'] . '"><i class="icon-check"></i></a>'; } else { $status = '<a title="Disabled" class="list-action-enable action-disabled lik-module-status" item-id="' . $item['id'] . '" value="' . $item['status'] . '"><i class="icon-check"></i></a>'; } $params = json_decode($item['params']); $html .= '<tr id="mod_' . $item['id'] . '"> <td><a class="module-item" href="javascript:void(0)" item-id="' . $item['id'] . '">' . $itemLang['module_title'] . '</a></td> <td class="center">' . $this->moduleLayout[$params->moduleLayout] . '</td> <td class="center">' . Hook::getNameById($item['position']) . '</td> <td class="pointer dragHandle center" ><div class="dragGroup"><div class="positions">' . $item['ordering'] . '</div></div></td> <td class="center">' . $status . '</td> <td class="center"> <a href="javascript:void(0)" item-id="' . $item['id'] . '" class="lik-module-edit"><i class="icon-edit"></i></a> <a href="javascript:void(0)" item-id="' . $item['id'] . '" class="lik-module-delete"><i class="icon-trash" ></i></a> </td> </tr>'; } } return $html; }
static function saveBanner() { $module = new OvicCustomBanner(); $module->clearCache(); $shopId = Context::getContext()->shop->id; $itemId = Tools::getValue('bannerId'); $position = Tools::getValue('position'); $position_name = Hook::getNameById($position); $langs = $module->getArrLangs(); $titles = $_POST['titles']; $images = $_POST['images']; $links = $_POST['links']; $params = array('layout' => Tools::getValue('layout', 'default'), 'width' => Tools::getValue('width', 'none-column'), 'className' => Tools::getValue('className', '')); $response = new stdClass(); $db = DB::getInstance(); if ($itemId == 0) { $maxOrdering = $db->getValue("Select MAX(ordering) From " . _DB_PREFIX_ . "ovic_custom_banners Where `position` = " . $position); if ($maxOrdering > 0) { $maxOrdering++; } else { $maxOrdering = 1; } if ($db->execute("Insert Into " . _DB_PREFIX_ . "ovic_custom_banners (`id_shop`, `position`, `position_name`, `status`, `params`, `ordering`) Values ('" . $shopId . "', '{$position}', '{$position_name}', 1, '" . json_encode($params) . "', '{$maxOrdering}')")) { $insertId = $db->Insert_ID(); if ($langs) { $arrSql = array(); foreach ($langs as $index => $lang) { if ($images[$index] && file_exists($module->pathTemp . $images[$index])) { $path_info = pathinfo($images[$index]); $ext = $path_info['extension']; $bannerName = $insertId . '-' . $lang->id . '-' . $shopId . '-banner.' . $ext; copy($module->pathTemp . $images[$index], $module->pathBanner . $bannerName); unlink($module->pathTemp . $images[$index]); $arrSql[] = array('bannerId' => $insertId, 'id_lang' => $lang->id, 'id_shop' => $shopId, 'banner_image' => $bannerName, 'banner_link' => $db->escape($links[$index]), 'banner_title' => $db->escape($titles[$index])); //"Insert Into "._DB_PREFIX_."ovic_custom_banner_lang (`bannerId`, `id_lang`, `id_shop`, `banner_image`, `banner_link`, `banner_title`) Values ('$insertId', '".$lang->id."', '$shopId', '".$bannerName."', '".$links[$index]."', '".$titles[$index]."')"; } } if ($arrSql) { $db->insert('ovic_custom_banner_lang', $arrSql); } } $response->status = 1; $response->msg = 'Add new Group Success!'; } else { $response->status = 0; $response->msg = 'Error: Add new Group Failed!'; } } else { $item = $db->getRow("Select * From " . _DB_PREFIX_ . "ovic_custom_banners Where id = " . $itemId); if ($item) { $db->execute("Update " . _DB_PREFIX_ . "ovic_custom_banners Set `params`='" . json_encode($params) . "', `position` = '{$position}', `position_name` = '{$position_name}' Where id = " . $itemId); $arrSql = array(); foreach ($langs as $index => $lang) { $check = DB::getInstance()->getValue("Select bannerId From " . _DB_PREFIX_ . "ovic_custom_banner_lang Where bannerId = " . $itemId . " AND id_lang = " . $lang->id . " AND id_shop = " . $shopId); if ($images[$index] && file_exists($module->pathTemp . $images[$index])) { $path_info = pathinfo($images[$index]); $ext = $path_info['extension']; $bannerName = $itemId . '-' . $lang->id . '-' . $shopId . '-banner.' . $ext; copy($module->pathTemp . $images[$index], $module->pathBanner . $bannerName); unlink($module->pathTemp . $images[$index]); if ($check) { $db->execute("Update " . _DB_PREFIX_ . "ovic_custom_banner_lang Set `banner_image` = '" . $bannerName . "', `banner_link`='" . $db->escape($links[$index]) . "', `banner_title`='" . $db->escape($titles[$index]) . "' Where `bannerId` = '" . $itemId . "' AND `id_lang` = '" . $lang->id . "' AND `id_shop` = '" . $shopId . "'"); } else { $arrSql[] = array('bannerId' => $itemId, 'id_lang' => $lang->id, 'id_shop' => $shopId, 'banner_image' => $bannerName, 'banner_link' => $db->escape($links[$index]), 'banner_title' => $db->escape($titles[$index])); //"Insert Into "._DB_PREFIX_."ovic_custom_banner_lang (`bannerId`, `id_lang`, `id_shop`, `banner_image`, `banner_link`, `banner_title`) Values ('$insertId', '".$lang->id."', '$shopId', '".$bannerName."', '".$links[$index]."', '".$titles[$index]."')"; } } else { if ($check) { $db->execute("Update " . _DB_PREFIX_ . "ovic_custom_banner_lang Set `banner_link`='" . $db->escape($links[$index]) . "', `banner_title`='" . $db->escape($titles[$index]) . "' Where `bannerId` = '" . $itemId . "' AND `id_lang` = '" . $lang->id . "' AND `id_shop` = '" . $shopId . "'"); } else { $arrSql[] = array('bannerId' => $itemId, 'id_lang' => $lang->id, 'id_shop' => $shopId, 'banner_image' => $bannerName, 'banner_link' => $db->escape($links[$index]), 'banner_title' => $db->escape($titles[$index])); //"Insert Into "._DB_PREFIX_."ovic_custom_banner_lang (`bannerId`, `id_lang`, `id_shop`, `banner_link`, `banner_title`) Values ('$insertId', '".$lang->id."', '$shopId', '".$links[$index]."', '".$titles[$index]."')"; } } } if ($arrSql) { $db->insert('ovic_custom_banner_lang', $arrSql); } $response->status = 1; $response->msg = 'Update Group success!'; } else { $response->status = 1; $response->msg = 'Error: Not isset Group.'; } } die(Tools::jsonEncode($response)); }
public function getAllGroups() { $langId = Context::getContext()->language->id; $shopId = Context::getContext()->shop->id; $items = DB::getInstance()->executeS("Select * From " . _DB_PREFIX_ . "ovic_custom_tags_groups Where `id_shop`='" . $shopId . "' Order By position, ordering"); $content = ''; if ($items) { foreach ($items as $item) { if ($item['status'] == "1") { $status = '<a title="Enabled" class="list-action-enable action-enabled lik-group-status" item-id="' . $item['id'] . '" value="' . $item['status'] . '"><i class="icon-check"></i></a>'; } else { $status = '<a title="Disabled" class="list-action-enable action-disabled lik-group-status" item-id="' . $item['id'] . '" value="' . $item['status'] . '"><i class="icon-check"></i></a>'; } $params = json_decode($item['params']); $value = '<div class="style-values"><span class="style-value" style="background: ' . $params->background . '"> </span><label>Background</label>: <span>' . $params->background . '</span></div>'; $value .= '<div class="style-values"><span class="style-value" style="background: ' . $params->color . '"> </span><label>Color</label>: <span>' . $params->color . '</span></div>'; $itemLang = $this->getGroupByLang($item['id'], $langId, $shopId); $content .= '<tr id="gr_' . $item['id'] . '"> <td><a class="lik-group" href="javascript:void(0)" item-id="' . $item['id'] . '">' . $itemLang['name'] . '</a></td> <td class="center">' . Hook::getNameById($item['position']) . '</td> <td>' . $value . '</td> <td class="pointer dragHandle center" ><div class="dragGroup"><div class="positions">' . $item['ordering'] . '</div></div></td> <td class="center">' . $status . '</td> <td class="center"> <a href="javascript:void(0)" item-id="' . $item['id'] . '" class="lik-group-edit"><i class="icon-edit"></i></a> <a href="javascript:void(0)" item-id="' . $item['id'] . '" class="lik-group-delete"><i class="icon-trash" ></i></a> </td> </tr>'; } } return $content; }
public function getAllBanner() { $langId = Context::getContext()->language->id; $shopId = Context::getContext()->shop->id; $items = DB::getInstance()->executeS("Select * From " . _DB_PREFIX_ . "ovic_custom_banners Where id_shop='" . $shopId . "' Order By position, ordering"); $content = ''; if ($items) { foreach ($items as $item) { if ($item['status'] == "1") { $status = '<a title="Enabled" class="list-action-enable action-enabled lik-banner-status" item-id="' . $item['id'] . '" value="' . $item['status'] . '"><i class="icon-check"></i></a>'; } else { $status = '<a title="Disabled" class="list-action-enable action-disabled lik-banner-status" item-id="' . $item['id'] . '" value="' . $item['status'] . '"><i class="icon-check"></i></a>'; } $params = json_decode($item['params']); $itemLang = $this->getBannerByLang($item['id'], $langId, $shopId); $content .= '<tr id="bn_' . $item['id'] . '"><td><img width="80" src="' . $this->getBannerSrc($itemLang['banner_image']) . '" alt="' . $itemLang['banner_title'] . '" /></td><td class="center">' . Hook::getNameById($item['position']) . '</td><td class="pointer dragHandle center" ><div class="dragGroup"><div class="positions">' . $item['ordering'] . '</div></div></td><td class="center">' . $status . '</td><td class="center"><a href="javascript:void(0)" item-id="' . $item['id'] . '" class="lik-banner-edit"><i class="icon-edit"></i></a> <a href="javascript:void(0)" item-id="' . $item['id'] . '" class="lik-banner-delete"><i class="icon-trash" ></i></a></td></tr>'; } } return $content; }
public static function saveGroup() { $module = new GroupCategory(); $module->clearCache(); $shopId = Context::getContext()->shop->id; $languages = $module->getAllLanguage(); $db = DB::getInstance(); $groupId = intval($_POST['groupId']); $names = Tools::getValue('names', array()); $groupIcon = Tools::getValue('groupIcon', ''); $banners = Tools::getValue('banners', array()); $links = Tools::getValue('links', array()); $style_id = intval($_POST['style_id']); $categoryId = intval($_POST['categoryId']); $type_default = $_POST['type_default']; $types = Tools::getValue('types', array()); if ($types) { $types = json_encode($_POST['types']); } else { $types = ''; } $manufacturerIds = Tools::getValue('manufacturerIds', array()); $imageWidth = intval($_POST['imageWidth']); $imageHeight = intval($_POST['imageHeight']); $layout = 'default'; $position = intval($_POST['position']); $position_name = Hook::getNameById($position); $itemData = new stdClass(); $itemData->itemWidth = $module->imageHomeSize['width']; $itemData->itemHeight = $module->imageHomeSize['height']; $itemData->itemMinWidth = 200; $itemData->countItem = intval($_POST['countItem']); $manufacturer = new stdClass(); $manufacturer->ids = array(); $manIds = array(); if ($manufacturerIds) { foreach ($manufacturerIds as $i => $value) { if ($value != '0') { $manufacturer->ids[] = $value; } } } $manufacturer->imageWidth = $imageWidth; $manufacturer->imageHeight = $imageHeight; $manufactureConfig = json_encode($manufacturer); $itemConfig = json_encode($itemData); require_once dirname(__FILE__) . '/GroupCategoryThumb.php'; $img = new GroupCategoryThumb(); $response = new stdClass(); if ($groupId == 0) { $maxOrdering = $db->getValue("Select MAX(ordering) From " . _DB_PREFIX_ . "groupcategory_groups Where `position` = " . $position); if ($maxOrdering > 0) { $maxOrdering++; } else { $maxOrdering = 1; } $sql = "Insert Into " . _DB_PREFIX_ . "groupcategory_groups (`position`, `position_name`, `id_shop`, `categoryId`, `style_id`, `manufactureConfig`, `itemConfig`, `types`, `ordering`, `status`, `type_default`, `layout`) Values ('" . $position . "', '{$position_name}', '{$shopId}', '" . $categoryId . "', '" . $style_id . "', '" . $manufactureConfig . "', '" . $itemConfig . "', '" . $types . "', '" . $maxOrdering . "', 1, '" . $type_default . "', '" . $layout . "')"; if (DB::getInstance()->execute($sql)) { $insertId = DB::getInstance()->Insert_ID(); if ($groupIcon && file_exists($module->pathTemp . $groupIcon)) { $path_info = pathinfo($groupIcon); $ext = $path_info['extension']; $iconName = $insertId . '-' . $shopId . '-icon.' . $ext; if (copy($module->pathTemp . $groupIcon, $module->pathBanner . $iconName)) { unlink($module->pathTemp . $groupIcon); DB::getInstance()->execute("Update " . _DB_PREFIX_ . "groupcategory_groups Set icon='" . $iconName . "' Where id = " . $insertId); } } if ($languages) { $insertDatas = array(); $defaultBanner = array(); foreach ($languages as $index => $language) { if ($banners[$index] && file_exists($module->pathTemp . $banners[$index])) { $path_info = pathinfo($banners[$index]); $ext = $path_info['extension']; $bannerName = $insertId . '-' . $language->id . '-' . $shopId . '-banner.' . $ext; $sourceSize = getimagesize($module->pathTemp . $banners[$index]); if ($sourceSize[0] > 281) { @$img->pCreate($module->pathTemp . $banners[$index], 281, null, 100, true); @$img->pSave($module->pathBanner . $bannerName); } else { copy($module->pathTemp . $banners[$index], $module->pathBanner . $bannerName); } unlink($module->pathTemp . $banners[$index]); $size = getimagesize($module->pathBanner . $bannerName); $params = new stdClass(); $params->width = $size[0]; $params->height = $size[1]; $params->w_per_h = round($size[0] / $size[1], 3); if (!$defaultBanner) { $defaultBanner['banner'] = $bannerName; $defaultBanner['params'] = $params; } $insertDatas[] = array('group_id' => $insertId, 'id_lang' => $language->id, 'id_shop' => $shopId, 'name' => $db->escape($names[$index]), 'banner' => $bannerName, 'banner_link' => $db->escape($links[$index]), 'banner_size' => json_encode($params)); } else { if ($defaultBanner) { $path_info = pathinfo($defaultBanner['banner']); $ext = $path_info['extension']; $bannerName = $insertId . '-' . $language->id . '-' . $shopId . '-banner.' . $ext; $insertDatas[] = array('group_id' => $insertId, 'id_lang' => $language->id, 'id_shop' => $shopId, 'name' => $db->escape($names[$index]), 'banner' => $bannerName, 'banner_link' => $db->escape($links[$index]), 'banner_size' => json_encode($defaultBanner['params'])); } else { $insertDatas[] = array('group_id' => $insertId, 'id_lang' => $language->id, 'id_shop' => $shopId, 'name' => $db->escape($names[$index]), 'banner' => '', 'banner_link' => $db->escape($links[$index])); } } } if ($insertDatas) { $db->insert('groupcategory_group_lang', $insertDatas); } } $response->status = 1; $response->msg = "Add new Group Success!"; } else { $response->status = 0; $response->msg = "Add new Group not Success!"; } } else { $item = DB::getInstance()->getRow("Select * From " . _DB_PREFIX_ . "groupcategory_groups Where id = " . $groupId); if ($item) { $sql = "Update " . _DB_PREFIX_ . "groupcategory_groups Set \n `position` = " . $position . ", \t\t\t\t\t\n `position_name` = '" . $position_name . "',\n `id_shop` = '" . $shopId . "', \n `categoryId` = '" . $categoryId . "',\n `type_default` = '" . $type_default . "', \n `style_id` = '" . $style_id . "', \n `manufactureConfig` = '" . $manufactureConfig . "', \n `itemConfig` = '" . $itemConfig . "', \n `types` = '" . $types . "', \n `layout` = '" . $layout . "' Where id = " . $groupId; DB::getInstance()->execute($sql); if ($groupIcon && file_exists($module->pathTemp . $groupIcon)) { $path_info = pathinfo($groupIcon); $ext = $path_info['extension']; $iconName = $groupId . '-' . $shopId . '-icon.' . $ext; copy($module->pathTemp . $groupIcon, $module->pathIcon . $iconName); unlink($module->pathTemp . $groupIcon); DB::getInstance()->execute("Update " . _DB_PREFIX_ . "groupcategory_groups Set `icon`='{$iconName}' Where `id` = " . $groupId); } if ($languages) { $insertDatas = array(); $defaultBanner = array(); foreach ($languages as $index => $language) { $check = DB::getInstance()->getValue("Select group_id From " . _DB_PREFIX_ . "groupcategory_group_lang Where group_id = " . $groupId . " AND `id_lang` = " . $language->id . " AND id_shop = " . $shopId); if ($banners[$index] && file_exists($module->pathTemp . $banners[$index])) { $path_info = pathinfo($banners[$index]); $ext = $path_info['extension']; $bannerName = $groupId . '-' . $language->id . '-' . $shopId . '-banner.' . $ext; $sourceSize = getimagesize($module->pathTemp . $banners[$index]); if ($sourceSize[0] > 281) { @$img->pCreate($module->pathTemp . $banners[$index], 281, null, 100, true); @$img->pSave($module->pathBanner . $bannerName); } else { copy($module->pathTemp . $banners[$index], $module->pathBanner . $bannerName); } unlink($module->pathTemp . $banners[$index]); $size = getimagesize($module->pathBanner . $bannerName); $params = new stdClass(); $params->width = $size[0]; $params->height = $size[1]; $params->w_per_h = round($size[0] / $size[1], 3); if (!$defaultBanner) { $defaultBanner['banner'] = $bannerName; $defaultBanner['params'] = $params; } if ($check) { $db->execute("Update " . _DB_PREFIX_ . "groupcategory_group_lang Set `name` = '" . $db->escape($names[$index]) . "', `banner` = '{$bannerName}', `banner_link` = '" . $db->escape($links[$index]) . "', `banner_size` = '" . json_encode($params) . "' Where `group_id` = {$groupId} AND `id_lang` = " . $language->id . " AND `id_shop` = " . $shopId); } else { $insertDatas[] = array('group_id' => $itemId, 'id_lang' => $language->id, 'id_shop' => $shopId, 'name' => $db->escape($names[$index]), 'banner' => $bannerName, 'banner_link' => $db->escape($links[$index]), 'banner_size' => json_encode($params)); } } else { if ($check) { $db->execute("Update " . _DB_PREFIX_ . "groupcategory_group_lang Set `name` = '" . $db->escape($names[$index]) . "', `banner_link` = '" . $db->escape($links[$index]) . "' Where `group_id` = {$groupId} AND `id_lang` = " . $language->id . " AND `id_shop` = " . $shopId); } else { if ($defaultBanner) { $path_info = pathinfo($defaultBanner['banner']); $ext = $path_info['extension']; $bannerName = $groupId . '-' . $language->id . '-' . $shopId . '-banner.' . $ext; $insertDatas[] = array('group_id' => $insertId, 'id_lang' => $language->id, 'id_shop' => $shopId, 'name' => $db->escape($names[$index]), 'banner' => $bannerName, 'banner_link' => $db->escape($links[$index]), 'banner_size' => json_encode($defaultBanner['params'])); } else { $insertDatas[] = array('group_id' => $insertId, 'id_lang' => $language->id, 'id_shop' => $shopId, 'name' => $db->escape($names[$index]), 'banner' => '', 'banner_link' => $db->escape($links[$index])); } } } } if ($insertDatas) { $db->insert('groupcategory_group_lang', $insertDatas); } } $response->status = 0; $response->msg = "Update Group Success!"; } else { $response->status = 0; $response->msg = "Item not found!"; } } $module->clearCache(); die(Tools::jsonEncode($response)); }
public function getContent() { $langId = Context::getContext()->language->id; $shopId = Context::getContext()->shop->id; $checkUpdate = DB::getInstance()->getRow("Select * From " . _DB_PREFIX_ . "verticalmegamenus_modules"); if ($checkUpdate) { if (!isset($checkUpdate['id_shop'])) { DB::getInstance()->execute("ALTER TABLE " . _DB_PREFIX_ . "verticalmegamenus_modules ADD `id_shop` INT(6) unsigned NOT NULL AFTER `id`"); DB::getInstance()->execute("Update " . _DB_PREFIX_ . "verticalmegamenus_modules Set `id_shop` = " . $shopId); } } $this->context->controller->addJS($this->_path . 'js/back-end/common.js'); $this->context->controller->addJS($this->_path . 'js/back-end/ajaxupload.3.5.js'); $this->context->controller->addJS($this->_path . 'js/back-end/tinymce.inc.js'); $this->context->controller->addJS($this->_path . 'js/back-end/jquery.serialize-object.min.js'); //Tools::addJS(_PS_BASE_URL_.__PS_BASE_URI__.'js/tinymce.inc.js'); $this->context->controller->addJS(__PS_BASE_URI__ . 'js/jquery/plugins/jquery.tablednd.js'); $this->context->controller->addJS(__PS_BASE_URI__ . 'js/jquery/plugins/jquery.colorpicker.js'); $this->context->controller->addJS(__PS_BASE_URI__ . 'js/tiny_mce/tinymce.min.js'); //Tools::addJS(_PS_BASE_URL_.__PS_BASE_URI__.'js/tinymce.inc.js'); $this->context->controller->addCSS($this->_path . 'css/back-end/style.css'); $this->context->controller->addCSS($this->_path . 'css/back-end/style-upload.css'); $items = DB::getInstance()->executeS("Select m.*, ml.name From " . _DB_PREFIX_ . "verticalmegamenus_modules AS m Left Join " . _DB_PREFIX_ . "verticalmegamenus_module_lang AS ml On ml.module_id = m.id Where m.id_shop=" . $shopId . " AND ml.id_lang = " . $langId . " Order By m.ordering"); $listModule = ''; $listLeftModule = ''; if ($items) { foreach ($items as $item) { if ($item['status'] == "1") { $status = '<a title="Enabled" class="list-action-enable action-enabled lik-module-status" item-id="' . $item['id'] . '" value="' . $item['status'] . '"><i class="icon-check"></i></a>'; } else { $status = '<a title="Disabled" class="list-action-enable action-disabled lik-module-status" item-id="' . $item['id'] . '" value="' . $item['status'] . '"><i class="icon-check"></i></a>'; } $listLeftModule .= '<a href="#item-module" class="list-group-item lik-module" item-id="' . $item['id'] . '" title="' . $item['name'] . '"> - ' . $item['name'] . '</a>'; $listModule .= '<tr id="mo_' . $item['id'] . '"> <td class="center">' . $item['id'] . '</td> <td>' . $item['name'] . '</td> <td class="center">' . Hook::getNameById($item['position']) . '</td> <td class="center">' . $this->arrLayout[$item['layout']] . '</td> <td class="pointer dragHandle center" ><div class="dragGroup"><div class="positions">' . $item['ordering'] . '</div></div></td> <td class="center">' . $status . '</td> <td class="center"><a href="javascript:void(0)" item-id="' . $item['id'] . '" class="lik-module-edit"><i class="icon-edit"></i></a> <a href="javascript:void(0)" item-id="' . $item['id'] . '" class="lik-module-delete"><i class="icon-trash" ></i></a></td> </tr>'; } } $this->context->smarty->assign(array('baseModuleUrl' => __PS_BASE_URI__ . 'modules/' . $this->name, 'moduleId' => $this->id, 'langId' => $langId, 'ad' => $ad = dirname($_SERVER["PHP_SELF"]), 'layoutOptions' => $this->getLayoutOptions(), 'typeOptions' => $this->getTypeOptions(), 'positionOptions' => $this->getPositionOptions(), 'categoryOptions' => $this->getCategoryOptions(), 'langOptions' => $this->getLangOptions(), 'columnOptions' => $this->getColumnOptions('col-sm-12'), 'list_module_tpl' => dirname(__FILE__) . '/views/templates/admin/list_module.tpl', 'list_menu_tpl' => dirname(__FILE__) . '/views/templates/admin/list_menu.tpl', 'listLeftModule' => $listLeftModule, 'listModule' => $listModule, 'allLink' => $this->getAllLinkOptions(), 'groupTypeOptions' => $this->getGroupTypeOptions(), 'productTypeOptions' => $this->getProductTypeOptions(), 'secure_key' => $this->secure_key, 'moduleForm' => $this->ovicRenderModuleForm(), 'menuForm' => $this->ovicRenderMenuForm(), 'menuGroupForm' => $this->ovicRenderMenuGroupForm(), 'menuItemForm' => $this->ovicRenderMenuItemForm())); return $this->display(__FILE__, 'views/templates/admin/modules.tpl'); }
static function saveModule() { $module = new FlexibleBrands(); $module->clearCache(); $languages = $module->getAllLanguages(); $shopId = Context::getContext()->shop->id; $itemId = Tools::getValue('moduleId'); $position = Tools::getValue('position', 0); $position_name = Hook::getNameById($position); $titles = Tools::getValue('titles', array()); $params = new stdClass(); $params->moduleLayout = Tools::getValue('moduleLayout'); $params->displayOnly = ''; // Tools::getValue('displayOnly'); $params->orderValue = ''; // Tools::getValue('orderValue'); $params->orderType = ''; // Tools::getValue('orderType'); $response = new stdClass(); $db = DB::getInstance(); if ($itemId == 0) { $maxOrdering = $db->getValue("Select MAX(ordering) From " . _DB_PREFIX_ . "flexiblebrand_modules Where `position` = " . $position); if ($maxOrdering > 0) { $maxOrdering++; } else { $maxOrdering = 1; } if ($db->execute("Insert Into " . _DB_PREFIX_ . "flexiblebrand_modules (`id_shop`, `position`, `position_name`, `status`, `params`, `ordering`) Values ('" . $shopId . "', '{$position}', '{$position_name}', 1, '" . json_encode($params) . "', '{$maxOrdering}')")) { $insertId = $db->Insert_ID(); if ($languages) { $insertSql = array(); foreach ($languages as $i => $language) { $images = Tools::getValue('bannerNames' . $language->id, array()); $links = Tools::getValue('bannerLink' . $language->id, array()); $alts = Tools::getValue('bannerAlt' . $language->id, array()); $banners = array(); if ($images) { foreach ($images as $j => $image) { if ($image && file_exists($module->tempPath . $image)) { if (copy($module->tempPath . $image, $module->bannerPath . $image)) { $banners[] = array('image' => $image, 'link' => $links[$j], 'alt' => $alts[$j]); unlink($module->tempPath . $image); } } } $insertSql[] = array('module_id' => $insertId, 'id_lang' => $language->id, 'id_shop' => $shopId, 'module_title' => $db->escape($titles[$i]), 'banners' => json_encode($banners)); } else { $insertSql[] = array('module_id' => $insertId, 'id_lang' => $language->id, 'id_shop' => $shopId, 'module_title' => $db->escape($titles[$i]), 'banners' => ''); } } if ($insertSql) { $db->insert('flexiblebrand_module_lang', $insertSql); } } $response->status = 1; $response->msg = 'Add new module success!'; } else { $response->status = 0; $response->msg = 'Error: Add new module failed!'; } } else { $item = $db->getRow("Select * From " . _DB_PREFIX_ . "flexiblebrand_modules Where id = " . $itemId); if ($item) { $db->execute("Update " . _DB_PREFIX_ . "flexiblebrand_modules Set `params`='" . json_encode($params) . "', `id_shop`='" . $shopId . "', `position` = '{$position}', `position_name` = '{$position_name}' Where id = " . $itemId); if ($languages) { $insertSql = array(); foreach ($languages as $i => $language) { $check = DB::getInstance()->getValue("Select module_id From " . _DB_PREFIX_ . "flexiblebrand_module_lang Where module_id = " . $itemId . " AND id_lang = " . $language->id . " AND id_shop = " . $shopId); $images = Tools::getValue('bannerNames' . $language->id, array()); $links = Tools::getValue('bannerLink' . $language->id, array()); $alts = Tools::getValue('bannerAlt' . $language->id, array()); $banners = array(); if ($images) { foreach ($images as $j => $image) { if ($image && file_exists($module->tempPath . $image)) { if (copy($module->tempPath . $image, $module->bannerPath . $image)) { unlink($module->tempPath . $image); } } $banners[] = array('image' => $image, 'link' => $links[$j], 'alt' => $alts[$j]); } if ($check) { $db->execute("Update " . _DB_PREFIX_ . "flexiblebrand_module_lang Set `module_title`='" . $db->escape($titles[$i]) . "', `banners`='" . json_encode($banners) . "' Where `module_id` = '" . $itemId . "' AND `id_lang` = '" . $language->id . "' AND `id_shop` = '" . $shopId . "'"); } else { $insertSql[] = array('module_id' => $itemId, 'id_lang' => $language->id, 'id_shop' => $shopId, 'module_title' => $db->escape($titles[$i]), 'banners' => json_encode($banners)); } } else { if ($check) { $db->execute("Update " . _DB_PREFIX_ . "flexiblebrand_module_lang Set `module_title`='" . $db->escape($titles[$i]) . "', `banners`='' Where `module_id` = '" . $itemId . "' AND `id_lang` = '" . $language->id . "' AND `id_shop` = '" . $shopId . "'"); } else { $insertSql[] = array('module_id' => $itemId, 'id_lang' => $language->id, 'id_shop' => $shopId, 'module_title' => $db->escape($titles[$i]), 'banners' => ''); } } } if ($insertSql) { $db->insert('flexiblebrand_module_lang', $insertSql); } } $response->status = 1; $response->msg = 'Update module success!'; } else { $response->status = 1; $response->msg = 'Error: Not isset Group.'; } } die(Tools::jsonEncode($response)); }
public static function unregisterHook($module_instance, $hook_name, $shop_list = null) { if (is_numeric($hook_name)) { // $hook_name passed it the id_hook $hook_id = $hook_name; $hook_name = Hook::getNameById((int) $hook_id); } else { $hook_id = Hook::getIdByName($hook_name); } if (!$hook_id) { return false; } Hook::exec('actionModuleUnRegisterHookBefore', array('object' => $module_instance, 'hook_name' => $hook_name)); // Unregister module on hook by id $sql = 'DELETE FROM `' . _DB_PREFIX_ . 'hook_module` WHERE `id_module` = ' . (int) $module_instance->id . ' AND `id_hook` = ' . (int) $hook_id . ($shop_list ? ' AND `id_shop` IN(' . implode(', ', array_map('intval', $shop_list)) . ')' : ''); $result = Db::getInstance()->execute($sql); // Clean modules position $module_instance->cleanPositions($hook_id, $shop_list); Hook::exec('actionModuleUnRegisterHookAfter', array('object' => $module_instance, 'hook_name' => $hook_name)); return $result; }