This commit is contained in:
2025-04-01 00:38:54 +02:00
parent d4d4c0c09d
commit 87da06293a
22351 changed files with 5168854 additions and 7538 deletions

View File

@@ -0,0 +1,33 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
function add_hook($hook, $title, $description, $position = 1)
{
return (bool) Db::getInstance()->execute('
INSERT INTO `' . _DB_PREFIX_ . 'hook` (`name`, `title`, `description`, `position`)
VALUES ("' . pSQL($hook) . '", "' . pSQL($title) . '", "' . pSQL($description) . '", ' . (int) $position . ')
ON DUPLICATE KEY UPDATE `title` = VALUES(`title`), `description` = VALUES(`description`)
');
}

View File

@@ -0,0 +1,67 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
// Allows you to catch up on a forgotten uniqueness constraint on the roles
function add_missing_unique_key_from_authorization_role()
{
// Verify if we need to create unique key
$keys = Db::getInstance()->executeS(
'SHOW KEYS FROM ' . _DB_PREFIX_ . "authorization_role WHERE Key_name='slug'"
);
if (!empty($keys)) {
return;
}
// We recover the duplicates that we want to keep
$duplicates = Db::getInstance()->executeS(
'SELECT MIN(id_authorization_role) AS keep_ID, slug FROM ' . _DB_PREFIX_ . 'authorization_role GROUP BY slug HAVING COUNT(*) > 1'
);
if (empty($duplicates)) {
return;
}
foreach ($duplicates as $duplicate) {
// We recover the duplicates that we want to remove
$elementsToRemoves = Db::getInstance()->executeS(
'SELECT id_authorization_role FROM ' . _DB_PREFIX_ . "authorization_role WHERE slug = '" . $duplicate['slug'] . "' AND id_authorization_role != " . $duplicate['keep_ID']
);
foreach ($elementsToRemoves as $elementToRemove) {
// We update the access table which may have used a duplicate role
Db::getInstance()->execute(
'UPDATE ' . _DB_PREFIX_ . "access SET id_authorization_role = '" . $duplicate['keep_ID'] . "' WHERE id_authorization_role = " . $elementToRemove['id_authorization_role']
);
// We remove the role
Db::getInstance()->delete('authorization_role', '`id_authorization_role` = ' . (int) $elementToRemove['id_authorization_role']);
}
}
Db::getInstance()->execute(
'ALTER TABLE ' . _DB_PREFIX_ . 'authorization_role ADD UNIQUE KEY `slug` (`slug`)'
);
}

View File

@@ -0,0 +1,148 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
function add_new_status_stock()
{
Language::resetCache();
$translator = Context::getContext()->getTranslator();
$languages = Language::getLanguages();
// insert ps_tab AdminStockManagement
$count = (int) Db::getInstance()->getValue(
'SELECT count(id_tab) FROM `' . _DB_PREFIX_ . 'tab`
WHERE `class_name` = \'AdminStockManagement\'
AND `id_parent` = 9'
);
if (!$count) {
Db::getInstance()->execute(
'INSERT INTO `' . _DB_PREFIX_ . 'tab`
(`id_tab`, `id_parent`, `position`, `module`, `class_name`, `active`, `hide_host_mode`, `icon`)
VALUES (null, 9, 7, NULL, \'AdminStockManagement\', 1, 0, \'\')'
);
$lastIdTab = (int) Db::getInstance()->Insert_ID();
// ps_tab_lang
foreach ($languages as $lang) {
$idLang = (int) $lang['id_lang'];
$stockName = pSQL(
$translator->trans(
'Stock',
[],
'Admin.Navigation.Menu',
$lang['locale']
)
);
Db::getInstance()->execute(
'INSERT INTO `' . _DB_PREFIX_ . 'tab_lang` (`id_tab`, `id_lang`, `name`)
VALUES (
' . $lastIdTab . ',
' . $idLang . ",
'" . $stockName . "'
)"
);
}
}
// Stock movements
$data = [
[
'name' => 'Customer Order',
'sign' => 1,
'conf' => 'PS_STOCK_CUSTOMER_ORDER_CANCEL_REASON',
],
[
'name' => 'Product Return',
'sign' => 1,
'conf' => 'PS_STOCK_CUSTOMER_RETURN_REASON',
],
[
'name' => 'Employee Edition',
'sign' => 1,
'conf' => 'PS_STOCK_MVT_INC_EMPLOYEE_EDITION',
],
[
'name' => 'Employee Edition',
'sign' => -1,
'conf' => 'PS_STOCK_MVT_DEC_EMPLOYEE_EDITION',
],
];
foreach ($data as $d) {
// We don't want duplicated data
if (configuration_exists($d['conf'])) {
continue;
}
// ps_stock_mvt_reason
Db::getInstance()->execute(
'INSERT INTO `' . _DB_PREFIX_ . 'stock_mvt_reason` (`sign`, `date_add`, `date_upd`, `deleted`)
VALUES (' . $d['sign'] . ', NOW(), NOW(), "0")'
);
// ps_configuration
$lastInsertedId = Db::getInstance()->Insert_ID();
Db::getInstance()->execute(
'INSERT INTO `' . _DB_PREFIX_ . 'configuration` (`name`, `value`, `date_add`, `date_upd`)
VALUES ("' . $d['conf'] . '", ' . (int) $lastInsertedId . ', NOW(), NOW())'
);
// ps_stock_mvt_reason_lang
foreach ($languages as $lang) {
$mvtName = pSQL(
$translator->trans(
$d['name'],
[],
'Admin.Catalog.Feature',
$lang['locale']
)
);
Db::getInstance()->execute(
'INSERT INTO `' . _DB_PREFIX_ . 'stock_mvt_reason_lang` (`id_stock_mvt_reason`, `id_lang`, `name`)
VALUES (' . (int) $lastInsertedId . ', ' . (int) $lang['id_lang'] . ', "' . $mvtName . '")'
);
}
}
// sync all stock
$shops = Shop::getShops();
foreach ($shops as $shop) {
(new \PrestaShop\PrestaShop\Adapter\StockManager())->updatePhysicalProductQuantity(
(int) $shop['id_shop'],
(int) Configuration::get('PS_OS_ERROR'),
(int) Configuration::get('PS_OS_CANCELED')
);
}
}
function configuration_exists($confName)
{
$count = (int) Db::getInstance()->getValue(
'SELECT count(id_configuration)
FROM `' . _DB_PREFIX_ . 'configuration`
WHERE `name` = \'' . $confName . '\''
);
return $count > 0;
}

View File

@@ -0,0 +1,133 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
use PrestaShopBundle\Security\Voter\PageVoter;
/**
* Common method to handle the tab registration
*
* @internal
*/
function register_tab($className, $name, $id_parent, $returnId = false, $parentTab = null, $module = '')
{
if (null !== $parentTab && !empty($parentTab) && strtolower(trim($parentTab)) !== 'null') {
$id_parent = (int) Db::getInstance()->getValue('SELECT `id_tab` FROM `' . _DB_PREFIX_ . 'tab` WHERE `class_name` = \'' . pSQL($parentTab) . '\'');
}
$array = [];
foreach (explode('|', $name) as $item) {
$temp = explode(':', $item);
$array[$temp[0]] = $temp[1];
}
if (!(int) Db::getInstance()->getValue('SELECT count(id_tab) FROM `' . _DB_PREFIX_ . 'tab` WHERE `class_name` = \'' . pSQL($className) . '\' ')) {
Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'tab` (`id_parent`, `class_name`, `module`, `position`) VALUES (' . (int) $id_parent . ', \'' . pSQL($className) . '\', \'' . pSQL($module) . '\',
(SELECT IFNULL(MAX(t.position),0)+ 1 FROM `' . _DB_PREFIX_ . 'tab` t WHERE t.id_parent = ' . (int) $id_parent . '))');
}
$languages = Db::getInstance()->executeS('SELECT id_lang, iso_code FROM `' . _DB_PREFIX_ . 'lang`');
foreach ($languages as $lang) {
Db::getInstance()->execute('
INSERT IGNORE INTO `' . _DB_PREFIX_ . 'tab_lang` (`id_lang`, `id_tab`, `name`)
VALUES (' . (int) $lang['id_lang'] . ', (
SELECT `id_tab`
FROM `' . _DB_PREFIX_ . 'tab`
WHERE `class_name` = \'' . pSQL($className) . '\' LIMIT 0,1
), \'' . pSQL(isset($array[$lang['iso_code']]) ? $array[$lang['iso_code']] : $array['en']) . '\')
');
}
}
/**
* Common method for getting the new tab ID
*
* @internal
*/
function get_new_tab_id($className, $returnId = false)
{
if ($returnId && strtolower(trim($returnId)) !== 'false') {
return (int) Db::getInstance()->getValue('SELECT `id_tab`
FROM `' . _DB_PREFIX_ . 'tab`
WHERE `class_name` = \'' . pSQL($className) . '\'');
}
}
/**
* Entrypoint for adding new tabs on +1.7 versions of PrestaShop
*
* @param string $className
* @param string $name Pipe-separated translated values
* @param int $id_parent
* @param bool $returnId
* @param string $parentTab
* @param string $module
*
* @return int|null Tab id if requested
*/
function add_new_tab_17($className, $name, $id_parent, $returnId = false, $parentTab = null, $module = '')
{
register_tab($className, $name, $id_parent, $returnId, $parentTab, $module);
// Preliminary - Get Parent class name for slug generation
$parentClassName = null;
if ($id_parent) {
$parentClassName = Db::getInstance()->getValue('
SELECT `class_name`
FROM `' . _DB_PREFIX_ . 'tab`
WHERE `id_tab` = "' . (int) $id_parent . '"
');
} elseif (!empty($parentTab)) {
$parentClassName = $parentTab;
}
foreach ([PageVoter::CREATE, PageVoter::READ, PageVoter::UPDATE, PageVoter::DELETE] as $role) {
// 1- Add role
$roleToAdd = strtoupper('ROLE_MOD_TAB_' . $className . '_' . $role);
Db::getInstance()->execute('INSERT IGNORE INTO `' . _DB_PREFIX_ . 'authorization_role` (`slug`)
VALUES ("' . pSQL($roleToAdd) . '")');
$newID = Db::getInstance()->Insert_ID();
if (!$newID) {
$newID = Db::getInstance()->getValue('
SELECT `id_authorization_role`
FROM `' . _DB_PREFIX_ . 'authorization_role`
WHERE `slug` = "' . pSQL($roleToAdd) . '"
');
}
// 2- Copy access from the parent
if (!empty($parentClassName) && !empty($newID)) {
$parentRole = strtoupper('ROLE_MOD_TAB_' . pSQL($parentClassName) . '_' . $role);
Db::getInstance()->execute(
'INSERT IGNORE INTO `' . _DB_PREFIX_ . 'access` (`id_profile`, `id_authorization_role`)
SELECT a.`id_profile`, ' . (int) $newID . ' as `id_authorization_role`
FROM `' . _DB_PREFIX_ . 'access` a join `' . _DB_PREFIX_ . 'authorization_role` ar on a.`id_authorization_role` = ar.`id_authorization_role`
WHERE ar.`slug` = "' . pSQL($parentRole) . '"'
);
}
}
return get_new_tab_id($className, $returnId);
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
/**
* In Prestashop 1.7.5 the supplier_rule and manufacturer_rule have been modified:
* {id}__{rewrite} => supplier/{id}-{rewrite}
* {id}_{rewrite} => brand/{id}-{rewrite}
*
* If the merchant kept the original routes the former urls won't be reachable any
* more and SEO will be lost. So we force a custom rule matching the former format.
*
* If the route was customized, no need to do anything. We don't change anything for
* multi shop either since it will be used it the merchant has already changed them.
*/
function add_supplier_manufacturer_routes()
{
Configuration::loadConfiguration();
$legacyRoutes = [
'supplier_rule' => '{id}__{rewrite}',
'manufacturer_rule' => '{id}_{rewrite}',
];
foreach ($legacyRoutes as $routeId => $rule) {
if (!Configuration::get('PS_ROUTE_' . $routeId, null, 0, 0)) {
Configuration::updateGlobalValue('PS_ROUTE_' . $routeId, $rule);
}
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
use PrestaShopBundle\Security\Voter\PageVoter;
function copy_tab_rights($fromTabName, $toTabName)
{
if (empty($fromTabName) || empty($toTabName)) {
return;
}
foreach ([PageVoter::CREATE, PageVoter::READ, PageVoter::UPDATE, PageVoter::DELETE] as $role) {
// 1- Add role
$roleToAdd = strtoupper('ROLE_MOD_TAB_' . $toTabName . '_' . $role);
Db::getInstance()->execute('INSERT IGNORE INTO `' . _DB_PREFIX_ . 'authorization_role` (`slug`)
VALUES ("' . pSQL($roleToAdd) . '")');
$newID = Db::getInstance()->Insert_ID();
if (!$newID) {
$newID = Db::getInstance()->getValue('
SELECT `id_authorization_role`
FROM `' . _DB_PREFIX_ . 'authorization_role`
WHERE `slug` = "' . pSQL($roleToAdd) . '"
');
}
// 2- Copy access
if (!empty($newID)) {
$parentRole = strtoupper('ROLE_MOD_TAB_' . pSQL($fromTabName) . '_' . $role);
Db::getInstance()->execute(
'INSERT IGNORE INTO `' . _DB_PREFIX_ . 'access` (`id_profile`, `id_authorization_role`)
SELECT a.`id_profile`, ' . (int) $newID . ' as `id_authorization_role`
FROM `' . _DB_PREFIX_ . 'access` a join `' . _DB_PREFIX_ . 'authorization_role` ar on a.`id_authorization_role` = ar.`id_authorization_role`
WHERE ar.`slug` = "' . pSQL($parentRole) . '"'
);
}
}
}

View File

@@ -0,0 +1,130 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
function deactivate_custom_modules(): bool
{
$db = Db::getInstance();
$modules = scandir(_PS_MODULE_DIR_, SCANDIR_SORT_NONE);
foreach ($modules as $name) {
if (!in_array($name, ['.', '..', 'index.php', '.htaccess']) && @is_dir(_PS_MODULE_DIR_ . $name . DIRECTORY_SEPARATOR) && @file_exists(_PS_MODULE_DIR_ . $name . DIRECTORY_SEPARATOR . $name . '.php')) {
if (!preg_match('/^[a-zA-Z0-9_-]+$/', $name)) {
exit(Tools::displayError() . ' (Module ' . $name . ')');
}
}
}
$module_list_xml = _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'modules_list.xml';
if (!file_exists($module_list_xml)) {
$module_list_xml = _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'modules_list.xml';
if (!file_exists($module_list_xml)) {
return false;
}
}
$nativeModules = @simplexml_load_file($module_list_xml);
if ($nativeModules) {
$nativeModules = $nativeModules->modules;
}
$arrNativeModules = [];
if (!empty($nativeModules)) {
foreach ($nativeModules as $nativeModulesType) {
if (in_array($nativeModulesType['type'], ['native', 'partner'])) {
$arrNativeModules[] = '""';
foreach ($nativeModulesType->module as $module) {
$arrNativeModules[] = '"' . pSQL($module['name']) . '"';
}
}
}
}
$arrNonNative = [];
if ($arrNativeModules) {
$arrNonNative = $db->executeS('
SELECT *
FROM `' . _DB_PREFIX_ . 'module` m
WHERE name NOT IN (' . implode(',', $arrNativeModules) . ') ');
}
$uninstallMe = ['undefined-modules'];
if (is_array($arrNonNative)) {
foreach ($arrNonNative as $k => $aModule) {
$uninstallMe[(int) $aModule['id_module']] = $aModule['name'];
}
}
if (!is_array($uninstallMe)) {
$uninstallMe = [$uninstallMe];
}
foreach ($uninstallMe as $k => $v) {
$uninstallMe[$k] = '"' . pSQL($v) . '"';
}
$return = Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'module` SET `active` = 0 WHERE `name` IN (' . implode(',', $uninstallMe) . ')');
if (count(Db::getInstance()->executeS('SHOW TABLES LIKE \'' . _DB_PREFIX_ . 'module_shop\'')) > 0) {
foreach ($uninstallMe as $k => $uninstall) {
$return &= Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'module_shop` WHERE `id_module` = ' . (int) $k);
}
}
return $return;
}
/**
* @param mixed $moduleRepository
*/
function deactivate_custom_modules80($moduleRepository): bool
{
$nonNativeModulesList = $moduleRepository->getNonNativeModules();
$return = Db::getInstance()->execute(
'UPDATE `' . _DB_PREFIX_ . 'module` SET `active` = 0 WHERE `name` IN (' . implode(',', array_map('add_quotes', $nonNativeModulesList)) . ')'
);
$nonNativeModules = \Db::getInstance()->executeS('
SELECT *
FROM `' . _DB_PREFIX_ . 'module` m
WHERE name IN (' . implode(',', array_map('add_quotes', $nonNativeModulesList)) . ') ');
if (!is_array($nonNativeModules) || empty($nonNativeModules)) {
return $return;
}
$toBeUninstalled = [];
foreach ($nonNativeModules as $aModule) {
$toBeUninstalled[] = (int) $aModule['id_module'];
}
$sql = 'DELETE FROM `' . _DB_PREFIX_ . 'module_shop` WHERE `id_module` IN (' . implode(',', array_map('add_quotes', $toBeUninstalled)) . ') ';
return $return && Db::getInstance()->execute($sql);
}
function add_quotes(string $str): string
{
return sprintf("'%s'", $str);
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
function drop_column_from_product_lang_if_exists()
{
$columns = Db::getInstance()->executeS('SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'product_lang`
WHERE Field IN (\'social_sharing_title\', \'social_sharing_description\')');
if (!empty($columns)) {
foreach ($columns as $column) {
Db::getInstance()->execute('ALTER TABLE `' . _DB_PREFIX_ . 'product_lang` DROP COLUMN `' . $column['Field'] . '`');
}
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
function drop_column_if_exists($table, $column)
{
$column_exists = Db::getInstance()->executeS('SHOW COLUMNS FROM `' . _DB_PREFIX_ . $table . "` WHERE Field = '" . $column . "'");
if (!empty($column_exists)) {
Db::getInstance()->execute('ALTER TABLE `' . _DB_PREFIX_ . $table . '` DROP COLUMN `' . $column . '`');
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
function execute_sql_if_table_exists($table, $sqlQuery)
{
if (empty(Db::getInstance()->executeS('SHOW TABLES LIKE "' . _DB_PREFIX_ . $table . '"'))) {
return true;
}
$sqlQuery = str_replace('PREFIX', _DB_PREFIX_, $sqlQuery);
return Db::getInstance()->execute($sqlQuery);
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,33 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
function install_ps_distributionapiclient()
{
if (class_exists('Ps_Distributionapiclient')) {
$module = new Ps_Distributionapiclient();
$module->updateTranslationsAfterInstall(false);
$module->install();
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
function ps_1730_add_quick_access_evaluation_catalog()
{
$moduleManagerBuilder = \PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder::getInstance();
$moduleManager = $moduleManagerBuilder->build();
$isStatscheckupInstalled = $moduleManager->isInstalled('statscheckup');
if ($isStatscheckupInstalled) {
$translator = Context::getContext()->getTranslator();
Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'quick_access` SET link = "index.php?controller=AdminStats&module=statscheckup" ');
$idQuickAccess = (int) Db::getInstance()->Insert_ID();
foreach (Language::getLanguages() as $language) {
Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'quick_access_lang` SET
`id_quick_access` = ' . $idQuickAccess . ',
`id_lang` = ' . (int) $language['id_lang'] . ',
`name` = "' . pSQL($translator->trans('Catalog evaluation', [], 'Admin.Navigation.Header')) . '" ');
}
}
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
function ps_1730_migrate_data_from_store_to_store_lang_and_clean_store()
{
$langs = Language::getLanguages();
foreach ($langs as $lang) {
Db::getInstance()->execute(
'INSERT INTO `' . _DB_PREFIX_ . 'store_lang`
SELECT `id_store`, ' . $lang['id_lang'] . ' as id_lang , `name`, `address1`, `address2`, `hours`, `note`
FROM `' . _DB_PREFIX_ . 'store`'
);
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
function ps_1730_move_some_aeuc_configuration_to_core()
{
$translator = Context::getContext()->getTranslator();
$labelInStock = [];
$labelOOSProductsBOA = [];
$labelOOSProductsBOD = [];
$deliveryTimeAvailable = [];
$deliveryTimeOutOfStockBackorderAllowed = [];
foreach (Language::getLanguages() as $language) {
$labelInStock[$language['id_lang']] = $translator->trans('In Stock', [], 'Admin.Shopparameters.Feature', $language['locale']);
$labelOOSProductsBOA[$language['id_lang']] = $translator->trans('Product available for orders', [], 'Admin.Shopparameters.Feature', $language['locale']);
$labelOOSProductsBOD[$language['id_lang']] = $translator->trans('Out-of-Stock', [], 'Admin.Shopparameters.Feature', $language['locale']);
if ($value = Configuration::get('AEUC_LABEL_DELIVERY_TIME_AVAILABLE', $language['id_lang'])) {
$deliveryTimeAvailable[$language['id_lang']] = $value;
}
if ($value = Configuration::get('AEUC_LABEL_DELIVERY_TIME_OOS', $language['id_lang'])) {
$deliveryTimeOutOfStockBackorderAllowed[$language['id_lang']] = $value;
}
}
Configuration::updateValue('PS_LABEL_IN_STOCK_PRODUCTS', $labelInStock);
Configuration::updateValue('PS_LABEL_OOS_PRODUCTS_BOA', $labelOOSProductsBOA);
Configuration::updateValue('PS_LABEL_OOS_PRODUCTS_BOD', $labelOOSProductsBOD);
Configuration::updateValue('PS_LABEL_DELIVERY_TIME_AVAILABLE', $deliveryTimeAvailable);
Configuration::updateValue('PS_LABEL_DELIVERY_TIME_OOSBOA', $deliveryTimeOutOfStockBackorderAllowed);
}

View File

@@ -0,0 +1,45 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
/**
* File copied from ps_update_tabs.php and modified for only adding modules related tabs
*/
function ps_1740_update_module_tabs()
{
// Add new sub menus for modules
$moduleTabsToBeAdded = [
'AdminModulesManage' => 'en:Installed modules|fr:Modules installés|es:Módulos instalados|de:Installierte Module|it:Moduli installati',
'AdminModulesCatalog' => 'en:Selection|fr:Selection|es:Selección|de:Auswahl|it:Selezione',
'AdminModulesNotifications' => 'en:Notifications|fr:Notifications|es:Notificaciones|de:Nachrichten|it:Notifiche',
];
include_once 'add_new_tab.php';
foreach ($moduleTabsToBeAdded as $className => $translations) {
add_new_tab_17($className, $translations, 0, false, 'AdminModulesSf');
}
Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'tab` SET `active`=1 WHERE `class_name` IN ("AdminModulesManage", "AdminModulesCatalog", "AdminModulesNotifications")');
}

View File

@@ -0,0 +1,132 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
/**
* File copied from ps_update_tabs.php and modified for only adding modules related tabs
*/
function ps_1750_update_module_tabs()
{
// STEP 1: Add new sub menus for modules
$moduleTabsToBeAdded = [
'AdminModulesUpdates' => [
'translations' => 'en:Updates|fr:Mises à jour|es:Actualizaciones|de:Aktualisierung|it:Aggiornamenti',
'parent' => 'AdminModulesSf',
],
'AdminParentModulesCatalog' => [
'translations' => 'en:Module Catalog|fr:Catalogue de modules|es:Catálogo de módulos|de:Modulkatalog|it:Catalogo dei moduli',
'parent' => 'AdminParentModulesSf',
],
];
include_once 'add_new_tab.php';
foreach ($moduleTabsToBeAdded as $className => $tabDetails) {
add_new_tab_17($className, $tabDetails['translations'], 0, false, $tabDetails['parent']);
Db::getInstance()->execute(
'UPDATE `' . _DB_PREFIX_ . 'tab` SET `active`= 1 WHERE `class_name` = "' . $className . '"'
);
}
// STEP 2: Rename module tabs (Notifications as Alerts, Module selection as Module Catalog, Module Catalog as Module Selections)
include_once 'rename_tab.php';
$adminModulesNotificationsTabId = Db::getInstance()->getValue(
'SELECT id_tab FROM ' . _DB_PREFIX_ . 'tab WHERE class_name = "AdminModulesNotifications"'
);
if (!empty($adminModulesNotificationsTabId)) {
renameTab(
$adminModulesNotificationsTabId,
[
'fr' => 'Alertes',
'es' => 'Alertas',
'en' => 'Alerts',
'gb' => 'Alerts',
'de' => 'Benachrichtigungen',
'it' => 'Avvisi',
]
);
}
$adminModulesCatalogTabId = Db::getInstance()->getValue(
'SELECT id_tab FROM ' . _DB_PREFIX_ . 'tab WHERE class_name = "AdminModulesCatalog"'
);
if (!empty($adminModulesCatalogTabId)) {
renameTab(
$adminModulesCatalogTabId,
[
'fr' => 'Catalogue de modules',
'es' => 'Catálogo de módulos',
'en' => 'Module Catalog',
'gb' => 'Module Catalog',
'de' => 'Versanddienst',
'it' => 'Catalogo dei moduli',
]
);
}
$adminModulesManageTabId = Db::getInstance()->getValue(
'SELECT id_tab FROM ' . _DB_PREFIX_ . 'tab WHERE class_name = "AdminModulesManage"'
);
if (!empty($adminModulesManageTabId)) {
renameTab(
$adminModulesManageTabId,
[
'fr' => 'Modules',
'es' => 'módulos',
'en' => 'Modules',
'gb' => 'Modules',
'de' => 'Modules',
'it' => 'Moduli',
]
);
}
$adminModulesAddonsSelectionsTabId = Db::getInstance()->getValue(
'SELECT id_tab FROM ' . _DB_PREFIX_ . 'tab WHERE class_name = "AdminAddonsCatalog"'
);
if (!empty($adminModulesAddonsSelectionsTabId)) {
renameTab(
$adminModulesAddonsSelectionsTabId,
[
'fr' => 'Sélections de modules',
'es' => 'Selecciones de módulos',
'en' => 'Module Selections',
'gb' => 'Module Selections',
'de' => 'Auswahl von Modulen',
'it' => 'Selezioni Moduli',
]
);
}
// STEP 3: Move the 2 module catalog controllers in the parent one
// Get The ID of the parent
$adminParentModuleCatalogTabId = Db::getInstance()->getValue(
'SELECT id_tab FROM ' . _DB_PREFIX_ . 'tab WHERE class_name = "AdminParentModulesCatalog"'
);
foreach (['AdminModulesCatalog', 'AdminAddonsCatalog'] as $key => $className) {
Db::getInstance()->execute(
'UPDATE `' . _DB_PREFIX_ . 'tab` SET `id_parent`= ' . (int) $adminParentModuleCatalogTabId . ', position = ' . $key . ' WHERE `class_name` = "' . $className . '"'
);
}
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
/**
* File copied from ps_update_tabs.php and modified for only adding modules related tabs
*/
function ps_1751_update_module_sf_tab()
{
// Rename parent module tab (= Module manager)
include_once 'rename_tab.php';
$adminModulesParentTabId = Db::getInstance()->getValue(
'SELECT id_tab FROM ' . _DB_PREFIX_ . 'tab WHERE class_name = "AdminModulesSf"'
);
if (!empty($adminModulesParentTabId)) {
renameTab(
$adminModulesParentTabId,
[
'fr' => 'Gestionnaire de modules',
'es' => 'Gestor de módulos',
'en' => 'Module Manager',
'gb' => 'Module Manager',
'de' => 'Modulmanager',
'it' => 'Gestione moduli',
]
);
}
}

View File

@@ -0,0 +1,102 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
use PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleRepository;
function ps_1760_copy_data_from_currency_to_currency_lang()
{
// Force cache reset of languages (load locale column)
ObjectModel::disableCache();
$languages = Language::getLanguages();
foreach ($languages as $language) {
Db::getInstance()->execute(
'INSERT INTO `' . _DB_PREFIX_ . 'currency_lang` (`id_currency`, `id_lang`, `name`)
SELECT `id_currency`, ' . (int) $language['id_lang'] . ' as id_lang , `name`
FROM `' . _DB_PREFIX_ . 'currency`
ON DUPLICATE KEY UPDATE
`name` = `' . _DB_PREFIX_ . 'currency`.`name`
'
);
}
/** @var Currency[] $currencies */
$currencies = Currency::getCurrencies(true, false);
$context = Context::getContext();
$container = isset($context->controller) ? $context->controller->getContainer() : null;
if (null === $container) {
$container = SymfonyContainer::getInstance();
}
/** @var LocaleRepository $localeRepoCLDR */
$localeRepoCLDR = $container->get('prestashop.core.localization.cldr.locale_repository');
foreach ($currencies as $currency) {
refreshLocalizedCurrencyData($currency, $languages, $localeRepoCLDR);
}
ObjectModel::enableCache();
}
function refreshLocalizedCurrencyData(Currency $currency, array $languages, LocaleRepository $localeRepoCLDR)
{
$language = new Language($languages[0]['id_lang']);
$cldrLocale = $localeRepoCLDR->getLocale($language->locale);
$cldrCurrency = $cldrLocale->getCurrency($currency->iso_code);
if (!empty($cldrCurrency)) {
$fields = [
'numeric_iso_code' => $cldrCurrency->getNumericIsoCode(),
'precision' => $cldrCurrency->getDecimalDigits(),
];
Db::getInstance()->update('currency', $fields, 'id_currency = ' . (int) $currency->id);
}
foreach ($languages as $languageData) {
$language = new Language($languageData['id_lang']);
if (empty($language->locale)) {
// Language doesn't have locale we can't install this language
continue;
}
// CLDR locale give us the CLDR reference specification
$cldrLocale = $localeRepoCLDR->getLocale($language->locale);
// CLDR currency gives data from CLDR reference, for the given language
$cldrCurrency = $cldrLocale->getCurrency($currency->iso_code);
if (empty($cldrCurrency)) {
continue;
}
$fields = [
'name' => $cldrCurrency->getDisplayName(),
'symbol' => (string) $cldrCurrency->getSymbol() ?: $currency->iso_code,
];
$where = 'id_currency = ' . (int) $currency->id
. ' AND id_lang = ' . (int) $language->id;
Db::getInstance()->update('currency_lang', $fields, $where);
}
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
/**
* Init new configuration values
*/
function ps_1760_update_configuration()
{
Configuration::updateValue('PS_MAIL_THEME', 'modern');
Configuration::updateValue('PS_CATALOG_MODE_WITH_PRICES', 0);
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
/**
* File copied from ps_1750_update_module_tabs.php and modified to add new roles
*/
function ps_1760_update_tabs()
{
// STEP 1: Add new sub menus for modules (tab may exist but we need authorization roles to be added as well)
$moduleTabsToBeAdded = [
'AdminMailThemeParent' => [
'translations' => 'en:Email Themes',
'parent' => 'AdminParentThemes',
],
'AdminMailTheme' => [
'translations' => 'en:Email Themes',
'parent' => 'AdminMailThemeParent',
],
'AdminModulesUpdates' => [
'translations' => 'en:Updates|fr:Mises à jour|es:Actualizaciones|de:Aktualisierung|it:Aggiornamenti',
'parent' => 'AdminModulesSf',
],
'AdminModulesNotifications' => [
'translations' => 'en:Updates|fr:Mises à jour|es:Actualizaciones|de:Aktualisierung|it:Aggiornamenti',
'parent' => 'AdminModulesSf',
],
];
include_once 'add_new_tab.php';
foreach ($moduleTabsToBeAdded as $className => $tabDetails) {
add_new_tab_17($className, $tabDetails['translations'], 0, false, $tabDetails['parent']);
Db::getInstance()->execute(
'UPDATE `' . _DB_PREFIX_ . 'tab` SET `active`= 1 WHERE `class_name` = "' . pSQL($className) . '"'
);
}
}

View File

@@ -0,0 +1,73 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
use PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleRepository;
/**
* On PrestaShop 1.7.6.0, two new columns have been introduced in the PREFIX_currency table: precision & numeric_iso_code
* A fresh install would add the proper data in these columns, however an upgraded shop to 1.7.6.0 would not get the
* corresponding values of each currency.
*
* This upgrade script will cover this need by loading the CLDR data and update the currency if it still has the default table values.
*/
function ps_1761_update_currencies()
{
// Force cache reset of languages (load locale column)
ObjectModel::disableCache();
/** @var Currency[] $currencies */
$currencies = Currency::getCurrencies(true, false);
$context = Context::getContext();
$container = isset($context->controller) ? $context->controller->getContainer() : null;
if (null === $container) {
$container = SymfonyContainer::getInstance();
}
/** @var LocaleRepository $localeRepoCLDR */
$localeRepoCLDR = $container->get('prestashop.core.localization.cldr.locale_repository');
// CLDR locale give us the CLDR reference specification
$cldrLocale = $localeRepoCLDR->getLocale($context->language->getLocale());
foreach ($currencies as $currency) {
if ((int) $currency->precision !== 6 || !empty((int) $currency->numeric_iso_code)) {
continue;
}
// CLDR currency gives data from CLDR reference, for the given language
$cldrCurrency = $cldrLocale->getCurrency($currency->iso_code);
if (!empty($cldrCurrency)) {
$currency->precision = (int) $cldrCurrency->getDecimalDigits();
$currency->numeric_iso_code = $cldrCurrency->getNumericIsoCode();
}
Db::getInstance()->execute(
'UPDATE `' . _DB_PREFIX_ . 'currency`
SET `precision` = ' . $currency->precision . ', `numeric_iso_code` = ' . $currency->numeric_iso_code . '
WHERE `id_currency` = ' . $currency->id
);
}
ObjectModel::enableCache();
}

View File

@@ -0,0 +1,52 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
/**
* File copied from ps_1750_update_module_tabs.php and modified to add new roles
*/
function ps_1763_update_tabs()
{
include_once 'add_new_tab.php';
include_once 'copy_tab_rights.php';
add_new_tab_17('AdminParentMailTheme', 'en:Email Themes', 0, false, 'AdminParentThemes');
Db::getInstance()->execute(
'UPDATE `' . _DB_PREFIX_ . 'tab` SET `active`= 1, `position`= 2 WHERE `class_name` = "AdminParentMailTheme"'
);
// Move AdminMailTheme's parent from AdminMailThemeParent to AdminParentMailTheme
$toParentTabId = Db::getInstance()->getValue(
'SELECT id_tab FROM `' . _DB_PREFIX_ . 'tab` WHERE `class_name` = "AdminParentMailTheme"'
);
Db::getInstance()->execute(
'UPDATE `' . _DB_PREFIX_ . 'tab` SET `id_parent` = ' . $toParentTabId . ' WHERE class_name = "AdminMailTheme"'
);
copy_tab_rights('AdminMailTheme', 'AdminParentMailTheme');
Db::getInstance()->execute(
'DELETE FROM `' . _DB_PREFIX_ . 'tab` WHERE `class_name` = "AdminMailThemeParent"'
);
}

View File

@@ -0,0 +1,52 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
/**
* Preset enabled new column in tabs to true for all (except for disabled modules)
*/
function ps_1770_preset_tab_enabled()
{
//First set all tabs enabled
$result = Db::getInstance()->execute(
'UPDATE `' . _DB_PREFIX_ . 'tab` SET `enabled` = 1'
);
//Then search for inactive modules and disable their tabs
$inactiveModules = Db::getInstance()->executeS(
'SELECT `name` FROM `' . _DB_PREFIX_ . 'module` WHERE `active` != 1'
);
$moduleNames = [];
foreach ($inactiveModules as $inactiveModule) {
$moduleNames[] = '"' . $inactiveModule['name'] . '"';
}
if (count($moduleNames) > 0) {
$result &= Db::getInstance()->execute(
'UPDATE `' . _DB_PREFIX_ . 'tab` SET `enabled` = 0 WHERE `module` IN (' . implode(',', $moduleNames) . ')'
);
}
return $result;
}

View File

@@ -0,0 +1,85 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
function ps_1770_update_charset()
{
$adminFilterTableExists = $adminFilterFilterIdExists = $moduleHistoryTableExists = $translationTableExists = false;
try {
$adminFilterTableExists = (bool) Db::getInstance()->executeS(
'SELECT count(*) FROM ' . _DB_PREFIX_ . 'admin_filter'
);
if ($adminFilterTableExists) {
$adminFilterFilterIdExists = (bool) Db::getInstance()->executeS(
'SELECT count(filter_id) FROM ' . _DB_PREFIX_ . 'admin_filter'
);
}
} catch (Exception $e) {
}
try {
$moduleHistoryTableExists = (bool) Db::getInstance()->executeS(
'SELECT count(*) FROM ' . _DB_PREFIX_ . 'module_history'
);
} catch (Exception $e) {
}
try {
$translationTableExists = (bool) Db::getInstance()->executeS(
'SELECT count(*) FROM ' . _DB_PREFIX_ . 'translation'
);
} catch (Exception $e) {
}
$result = true;
if ($adminFilterTableExists) {
if ($adminFilterFilterIdExists) {
$result &= Db::getInstance()->execute(
'UPDATE ' . _DB_PREFIX_ . '`admin_filter` SET `filter_id` = SUBSTRING(`filter_id`, 1, 191)'
);
$result &= Db::getInstance()->execute(
'ALTER TABLE ' . _DB_PREFIX_ . '`admin_filter` CHANGE `filter_id` `filter_id` VARCHAR(191) NOT NULL'
);
}
$result &= Db::getInstance()->execute(
'ALTER TABLE ' . _DB_PREFIX_ . '`admin_filter` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci'
);
}
if ($moduleHistoryTableExists) {
$result &= Db::getInstance()->execute(
'ALTER TABLE ' . _DB_PREFIX_ . '`module_history` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci'
);
}
if ($translationTableExists) {
$result &= Db::getInstance()->execute(
'ALTER TABLE ' . _DB_PREFIX_ . '`translation` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci'
);
}
return (bool) $result;
}

View File

@@ -0,0 +1,83 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
use PrestaShop\PrestaShop\Core\Domain\Order\Status\OrderStatusColor;
/**
* Updates order status colors according to new color schema
*/
function ps_1770_update_order_status_colors()
{
$statusColorMap = [
OrderStatusColor::AWAITING_PAYMENT => Configuration::getMultiple([
'PS_OS_CHEQUE',
'PS_OS_BANKWIRE',
'PS_OS_OUTOFSTOCK_UNPAID',
'PS_OS_COD_VALIDATION',
]),
OrderStatusColor::ACCEPTED_PAYMENT => Configuration::getMultiple([
'PS_OS_PAYMENT',
'PS_OS_PREPARATION',
'PS_OS_OUTOFSTOCK_PAID',
'PS_OS_WS_PAYMENT',
]),
OrderStatusColor::COMPLETED => Configuration::getMultiple([
'PS_OS_SHIPPING',
'PS_OS_DELIVERED',
'PS_OS_REFUND',
]),
OrderStatusColor::ERROR => Configuration::getMultiple([
'PS_OS_ERROR',
]),
OrderStatusColor::SPECIAL => Configuration::getMultiple([
'PS_OS_CANCELED',
]),
];
foreach ($statusColorMap as $color => $statuses) {
foreach ($statuses as $statusId) {
Db::getInstance()->execute(
'UPDATE `' . _DB_PREFIX_ . 'order_state` SET `color` = "' . pSQL($color) . '" WHERE `id_order_state` = ' . (int) $statusId
);
}
}
// Some of the statuses can be deduced by their parameters, this allows to update the modules status colors
$statusColorConditions = [
OrderStatusColor::ACCEPTED_PAYMENT => ['paid' => 1, 'shipped' => 0],
OrderStatusColor::COMPLETED => ['paid' => 1, 'shipped' => 1],
OrderStatusColor::AWAITING_PAYMENT => ['color' => '#4169E1'], // Former color of awaiting payment
];
foreach ($statusColorConditions as $color => $conditions) {
$whereCondition = ' WHERE 1';
foreach ($conditions as $field => $expectedValue) {
$whereCondition .= ' AND `' . $field . '` = "' . pSQL($expectedValue) . '"';
}
Db::getInstance()->execute(
'UPDATE `' . _DB_PREFIX_ . 'order_state` SET `color` = "' . pSQL($color) . '"' . $whereCondition
);
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
/*
* Since note is now TYPE_STRING instead of TYPE_HTML it needs to be decoded
*/
function ps_1771_update_customer_note()
{
$notes = Db::getInstance()->executeS(
'SELECT id_customer, note FROM ' . _DB_PREFIX_ . 'customer
WHERE note IS NOT NULL AND note != ""'
);
$result = true;
foreach ($notes as $note) {
$result &= Db::getInstance()->execute(
'UPDATE ' . _DB_PREFIX_ . 'customer
SET note = "' . pSQL(html_entity_decode($note['note'])) . '"
WHERE id_customer = ' . $note['id_customer']
);
}
return (bool) $result;
}

View File

@@ -0,0 +1,52 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
function ps_1780_add_feature_flag_tab()
{
$className = 'AdminFeatureFlag';
$result = Db::getInstance()->executeS(
'SELECT id_tab FROM `' . _DB_PREFIX_ . 'tab` WHERE `class_name` = \'AdminAdvancedParameters\''
);
if (empty($result)) {
return;
}
if (empty($result[0]['id_tab'])) {
return;
}
$advancedParametersTabId = (int) $result[0]['id_tab'];
include_once __DIR__ . '/add_new_tab.php';
add_new_tab_17(
$className,
'en:Experimental Feature|fr:Fonctionnalités expérimentales',
$advancedParametersTabId
);
Db::getInstance()->execute(
'UPDATE `' . _DB_PREFIX_ . 'tab` SET `active`= 1, `enabled` = 1 WHERE `class_name` = \'' . $className . '\''
);
}

View File

@@ -0,0 +1,75 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
function ps_800_add_security_tab()
{
include_once __DIR__ . '/add_new_tab.php';
$tabs = [
['AdminParentSecurity', 'en:Security', 0, false, 'AdminAdvancedParameters'],
['AdminSecurity', 'en:Security', 0, false, 'AdminParentSecurity'],
['AdminSecuritySessionEmployee', 'en:Employee Sessions', 0, false, 'AdminParentSecurity'],
['AdminSecuritySessionCustomer', 'en:Customer Sessions', 0, false, 'AdminParentSecurity'],
];
$tabsData = [
'AdminParentSecurity' => [
'active' => 1,
'enabled' => 1,
'wording' => '\'Security\'',
'wording_domain' => '\'Admin.Navigation.Menu\'',
],
'AdminSecurity' => [
'active' => 1,
'enabled' => 1,
'wording' => '\'Security\'',
'wording_domain' => '\'Admin.Navigation.Menu\'',
'route_name' => '\'admin_security\'',
],
'AdminSecuritySessionEmployee' => [
'active' => 1,
'enabled' => 1,
'wording' => '\'Employee Sessions\'',
'wording_domain' => '\'Admin.Navigation.Menu\'',
'route_name' => '\'admin_security_sessions_employee_list\'',
],
'AdminSecuritySessionCustomer' => [
'active' => 1,
'enabled' => 1,
'wording' => '\'Customer Sessions\'',
'wording_domain' => '\'Admin.Navigation.Menu\'',
'route_name' => '\'admin_security_sessions_customer_list\'',
],
];
foreach ($tabs as $tab) {
add_new_tab_17(...$tab);
$data = [];
foreach ($tabsData[$tab[0]] as $key => $value) {
$data[] = '`' . $key . '` = ' . $value;
}
Db::getInstance()->execute(
'UPDATE `' . _DB_PREFIX_ . 'tab` SET ' . implode(', ', $data) . ' WHERE `class_name` = \'' . $tab[0] . '\''
);
}
}

View File

@@ -0,0 +1,54 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
function ps_810_update_product_page_feature_flags()
{
$featureFlags = Db::getInstance()->executeS('SELECT name, state FROM `' . _DB_PREFIX_ . 'feature_flag`');
// Check if one of the feature flag is already enabled
$productState = 0;
if (!empty($featureFlags)) {
foreach ($featureFlags as $featureFlag) {
if ($featureFlag['name'] === 'product_page_v2' && (int) $featureFlag['state'] === 1) {
$productState = 1;
break;
}
if ($featureFlag['name'] === 'product_page_v2_multi_shop' && (int) $featureFlag['state'] === 1) {
$productState = 1;
break;
}
}
}
// Update product feature flag with stability, and appropriate state
Db::getInstance()->update('feature_flag', [
'stability' => 'stable',
'state' => $productState,
'label_wording' => 'New product page',
], '`name` = \'product_page_v2\'');
// Delete the multishop feature flag
Db::getInstance()->delete('feature_flag', '`name` = \'product_page_v2_multi_shop\'');
}

View File

@@ -0,0 +1,53 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
function ps_811_update_redirect_type()
{
// Get information about redirect_type column
$columnInformation = Db::getInstance()->executeS('SHOW COLUMNS FROM `' . _DB_PREFIX_ . 'product` LIKE "redirect_type"');
if (empty($columnInformation)) {
return true;
}
// Get first record found
$columnInformation = reset($columnInformation);
// Check if it was already upgraded and contains new information
if (strpos($columnInformation['Type'], '200-displayed') !== false) {
return true;
}
// If not, we execute our upgrade queries
Db::getInstance()->execute('ALTER TABLE `' . _DB_PREFIX_ . "product` MODIFY COLUMN `redirect_type` ENUM(
'','404','410','301-product','302-product','301-category','302-category','200-displayed','404-displayed','410-displayed','default'
) NOT NULL DEFAULT 'default';");
Db::getInstance()->execute('ALTER TABLE `' . _DB_PREFIX_ . "product_shop` MODIFY COLUMN `redirect_type` ENUM(
'','404','410','301-product','302-product','301-category','302-category','200-displayed','404-displayed','410-displayed','default'
) NOT NULL DEFAULT 'default';");
Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . "product` SET `redirect_type` = 'default' WHERE `redirect_type` = '404' OR `redirect_type` = '' OR `redirect_type` IS NULL;");
Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . "product_shop` SET `redirect_type` = 'default' WHERE `redirect_type` = '404' OR `redirect_type` = '' OR `redirect_type` IS NULL;");
return true;
}

View File

@@ -0,0 +1,115 @@
<?php
function ps_remove_controller_tab($className, $quickAccessUrls = [])
{
// select given tab
$tabsToBeDeleted = [];
$rolesToBeDeleted = [];
$tabToDelete = Db::getInstance()->getRow(
sprintf("SELECT id_tab, id_parent, class_name FROM %stab WHERE class_name = '%s'", _DB_PREFIX_, $className)
);
if (empty($tabToDelete)) {
return;
}
// get tabs and roles that should be deleted
getElementsToBeDeleted($tabToDelete['id_tab'], $tabToDelete['id_parent'], $className, $tabsToBeDeleted, $rolesToBeDeleted);
// delete tabs fetched by the recursive function
Db::getInstance()->execute(
sprintf(
'DELETE FROM %stab WHERE id_tab IN (%s)',
_DB_PREFIX_,
implode(', ', $tabsToBeDeleted)
)
);
// delete orphan tab langs
Db::getInstance()->execute(
sprintf(
'DELETE FROM `%stab_lang` WHERE `id_tab` NOT IN (SELECT id_tab FROM `%stab`)',
_DB_PREFIX_,
_DB_PREFIX_
)
);
// delete orphan legacy quick access links
$sqlLegacyQuickAccessLinkDeletion = sprintf(
"DELETE FROM `%squick_access_lang`
WHERE id_quick_access IN (SELECT id_quick_access FROM `%squick_access` WHERE link LIKE '%%controller=%s%%')",
_DB_PREFIX_,
_DB_PREFIX_,
$className
);
Db::getInstance()->execute($sqlLegacyQuickAccessLinkDeletion);
Db::getInstance()->execute(
sprintf(
"DELETE FROM `%squick_access` WHERE link LIKE '%%controller=%s%%'",
_DB_PREFIX_,
$className
)
);
if (!empty($quickAccessUrls)) {
// delete orphan quick access links (given links, for symfony urls)
foreach ($quickAccessUrls as &$link) {
$link = "'" . $link . "'";
}
Db::getInstance()->execute(
sprintf(
'DELETE FROM %squick_access WHERE link IN (%s)',
_DB_PREFIX_,
implode(', ', $quickAccessUrls)
)
);
}
// delete orphan roles
$sqlRoleDeletion = sprintf('DELETE FROM %sauthorization_role WHERE ', _DB_PREFIX_);
foreach ($rolesToBeDeleted as $key => $role) {
if ($key === 0) {
$sqlRoleDeletion .= "slug LIKE '" . $role . "'";
continue;
}
$sqlRoleDeletion .= "OR slug LIKE '" . $role . "'";
}
Db::getInstance()->execute($sqlRoleDeletion);
}
function getElementsToBeDeleted($idTab, $idParent, $className, &$tabsToBeDeleted, &$rolesToBeDeleted)
{
// add current tab to tabs that will be deleted
$tabsToBeDeleted[] = $idTab;
$rolesToBeDeleted[] = sprintf('ROLE_MOD_TAB_%s%%', strtoupper($className));
if (empty($idParent)) {
return;
}
// check if parent has any other children
$sibling = Db::getInstance()->getRow(
sprintf(
'SELECT id_tab FROM %stab WHERE id_parent = ' . $idParent . ' AND id_tab NOT IN (%s)',
_DB_PREFIX_,
implode(', ', $tabsToBeDeleted)
)
);
// tab has at least one sibling, we stop here
if (!empty($sibling)) {
return;
}
// no sibling, get parent and repeat the process recursively
$parentTab = Db::getInstance()->getRow(
sprintf('SELECT id_tab, id_parent, class_name FROM %stab WHERE id_tab = %s', _DB_PREFIX_, $idParent)
);
// this is just in case, it should never happen, if a tab has an id_parent, parent should exist
if (empty($parentTab)) {
return;
}
getElementsToBeDeleted($parentTab['id_tab'], $parentTab['id_parent'], $parentTab['class_name'], $tabsToBeDeleted, $rolesToBeDeleted);
}

View File

@@ -0,0 +1,75 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
/**
* Updates ps_tab_lang table for a given domain and className
*
* This method will fetch the tab from className, and update ps_tab_lang
* with translated wordings for all available languages
*
* @param string $domain
* @param string $className
*/
function ps_update_tab_lang($domain, $className)
{
$translator = Context::getContext()->getTranslator();
// get tab ID
$tabQuery = sprintf(
'SELECT id_tab, wording FROM `%stab` WHERE `class_name` = "%s"',
_DB_PREFIX_,
$className
);
$tab = Db::getInstance()->getRow($tabQuery);
if (empty($tab)) {
return;
}
// get languages
$languages = Language::getLanguages();
// for each language, update tab_lang
foreach ($languages as $lang) {
$tabName = pSQL(
$translator->trans(
$tab['wording'],
[],
$domain,
$lang['locale']
)
);
$updateQuery = sprintf(
'UPDATE `%stab_lang` SET `name` = "%s" WHERE `id_tab` = "%s" AND `id_lang` = "%s"',
_DB_PREFIX_,
$tabName,
$tab['id_tab'],
$lang['id_lang']
);
Db::getInstance()->execute($updateQuery);
}
}

View File

@@ -0,0 +1,116 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
function ps_update_tabs()
{
if (file_exists(__DIR__ . '/../../data/xml/tab.xml')) {
$tab_xml = simplexml_load_file(__DIR__ . '/../../data/xml/tab.xml');
if (!empty($tab_xml)) {
$tab_class_name = [];
$tab_ids = [];
foreach ($tab_xml->entities->tab as $tab) {
$tab = (array) $tab;
$tab_class_name[$tab['class_name']] = $tab['@attributes']['id'];
}
$tabs = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'tab`', true, false);
if (!empty($tabs)) {
foreach ($tabs as $tab) {
if (isset($tab_class_name[$tab['class_name']])) {
$tab_ids[$tab['class_name']] = $tab['id_tab'];
}
}
}
} else {
return;
}
if (!empty($tab_class_name)) {
$langs = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'lang` WHERE `iso_code` != "en" ', true, false);
if (!empty($langs)) {
foreach ($langs as $lang) {
if (file_exists(__DIR__ . '/../../langs/' . $lang['iso_code'] . '/data/tab.xml')) {
// store XML data
$tab_xml_data = [];
$tab_xml_lang = simplexml_load_file(__DIR__ . '/../../langs/' . $lang['iso_code'] . '/data/tab.xml');
if (!empty($tab_xml_lang)) {
foreach ($tab_xml_lang->tab as $tab) {
$tab = (array) $tab;
$tab_xml_data[$tab['@attributes']['id']] = $tab['@attributes']['name'];
}
}
// store DB data
$tab_db_data = [];
$results = Db::getInstance()->executeS('
SELECT t.`id_tab`, tl.`id_lang`, t.`class_name`, tl.`name` FROM `' . _DB_PREFIX_ . 'tab` t
INNER JOIN `' . _DB_PREFIX_ . 'tab_lang` tl ON tl.`id_tab` = t.`id_tab`
WHERE tl.`id_lang` = ' . (int) $lang['id_lang'], true, false);
if (!empty($results)) {
foreach ($results as $res) {
$tab_db_data[$res['class_name']] = $res['name'];
}
}
if (!empty($tab_xml_data)) {
foreach ($tab_xml_data as $k => $tab) {
if (in_array($k, $tab_class_name)) {
$tmp_class_name = array_keys($tab_class_name, $k)[0];
if (array_key_exists($tmp_class_name, $tab_ids)) {
$tmp_class_id = $tab_ids[$tmp_class_name];
// if data XML is not in DB => insert
if (!array_key_exists($tmp_class_name, $tab_db_data)) {
$sql = 'INSERT INTO `' . _DB_PREFIX_ . 'tab_lang`
(`id_tab`, `id_lang`, `name`)
VALUES (' . (int) $tmp_class_id . ',' . (int) $lang['id_lang'] . ',"' . pSQL($tab) . '")';
Db::getInstance()->execute($sql);
} else {
// if DB is != XML
if ($tab_db_data[$tmp_class_name] != $tab) {
$sql = 'UPDATE `' . _DB_PREFIX_ . 'tab_lang`
SET `name` = "' . pSQL($tab) . '"
WHERE `id_tab` = ' . (int) $tmp_class_id . ' AND
`id_lang` = ' . (int) $lang['id_lang'] . ' AND
`name` = "' . pSQL($tab_db_data[$tmp_class_name]) . '" ';
Db::getInstance()->execute($sql);
}
}
}
}
}
}
}
}
}
}
}
}

View File

@@ -0,0 +1,38 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
function renameTab($id_tab, $names)
{
if (!$id_tab) {
return;
}
$langues = Db::getInstance()->executeS('SELECT * FROM ' . _DB_PREFIX_ . 'lang');
foreach ($langues as $lang) {
if (array_key_exists($lang['iso_code'], $names)) {
Db::getInstance()->update('tab_lang', ['name' => $names[$lang['iso_code']]], '`id_tab`= ' . $id_tab . ' AND `id_lang` =' . $lang['id_lang']);
}
}
}

View File

@@ -0,0 +1,247 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
/**
* This function aims to update the null values of several columns, to default values,
* in order to avoid unexpected behavior on data that does not take null values into account
*
* @internal
*/
function update_null_values()
{
$db = Db::getInstance();
$updates = [
['address', 'address2', ''],
['address', 'company', ''],
['address', 'dni', ''],
['address', 'id_state', '0'],
['address', 'other', ''],
['address', 'phone_mobile', ''],
['address', 'phone', ''],
['address', 'postcode', ''],
['address', 'vat_number', ''],
['attachment_lang', 'description', ''],
['carrier_lang', 'delay', ''],
['carrier', 'external_module_name', ''],
['cart_rule', 'description', ''],
['cart', 'gift_message', ''],
['category_lang', 'additional_description', ''],
['category_lang', 'description', ''],
['category_lang', 'meta_description', ''],
['category_lang', 'meta_keywords', ''],
['category_lang', 'meta_title', ''],
['cms_category_lang', 'description', ''],
['cms_category_lang', 'meta_description', ''],
['cms_category_lang', 'meta_keywords', ''],
['cms_category_lang', 'meta_title', ''],
['cms_lang', 'content', ''],
['cms_lang', 'head_seo_title', ''],
['cms_lang', 'meta_description', ''],
['cms_lang', 'meta_keywords', ''],
['configuration_kpi_lang', 'date_upd', 'CURRENT_TIMESTAMP'],
['configuration_kpi_lang', 'value', ''],
['configuration_lang', 'date_upd', 'CURRENT_TIMESTAMP'],
['configuration_lang', 'value', ''],
['connections_source', 'http_referer', ''],
['connections_source', 'keywords', ''],
['connections', 'http_referer', ''],
['connections', 'ip_address', '0'],
['contact_lang', 'description', ''],
['currency_lang', 'pattern', ''],
['customer_message', 'file_name', ''],
['customer_message', 'id_employee', '0'],
['customer_message', 'ip_address', ''],
['customer_message', 'user_agent', ''],
['customer_thread', 'id_order', '0'],
['customer_thread', 'id_product', '0'],
['customer', 'birthday', '0000-00-00'],
['customer', 'newsletter_date_add', '0000-00-00 00:00:00'],
['customer', 'reset_password_validity', '0000-00-00 00:00:00'],
['employee', 'bo_css', ''],
['employee', 'reset_password_validity', '0000-00-00 00:00:00'],
['employee', 'stats_compare_from', '0000-00-00'],
['employee', 'stats_compare_to', '0000-00-00'],
['employee', 'stats_date_from', 'CURRENT_TIMESTAMP'],
['employee', 'stats_date_to', 'CURRENT_TIMESTAMP'],
['feature_value', 'custom', '0'],
['guest', 'accept_language', ''],
['guest', 'adobe_director', '0'],
['guest', 'adobe_flash', '0'],
['guest', 'apple_quicktime', '0'],
['guest', 'id_customer', '0'],
['guest', 'id_operating_system', '0'],
['guest', 'id_web_browser', '0'],
['guest', 'real_player', '0'],
['guest', 'screen_color', '0'],
['guest', 'screen_resolution_x', '0'],
['guest', 'screen_resolution_y', '0'],
['guest', 'sun_java', '0'],
['guest', 'windows_media', '0'],
['hook', 'description', ''],
['image_lang', 'legend', ''],
['log', 'error_code', '0'],
['log', 'id_employee', '0'],
['log', 'id_lang', '0'],
['log', 'object_id', '0'],
['log', 'object_type', ''],
['manufacturer_lang', 'description', ''],
['manufacturer_lang', 'meta_description', ''],
['manufacturer_lang', 'meta_keywords', ''],
['manufacturer_lang', 'meta_title', ''],
['manufacturer_lang', 'short_description', ''],
['message', 'id_employee', '0'],
['meta_lang', 'description', ''],
['meta_lang', 'keywords', ''],
['meta_lang', 'title', ''],
['order_carrier', 'id_order_invoice', '0'],
['order_carrier', 'shipping_cost_tax_excl', '0'],
['order_carrier', 'shipping_cost_tax_incl', '0'],
['order_carrier', 'tracking_number', ''],
['order_carrier', 'weight', '0'],
['order_detail', 'download_deadline', '0000-00-00 00:00:00'],
['order_detail', 'download_hash', ''],
['order_detail', 'id_order_invoice', '0'],
['order_detail', 'product_attribute_id', '0'],
['order_detail', 'product_ean13', ''],
['order_detail', 'product_isbn', ''],
['order_detail', 'product_mpn', ''],
['order_detail', 'product_reference', ''],
['order_detail', 'product_supplier_reference', ''],
['order_detail', 'product_upc', ''],
['order_invoice', 'delivery_date', '0000-00-00 00:00:00'],
['order_invoice', 'note', ''],
['order_invoice', 'shop_address', ''],
['order_payment', 'card_brand', ''],
['order_payment', 'card_expiration', ''],
['order_payment', 'card_holder', ''],
['order_payment', 'card_number', ''],
['order_payment', 'transaction_id', ''],
['order_return_state', 'color', ''],
['order_slip_detail', 'amount_tax_excl', '0'],
['order_slip_detail', 'amount_tax_incl', '0'],
['order_slip_detail', 'total_price_tax_excl', '0'],
['order_slip_detail', 'total_price_tax_incl', '0'],
['order_slip_detail', 'unit_price_tax_excl', '0'],
['order_slip_detail', 'unit_price_tax_incl', '0'],
['order_slip', 'total_products_tax_excl', '0'],
['order_slip', 'total_products_tax_incl', '0'],
['order_slip', 'total_shipping_tax_excl', '0'],
['order_slip', 'total_shipping_tax_incl', '0'],
['order_state', 'color', ''],
['order_state', 'module_name', ''],
['orders', 'gift_message', ''],
['orders', 'note', ''],
['product_attribute_lang', 'available_later', ''],
['product_attribute_lang', 'available_now', ''],
['product_attribute_shop', 'available_date', '0000-00-00'],
['product_attribute_shop', 'low_stock_threshold', '0'],
['product_attribute', 'available_date', '0000-00-00'],
['product_attribute', 'ean13', ''],
['product_attribute', 'isbn', ''],
['product_attribute', 'low_stock_threshold', '0'],
['product_attribute', 'mpn', ''],
['product_attribute', 'reference', ''],
['product_attribute', 'supplier_reference', ''],
['product_attribute', 'upc', ''],
['product_download', 'date_expiration', '0000-00-00 00:00:00'],
['product_download', 'nb_days_accessible', '0'],
['product_lang', 'available_later', ''],
['product_lang', 'available_now', ''],
['product_lang', 'delivery_in_stock', ''],
['product_lang', 'delivery_out_stock', ''],
['product_lang', 'description_short', ''],
['product_lang', 'description', ''],
['product_lang', 'meta_description', ''],
['product_lang', 'meta_keywords', ''],
['product_lang', 'meta_title', ''],
['product_sale', 'date_upd', 'CURRENT_TIMESTAMP'],
['product_shop', 'available_date', '0000-00-00'],
['product_shop', 'cache_default_attribute', '0'],
['product_shop', 'id_category_default', '0'],
['product_shop', 'low_stock_threshold', '0'],
['product_shop', 'unity', ''],
['product_supplier', 'product_supplier_reference', ''],
['product', 'available_date', '0000-00-00'],
['product', 'cache_default_attribute', '0'],
['product', 'ean13', ''],
['product', 'id_category_default', '0'],
['product', 'id_manufacturer', '0'],
['product', 'id_supplier', '0'],
['product', 'isbn', ''],
['product', 'low_stock_threshold', '0'],
['product', 'mpn', ''],
['product', 'reference', ''],
['product', 'supplier_reference', ''],
['product', 'unity', ''],
['product', 'upc', ''],
['risk', 'color', ''],
['stock', 'ean13', ''],
['stock', 'isbn', ''],
['stock', 'mpn', ''],
['stock', 'upc', ''],
['store_lang', 'address2', ''],
['store_lang', 'note', ''],
['store', 'email', ''],
['store', 'fax', ''],
['store', 'id_state', '0'],
['store', 'phone', ''],
['supplier_lang', 'description', ''],
['supplier_lang', 'meta_description', ''],
['supplier_lang', 'meta_keywords', ''],
['supplier_lang', 'meta_title', ''],
['supply_order_detail', 'ean13', ''],
['supply_order_detail', 'isbn', ''],
['supply_order_detail', 'mpn', ''],
['supply_order_detail', 'upc', ''],
['supply_order_state', 'color', ''],
['supply_order', 'date_delivery_expected', '0000-00-00 00:00:00'],
['warehouse_product_location', 'location', ''],
['warehouse', 'reference', ''],
['webservice_account', 'description', ''],
];
foreach ($updates as $update) {
// Extract values from the update array
list($tabName, $columnName, $newValue) = $update;
// Check if the table exists
if (empty($db->executeS('SHOW TABLES LIKE "' . _DB_PREFIX_ . $tabName . '"'))) {
continue;
}
// Check if the column exists
if (empty($db->executeS('SHOW COLUMNS FROM `' . _DB_PREFIX_ . $tabName . "` WHERE Field = '" . $columnName . "'"))) {
continue;
}
$newValue = $newValue === 'CURRENT_TIMESTAMP' ? 'CURRENT_TIMESTAMP' : '\'' . $newValue . '\'';
// Update existing null values
$updateQuery = 'UPDATE `' . _DB_PREFIX_ . $tabName . '` SET `' . $columnName . '`=' . $newValue . ' WHERE `' . $columnName . '` IS NULL';
$db->execute($updateQuery);
}
}