From 232d487b679d476d82044f4f82bcc68ae0149ddc Mon Sep 17 00:00:00 2001 From: vSchoener Date: Wed, 16 May 2012 15:22:09 +0000 Subject: [PATCH] [+] CORE : Add statistic request for theme too (refacto of the last commit for module) git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15351 b9a71923-0436-4b27-9f14-aed3839534dd --- controllers/admin/AdminModulesController.php | 65 +++++++++++-------- modules/themeinstallator/themeinstallator.php | 25 ++++++- 2 files changed, 62 insertions(+), 28 deletions(-) diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php index 26be2da1d..173b3dd0a 100644 --- a/controllers/admin/AdminModulesController.php +++ b/controllers/admin/AdminModulesController.php @@ -341,6 +341,28 @@ class AdminModulesControllerCore extends AdminController } + 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 * @@ -349,37 +371,26 @@ class AdminModulesControllerCore extends AdminController public function ajaxProcessWsModuleCall() { if (($list = Tools::getValue('modules_list')) && is_array($list)) - { foreach ($list as $id) - if ($obj = Module::getInstanceById($id)) - { - if (isset($obj->module_key) && isset($obj->version)) - { - $post_data = http_build_query(array( - 'key' => urlencode($obj->module_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); - } - } - } + 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 diff --git a/modules/themeinstallator/themeinstallator.php b/modules/themeinstallator/themeinstallator.php index 2f6e99bba..94dff3ab8 100644 --- a/modules/themeinstallator/themeinstallator.php +++ b/modules/themeinstallator/themeinstallator.php @@ -663,7 +663,30 @@ class ThemeInstallator extends Module - '; + + '; } private function _displayForm2()