[*] BO : Native modules are now downloadable without login on addons

This commit is contained in:
fSerny committed 2011-12-21 17:24:59 +00:00
1 parent a768213b3c
commit 443dccef20
2 files changed
+21 -15

No files matched your search

+9 -7
View File
@@ -998,12 +998,14 @@ abstract class ModuleCore
// Get Default Country Modules and customer module // Get Default Country Modules and customer module
if ($loggedOnAddons) $filesList = array(
{ array('type' => 'addonsNative', 'file' => _PS_ROOT_DIR_.'/config/xml/default_country_modules_list.xml', 'loggedOnAddons' => 0),
$filesList = array(_PS_ROOT_DIR_.'/config/default_country_modules_list.xml', _PS_ROOT_DIR_.'/config/customer_modules_list.xml'); array('type' => 'addonsBought', 'file' => _PS_ROOT_DIR_.'/config/xml/customer_modules_list.xml', 'loggedOnAddons' => 1),
foreach ($filesList as $file) );
if (file_exists($file)) foreach ($filesList as $f)
if (file_exists($f['file']) && ($f['loggedOnAddons'] == 0 || $loggedOnAddons))
{ {
$file = $f['file'];
$content = Tools::file_get_contents($file); $content = Tools::file_get_contents($file);
$xml = @simplexml_load_string($content, NULL, LIBXML_NOCDATA); $xml = @simplexml_load_string($content, NULL, LIBXML_NOCDATA);
foreach ($xml->module as $modaddons) foreach ($xml->module as $modaddons)
@@ -1021,6 +1023,7 @@ abstract class ModuleCore
$item = new stdClass(); $item = new stdClass();
$item->id = 0; $item->id = 0;
$item->warning = ''; $item->warning = '';
$item->type = strip_tags((string)$f['type']);
$item->name = strip_tags((string)$modaddons->name); $item->name = strip_tags((string)$modaddons->name);
$item->version = strip_tags((string)$modaddons->version); $item->version = strip_tags((string)$modaddons->version);
$item->tab = strip_tags((string)$modaddons->tab); $item->tab = strip_tags((string)$modaddons->tab);
@@ -1043,7 +1046,6 @@ abstract class ModuleCore
} }
} }
} }
}
//echo round($current_memory / 1024 / 1024, 2).'Mo<br />'; //echo round($current_memory / 1024 / 1024, 2).'Mo<br />';
@@ -1091,7 +1093,7 @@ abstract class ModuleCore
{ {
$db = Db::getInstance(); $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 = simplexml_load_file($module_list_xml);
$nativeModules = $nativeModules->modules; $nativeModules = $nativeModules->modules;
foreach ($nativeModules as $nativeModulesType) foreach ($nativeModules as $nativeModulesType)
+12 -8
View File
@@ -53,8 +53,8 @@ class AdminModulesControllerCore extends AdminController
private $iso_default_country; private $iso_default_country;
private $filter_configuration = array(); private $filter_configuration = array();
private $xml_modules_list = 'http://api.prestashop.com/xml/modules_list.xml'; private $xml_modules_list = 'https://api.prestashop.com/xml/modules_list.xml';
private $addons_url = 'http://api.addons.prestashop.com/151/'; private $addons_url = 'https://api.addons.prestashop.com/151/';
private $logged_on_addons = false; private $logged_on_addons = false;
private $cache_file_modules_list = '/config/xml/modules_list.xml'; private $cache_file_modules_list = '/config/xml/modules_list.xml';
private $cache_file_default_country_modules_list = '/config/xml/default_country_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 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)) if (!$this->isFresh($this->cache_file_default_country_modules_list, 86400))
{ {
@@ -491,16 +491,20 @@ class AdminModulesControllerCore extends AdminController
foreach ($modules AS $name) foreach ($modules AS $name)
{ {
// If Addons module, download and unzip it before installing it // 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); $filesList = array(
foreach ($filesList as $file) array('type' => 'addonsNative', 'file' => $this->cache_file_default_country_modules_list, 'loggedOnAddons' => 0),
if (file_exists(_PS_ROOT_DIR_.$file)) 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); $content = Tools::file_get_contents(_PS_ROOT_DIR_.$file);
$xml = @simplexml_load_string($content, NULL, LIBXML_NOCDATA); $xml = @simplexml_load_string($content, NULL, LIBXML_NOCDATA);
foreach ($xml->module as $modaddons) 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')) 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'); $this->extractArchive('../modules/'.$modaddons->name.'.zip');
} }