// cms_block multishop
This commit is contained in:
1 parent
894a1f14d1
commit
85d0861c9e
4 files changed
+73
-15
No files matched your search
@@ -324,14 +324,13 @@ class HelperCore
|
|||||||
|
|
||||||
if ((int)$this->id)
|
if ((int)$this->id)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT id_'.$type.', `'.pSQL($this->identifier).'`
|
$sql = 'SELECT `id_'.bqSQL($type).'`, `'.bqSQL($this->identifier).'`
|
||||||
FROM `'._DB_PREFIX_.pSQL($this->table).'_'.$type.'`
|
FROM `'._DB_PREFIX_.bqSQL($this->table).'_'.bqSQL($type).'`
|
||||||
WHERE `'.pSQL($this->identifier).'` = '.(int)$this->id;
|
WHERE `'.bqSQL($this->identifier).'` = '.(int)$this->id;
|
||||||
|
|
||||||
foreach (Db::getInstance()->executeS($sql) as $row)
|
foreach (Db::getInstance()->executeS($sql) as $row)
|
||||||
$assos[$row['id_'.$type]] = $row['id_'.$type];
|
$assos[$row['id_'.$type]] = $row['id_'.$type];
|
||||||
}
|
}
|
||||||
|
|
||||||
$tpl = $this->createTemplate('helper/assoshop.tpl');
|
$tpl = $this->createTemplate('helper/assoshop.tpl');
|
||||||
$tpl->assign(array(
|
$tpl->assign(array(
|
||||||
'input' => array(
|
'input' => array(
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function update_modules_multishop()
|
||||||
|
{
|
||||||
|
//BlockCMS
|
||||||
|
$block_cms = Module::getInstanceByName('blockcms');
|
||||||
|
if ($block_cms->id)
|
||||||
|
{
|
||||||
|
Db::getInstance()->execute('CREATE TABLE '._DB_PREFIX_.'blocklink_shop (
|
||||||
|
`id_blocklink` int(2) NOT NULL AUTO_INCREMENT,
|
||||||
|
`id_shop` varchar(255) NOT NULL,
|
||||||
|
PRIMARY KEY(`id_blocklink`, `id_shop`))
|
||||||
|
ENGINE='._MYSQL_ENGINE_.' default CHARSET=utf8');
|
||||||
|
|
||||||
|
Db::getInstance()->execute('
|
||||||
|
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_shop` (
|
||||||
|
`id_cms_block` int(10) unsigned NOT NULL auto_increment,
|
||||||
|
`id_shop` int(10) unsigned NOT NULL,
|
||||||
|
PRIMARY KEY (`id_cms_block`, `id_shop`)
|
||||||
|
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8');
|
||||||
|
Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'cms_block_shop (cms_block, id_shop)
|
||||||
|
(SELECT id_cms_block, 1 FROM '._DB_PREFIX_.'cms_block)');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -392,3 +392,4 @@ INSERT INTO `PREFIX_configuration` (`name`, `value`, `date_add`, `date_upd`) VAL
|
|||||||
('PS_SMARTY_CONSOLE', '0', NOW(), NOW());
|
('PS_SMARTY_CONSOLE', '0', NOW(), NOW());
|
||||||
ALTER TABLE `PREFIX_specific_price` ADD `id_cart` INT(11) UNSIGNED NOT NULL AFTER `id_specific_price_rule`;
|
ALTER TABLE `PREFIX_specific_price` ADD `id_cart` INT(11) UNSIGNED NOT NULL AFTER `id_specific_price_rule`;
|
||||||
ALTER TABLE `PREFIX_specific_price` ADD INDEX `id_cart` (`id_cart`);
|
ALTER TABLE `PREFIX_specific_price` ADD INDEX `id_cart` (`id_cart`);
|
||||||
|
/* PHP:update_modules_multishop.php; */;
|
||||||
@@ -56,7 +56,6 @@ class BlockCms extends Module
|
|||||||
!Db::getInstance()->execute('
|
!Db::getInstance()->execute('
|
||||||
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block`(
|
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block`(
|
||||||
`id_cms_block` int(10) unsigned NOT NULL auto_increment,
|
`id_cms_block` int(10) unsigned NOT NULL auto_increment,
|
||||||
`id_shop` INT(11) UNSIGNED NOT NULL DEFAULT \'1\',
|
|
||||||
`id_cms_category` int(10) unsigned NOT NULL,
|
`id_cms_category` int(10) unsigned NOT NULL,
|
||||||
`location` tinyint(1) unsigned NOT NULL,
|
`location` tinyint(1) unsigned NOT NULL,
|
||||||
`position` int(10) unsigned NOT NULL default \'0\',
|
`position` int(10) unsigned NOT NULL default \'0\',
|
||||||
@@ -78,6 +77,12 @@ class BlockCms extends Module
|
|||||||
`is_category` tinyint(1) unsigned NOT NULL,
|
`is_category` tinyint(1) unsigned NOT NULL,
|
||||||
PRIMARY KEY (`id_cms_block_page`)
|
PRIMARY KEY (`id_cms_block_page`)
|
||||||
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') OR
|
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') OR
|
||||||
|
!Db::getInstance()->execute('
|
||||||
|
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_shop` (
|
||||||
|
`id_cms_block` int(10) unsigned NOT NULL auto_increment,
|
||||||
|
`id_shop` int(10) unsigned NOT NULL,
|
||||||
|
PRIMARY KEY (`id_cms_block`, `id_shop`)
|
||||||
|
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') OR
|
||||||
!Configuration::updateValue('FOOTER_CMS', '') OR
|
!Configuration::updateValue('FOOTER_CMS', '') OR
|
||||||
!Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1) OR
|
!Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1) OR
|
||||||
!Configuration::updateValue('FOOTER_POWEREDBY', 1))
|
!Configuration::updateValue('FOOTER_POWEREDBY', 1))
|
||||||
@@ -90,9 +95,16 @@ class BlockCms extends Module
|
|||||||
'position' => 0,
|
'position' => 0,
|
||||||
), 'INSERT'))
|
), 'INSERT'))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$id_cms_block = Db::getInstance()->Insert_ID();
|
$id_cms_block = Db::getInstance()->Insert_ID();
|
||||||
$result = true;
|
$result = true;
|
||||||
|
$shops = Shop::getShops(true, null, true);
|
||||||
|
foreach ($shops as $shop)
|
||||||
|
$result &= Db::getInstance()->autoExecute(_DB_PREFIX_.'cms_block_shop', array(
|
||||||
|
'id_cms_block' => $id_cms_block,
|
||||||
|
'id_shop' => $shop
|
||||||
|
), 'INSERT');
|
||||||
|
|
||||||
|
|
||||||
foreach (Language::getLanguages(false) as $lang)
|
foreach (Language::getLanguages(false) as $lang)
|
||||||
$result &= Db::getInstance()->autoExecute(_DB_PREFIX_.'cms_block_lang', array(
|
$result &= Db::getInstance()->autoExecute(_DB_PREFIX_.'cms_block_lang', array(
|
||||||
'id_cms_block' => $id_cms_block,
|
'id_cms_block' => $id_cms_block,
|
||||||
@@ -116,7 +128,7 @@ class BlockCms extends Module
|
|||||||
!Configuration::deleteByName('FOOTER_CMS') OR
|
!Configuration::deleteByName('FOOTER_CMS') OR
|
||||||
!Configuration::deleteByName('FOOTER_BLOCK_ACTIVATION') OR
|
!Configuration::deleteByName('FOOTER_BLOCK_ACTIVATION') OR
|
||||||
!Configuration::deleteByName('FOOTER_POWEREDBY') OR
|
!Configuration::deleteByName('FOOTER_POWEREDBY') OR
|
||||||
!Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'cms_block` , `'._DB_PREFIX_.'cms_block_page`, `'._DB_PREFIX_.'cms_block_lang`'))
|
!Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'cms_block` , `'._DB_PREFIX_.'cms_block_page`, `'._DB_PREFIX_.'cms_block_lang`, `'._DB_PREFIX_.'cms_block_shop`'))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -206,9 +218,10 @@ class BlockCms extends Module
|
|||||||
$cmsCategories = Db::getInstance()->executeS('
|
$cmsCategories = Db::getInstance()->executeS('
|
||||||
SELECT bc.`id_cms_block`, bc.`id_cms_category`, bc.`display_store`, ccl.`link_rewrite`, ccl.`name` category_name, bcl.`name` block_name
|
SELECT bc.`id_cms_block`, bc.`id_cms_category`, bc.`display_store`, ccl.`link_rewrite`, ccl.`name` category_name, bcl.`name` block_name
|
||||||
FROM `'._DB_PREFIX_.'cms_block` bc
|
FROM `'._DB_PREFIX_.'cms_block` bc
|
||||||
|
LEFT JOIN `'._DB_PREFIX_.'cms_block_shop` bcs ON (bcs.id_cms_block = bc.id_cms_block)
|
||||||
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` ccl ON (bc.`id_cms_category` = ccl.`id_cms_category`)
|
INNER JOIN `'._DB_PREFIX_.'cms_category_lang` ccl ON (bc.`id_cms_category` = ccl.`id_cms_category`)
|
||||||
INNER JOIN `'._DB_PREFIX_.'cms_block_lang` bcl ON (bc.`id_cms_block` = bcl.`id_cms_block`)
|
INNER JOIN `'._DB_PREFIX_.'cms_block_lang` bcl ON (bc.`id_cms_block` = bcl.`id_cms_block`)
|
||||||
WHERE bc.`location` = '.(int)($location).' AND ccl.`id_lang` = '.(int)$context->language->id.' AND bcl.`id_lang` = '.(int)$context->language->id.' AND bc.id_shop = '.$context->shop->getID(true).'
|
WHERE bc.`location` = '.(int)($location).' AND ccl.`id_lang` = '.(int)$context->language->id.' AND bcl.`id_lang` = '.(int)$context->language->id.' AND bcs.id_shop = '.$context->shop->getID(true).'
|
||||||
ORDER BY `position`');
|
ORDER BY `position`');
|
||||||
|
|
||||||
$content = array();
|
$content = array();
|
||||||
@@ -532,16 +545,23 @@ class BlockCms extends Module
|
|||||||
<label class="t" for="PS_STORES_DISPLAY_CMS_off">'.$this->l('No').'</label><br />'
|
<label class="t" for="PS_STORES_DISPLAY_CMS_off">'.$this->l('No').'</label><br />'
|
||||||
.$this->l('Display "our stores" at the end of the block')
|
.$this->l('Display "our stores" at the end of the block')
|
||||||
.'</div>';
|
.'</div>';
|
||||||
$this->_html .= '<div id="cms_subcategories"></div>
|
$this->_html .= '<div class="margin-form" id="cms_subcategories"></div><div class="clear"> </div>';
|
||||||
|
|
||||||
|
$helper = new Helper();
|
||||||
|
$helper->id = (int)Tools::getValue('id_cms_block');
|
||||||
|
$helper->table = 'cms_block';
|
||||||
|
$helper->identifier = 'id_cms_block';
|
||||||
|
|
||||||
|
if (Shop::isFeatureActive())
|
||||||
|
$this->_html .= '<label for="shop_association">'.$this->l('Shop association:').'</label><div id="shop_association" class="margin-form">'.$helper->renderAssoShop().'</div>';
|
||||||
|
$this->_html .= '
|
||||||
<p class="center">
|
<p class="center">
|
||||||
<input type="submit" class="button" name="submitBlockCMS" value="'.$this->l('Save').'" />
|
<input type="submit" class="button" name="submitBlockCMS" value="'.$this->l('Save').'" />
|
||||||
<a class="button" style="position:relative; padding:3px 3px 4px 3px; top:1px" href="'.AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'">'.$this->l('Cancel').'</a>
|
<a class="button" style="position:relative; padding:3px 3px 4px 3px; top:1px" href="'.AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'">'.$this->l('Cancel').'</a>
|
||||||
</p>';
|
</p>
|
||||||
|
</fieldset>
|
||||||
$this->_html .= '
|
</form>
|
||||||
</fieldset>
|
<script type="text/javascript">CMSCategory_js($(\'#id_category\').val(), \''.$this->secure_key.'\')</script>';
|
||||||
</form>
|
|
||||||
<script type="text/javascript">CMSCategory_js($(\'#id_category\').val(), \''.$this->secure_key.'\')</script>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _postValidation()
|
private function _postValidation()
|
||||||
@@ -713,6 +733,19 @@ class BlockCms extends Module
|
|||||||
WHERE `id_cms_block` = '.(int)$id_cms_block.'
|
WHERE `id_cms_block` = '.(int)$id_cms_block.'
|
||||||
AND `id_lang`= '.(int)$language['id_lang']);
|
AND `id_lang`= '.(int)$language['id_lang']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Tools::isSubmit('submitBlockCMS') || Tools::isSubmit('editBlockCMS'))
|
||||||
|
{
|
||||||
|
$assos_shop = Tools::getValue('checkBoxShopAsso_cms_block');
|
||||||
|
Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'cms_block_shop WHERE id_cms_block='.(int)$id_cms_block);
|
||||||
|
foreach ($assos_shop as $asso)
|
||||||
|
foreach ($asso as $id_shop => $row)
|
||||||
|
Db::getInstance()->autoExecute(_DB_PREFIX_.'cms_block_shop', array(
|
||||||
|
'id_cms_block' => (int)$id_cms_block,
|
||||||
|
'id_shop' => (int)$id_shop,
|
||||||
|
), 'INSERT');
|
||||||
|
}
|
||||||
|
|
||||||
$cmsBoxes = Tools::getValue('cmsBox');
|
$cmsBoxes = Tools::getValue('cmsBox');
|
||||||
if (sizeof($cmsBoxes))
|
if (sizeof($cmsBoxes))
|
||||||
foreach ($cmsBoxes as $cmsBox)
|
foreach ($cmsBoxes as $cmsBox)
|
||||||
@@ -722,6 +755,7 @@ class BlockCms extends Module
|
|||||||
INSERT INTO `'._DB_PREFIX_.'cms_block_page` (`id_cms_block`, `id_cms`, `is_category`)
|
INSERT INTO `'._DB_PREFIX_.'cms_block_page` (`id_cms_block`, `id_cms`, `is_category`)
|
||||||
VALUES('.(int)$id_cms_block.', '.(int)$cms_properties[1].', '.(int)$cms_properties[0].')');
|
VALUES('.(int)$id_cms_block.', '.(int)$cms_properties[1].', '.(int)$cms_properties[0].')');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Tools::isSubmit('addBlockCMS'))
|
if (Tools::isSubmit('addBlockCMS'))
|
||||||
Tools::redirectAdmin(AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&addBlockCMSConfirmation');
|
Tools::redirectAdmin(AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&addBlockCMSConfirmation');
|
||||||
elseif (Tools::isSubmit('editBlockCMS'))
|
elseif (Tools::isSubmit('editBlockCMS'))
|
||||||
|
|||||||
Reference in new issue
Block a user