[-] BO : AdminModules fix on Addons Connection
This commit is contained in:
@@ -73,10 +73,10 @@
|
|||||||
{if !isset($logged_on_addons)}
|
{if !isset($logged_on_addons)}
|
||||||
<!--start addons login-->
|
<!--start addons login-->
|
||||||
<div class="filter-module" id="addons_login_div">
|
<div class="filter-module" id="addons_login_div">
|
||||||
<p>{l s='You have already got an Add On customer account'}</p>
|
<p>{l s='You have a PrestaShop Addons account ?'}</p>
|
||||||
<form id="addons_login_form" method="post">
|
<form id="addons_login_form" method="post">
|
||||||
<label>{l s='Login Addons'} :</label> <input type="text" value="" id="username_addons" autocomplete="off" class="ac_input">
|
<label>{l s='Login Addons'} :</label> <input type="text" value="" id="username_addons" autocomplete="off" class="ac_input">
|
||||||
<label>{l s= 'Password Addons'} :</label> <input type="text" value="" id="password_addons" autocomplete="off" class="ac_input">
|
<label>{l s= 'Password Addons'} :</label> <input type="password" value="" id="password_addons" autocomplete="off" class="ac_input">
|
||||||
<input type="submit" class="button" id="addons_login_button" value="{l s='Log in'}">
|
<input type="submit" class="button" id="addons_login_button" value="{l s='Log in'}">
|
||||||
<span id="addons_loading" style="color:red"></span>
|
<span id="addons_loading" style="color:red"></span>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -37,6 +37,12 @@
|
|||||||
var by = '{l s='by'}';
|
var by = '{l s='by'}';
|
||||||
var errorLogin = '{l s='Could not login to Addons'}';
|
var errorLogin = '{l s='Could not login to Addons'}';
|
||||||
|
|
||||||
|
{if isset($smarty.get.anchor)}
|
||||||
|
$('document').ready( function() {
|
||||||
|
$.scrollTo('#{$smarty.get.anchor|htmlentities}', 1200, {literal}{offset: -100}{/literal});
|
||||||
|
});
|
||||||
|
{/if}
|
||||||
|
|
||||||
{literal}
|
{literal}
|
||||||
function getPrestaStore(){if(getE("prestastore").style.display!='block')return;$.post(dirNameCurrentIndex+"/ajax.php",{page:"prestastore"},function(a){getE("prestastore-content").innerHTML=a;})}
|
function getPrestaStore(){if(getE("prestastore").style.display!='block')return;$.post(dirNameCurrentIndex+"/ajax.php",{page:"prestastore"},function(a){getE("prestastore-content").innerHTML=a;})}
|
||||||
function truncate_author(author){return ((author.length > 20) ? author.substring(0, 20)+"..." : author);}
|
function truncate_author(author){return ((author.length > 20) ? author.substring(0, 20)+"..." : author);}
|
||||||
@@ -177,10 +183,11 @@
|
|||||||
success : function(data)
|
success : function(data)
|
||||||
{
|
{
|
||||||
// res.status = cache or refresh
|
// res.status = cache or refresh
|
||||||
if (data != 'KO')
|
if (data == 'OK')
|
||||||
{
|
{
|
||||||
$('#addons_loading').html('');
|
$('#addons_loading').html('');
|
||||||
$('#addons_login_div').fadeOut();
|
$('#addons_login_div').fadeOut();
|
||||||
|
window.location.href = window.location.href;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$('#addons_loading').html(errorLogin);
|
$('#addons_loading').html(errorLogin);
|
||||||
|
|||||||
+43
-41
@@ -588,7 +588,7 @@ abstract class ModuleCore
|
|||||||
* @param boolean $useConfig in order to use config.xml file in module dir
|
* @param boolean $useConfig in order to use config.xml file in module dir
|
||||||
* @return array Modules
|
* @return array Modules
|
||||||
*/
|
*/
|
||||||
public static function getModulesOnDisk($useConfig = false)
|
public static function getModulesOnDisk($useConfig = false, $loggedOnAddons = false)
|
||||||
{
|
{
|
||||||
global $_MODULES;
|
global $_MODULES;
|
||||||
|
|
||||||
@@ -737,52 +737,54 @@ abstract class ModuleCore
|
|||||||
|
|
||||||
|
|
||||||
// Get Default Country Modules and customer module
|
// Get Default Country Modules and customer module
|
||||||
$filesList = array(_PS_ROOT_DIR_.'/config/default_country_modules_list.xml', _PS_ROOT_DIR_.'/config/default_customer_modules_list.xml');
|
if ($loggedOnAddons)
|
||||||
foreach ($filesList as $file)
|
{
|
||||||
if (file_exists($file))
|
$filesList = array(_PS_ROOT_DIR_.'/config/default_country_modules_list.xml', _PS_ROOT_DIR_.'/config/customer_modules_list.xml');
|
||||||
{
|
foreach ($filesList as $file)
|
||||||
$content = Tools::file_get_contents($file);
|
if (file_exists($file))
|
||||||
$xml = @simplexml_load_string($content, NULL, LIBXML_NOCDATA);
|
|
||||||
foreach ($xml->module as $modaddons)
|
|
||||||
{
|
{
|
||||||
$flagFound = 0;
|
$content = Tools::file_get_contents($file);
|
||||||
foreach ($moduleList as $k => $m)
|
$xml = @simplexml_load_string($content, NULL, LIBXML_NOCDATA);
|
||||||
if ($m->name == $modaddons->name && !isset($m->available_on_addons))
|
foreach ($xml->module as $modaddons)
|
||||||
{
|
|
||||||
$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();
|
$flagFound = 0;
|
||||||
$item->id = 0;
|
foreach ($moduleList as $k => $m)
|
||||||
$item->warning = '';
|
if ($m->name == $modaddons->name && !isset($m->available_on_addons))
|
||||||
$item->name = strip_tags((string)$modaddons->name);
|
{
|
||||||
$item->version = strip_tags((string)$modaddons->version);
|
$flagFound = 1;
|
||||||
$item->tab = strip_tags((string)$modaddons->tab);
|
if ($m->version != $modaddons->version && version_compare($m->version, $modaddons->version) === -1)
|
||||||
$item->displayName = strip_tags((string)$modaddons->displayName).' (Addons)';
|
$moduleList[$k]->version_addons = $modaddons->version;
|
||||||
$item->description = strip_tags((string)$modaddons->description);
|
}
|
||||||
$item->author = strip_tags((string)$modaddons->author);
|
if ($flagFound == 0)
|
||||||
$item->limited_countries = array();
|
|
||||||
$item->is_configurable = 0;
|
|
||||||
$item->need_instance = 0;
|
|
||||||
$item->available_on_addons = 1;
|
|
||||||
$item->active = 0;
|
|
||||||
if (!isset($modaddons->img) && isset($modaddons->id))
|
|
||||||
$modaddons->img = 'http://media.prestastore.com/img/pico/'.(int)$modaddons->id.'.jpg';
|
|
||||||
if (isset($modaddons->img))
|
|
||||||
{
|
{
|
||||||
if (!file_exists('../img/tmp/'.md5($modaddons->name).'.jpg'))
|
$item = new stdClass();
|
||||||
copy($modaddons->img, '../img/tmp/'.md5($modaddons->name).'.jpg');
|
$item->id = 0;
|
||||||
if (file_exists('../img/tmp/'.md5($modaddons->name).'.jpg'))
|
$item->warning = '';
|
||||||
$item->image = '../img/tmp/'.md5($modaddons->name).'.jpg';
|
$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) && isset($modaddons->id))
|
||||||
|
$modaddons->img = 'http://media.prestastore.com/img/pico/'.(int)$modaddons->id.'.jpg';
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
$moduleList[] = $item;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//echo round($current_memory / 1024 / 1024, 2).'Mo<br />';
|
//echo round($current_memory / 1024 / 1024, 2).'Mo<br />';
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
private $addons_url = 'https://addons.prestashop.com/webservice/151/';
|
private $addons_url = 'https://addons.prestashop.com/webservice/151/';
|
||||||
private $logged_on_addons = false;
|
private $logged_on_addons = false;
|
||||||
private $cache_file_default_country_modules_list = '/config/default_country_modules_list.xml';
|
private $cache_file_default_country_modules_list = '/config/default_country_modules_list.xml';
|
||||||
private $cache_file_customer_modules_list = '/config/default_customer_modules_list.xml';
|
private $cache_file_customer_modules_list = '/config/customer_modules_list.xml';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Admin Modules Controller Constructor
|
** Admin Modules Controller Constructor
|
||||||
@@ -131,6 +131,11 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
$this->logged_on_addons = true;
|
$this->logged_on_addons = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setMedia()
|
||||||
|
{
|
||||||
|
parent::setMedia();
|
||||||
|
$this->addJqueryPlugin('scrollTo');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -189,7 +194,7 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
// If logged to Addons Webservices, refresh customer modules list every day
|
// If logged to Addons Webservices, refresh customer modules list every day
|
||||||
if ($this->logged_on_addons && $this->status != 'error')
|
if ($this->logged_on_addons && $this->status != 'error')
|
||||||
{
|
{
|
||||||
if (!$this->isFresh($this->cache_file_customer_modules_list, 86400))
|
if (!$this->isFresh($this->cache_file_customer_modules_list, 60))
|
||||||
{
|
{
|
||||||
if ($this->refresh($this->cache_file_customer_modules_list, $this->addons_url.'listing/customer/'.pSQL(trim($this->context->cookie->username_addons)).'/'.pSQL(trim($this->context->cookie->password_addons))))
|
if ($this->refresh($this->cache_file_customer_modules_list, $this->addons_url.'listing/customer/'.pSQL(trim($this->context->cookie->username_addons)).'/'.pSQL(trim($this->context->cookie->password_addons))))
|
||||||
$this->status = 'refresh';
|
$this->status = 'refresh';
|
||||||
@@ -209,13 +214,19 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
|
|
||||||
public function ajaxProcessLogOnAddonsWebservices()
|
public function ajaxProcessLogOnAddonsWebservices()
|
||||||
{
|
{
|
||||||
$content = Tools::file_get_contents($this->addons_url.'listing/customer/'.pSQL(trim(Tools::getValue('username_addons'))).'/'.pSQL(trim(Tools::getValue('password_addons'))));
|
$content = Tools::file_get_contents($this->addons_url.'check_customer/'.pSQL(trim(Tools::getValue('username_addons'))).'/'.pSQL(trim(Tools::getValue('password_addons'))));
|
||||||
$xml = @simplexml_load_string($content, NULL, LIBXML_NOCDATA);
|
$xml = @simplexml_load_string($content, NULL, LIBXML_NOCDATA);
|
||||||
if (!$xml)
|
if (!$xml)
|
||||||
die('KO');
|
die('KO');
|
||||||
$this->context->cookie->username_addons = pSQL(trim(Tools::getValue('username_addons')));
|
$result = strtoupper((string)$xml->msg);
|
||||||
$this->context->cookie->password_addons = pSQL(trim(Tools::getValue('password_addons')));
|
if (!in_array($result, array('OK', 'KO')))
|
||||||
die('OK');
|
die ('KO');
|
||||||
|
if ($result == 'OK')
|
||||||
|
{
|
||||||
|
$this->context->cookie->username_addons = pSQL(trim(Tools::getValue('username_addons')));
|
||||||
|
$this->context->cookie->password_addons = pSQL(trim(Tools::getValue('password_addons')));
|
||||||
|
}
|
||||||
|
die($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ajaxProcessReloadModulesList()
|
public function ajaxProcessReloadModulesList()
|
||||||
@@ -383,7 +394,7 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
if ($module->uninstall())
|
if ($module->uninstall())
|
||||||
if ($module->install())
|
if ($module->install())
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&conf=21'.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
|
Tools::redirectAdmin(self::$currentIndex.'&conf=21'.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name));
|
||||||
else
|
else
|
||||||
$this->_errors[] = Tools::displayError('Cannot install module');
|
$this->_errors[] = Tools::displayError('Cannot install module');
|
||||||
else
|
else
|
||||||
@@ -489,16 +500,17 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
// 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 ($this->logged_on_addons && !is_dir('../modules/'.$name.'/'))
|
||||||
{
|
{
|
||||||
$file = _PS_ROOT_DIR_.'/config/default_customer_modules_list.xml';
|
$filesList = array($this->cache_file_default_country_modules_list, $this->cache_file_customer_modules_list);
|
||||||
if (file_exists($file))
|
foreach ($filesList as $file)
|
||||||
{
|
if (file_exists(_PS_ROOT_DIR_.$file))
|
||||||
$content = Tools::file_get_contents($file);
|
{
|
||||||
$xml = @simplexml_load_string($content, NULL, LIBXML_NOCDATA);
|
$content = Tools::file_get_contents(_PS_ROOT_DIR_.$file);
|
||||||
foreach ($xml->module as $modaddons)
|
$xml = @simplexml_load_string($content, NULL, LIBXML_NOCDATA);
|
||||||
if ($name == $modaddons->name && isset($modaddons->id))
|
foreach ($xml->module as $modaddons)
|
||||||
if (@copy($this->addons_url.'module/'.pSQL($modaddons->id).'/'.pSQL(trim($this->context->cookie->username_addons)).'/'.pSQL(trim($this->context->cookie->password_addons)), '../modules/'.$this->name.'.zip'))
|
if ($name == $modaddons->name && isset($modaddons->id))
|
||||||
$this->extractArchive('../modules/'.$this->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');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -599,7 +611,7 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($return)
|
if ($return)
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&conf='.$return.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name);
|
Tools::redirectAdmin(self::$currentIndex.'&conf='.$return.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function postProcess()
|
public function postProcess()
|
||||||
@@ -782,7 +794,7 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
$this->list_modules_categories[$k]['nb'] = 0;
|
$this->list_modules_categories[$k]['nb'] = 0;
|
||||||
|
|
||||||
// Retrieve Modules List
|
// Retrieve Modules List
|
||||||
$modules = Module::getModulesOnDisk(true);
|
$modules = Module::getModulesOnDisk(true, $this->logged_on_addons);
|
||||||
$this->initModulesList($modules);
|
$this->initModulesList($modules);
|
||||||
$this->nb_modules_total = count($modules);
|
$this->nb_modules_total = count($modules);
|
||||||
|
|
||||||
@@ -803,8 +815,8 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
$modules[$km]->logo = 'logo.png';
|
$modules[$km]->logo = 'logo.png';
|
||||||
$modules[$km]->optionsHtml = $this->displayModuleOptions($module);
|
$modules[$km]->optionsHtml = $this->displayModuleOptions($module);
|
||||||
$modules[$km]->categoryName = (isset($this->list_modules_categories[$module->tab]['name']) ? $this->list_modules_categories[$module->tab]['name'] : $this->list_modules_categories['others']['name']);
|
$modules[$km]->categoryName = (isset($this->list_modules_categories[$module->tab]['name']) ? $this->list_modules_categories[$module->tab]['name'] : $this->list_modules_categories['others']['name']);
|
||||||
$modules[$km]->options['install_url'] = self::$currentIndex.'&install='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'#anchor'.ucfirst($module->name);
|
$modules[$km]->options['install_url'] = self::$currentIndex.'&install='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name);
|
||||||
$modules[$km]->options['uninstall_url'] = self::$currentIndex.'&uninstall='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'#anchor'.ucfirst($module->name);
|
$modules[$km]->options['uninstall_url'] = self::$currentIndex.'&uninstall='.urlencode($module->name).'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name);
|
||||||
$modules[$km]->options['uninstall_onclick'] = ((!method_exists($module, 'onclickOption')) ? ((empty($module->confirmUninstall)) ? '' : 'if(confirm(\''.addslashes($module->confirmUninstall).'\')) ').'document.location.href=\''.$modules[$km]->options['uninstall_url'].'\'' : $module->onclickOption('uninstall', $modules[$km]->options['uninstall_url']));
|
$modules[$km]->options['uninstall_onclick'] = ((!method_exists($module, 'onclickOption')) ? ((empty($module->confirmUninstall)) ? '' : 'if(confirm(\''.addslashes($module->confirmUninstall).'\')) ').'document.location.href=\''.$modules[$km]->options['uninstall_url'].'\'' : $module->onclickOption('uninstall', $modules[$km]->options['uninstall_url']));
|
||||||
if (Tools::getValue('module_name') == $module->name && (int)Tools::getValue('conf') > 0)
|
if (Tools::getValue('module_name') == $module->name && (int)Tools::getValue('conf') > 0)
|
||||||
$modules[$km]->message = $this->_conf[(int)Tools::getValue('conf')];
|
$modules[$km]->message = $this->_conf[(int)Tools::getValue('conf')];
|
||||||
|
|||||||
Reference in New Issue
Block a user