Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge dev branch into master branch (publish the module on Addons) #32

Merged
merged 5 commits into from Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions Readme.md
Expand Up @@ -43,3 +43,11 @@ This module is shipped with a testsuite using PHPUnit, you need Composer to inst
composer install
composer test
```

### Versions of PrestaShop supported

This module is compatible with 1.6.1.x and 1.7.x versions.

> As of 31th of october, 2018, PrestaShop 1.6.1.x will only receives security patches.

This module is maintained for 1.7.4.x and above *only*.
2 changes: 1 addition & 1 deletion classes/GamificationTools.php
Expand Up @@ -64,7 +64,7 @@ public static function retrieveJsonApiFile($url, $withResponseHeaders = false)
curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
curl_setopt($curl, CURLOPT_USERAGENT, 'gzip');
curl_setopt($curl, CURLOPT_HEADER, $withResponseHeaders);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, $withResponseHeaders);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$content = curl_exec($curl);

Expand Down
2 changes: 1 addition & 1 deletion config.xml
Expand Up @@ -2,7 +2,7 @@
<module>
<name>gamification</name>
<displayName><![CDATA[Merchant Expertise]]></displayName>
<version><![CDATA[2.1.0]]></version>
<version><![CDATA[2.2.0]]></version>
<description><![CDATA[Become an e-commerce expert within the blink of an eye!]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[administration]]></tab>
Expand Down
Empty file modified data/index.php 100644 → 100755
Empty file.
14 changes: 10 additions & 4 deletions gamification.php
Expand Up @@ -46,10 +46,10 @@ public function __construct()
{
$this->name = 'gamification';
$this->tab = 'administration';
$this->version = '2.1.0';
$this->version = '2.2.0';
$this->author = 'PrestaShop';
$this->ps_versions_compliancy = array(
'min' => '1.7.0.0',
'min' => '1.6.1.0',
);

parent::__construct();
Expand Down Expand Up @@ -205,7 +205,12 @@ public function hookDisplayBackOfficeHeader()

if (method_exists($this->context->controller, 'addJquery')) {
$this->context->controller->addJquery();
$this->context->controller->addCss($this->_path.'views/css/gamification.css');
$cssFile = 'gamification.css';
if (version_compare(_PS_VERSION_, '1.7.0.0', '<=')) {
$cssFile = 'gamification-1.6.css';
}

$this->context->controller->addCss($this->_path.'views/css/'. $cssFile);

//add css for advices
$advices = Advice::getValidatedByIdTab($this->context->controller->id, true);
Expand Down Expand Up @@ -298,6 +303,7 @@ public function refreshDatas($iso_lang = null)
}

$cache_file = $this->cache_data.'data_'.strtoupper($iso_lang).'_'.strtoupper($iso_currency).'_'.strtoupper($iso_country).'.json';

if (!$this->isFresh($cache_file, 86400)) {
if ($this->getData($iso_lang)) {
$data = Tools::jsonDecode(Tools::file_get_contents($cache_file));
Expand Down Expand Up @@ -350,7 +356,7 @@ public function getData($iso_lang = null)
$versioning = '?v='.$this->version.'&ps_version='._PS_VERSION_;
$data = GamificationTools::retrieveJsonApiFile($this->url_data.$file_name.$versioning);

return (bool)file_put_contents($this->cache_data.'data_'.strtoupper($iso_lang).'_'.strtoupper($iso_currency).'_'.strtoupper($iso_country).'.json', $data);
return (bool) file_put_contents($this->cache_data.'data_'.strtoupper($iso_lang).'_'.strtoupper($iso_currency).'_'.strtoupper($iso_country).'.json', $data, FILE_USE_INCLUDE_PATH);
}

public function processCleanAdvices()
Expand Down
10 changes: 9 additions & 1 deletion tools/install_module.sh
Expand Up @@ -14,4 +14,12 @@ rm -Rf $TRAVIS_BUILD_DIR/modules/$1/*
cp -Rf $MODULE_DIR/* $TRAVIS_BUILD_DIR/modules/$1/

# Enable the Module
php bin/console prestashop:module install $1
case $PS_VERSION in
1.7.0.x|1.7.1.x|1.7.2.x|1.7.3.x)
sql_insert="INSERT INTO ps_module (name, active, version) VALUES ('$1', 1 , 'test');"
mysql -D prestashop -e $sql_insert
;;
*)
php bin/console prestashop:module install $1
;;
esac