[-] MO : #PSCFV-2567 - Module CMS block was not merged with new shop

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15678 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
mDeflotte
2012-05-25 08:58:11 +00:00
parent 81f87e0bfe
commit 27ca8f5481
2 changed files with 37 additions and 25 deletions
+36 -24
View File
@@ -39,7 +39,7 @@ class BlockCms extends Module
{ {
$this->name = 'blockcms'; $this->name = 'blockcms';
$this->tab = 'front_office_features'; $this->tab = 'front_office_features';
$this->version = 1.1; $this->version = '1.1.1';
$this->author = 'PrestaShop'; $this->author = 'PrestaShop';
$this->need_instance = 0; $this->need_instance = 0;
@@ -54,6 +54,7 @@ class BlockCms extends Module
{ {
if (!parent::install() || if (!parent::install() ||
!$this->registerHooks() || !$this->registerHooks() ||
!$this->registerHook('actionShopDataDuplication') ||
!BlockCMSModel::createTables() || !BlockCMSModel::createTables() ||
!Configuration::updateValue('FOOTER_CMS', '') || !Configuration::updateValue('FOOTER_CMS', '') ||
!Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1) || !Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1) ||
@@ -103,6 +104,7 @@ class BlockCms extends Module
{ {
if (!parent::uninstall() || if (!parent::uninstall() ||
!BlockCMSModel::DropTables() || !BlockCMSModel::DropTables() ||
!$this->unregisterHook('actionShopDataDuplication') ||
!Configuration::deleteByName('FOOTER_CMS') || !Configuration::deleteByName('FOOTER_CMS') ||
!Configuration::deleteByName('FOOTER_BLOCK_ACTIVATION') || !Configuration::deleteByName('FOOTER_BLOCK_ACTIVATION') ||
!Configuration::deleteByName('FOOTER_POWEREDBY')) !Configuration::deleteByName('FOOTER_POWEREDBY'))
@@ -541,7 +543,7 @@ class BlockCms extends Module
if ($this->_postValidation() == false) if ($this->_postValidation() == false)
return false; return false;
$this->_errors = array(); $this->_errors = array();
if (Tools::isSubmit('submitBlockCMS')) if (Tools::isSubmit('submitBlockCMS'))
{ {
$this->context->controller->getLanguages(); $this->context->controller->getLanguages();
@@ -554,17 +556,17 @@ class BlockCms extends Module
{ {
$id_cms_block = BlockCMSModel::insertCMSBlock($id_cms_category, $location, $position, $display_store); $id_cms_block = BlockCMSModel::insertCMSBlock($id_cms_category, $location, $position, $display_store);
if ($id_cms_block !== false) if ($id_cms_block !== false)
{ {
foreach ($this->context->controller->_languages as $language) foreach ($this->context->controller->_languages as $language)
BlockCMSModel::insertCMSBlockLang($id_cms_block, $language['id_lang']); BlockCMSModel::insertCMSBlockLang($id_cms_block, $language['id_lang']);
BlockCMSModel::insertCMSBlockShop($id_cms_block, Shop::getContextShopGroupID(), Shop::getContextShopID()); BlockCMSModel::insertCMSBlockShop($id_cms_block, Shop::getContextShopGroupID(), Shop::getContextShopID());
} }
$this->_errors[] = $this->l('New block cannot be created !'); $this->_errors[] = $this->l('New block cannot be created !');
} }
else if (Tools::isSubmit('editBlockCMS')) elseif (Tools::isSubmit('editBlockCMS'))
{ {
$id_cms_block = Tools::getvalue('id_cms_block'); $id_cms_block = Tools::getvalue('id_cms_block');
$old_block = BlockCMSModel::getBlockCMS($id_cms_block); $old_block = BlockCMSModel::getBlockCMS($id_cms_block);
@@ -595,12 +597,12 @@ class BlockCms extends Module
if (Tools::isSubmit('addBlockCMS')) if (Tools::isSubmit('addBlockCMS'))
$redirect = 'addBlockCMSConfirmation'; $redirect = 'addBlockCMSConfirmation';
else if (Tools::isSubmit('editBlockCMS')) elseif (Tools::isSubmit('editBlockCMS'))
$redirect = 'editBlockCMSConfirmation'; $redirect = 'editBlockCMSConfirmation';
Tools::redirectAdmin(AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&'.$redirect); Tools::redirectAdmin(AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&'.$redirect);
} }
else if (Tools::isSubmit('deleteBlockCMS') && Tools::getValue('id_cms_block')) elseif (Tools::isSubmit('deleteBlockCMS') && Tools::getValue('id_cms_block'))
{ {
$id_cms_block = Tools::getvalue('id_cms_block'); $id_cms_block = Tools::getvalue('id_cms_block');
@@ -614,11 +616,11 @@ class BlockCms extends Module
else else
$this->_html .= $this->displayError($this->l('Error: you are trying to delete a non-existent block cms')); $this->_html .= $this->displayError($this->l('Error: you are trying to delete a non-existent block cms'));
} }
else if (Tools::isSubmit('submitFooterCMS')) elseif (Tools::isSubmit('submitFooterCMS'))
{ {
$powered_by = Tools::getValue('cms_footer_powered_by_on') ? 1 : 0; $powered_by = Tools::getValue('cms_footer_powered_by_on') ? 1 : 0;
$footer_boxes = Tools::getValue('footerBox') ? implode('|', Tools::getValue('footerBox')) : ''; $footer_boxes = Tools::getValue('footerBox') ? implode('|', Tools::getValue('footerBox')) : '';
$block_activation = (Tools::getValue('cms_footer_on') == 1) ? 1 : 0; $block_activation = (Tools::getValue('cms_footer_on') == 1) ? 1 : 0;
Configuration::updateValue('FOOTER_CMS', rtrim($footer_boxes, '|')); Configuration::updateValue('FOOTER_CMS', rtrim($footer_boxes, '|'));
Configuration::updateValue('FOOTER_POWEREDBY', $powered_by); Configuration::updateValue('FOOTER_POWEREDBY', $powered_by);
@@ -626,21 +628,21 @@ class BlockCms extends Module
$this->_html .= $this->displayConfirmation($this->l('Footer\'s informations updated')); $this->_html .= $this->displayConfirmation($this->l('Footer\'s informations updated'));
} }
else if (Tools::isSubmit('addBlockCMSConfirmation')) elseif (Tools::isSubmit('addBlockCMSConfirmation'))
$this->_html .= $this->displayConfirmation($this->l('Block CMS added')); $this->_html .= $this->displayConfirmation($this->l('Block CMS added'));
else if (Tools::isSubmit('editBlockCMSConfirmation')) elseif (Tools::isSubmit('editBlockCMSConfirmation'))
$this->_html .= $this->displayConfirmation($this->l('Block CMS edited')); $this->_html .= $this->displayConfirmation($this->l('Block CMS edited'));
else if (Tools::isSubmit('deleteBlockCMSConfirmation')) elseif (Tools::isSubmit('deleteBlockCMSConfirmation'))
$this->_html .= $this->displayConfirmation($this->l('Deletion successful')); $this->_html .= $this->displayConfirmation($this->l('Deletion successful'));
else if (Tools::isSubmit('id_cms_block') && Tools::isSubmit('way') && Tools::isSubmit('position') && Tools::isSubmit('location')) elseif (Tools::isSubmit('id_cms_block') && Tools::isSubmit('way') && Tools::isSubmit('position') && Tools::isSubmit('location'))
$this->changePosition(); $this->changePosition();
else if (Tools::isSubmit('updatePositions')) elseif (Tools::isSubmit('updatePositions'))
$this->updatePositionsDnd(); $this->updatePositionsDnd();
if (count($this->_errors)) if (count($this->_errors))
{ {
foreach ($this->_errors as $err) foreach ($this->_errors as $err)
$this->_html .= '<div class="alert error">'.$err.'</div>'; $this->_html .= '<div class="alert error">'.$err.'</div>';
} }
} }
public function getContent() public function getContent()
@@ -733,4 +735,14 @@ class BlockCms extends Module
BlockCMSModel::updateCMSBlockPosition($pos[2], $position); BlockCMSModel::updateCMSBlockPosition($pos[2], $position);
} }
} }
public function hookActionShopDataDuplication($params)
{
Db::getInstance()->execute('
INSERT INTO '._DB_PREFIX_.'cms_block_shop (id_cms_block, id_shop)
SELECT id_cms_block, '.(int)$params['new_id_shop'].'
FROM '._DB_PREFIX_.'cms_block_shop
WHERE id_shop = '.(int)$params['old_id_shop'].'
');
}
} }
+1 -1
View File
@@ -2,7 +2,7 @@
<module> <module>
<name>blockcms</name> <name>blockcms</name>
<displayName><![CDATA[CMS Block]]></displayName> <displayName><![CDATA[CMS Block]]></displayName>
<version><![CDATA[1.1]]></version> <version><![CDATA[1.1.1]]></version>
<description><![CDATA[Adds a block with several CMS links.]]></description> <description><![CDATA[Adds a block with several CMS links.]]></description>
<author><![CDATA[PrestaShop]]></author> <author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[front_office_features]]></tab> <tab><![CDATA[front_office_features]]></tab>