Files
wyczarujprezent.pl/modules/anblog/upgrade/install-3.3.9.php
2025-07-03 20:56:08 +02:00

83 lines
2.4 KiB
PHP

<?php
/**
* 2024 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2024 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
function upgrade_module_3_3_9($object)
{
$tabs = [
[
'class_name' => 'AdminAnblogWidgets',
'parent' => 'AdminAnblogManagement',
'name' => 'Widgets',
'active' => 1
],
];
$languages = Language::getLanguages();
foreach ($tabs as $tab) {
$_tab = new Tab();
$_tab->active = $tab['active'];
$_tab->class_name = $tab['class_name'];
$_tab->id_parent = Tab::getIdFromClassName($tab['parent']);
if (empty($_tab->id_parent)) {
$_tab->id_parent = 0;
}
$_tab->module = 'anblog';
foreach ($languages as $language) {
$_tab->name[$language['id_lang']] = $tab['name'];
}
$_tab->add();
}
$sql = [];
$sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'anblog_blog_widgets` (
`id_anblog_blog_widgets` int(11) unsigned NOT NULL AUTO_INCREMENT,
`id_anblogcat` int(11) NOT NULL,
`snow_on` int(11) NOT NULL,
`sort` varchar(150) NOT NULL,
`slider` tinyint(1) unsigned NOT NULL DEFAULT 1,
`limit` int(11) NOT NULL,
PRIMARY KEY(`id_anblog_blog_widgets`)
) ENGINE = ' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET = utf8;';
$sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'anblog_blog_widgets_lang` (
`id_anblog_blog_widgets` int(10) unsigned NOT NULL,
`title` varchar(255) NOT NULL,
`id_lang` varchar(255) NOT NULL,
PRIMARY KEY(`id_anblog_blog_widgets`, `id_lang`)
) ENGINE = ' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET = utf8;';
$sql[] = 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'anblog_blog_widgets_shop` (
`id_anblog_blog_widgets` int(11) NOT NULL DEFAULT 0,
`id_shop` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id_anblog_blog_widgets`,`id_shop`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8;';
$return = true;
foreach ($sql as $_sql) {
$return = Db::getInstance()->Execute($_sql);
if (!$return){
return false;
}
}
return true;
}