Activation/Désactivation sensefuel

This commit is contained in:
Michael RICOIS 2017-11-30 12:28:45 +01:00
parent 699ff5d806
commit e54c47815a
3 changed files with 35 additions and 8 deletions

View File

@ -4,9 +4,10 @@ include_once _PS_MODULE_DIR_ . 'sensefuel/models/SenseFuelFluxExport.php';
class SenseFuel extends Module
{
public static $ACTIVE_VERSION_ARRAY = array('fr', 'com', 'es', 'it');
public static $ACTIVE_VERSION_ARRAY = array('com', 'fr');
public static $SETUP_VERSION_ARRAY = array();
private $display = true;
public function __construct()
{
@ -21,6 +22,8 @@ class SenseFuel extends Module
$this->version = '1.0';
$this->author = 'Antadis';
$this->_checkDisplay();
}
public function install()
@ -36,19 +39,32 @@ class SenseFuel extends Module
return true;
}
private function _checkDisplay()
{
global $cookie;
// Groupe test
$groups = Customer::getGroupsStatic($cookie->id_customer);
if (in_array(2, array_values($groups))) {
$this->display = true;
}
}
public function hookTop($params)
{
if(_PS_MOBILE_){
return false;
}
global $site_version, $page_name;
global $site_version, $smarty, $page_name, $cookie;
if (null !== $site_version &&
null !== $page_name &&
in_array($site_version, self::$ACTIVE_VERSION_ARRAY, true) /*&&
in_array($page_name, array('index', 'category', 'product'), true)*/
) {
$smarty->assign(array('display' => $this->display));
return self::display(__FILE__, 'views/top-sensefuel.tpl');
}
@ -69,12 +85,16 @@ class SenseFuel extends Module
if(!_PS_MOBILE_){
return false;
}
global $site_version, $page_name;
global $site_version, $smarty, $page_name;
if (null !== $site_version &&
null !== $page_name &&
in_array($site_version, self::$ACTIVE_VERSION_ARRAY , true) /*&&
in_array($page_name, array('index', 'category', 'product'), true)*/
) {
$smarty->assign(array('display' => $this->display));
return self::display(__FILE__, 'views/top-sensefuel.tpl');
}
@ -93,11 +113,16 @@ class SenseFuel extends Module
public function hookFooter($params)
{
global $site_version, $smarty;
$display = false;
if (null !== $site_version &&
( in_array($site_version, self::$ACTIVE_VERSION_ARRAY, true)
|| in_array($site_version, self::$SETUP_VERSION_ARRAY, true))) {
$smarty->assign(array('sensefuelversion' => $site_version));
return self::display(__FILE__, 'views/footer.tpl');
$smarty->assign(array('display' => $this->display));
$smarty->assign(array('sensefuelversion' => $site_version));
return self::display(__FILE__, 'views/footer.tpl');
}
return false;

View File

@ -1,4 +1,4 @@
{if isset($sensefuelversion)}
{if isset($sensefuelversion) && $display}
{literal}
<script type="text/javascript">
(function () {

View File

@ -1,5 +1,6 @@
{if null !== $cookie && $cookie->isLogged()}
<div id="sensefuel">
{if $display}
<form action="{$base_dir_ssl}search.php" id="search" role="search">
<div class="search">
<div class="search_form">
@ -8,6 +9,7 @@
</div>
</div>
</form>
{/if}
</div>
<style>
#category #shop_category .shop_category_filter.horizontal .search {