public static function getMenus($id_lang, $active = true, $get_from_all_shops = false, $groupRestrict = false) { $sql_groups_join = ''; $sql_groups_where = ''; if ($groupRestrict && (version_compare(_PS_VERSION_, '1.5.0.0', '>=') && Group::isFeatureActive() || version_compare(_PS_VERSION_, '1.5.0.0', '<') && version_compare(_PS_VERSION_, '1.2.5.0', '>='))) { $groups = PM_AdvancedTopMenu::getCustomerGroups(); if (sizeof($groups)) { $sql_groups_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cg.`id_category` = ca.`id_category`)'; $sql_groups_where = 'AND IF (atp.`id_category` IS NULL OR atp.`id_category` = 0, 1, cg.`id_group` IN (' . implode(',', $groups) . '))'; } } $sql = 'SELECT atp.*, atpl.*, cl.link_rewrite, cl.meta_title, cal.link_rewrite as category_link_rewrite, cal.name as category_name, m.name as manufacturer_name, s.name as supplier_name FROM `' . _DB_PREFIX_ . 'pm_advancedtopmenu` atp ' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') && Shop::isFeatureActive() ? self::addSqlAssociation('pm_advancedtopmenu', 'atp', 'id_menu', true, null, $get_from_all_shops ? 'all' : false) : '') . ' LEFT JOIN `' . _DB_PREFIX_ . 'pm_advancedtopmenu_lang` atpl ON (atp.`id_menu` = atpl.`id_menu` AND atpl.`id_lang` = ' . intval($id_lang) . ') LEFT JOIN ' . _DB_PREFIX_ . 'cms c ON (c.id_cms = atp.`id_cms`) ' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? Shop::addSqlAssociation('cms', 'c', false, true, null, $get_from_all_shops ? 'all' : false) : '') . ' LEFT JOIN ' . _DB_PREFIX_ . 'cms_lang cl ON (c.id_cms = cl.id_cms AND cl.id_lang = ' . intval($id_lang) . ') LEFT JOIN ' . _DB_PREFIX_ . 'category ca ON (ca.id_category = atp.`id_category`) ' . $sql_groups_join . ' LEFT JOIN ' . _DB_PREFIX_ . 'category_lang cal ON (ca.id_category = cal.id_category AND cal.id_lang = ' . intval($id_lang) . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? Shop::addSqlRestrictionOnLang('cal') : '') . ') LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (atp.`id_manufacturer` = m.`id_manufacturer`) ' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? Shop::addSqlAssociation('manufacturer', 'm', false, true, null, $get_from_all_shops ? 'all' : false) : '') . ' LEFT JOIN `' . _DB_PREFIX_ . 'supplier` s ON (atp.`id_supplier` = s.`id_supplier`) ' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? Shop::addSqlAssociation('supplier', 's', false, true, null, $get_from_all_shops ? 'all' : false) : '') . ' ' . ($active ? ' WHERE atp.`active` = 1 AND ((atp.`id_manufacturer` = 0 AND atp.`id_supplier` = 0 AND atp.`id_category` = 0 AND atp.`id_cms` = 0) OR c.id_cms IS NOT NULL OR m.id_manufacturer IS NOT NULL OR ca.id_category IS NOT NULL OR s.`id_supplier` IS NOT NULL) ' . $sql_groups_where : '') . ' GROUP BY atp.`id_menu` ORDER BY atp.`position`'; return Db::getInstance()->ExecuteS($sql); }
private function _enableCachePM($level = 1) { if (version_compare(_PS_VERSION_, '1.4.0.0', '<') && !Configuration::get('ATM_CACHE') || version_compare(_PS_VERSION_, '1.4.0.0', '>=') && !Configuration::get('PS_SMARTY_CACHE')) { return; } if ($this->_smarty->force_compile == 0 and $this->_smarty->compile_check == 0 and $this->_smarty->caching == $level) { return; } self::$_forceCompile = (int) $this->_smarty->force_compile; self::$_compileCheck = (int) $this->_smarty->compile_check; self::$_caching = (int) $this->_smarty->caching; $this->_smarty->force_compile = 0; $this->_smarty->compile_check = 0; $this->_smarty->caching = (int) $level; }