diff --git a/classes/Module.php b/classes/Module.php index 7ce30d452..d1462f28f 100644 --- a/classes/Module.php +++ b/classes/Module.php @@ -998,52 +998,54 @@ abstract class ModuleCore // Get Default Country Modules and customer module - if ($loggedOnAddons) - { - $filesList = array(_PS_ROOT_DIR_.'/config/default_country_modules_list.xml', _PS_ROOT_DIR_.'/config/customer_modules_list.xml'); - foreach ($filesList as $file) - if (file_exists($file)) + $filesList = array( + array('type' => 'addonsNative', 'file' => _PS_ROOT_DIR_.'/config/xml/default_country_modules_list.xml', 'loggedOnAddons' => 0), + array('type' => 'addonsBought', 'file' => _PS_ROOT_DIR_.'/config/xml/customer_modules_list.xml', 'loggedOnAddons' => 1), + ); + foreach ($filesList as $f) + if (file_exists($f['file']) && ($f['loggedOnAddons'] == 0 || $loggedOnAddons)) + { + $file = $f['file']; + $content = Tools::file_get_contents($file); + $xml = @simplexml_load_string($content, NULL, LIBXML_NOCDATA); + foreach ($xml->module as $modaddons) { - $content = Tools::file_get_contents($file); - $xml = @simplexml_load_string($content, NULL, LIBXML_NOCDATA); - foreach ($xml->module as $modaddons) - { - $flagFound = 0; - foreach ($moduleList as $k => $m) - if ($m->name == $modaddons->name && !isset($m->available_on_addons)) - { - $flagFound = 1; - if ($m->version != $modaddons->version && version_compare($m->version, $modaddons->version) === -1) - $moduleList[$k]->version_addons = $modaddons->version; - } - if ($flagFound == 0) + $flagFound = 0; + foreach ($moduleList as $k => $m) + if ($m->name == $modaddons->name && !isset($m->available_on_addons)) { - $item = new stdClass(); - $item->id = 0; - $item->warning = ''; - $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).' (Addons)'; - $item->description = strip_tags((string)$modaddons->description); - $item->author = strip_tags((string)$modaddons->author); - $item->limited_countries = array(); - $item->is_configurable = 0; - $item->need_instance = 0; - $item->available_on_addons = 1; - $item->active = 0; - if (isset($modaddons->img)) - { - if (!file_exists('../img/tmp/'.md5($modaddons->name).'.jpg')) - copy($modaddons->img, '../img/tmp/'.md5($modaddons->name).'.jpg'); - if (file_exists('../img/tmp/'.md5($modaddons->name).'.jpg')) - $item->image = '../img/tmp/'.md5($modaddons->name).'.jpg'; - } - $moduleList[] = $item; + $flagFound = 1; + if ($m->version != $modaddons->version && version_compare($m->version, $modaddons->version) === -1) + $moduleList[$k]->version_addons = $modaddons->version; } + if ($flagFound == 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).' (Addons)'; + $item->description = strip_tags((string)$modaddons->description); + $item->author = strip_tags((string)$modaddons->author); + $item->limited_countries = array(); + $item->is_configurable = 0; + $item->need_instance = 0; + $item->available_on_addons = 1; + $item->active = 0; + if (isset($modaddons->img)) + { + if (!file_exists('../img/tmp/'.md5($modaddons->name).'.jpg')) + copy($modaddons->img, '../img/tmp/'.md5($modaddons->name).'.jpg'); + if (file_exists('../img/tmp/'.md5($modaddons->name).'.jpg')) + $item->image = '../img/tmp/'.md5($modaddons->name).'.jpg'; + } + $moduleList[] = $item; } } - } + } //echo round($current_memory / 1024 / 1024, 2).'Mo
'; @@ -1091,7 +1093,7 @@ abstract class ModuleCore { $db = Db::getInstance(); - $module_list_xml = _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'modules_list.xml'; + $module_list_xml = _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'xml'.DIRECTORY_SEPARATOR.'modules_list.xml'; $nativeModules = simplexml_load_file($module_list_xml); $nativeModules = $nativeModules->modules; foreach ($nativeModules as $nativeModulesType) diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php index b939a0b2a..ade1bfa9c 100644 --- a/controllers/admin/AdminModulesController.php +++ b/controllers/admin/AdminModulesController.php @@ -53,8 +53,8 @@ class AdminModulesControllerCore extends AdminController private $iso_default_country; private $filter_configuration = array(); - private $xml_modules_list = 'http://api.prestashop.com/xml/modules_list.xml'; - private $addons_url = 'http://api.addons.prestashop.com/151/'; + private $xml_modules_list = 'https://api.prestashop.com/xml/modules_list.xml'; + private $addons_url = 'https://api.addons.prestashop.com/151/'; private $logged_on_addons = false; private $cache_file_modules_list = '/config/xml/modules_list.xml'; private $cache_file_default_country_modules_list = '/config/xml/default_country_modules_list.xml'; @@ -168,7 +168,7 @@ class AdminModulesControllerCore extends AdminController // If logged to Addons Webservices, refresh default country native modules list every day - if ($this->logged_on_addons && $this->status != 'error') + if ($this->status != 'error') { if (!$this->isFresh($this->cache_file_default_country_modules_list, 86400)) { @@ -491,16 +491,20 @@ class AdminModulesControllerCore extends AdminController foreach ($modules AS $name) { // If Addons module, download and unzip it before installing it - if ($this->logged_on_addons && !is_dir('../modules/'.$name.'/')) + if (!is_dir('../modules/'.$name.'/')) { - $filesList = array($this->cache_file_default_country_modules_list, $this->cache_file_customer_modules_list); - foreach ($filesList as $file) - if (file_exists(_PS_ROOT_DIR_.$file)) + $filesList = array( + array('type' => 'addonsNative', 'file' => $this->cache_file_default_country_modules_list, 'loggedOnAddons' => 0), + array('type' => 'addonsBought', 'file' => $this->cache_file_customer_modules_list, 'loggedOnAddons' => 1), + ); + foreach ($filesList as $f) + if (file_exists(_PS_ROOT_DIR_.$f['file'])) { + $file = $f['file']; $content = Tools::file_get_contents(_PS_ROOT_DIR_.$file); $xml = @simplexml_load_string($content, NULL, LIBXML_NOCDATA); foreach ($xml->module as $modaddons) - if ($name == $modaddons->name && isset($modaddons->id)) + if ($name == $modaddons->name && isset($modaddons->id) && ($this->logged_on_addons || $f['loggedOnAddons'] == 0)) if (@copy($this->addons_url.'module/'.pSQL($modaddons->id).'/'.pSQL(trim($this->context->cookie->username_addons)).'/'.pSQL(trim($this->context->cookie->password_addons)), '../modules/'.$modaddons->name.'.zip')) $this->extractArchive('../modules/'.$modaddons->name.'.zip'); }