From ee41a76dfed5c2d80c92dc00a0a1bb29e14c2190 Mon Sep 17 00:00:00 2001 From: rGaillard Date: Tue, 22 Nov 2011 22:21:05 +0000 Subject: [PATCH] // blockstores is now multishop --- modules/blockstore/blockstore.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/modules/blockstore/blockstore.php b/modules/blockstore/blockstore.php index 8fe5a5ab5..074b54ba8 100644 --- a/modules/blockstore/blockstore.php +++ b/modules/blockstore/blockstore.php @@ -63,8 +63,6 @@ class BlockStore extends Module function hookRightColumn($params) { - - $this->context->smarty->assign('store_img', Configuration::get('BLOCKSTORE_IMG')); return $this->display(__FILE__, 'blockstore.tpl'); } @@ -87,9 +85,10 @@ class BlockStore extends Module if (!move_uploaded_file($_FILES['store_img']['tmp_name'], dirname(__FILE__).'/'.$_FILES['store_img']['name'])) return $this->displayError($this->l('an error occurred on uploading file')); else - { + { if (Configuration::get('BLOCKSTORE_IMG') != $_FILES['store_img']['name']) - @unlink(dirname(__FILE__).'/'.Configuration::get('BLOCKSTORE_IMG')); + if ($this->context->shop->getContextType() != Shop::CONTEXT_SHOP || Configuration::hasContext('BLOCKSTORE_IMG', null, Shop::CONTEXT_SHOP)) + @unlink(dirname(__FILE__).'/'.Configuration::get('BLOCKSTORE_IMG')); Configuration::updateValue('BLOCKSTORE_IMG', $_FILES['store_img']['name']); return $this->displayConfirmation($this->l('Settings are updated')); } @@ -101,12 +100,21 @@ class BlockStore extends Module public function getContent() { + $img = false; + if ($this->context->shop->getContextType() == Shop::CONTEXT_SHOP && file_exists(dirname(__FILE__).'/'.Configuration::get('BLOCKSTORE_IMG'))) + $img = Configuration::get('BLOCKSTORE_IMG'); + if (!$img || ($this->context->shop->getContextType() != Shop::CONTEXT_SHOP && file_exists(dirname(__FILE__).'/'.Configuration::getGlobalValue('BLOCKSTORE_IMG')))); + $img = Configuration::getGlobalValue('BLOCKSTORE_IMG'); + + $img_src = ($img ? Tools::getProtocol().Tools::getMediaServer($this->name)._MODULE_DIR_.$this->name.'/'.$img : false); + + $output = $this->postProcess().'
'.$this->l('Store block configuration').''; - if (Configuration::get('BLOCKSTORE_IMG')) - $output .= '
'.$this->l('Store image').'
'; + if ($img_src) + $output .= '
'.$this->l('Store image').'
'; $output .= '