diff --git a/admin/themes/default/template/controllers/modules/list.tpl b/admin/themes/default/template/controllers/modules/list.tpl index 885a4e026..194b65764 100644 --- a/admin/themes/default/template/controllers/modules/list.tpl +++ b/admin/themes/default/template/controllers/modules/list.tpl @@ -54,11 +54,11 @@ {$module->displayName|escape:'html':'UTF-8'} v{$module->version} - {l s='by'} {$module->author} {if isset($module->type) && $module->type == 'addonsBought'} - - {l s="Bought"} + - {l s="Bought"} {elseif isset($module->type) && $module->type == 'addonsMustHave'} - - {l s="Popular"} + - {l s="Popular"} {elseif isset($module->type) && $module->type == 'addonsPartner'} - - {l s="Official"} + - {l s="Official"} {elseif isset($module->id) && $module->id gt 0} {if isset($module->version_addons) && $module->version_addons} {l s='Need update'} diff --git a/admin/themes/default/template/controllers/modules/page_header_toolbar.tpl b/admin/themes/default/template/controllers/modules/page_header_toolbar.tpl index ee9d38c0d..eb2e98402 100644 --- a/admin/themes/default/template/controllers/modules/page_header_toolbar.tpl +++ b/admin/themes/default/template/controllers/modules/page_header_toolbar.tpl @@ -36,7 +36,7 @@
{/if}
- {l s='More modules on addons.prestashop.com'} + {l s='More modules on qloapps.com/addons/'}
diff --git a/classes/Hook.php b/classes/Hook.php index 3f734331c..4483ced1b 100644 --- a/classes/Hook.php +++ b/classes/Hook.php @@ -476,13 +476,6 @@ class HookCore extends ObjectModel if ($disable_non_native_modules && !isset(Hook::$native_module)) { Hook::$native_module = Module::getNativeModuleList(); - if (Module::isInstalled('hotelreservationsystem')) { - include_once _PS_MODULE_DIR_.'hotelreservationsystem/classes/HotelHelper.php'; - $qloNativeMods = array(); - if ($qloNativeMods = HotelHelper::getQloNativeModules()) { - Hook::$native_module = array_merge(Hook::$native_module, $qloNativeMods); - } - } } $different_shop = false; diff --git a/classes/Tab.php b/classes/Tab.php index a95e91127..24932aed8 100644 --- a/classes/Tab.php +++ b/classes/Tab.php @@ -46,7 +46,7 @@ class TabCore extends ObjectModel /** @var int hide_host_mode */ public $hide_host_mode = false; - const TAB_MODULE_LIST_URL = _PS_TAB_MODULE_LIST_URL_; + const TAB_MODULE_LIST_URL = _QLO_TAB_MODULE_LIST_URL_; /** * @see ObjectModel::$definition @@ -563,9 +563,6 @@ class TabCore extends ObjectModel public static function getTabModulesList($id_tab) { $modules_list = array('default_list' => array(), 'slider_list' => array()); - //@TODO in future we will show Qloapps recommended addons as per the tabs - // for not we will not show any recommended addons of prestashop - return $modules_list; $xml_tab_modules_list = false; diff --git a/classes/Tools.php b/classes/Tools.php index 2d58fbfae..8fc419740 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -3318,7 +3318,7 @@ exit; } $post_data = http_build_query(array( - 'version' => isset($params['version']) ? $params['version'] : _PS_VERSION_, + 'version' => isset($params['version']) ? $params['version'] : _QLOAPPS_VERSION_, 'iso_lang' => Tools::strtolower(isset($params['iso_lang']) ? $params['iso_lang'] : Context::getContext()->language->iso_code), 'iso_code' => Tools::strtolower(isset($params['iso_country']) ? $params['iso_country'] : Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))), 'shop_url' => isset($params['shop_url']) ? $params['shop_url'] : Tools::getShopDomain(), @@ -3326,7 +3326,7 @@ exit; )); $protocols = array('https'); - $end_point = 'api.addons.prestashop.com'; + $end_point = 'api.qloapps.com'; switch ($request) { case 'native': @@ -3360,7 +3360,7 @@ exit; $post_data .= '&method=check&module_name='.urlencode($params['module_name']).'&module_key='.urlencode($params['module_key']); break; case 'module': - $post_data .= '&method=module&id_module='.urlencode($params['id_module']); + $post_data .= '&method=module&module_name='.urlencode($params['module_name']); if (isset($params['username_addons']) && isset($params['password_addons'])) { $post_data .= '&username='.urlencode($params['username_addons']).'&password='.urlencode($params['password_addons']); } else { @@ -3388,7 +3388,7 @@ exit; 'method' => 'POST', 'content' => $post_data, 'header' => 'Content-type: application/x-www-form-urlencoded', - 'timeout' => 5, + 'timeout' => 10, ) )); diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 650355110..a50721962 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -239,6 +239,9 @@ class AdminControllerCore extends Controller /** @var HelperList */ protected $helper; + /** @var bool */ + protected static $is_qloapps_up = true; + /** * Actions to execute on multiple selections. * @@ -2126,7 +2129,7 @@ class AdminControllerCore extends Controller @file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, Tools::addonsRequest('must-have')); } if (!$this->isFresh(Module::CACHE_FILE_TAB_MODULES_LIST, 604800)) { - $this->refresh(Module::CACHE_FILE_TAB_MODULES_LIST, _PS_TAB_MODULE_LIST_URL_); + $this->refresh(Module::CACHE_FILE_TAB_MODULES_LIST, _QLO_TAB_MODULE_LIST_URL_); } $this->tab_modules_list = Tab::getTabModulesList($this->id); @@ -4042,9 +4045,6 @@ class AdminControllerCore extends Controller return false; } - /** @var bool */ - protected static $is_prestashop_up = true; - /** * @param string $file_to_refresh * @param string $external_file @@ -4052,10 +4052,10 @@ class AdminControllerCore extends Controller */ public function refresh($file_to_refresh, $external_file) { - if (self::$is_prestashop_up && $content = Tools::file_get_contents($external_file)) { + if (self::$is_qloapps_up && $content = Tools::file_get_contents($external_file)) { return (bool)file_put_contents(_PS_ROOT_DIR_.$file_to_refresh, $content); } - self::$is_prestashop_up = false; + self::$is_qloapps_up = false; return false; } diff --git a/classes/module/Module.php b/classes/module/Module.php index a1160bb15..90a0d270c 100644 --- a/classes/module/Module.php +++ b/classes/module/Module.php @@ -1473,7 +1473,100 @@ abstract class ModuleCore } } } - //INFO:: addons module are removed from the module lists + + $files_list = array( + array('type' => 'addonsNative', 'file' => _PS_ROOT_DIR_.self::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 'loggedOnAddons' => 0), + array('type' => 'addonsMustHave', 'file' => _PS_ROOT_DIR_.self::CACHE_FILE_MUST_HAVE_MODULES_LIST, 'loggedOnAddons' => 0), + array('type' => 'addonsBought', 'file' => _PS_ROOT_DIR_.self::CACHE_FILE_CUSTOMER_MODULES_LIST, 'loggedOnAddons' => 1), + ); + foreach ($files_list as $f) { + if (file_exists($f['file']) && ($f['loggedOnAddons'] == 0 || $logged_on_addons)) { + if (Module::useTooMuchMemory()) { + $errors[] = Tools::displayError('All modules cannot be loaded due to memory limit restrictions, please increase your memory_limit value on your server configuration'); + break; + } + + $file = $f['file']; + $content = Tools::file_get_contents($file); + $xml = @simplexml_load_string($content, null, LIBXML_NOCDATA); + if ($xml && isset($xml->module)) { + foreach ($xml->module as $modaddons) { + $flag_found = 0; + + foreach ($module_list as $k => &$m) { + if (Tools::strtolower($m->name) == Tools::strtolower($modaddons->name) && !isset($m->available_on_addons)) { + $flag_found = 1; + if ($m->version != $modaddons->version && version_compare($m->version, $modaddons->version) === -1) { + $module_list[$k]->version_addons = $modaddons->version; + } + } + } + + if ($flag_found == 0) { + $item = new stdClass(); + $item->id = 0; + $item->warning = ''; + $item->type = strip_tags((string)$f['type']); + $item->name = strip_tags((string)$modaddons->name); + $item->version = strip_tags((string)$modaddons->version); + $item->tab = strip_tags((string)$modaddons->tab); + $item->displayName = strip_tags((string)$modaddons->displayName); + $item->description = stripslashes(strip_tags((string)$modaddons->description)); + $item->description_full = stripslashes(strip_tags((string)$modaddons->description_full)); + $item->author = strip_tags((string)$modaddons->author); + $item->limited_countries = array(); + $item->parent_class = ''; + $item->onclick_option = false; + $item->is_configurable = 0; + $item->need_instance = 0; + $item->not_on_disk = 1; + $item->available_on_addons = 1; + $item->trusted = Module::isModuleTrusted($item->name); + $item->active = 0; + $item->description_full = stripslashes($modaddons->description_full); + $item->additional_description = isset($modaddons->additional_description) ? stripslashes($modaddons->additional_description) : null; + $item->compatibility = isset($modaddons->compatibility) ? (array)$modaddons->compatibility : null; + $item->nb_rates = isset($modaddons->nb_rates) ? (array)$modaddons->nb_rates : null; + $item->avg_rate = isset($modaddons->avg_rate) ? (array)$modaddons->avg_rate : null; + $item->badges = isset($modaddons->badges) ? (array)$modaddons->badges : null; + $item->url = isset($modaddons->url) ? $modaddons->url : null; + + if (isset($modaddons->img)) { + if (!file_exists(_PS_TMP_IMG_DIR_.md5((int)$modaddons->id.'-'.$modaddons->name).'.jpg')) { + if (!file_put_contents(_PS_TMP_IMG_DIR_.md5((int)$modaddons->id.'-'.$modaddons->name).'.jpg', Tools::file_get_contents($modaddons->img))) { + copy(_PS_IMG_DIR_.'404.gif', _PS_TMP_IMG_DIR_.md5((int)$modaddons->id.'-'.$modaddons->name).'.jpg'); + } + } + + if (file_exists(_PS_TMP_IMG_DIR_.md5((int)$modaddons->id.'-'.$modaddons->name).'.jpg')) { + $item->image = '../img/tmp/'.md5((int)$modaddons->id.'-'.$modaddons->name).'.jpg'; + } + } + + if ($item->type == 'addonsMustHave') { + $item->addons_buy_url = strip_tags((string)$modaddons->url); + $prices = (array)$modaddons->price; + $id_default_currency = Configuration::get('PS_CURRENCY_DEFAULT'); + + foreach ($prices as $currency => $price) { + if ($id_currency = Currency::getIdByIsoCode($currency)) { + $item->price = (float)$price; + $item->id_currency = (int)$id_currency; + + if ($id_default_currency == $id_currency) { + break; + } + } + } + } + + $module_list[$modaddons->id.'-'.$item->name] = $item; + } + } + } + } + } + foreach ($module_list as $key => &$module) { if (defined('_PS_HOST_MODE_') && in_array($module->name, self::$hosted_modules_blacklist)) { unset($module_list[$key]); @@ -1669,9 +1762,6 @@ abstract class ModuleCore } // The module seems to be trusted, but it does not seem to be dedicated to this country return 2; - // Check if module is from webkul then it will be considered as trusted module - } elseif (isset($objModule->author) && (strtolower($objModule->author) == 'webkul')) { - return 1; } elseif (stripos($untrusted_modules_list_content, $module_name) !== false) { // If the module is already in the untrusted list, then return 0 (untrusted) return 0; diff --git a/config/defines_uri.inc.php b/config/defines_uri.inc.php index 025696c44..8e5970337 100644 --- a/config/defines_uri.inc.php +++ b/config/defines_uri.inc.php @@ -82,6 +82,8 @@ define('_MODULE_DIR_', __PS_BASE_URI__.'modules/'); /* Define API URLs if not defined before */ Tools::safeDefine('_PS_API_DOMAIN_', 'api.prestashop.com'); Tools::safeDefine('_PS_API_URL_', 'http://'._PS_API_DOMAIN_); -Tools::safeDefine('_PS_TAB_MODULE_LIST_URL_', _PS_API_URL_.'/xml/tab_modules_list.xml'); -Tools::safeDefine('_PS_API_MODULES_LIST_16_', _PS_API_DOMAIN_.'/xml/modules_list_16.xml'); Tools::safeDefine('_PS_CURRENCY_FEED_URL_', _PS_API_URL_.'/xml/currencies.xml'); +Tools::safeDefine('_QLO_API_DOMAIN_', 'api.qloapps.com'); +Tools::safeDefine('_QLO_API_URL_', 'http://'._QLO_API_DOMAIN_); +Tools::safeDefine('_QLO_TAB_MODULE_LIST_URL_', _QLO_API_URL_.'/xml/tab_modules_list.xml'); +Tools::safeDefine('_QLO_NATIVE_MODULES_LIST_',_QLO_API_DOMAIN_.'/xml/'.str_replace('.', '', _QLOAPPS_VERSION_).'.xml'); diff --git a/controllers/admin/AdminInformationController.php b/controllers/admin/AdminInformationController.php index 4f05a418f..48bb920c7 100644 --- a/controllers/admin/AdminInformationController.php +++ b/controllers/admin/AdminInformationController.php @@ -169,7 +169,7 @@ class AdminInformationControllerCore extends AdminController public function displayAjaxCheckFiles() { $this->file_list = array('missing' => array(), 'updated' => array()); - $xml = @simplexml_load_file(_PS_API_URL_.'/xml/md5/'._PS_VERSION_.'.xml'); + $xml = @simplexml_load_file(_QLO_API_URL_.'/xml/md5/'._QLOAPPS_VERSION_.'.xml'); if (!$xml || !isset($xml->ps_root_dir[0])) { die(json_encode($this->file_list)); } diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php index 37a20c8be..44e60ce86 100644 --- a/controllers/admin/AdminModulesController.php +++ b/controllers/admin/AdminModulesController.php @@ -60,7 +60,7 @@ class AdminModulesControllerCore extends AdminController protected $iso_default_country; protected $filter_configuration = array(); - protected $xml_modules_list = _PS_API_MODULES_LIST_16_; + protected $xml_modules_list = _QLO_NATIVE_MODULES_LIST_; /** * Admin Modules Controller Constructor @@ -768,8 +768,8 @@ class AdminModulesControllerCore extends AdminController if (!file_exists(_PS_MODULE_DIR_.$name.'/'.$name.'.php') || $key == 'update' || $key == 'updateAll') { $files_list = array( array('type' => 'addonsNative', 'file' => Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 'loggedOnAddons' => 0), - array('type' => 'addonsBought', 'file' => Module::CACHE_FILE_CUSTOMER_MODULES_LIST, 'loggedOnAddons' => 1), - array('type' => 'addonsMustHave', 'file' => Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, 'loggedOnAddons' => 1), + // array('type' => 'addonsBought', 'file' => Module::CACHE_FILE_CUSTOMER_MODULES_LIST, 'loggedOnAddons' => 1), + // array('type' => 'addonsMustHave', 'file' => Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, 'loggedOnAddons' => 1), ); foreach ($files_list as $f) { @@ -779,7 +779,8 @@ class AdminModulesControllerCore extends AdminController if ($xml = @simplexml_load_string($content, null, LIBXML_NOCDATA)) { foreach ($xml->module as $modaddons) { if (Tools::strtolower($name) == Tools::strtolower($modaddons->name)) { - $module_to_update[$name]['id'] = $modaddons->id; + // $module_to_update[$name]['id'] = $modaddons->id; + $module_to_update[$name]['name'] = $modaddons->name; $module_to_update[$name]['displayName'] = $modaddons->displayName; $module_to_update[$name]['need_loggedOnAddons'] = $f['loggedOnAddons']; } @@ -791,11 +792,11 @@ class AdminModulesControllerCore extends AdminController foreach ($module_to_update as $name => $attr) { if ((is_null($attr) && $this->logged_on_addons == 0) || ($attr['need_loggedOnAddons'] == 1 && $this->logged_on_addons == 0)) { $this->errors[] = sprintf(Tools::displayError('You need to be logged in to your PrestaShop Addons account in order to update the %s module. %s'), ''.$name.'', ''.$this->l('Click here to log in.').''); - } elseif (!is_null($attr['id'])) { + } elseif (!is_null($attr['name'])) { $download_ok = false; - if ($attr['need_loggedOnAddons'] == 0 && file_put_contents(_PS_MODULE_DIR_.$name.'.zip', Tools::addonsRequest('module', array('id_module' => pSQL($attr['id']))))) { + if ($attr['need_loggedOnAddons'] == 0 && file_put_contents(_PS_MODULE_DIR_.$name.'.zip', Tools::addonsRequest('module', array('module_name' => pSQL($attr['name']))))) { $download_ok = true; - } elseif ($attr['need_loggedOnAddons'] == 1 && $this->logged_on_addons && file_put_contents(_PS_MODULE_DIR_.$name.'.zip', Tools::addonsRequest('module', array('id_module' => pSQL($attr['id']), 'username_addons' => pSQL(trim($this->context->cookie->username_addons)), 'password_addons' => pSQL(trim($this->context->cookie->password_addons)))))) { + } elseif ($attr['need_loggedOnAddons'] == 1 && $this->logged_on_addons && file_put_contents(_PS_MODULE_DIR_.$name.'.zip', Tools::addonsRequest('module', array('module_name' => pSQL($attr['name']), 'username_addons' => pSQL(trim($this->context->cookie->username_addons)), 'password_addons' => pSQL(trim($this->context->cookie->password_addons)))))) { $download_ok = true; } diff --git a/controllers/admin/AdminThemesController.php b/controllers/admin/AdminThemesController.php index edc0e09ae..cb7f742dc 100644 --- a/controllers/admin/AdminThemesController.php +++ b/controllers/admin/AdminThemesController.php @@ -2039,7 +2039,12 @@ class AdminThemesControllerCore extends AdminController */ private function getNativeModule($type = 0) { - $xml = @simplexml_load_string(Tools::file_get_contents(_PS_API_URL_.'/xml/modules_list_16.xml')); + $protocols = array('https://', 'http://'); + foreach ($protocols as $protocol) { + if($xml = @simplexml_load_string(Tools::file_get_contents($protocol._QLO_NATIVE_MODULES_LIST_))) { + break; + } + } if ($xml) { $natives = array();