diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php
index 50469f459..a93fc58a9 100644
--- a/controllers/admin/AdminModulesController.php
+++ b/controllers/admin/AdminModulesController.php
@@ -474,10 +474,13 @@ class AdminModulesControllerCore extends AdminController
// If we install a module, force temporary global context for multishop
if (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL)
{
- Context::getContext()->tmpOldShop = clone(Context::getContext()->shop);
- Context::getContext()->shop = new Shop();
- Configuration::updateValue('RSS_FEED_TITLE', 'lol');
- }
+ // If we install a module, force temporary global context for multishop
+ if (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL && $method != 'getContent')
+ {
+ Context::getContext()->tmpOldShop = clone(Context::getContext()->shop);
+ Context::getContext()->shop = new Shop();
+ Configuration::updateValue('RSS_FEED_TITLE', 'lol');
+ }
if (((method_exists($module, $method) && ($echo = $module->{$method}())) || ($echo = ' ')) AND $key == 'configure' AND Module::isInstalled($module->name))
{
@@ -512,9 +515,11 @@ class AdminModulesControllerCore extends AdminController
}
$toolbar .= '';
- // Display configure page
- // TODO : MAKE SOMETHING CLEANER
- $this->context->smarty->assign('module_content', $toolbar.'
'.$echo.'
'.$toolbar);
+ if (Shop::isFeatureActive() && isset(Context::getContext()->tmpOldShop))
+ {
+ Context::getContext()->shop = clone(Context::getContext()->tmpOldShop);
+ unset(Context::getContext()->tmpOldShop);
+ }
}
elseif($echo)
$return = ($method == 'install' ? 12 : 13);
diff --git a/modules/blockadvertising/blockadvertising.php b/modules/blockadvertising/blockadvertising.php
index c1dd00b64..81fc4026b 100644
--- a/modules/blockadvertising/blockadvertising.php
+++ b/modules/blockadvertising/blockadvertising.php
@@ -44,6 +44,8 @@ class BlockAdvertising extends Module
* @var mixed
*/
public $adv_img;
+
+ public $use_global = true;
/**
* adv_imgname is the filename of the image to display
@@ -56,7 +58,7 @@ class BlockAdvertising extends Module
{
$this->name = 'blockadvertising';
$this->tab = 'advertising_marketing';
- $this->version = 0.3;
+ $this->version = '0.4';
$this->author = 'PrestaShop';
$this->need_instance = 0;
@@ -64,7 +66,26 @@ class BlockAdvertising extends Module
$this->displayName = $this->l('Block advertising');
$this->description = $this->l('Adds a block to display an advertisement.');
+
+ if ($this->context->shop->getContextType() == Shop::CONTEXT_SHOP)
+ {
+ if (defined('_PS_ADMIN_DIR_') || file_exists(_PS_MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'-'.(int)$this->context->shop->id.'.'.Configuration::get('BLOCKADVERT_IMG_EXT')))
+ {
+ $this->adv_imgname .= '-'.(int)$this->context->shop->id;
+ $this->use_global = false;
+ $advert_link = Configuration::get('BLOCKADVERT_LINK');
+ $advert_title = Configuration::get('BLOCKADVERT_TITLE');
+ }
+ else
+ $this->use_global = true;
+ }
+ if ($this->use_global)
+ {
+ $advert_link = Configuration::getGlobalValue('BLOCKADVERT_LINK');
+ $advert_title = Configuration::getGlobalValue('BLOCKADVERT_TITLE');
+ }
+
if (!file_exists(_PS_MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT')))
{
$this->adv_imgname = 'advertising';
@@ -77,8 +98,8 @@ class BlockAdvertising extends Module
if (!empty($this->adv_imgname))
$this->adv_img = Tools::getMediaServer($this->name)._MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT');
- $this->adv_link = htmlentities(Configuration::get('BLOCKADVERT_LINK'), ENT_QUOTES, 'UTF-8');
- $this->adv_title = htmlentities(Configuration::get('BLOCKADVERT_TITLE'), ENT_QUOTES, 'UTF-8');
+ $this->adv_link = htmlentities($advert_link, ENT_QUOTES, 'UTF-8');
+ $this->adv_title = htmlentities($advert_title, ENT_QUOTES, 'UTF-8');
}
@@ -99,7 +120,8 @@ class BlockAdvertising extends Module
*/
private function _deleteCurrentImg()
{
-
+ if ($this->adv_imgname == 'advertising')
+ return;
if (file_exists(_PS_MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT')))
unlink(_PS_MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT'));
$this->adv_imgname = $this->adv_imgname == 'advertising_custom'?'advertising':'';
@@ -130,8 +152,7 @@ class BlockAdvertising extends Module
$this->_deleteCurrentImg();
$this->adv_imgname = 'advertising';
$ext = substr($_FILES['adv_img']['name'], $dot_pos+1);
- $newname = 'advertising_custom';
-
+ $newname = 'advertising_custom'.'-'.(int)$this->context->shop->id;
if (!move_uploaded_file($_FILES['adv_img']['tmp_name'],_PS_MODULE_DIR_.$this->name.'/'.$newname.'.'.$ext))
$errors .= $this->l('Error move uploaded file');
else
@@ -141,7 +162,6 @@ class BlockAdvertising extends Module
$this->adv_img = Tools::getMediaServer($this->name)._MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT');
}
}
-
if ($link = Tools::getValue('adv_link'))
{
Configuration::updateValue('BLOCKADVERT_LINK', $link);
@@ -167,35 +187,34 @@ class BlockAdvertising extends Module
{
$this->postProcess();
- $output = '';
- $output .= '
-
-';
+ $output = '';
return $output;
}