// Cleaned modules call
This commit is contained in:
@@ -66,10 +66,6 @@
|
||||
if (anchor != '')
|
||||
$.scrollTo('#'+anchor, 1200, {offset: -100});
|
||||
|
||||
// If a list of modules is set, install request has been called
|
||||
if (installed_modules !== false)
|
||||
wsModuleCall(installed_modules);
|
||||
|
||||
// AutoComplete Search
|
||||
$('input[name="filtername"]').autocomplete(moduleList, {
|
||||
minChars: 0,
|
||||
@@ -340,28 +336,5 @@
|
||||
});
|
||||
});
|
||||
|
||||
function wsModuleCall(modules_list)
|
||||
{
|
||||
$.ajax({
|
||||
type : 'POST',
|
||||
url : ajaxCurrentIndex,
|
||||
data : {
|
||||
'modules_list' : modules_list,
|
||||
'controller' : 'AdminModules',
|
||||
'action' : 'wsModuleCall',
|
||||
'token' : token
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(json)
|
||||
{
|
||||
//console.log(json);
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError)
|
||||
{
|
||||
//jAlert("TECHNICAL ERROR"+xhr);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
{/literal}
|
||||
</script>
|
||||
@@ -2733,30 +2733,42 @@ class AdminControllerCore extends Controller
|
||||
|
||||
public function addonsRequest($request, $params = array())
|
||||
{
|
||||
$postData = '';
|
||||
$postDataArray = array(
|
||||
'version' => _PS_VERSION_,
|
||||
'iso_lang' => strtolower(Context::getContext()->language->iso_code),
|
||||
'iso_code' => strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))),
|
||||
'shop_url' => urlencode(Tools::getShopDomain()),
|
||||
'mail' => urlencode(Configuration::get('PS_SHOP_EMAIL'))
|
||||
);
|
||||
foreach ($postDataArray as $postDataKey => $postDataValue)
|
||||
$postData .= '&'.$postDataKey.'='.$postDataValue;
|
||||
$postData = ltrim($postData, '&');
|
||||
|
||||
// Config for each request
|
||||
if ($request == 'native')
|
||||
{
|
||||
// Define protocol accepted and post data values for this request
|
||||
$protocolsList = array('https://' => 443, 'http://' => 80);
|
||||
$postData = 'version='._PS_VERSION_.'&method=listing&action=native&iso_code='.strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))).'&iso_lang='.strtolower(Context::getContext()->language->iso_code);
|
||||
$postData .= '&method=listing&action=native';
|
||||
}
|
||||
if ($request == 'must-have')
|
||||
{
|
||||
// Define protocol accepted and post data values for this request
|
||||
$protocolsList = array('https://' => 443, 'http://' => 80);
|
||||
$postData = 'version='._PS_VERSION_.'&method=listing&action=must-have&iso_code='.strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))).'&iso_lang='.strtolower(Context::getContext()->language->iso_code);
|
||||
$postData .= '&method=listing&action=must-have';
|
||||
}
|
||||
if ($request == 'customer')
|
||||
{
|
||||
// Define protocol accepted and post data values for this request
|
||||
$protocolsList = array('https://' => 443);
|
||||
$postData = 'version='._PS_VERSION_.'&method=listing&action=customer&username='.pSQL(trim($this->context->cookie->username_addons)).'&password='.pSQL(trim($this->context->cookie->password_addons)).'&iso_lang='.strtolower(Context::getContext()->language->iso_code);
|
||||
$postData .= '&method=listing&action=customer&username='.urlencode(trim($this->context->cookie->username_addons)).'&password='.urlencode(trim($this->context->cookie->password_addons));
|
||||
}
|
||||
if ($request == 'check_customer')
|
||||
{
|
||||
// Define protocol accepted and post data values for this request
|
||||
$protocolsList = array('https://' => 443);
|
||||
$postData = 'version='._PS_VERSION_.'&method=check_customer&username='.pSQL($params['username_addons']).'&password='.pSQL($params['password_addons']);
|
||||
$postData .= '&method=check_customer&username='.urlencode($params['username_addons']).'&password='.urlencode($params['password_addons']);
|
||||
}
|
||||
if ($request == 'module')
|
||||
{
|
||||
@@ -2764,12 +2776,12 @@ class AdminControllerCore extends Controller
|
||||
if (isset($params['username_addons']) && isset($params['password_addons']))
|
||||
{
|
||||
$protocolsList = array('https://' => 443);
|
||||
$postData = 'version='._PS_VERSION_.'&method=module&id_module='.pSQL($params['id_module']).'&username='.pSQL($params['username_addons']).'&password='.pSQL($params['password_addons']);
|
||||
$postData .= '&method=module&id_module='.urlencode($params['id_module']).'&username='.urlencode($params['username_addons']).'&password='.urlencode($params['password_addons']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$protocolsList = array('https://' => 443, 'http://' => 80);
|
||||
$postData = 'version='._PS_VERSION_.'&method=module&id_module='.pSQL($params['id_module']);
|
||||
$postData .= '&method=module&id_module='.urlencode($params['id_module']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -262,66 +262,13 @@ class AdminModulesControllerCore extends AdminController
|
||||
}
|
||||
die('OK');
|
||||
}
|
||||
|
||||
|
||||
private function sendStatisticRequest($object_key)
|
||||
{
|
||||
$post_data = http_build_query(array(
|
||||
'key' => urlencode($object_key),
|
||||
'url' => urlencode(Tools::getShopDomain()),
|
||||
'mail' => urlencode(Configuration::get('PS_SHOP_EMAIL')),
|
||||
'version' => urlencode(_PS_VERSION_),
|
||||
'method' => 'product_key'
|
||||
));
|
||||
|
||||
$opts = array(
|
||||
'http' => array(
|
||||
'method' => 'POST',
|
||||
'header' => 'Content-type: application/x-www-form-urlencoded',
|
||||
'content' => $post_data
|
||||
)
|
||||
);
|
||||
|
||||
$context = stream_context_create($opts);
|
||||
file_get_contents('http://api.addons.prestashop.com/', false, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax call for statistic
|
||||
*
|
||||
* @result : die the request
|
||||
*/
|
||||
public function ajaxProcessWsModuleCall()
|
||||
{
|
||||
if (($list = Tools::getValue('modules_list')) && is_array($list))
|
||||
foreach ($list as $id)
|
||||
if (($obj = Module::getInstanceById($id)) && (isset($obj->module_key)))
|
||||
$this->sendStatisticRequest($obj->module_key);
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax call for statistic
|
||||
*
|
||||
* @result : die the request
|
||||
*/
|
||||
public function ajaxProcessWsThemeCall()
|
||||
{
|
||||
// Theme list contains just the key for each theme
|
||||
if (($list = Tools::getValue('theme_list')) && is_array($list))
|
||||
foreach ($list as $theme_key)
|
||||
if (!empty($theme_key))
|
||||
$this->sendStatisticRequest($theme_key);
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Get current URL
|
||||
**
|
||||
** @param array $remove List of keys to remove from URL
|
||||
** @return string
|
||||
*/
|
||||
|
||||
protected function getCurrentUrl($remove = array())
|
||||
{
|
||||
$url = $_SERVER['REQUEST_URI'];
|
||||
@@ -605,6 +552,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Check potential error
|
||||
if (!($module = Module::getInstanceByName(urldecode($name))))
|
||||
$this->errors[] = $this->l('module not found');
|
||||
|
||||
Reference in New Issue
Block a user