first commit

This commit is contained in:
2024-10-25 14:16:28 +02:00
commit 925276dbb2
33795 changed files with 4780077 additions and 0 deletions

View File

@@ -0,0 +1,131 @@
<?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)
*/
class ToolsInstall
{
/**
* Converts a simpleXML element into an array. Preserves attributes and everything.
* You can choose to get your elements either flattened, or stored in a custom index that
* you define.
* For example, for a given element
* <field name="someName" type="someType"/>
* if you choose to flatten attributes, you would get:
* $array['field']['name'] = 'someName';
* $array['field']['type'] = 'someType';
* If you choose not to flatten, you get:
* $array['field']['@attributes']['name'] = 'someName';
* _____________________________________
* Repeating fields are stored in indexed arrays. so for a markup such as:
* <parent>
* <child>a</child>
* <child>b</child>
* <child>c</child>
* </parent>
* you array would be:
* $array['parent']['child'][0] = 'a';
* $array['parent']['child'][1] = 'b';
* ...And so on.
* _____________________________________
* @param simpleXMLElement $xml the XML to convert
* @param bool $flattenValues Choose wether to flatten values
* or to set them under a particular index.
* defaults to true;
* @param bool $flattenAttributes Choose wether to flatten attributes
* or to set them under a particular index.
* Defaults to true;
* @param bool $flattenChildren Choose wether to flatten children
* or to set them under a particular index.
* Defaults to true;
* @param string $valueKey index for values, in case $flattenValues was set to
* false. Defaults to "@value"
* @param string $attributesKey index for attributes, in case $flattenAttributes was set to
* false. Defaults to "@attributes"
* @param string $childrenKey index for children, in case $flattenChildren was set to
* false. Defaults to "@children"
* @return array the resulting array.
*/
public static function simpleXMLToArray($xml, $flattenValues = true, $flattenAttributes = true, $flattenChildren = true, $valueKey = '@value', $attributesKey = '@attributes', $childrenKey = '@children')
{
$return = array();
if (!($xml instanceof SimpleXMLElement)) {
return $return;
}
$name = $xml->getName();
$_value = trim((string)$xml);
if (strlen($_value) == 0) {
$_value = null;
}
if ($_value !== null) {
if (!$flattenValues) {
$return[$valueKey] = $_value;
} else {
$return = $_value;
}
}
$children = array();
$first = true;
foreach ($xml->children() as $elementName => $child) {
$value = static::simpleXMLToArray($child, $flattenValues, $flattenAttributes, $flattenChildren, $valueKey, $attributesKey, $childrenKey);
if (isset($children[$elementName])) {
if ($first) {
$temp = $children[$elementName];
unset($children[$elementName]);
$children[$elementName][] = $temp;
$first=false;
}
$children[$elementName][] = $value;
} else {
$children[$elementName] = $value;
}
}
if (count($children) > 0) {
if (!$flattenChildren) {
$return[$childrenKey] = $children;
} else {
$return = array_merge($return, $children);
}
}
$attributes = array();
foreach ($xml->attributes() as $name => $value) {
$attributes[$name] = trim($value);
}
if (count($attributes) > 0) {
if (!$flattenAttributes) {
$return[$attributesKey] = $attributes;
} else {
$return = array_merge($return, $attributes);
}
}
return $return;
}
}

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)
*/
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,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)
*/
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,30 @@
<?php
/*
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* 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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2016 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
function upgrade_module_4_9_0($module)
{
return $module->registerHookAndSetToTop('dashboardZoneOne');
}

View File

@@ -0,0 +1,72 @@
<?php
/**
* 2007-2020 PrestaShop.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_PS_VERSION_')) {
exit;
}
/**
* Removes files or directories.
*
* @param array $files An array of files to remove
*
* @return true|string True if everything goes fine, error details otherwise
*/
function removeAutoupgradePhpUnitFromFsDuringUpgrade(array $files)
{
$files = array_reverse($files);
foreach ($files as $file) {
if (is_dir($file)) {
$iterator = new FilesystemIterator($file, FilesystemIterator::CURRENT_AS_PATHNAME | FilesystemIterator::SKIP_DOTS);
removeAutoupgradePhpUnitFromFsDuringUpgrade(iterator_to_array($iterator));
if (!rmdir($file) && file_exists($file)) {
return 'Deletion of directory ' . $file . 'failed';
}
} elseif (!unlink($file) && file_exists($file)) {
return 'Deletion of file ' . $file . 'failed';
}
}
return true;
}
/**
* This upgrade file removes the folder vendor/phpunit, when added from a previous release installed on the shop.
*
* @return true|array
*/
function upgrade_module_4_10_1($module)
{
$path = __DIR__ . '/../vendor/phpunit';
if (file_exists($path)) {
$result = removeAutoupgradePhpUnitFromFsDuringUpgrade(array($path));
if ($result !== true) {
PrestaShopLogger::addLog('Could not delete PHPUnit from module. ' . $result, 3);
return false;
}
}
return true;
}

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 Academic Free License 3.0 (AFL-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/AFL-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/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
function upgrade_module_4_9_0($module)
{
return $module->registerHookAndSetToTop('dashboardZoneOne');
}

View File

@@ -0,0 +1,82 @@
{
"an": "an-AR",
"af": "af-ZA",
"ag": "es-AR",
"ar": "ar-SA",
"az": "az-AZ",
"bg": "bg-BG",
"bn": "bn-BD",
"bs": "bs-BA",
"br": "pt-BR",
"bz": "br-FR",
"ca": "ca-ES",
"cb": "es-CO",
"cs": "cs-CZ",
"da": "da-DK",
"de": "de-DE",
"dh": "de-CH",
"el": "el-GR",
"en": "en-US",
"eo": "eo-EO",
"es": "es-ES",
"et": "et-EE",
"eu": "eu-ES",
"fa": "fa-IR",
"fi": "fi-FI",
"tl": "tl-PH",
"fo": "fo-FO",
"fr": "fr-FR",
"ga": "ga-IE",
"gb": "en-GB",
"gl": "gl-ES",
"gu": "gu-IN",
"he": "he-IL",
"hi": "hi-IN",
"hr": "hr-HR",
"hu": "hu-HU",
"hy": "hy-AM",
"id": "id-ID",
"it": "it-IT",
"is": "is-IS",
"ja": "ja-JP",
"ka": "ka-GE",
"km": "km-KH",
"ko": "ko-KR",
"ku": "ku-IQ",
"lo": "lo-LA",
"lt": "lt-LT",
"lv": "lv-LV",
"mg": "mg-MG",
"mk": "mk-MK",
"ml": "ml-IN",
"ms": "ms-MY",
"mx": "es-MX",
"nl": "nl-NL",
"nn": "nn-NO",
"no": "no-NO",
"pl": "pl-PL",
"pe": "es-PE",
"pt": "pt-PT",
"qc": "fr-CA",
"ro": "ro-RO",
"ru": "ru-RU",
"sh": "si-LK",
"si": "sl-SI",
"sk": "sk-SK",
"sq": "sq-AL",
"sr": "sr-CS",
"sv": "sv-SE",
"sw": "sw-KE",
"ta": "ta-IN",
"te": "te-IN",
"th": "th-TH",
"tr": "tr-TR",
"tw": "zh-TW",
"ug": "ug-CN",
"uk": "uk-UA",
"ur": "ur-PK",
"uz": "uz-UZ",
"ve": "es-VE",
"vn": "vi-VN",
"zh": "zh-CN"
}

View File

@@ -0,0 +1,48 @@
<?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_accounting_tab()
{
include_once __DIR__.'/add_new_tab.php';
$id_parent = add_new_tab(
'AdminAccounting',
'en:Accounting|fr:Comptabilité|es:Accounting|de:Accounting|it:Accounting',
0,
true
);
add_new_tab(
'AdminAccountingManagement',
'en:Account Number Management|fr:Gestion des numéros de comptes|es:Account Number Management|de:Account Number Management|it:Account Number Management',
$id_parent
);
add_new_tab(
'AdminAccountingExport',
'en:Export|fr:Export|es:Export|de:Export|it:Export',
$id_parent
);
}

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)
*/
function add_attribute_position()
{
$groups = Db::getInstance()->executeS('
SELECT DISTINCT `id_attribute_group`
FROM `'._DB_PREFIX_.'attribute`');
if (is_array($groups) && count($groups)) {
foreach ($groups as $group) {
$attributes = Db::getInstance()->executeS('
SELECT *
FROM `'._DB_PREFIX_.'attribute`
WHERE `id_attribute_group` = '. (int)($group['id_attribute_group']));
$i = 0;
if (is_array($attributes) && count($attributes)) {
foreach ($attributes as $attribute) {
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'attribute`
SET `position` = '.$i++.'
WHERE `id_attribute` = '.(int)$attribute['id_attribute'].'
AND `id_attribute_group` = '.(int)$attribute['id_attribute_group']);
}
}
}
}
}

View File

@@ -0,0 +1,42 @@
<?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_carrier_position()
{
$carriers = Db::getInstance()->executeS('
SELECT `id_carrier`
FROM `'._DB_PREFIX_.'carrier`
WHERE `deleted` = 0');
if (is_array($carriers) && count($carriers)) {
$i = 0;
foreach ($carriers as $carrier) {
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'carrier`
SET `position` = '.$i++.'
WHERE `id_carrier` = '.(int)$carrier['id_carrier']);
}
}
}

View File

@@ -0,0 +1,41 @@
<?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_column_order_state_deleted_if_not_exists()
{
$res = true;
$column = Db::getInstance()->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.'order_state` LIKE "deleted"');
if (empty($column)) {
$res = Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'order_state`
ADD COLUMN `deleted` tinyint(1) UNSIGNED NOT NULL default "0" AFTER `paid`');
}
if (!$res) {
return array('error' => Db::getInstance()->getNumberError(), 'msg' => Db::getInstance()->getMsgError());
}
return true;
}

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_column_orders_reference_if_not_exists()
{
$column = Db::getInstance()->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.'orders` LIKE "reference"');
if (empty($column)) {
return Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'orders` ADD COLUMN `reference` varchar(10) AFTER `id_order`');
}
}

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)
*/
function add_default_restrictions_modules_groups()
{
$res = true;
// Table module_group had another use in previous versions, we need to clean it up.
$res &= Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'module_group`');
$groups = Db::getInstance()->executeS('
SELECT `id_group`
FROM `'._DB_PREFIX_.'group`');
$modules = Db::getInstance()->executeS('
SELECT m.*
FROM `'._DB_PREFIX_.'module` m');
$shops = Db::getInstance()->executeS('
SELECT `id_shop`
FROM `'._DB_PREFIX_.'shop`');
foreach ($groups as $group) {
if (!is_array($modules) || !is_array($shops)) {
return false;
} else {
$sql = 'INSERT INTO `'._DB_PREFIX_.'module_group` (`id_module`, `id_shop`, `id_group`) VALUES ';
foreach ($modules as $mod) {
foreach ($shops as $s) {
$sql .= '("'.(int)$mod['id_module'].'", "'.(int)$s.'", "'.(int)$group['id_group'].'"),';
}
}
// removing last comma to avoid SQL error
$sql = substr($sql, 0, strlen($sql) - 1);
$res &= Db::getInstance()->execute($sql);
}
}
return $res;
}

View File

@@ -0,0 +1,41 @@
<?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_feature_position()
{
$features = Db::getInstance()->executeS('
SELECT `id_feature`
FROM `'._DB_PREFIX_.'feature`');
$i = 0;
if (is_array($features) && count($features)) {
foreach ($features as $feature) {
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'feature`
SET `position` = '.$i++.'
WHERE `id_feature` = '.(int)$feature['id_feature']);
}
}
}

View File

@@ -0,0 +1,41 @@
<?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_group_attribute_position()
{
$groups = Db::getInstance()->executeS('
SELECT *
FROM `'._DB_PREFIX_.'attribute_group`');
$i = 0;
if (is_array($groups) && count($groups)) {
foreach ($groups as $group) {
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'attribute_group`
SET `position` = '.$i++.'
WHERE `id_attribute_group` = '.(int)$group['id_attribute_group']);
}
}
}

View File

@@ -0,0 +1,41 @@
<?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_id_shop_to_shipper_lang_index()
{
$res = true;
$key_exists = Db::getInstance()->executeS('
SHOW INDEX
FROM `'._DB_PREFIX_.'carrier_lang`
WHERE Key_name = "shipper_lang_index"');
if ($key_exists) {
$res &= Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'carrier_lang` DROP KEY `shipper_lang_index`');
}
$res &= Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'carrier_lang` ADD PRIMARY KEY (`id_carrier`, `id_shop`, `id_lang`)');
return $res;
}

View File

@@ -0,0 +1,58 @@
<?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_missing_columns_customer()
{
$db = Db::getInstance();
$res = true;
$current_fields = $db->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.'customer`');
foreach ($current_fields as $k => $field) {
$current_fields[$k] = $field['Field'];
}
$missing_fields = array(
'id_risk' => 'ALTER TABLE `'._DB_PREFIX_.'customer`
ADD `id_risk` int(10) unsigned NOT NULL DEFAULT "1"',
'company' => 'ALTER TABLE `'._DB_PREFIX_.'customer` ADD `company` varchar(64)',
'siret' => 'ALTER TABLE `'._DB_PREFIX_.'customer` ADD `siret` varchar(14)',
'ape' => 'ALTER TABLE `'._DB_PREFIX_.'customer` ADD `ape` varchar(5)',
'website' => 'ALTER TABLE `'._DB_PREFIX_.'customer` ADD `website` varchar(128)',
'outstanding_allow_amount' => 'ALTER TABLE `'._DB_PREFIX_.'customer`
ADD `outstanding_allow_amount` DECIMAL( 10,6 ) NOT NULL default "0.00"',
'show_public_prices' => 'ALTER TABLE `'._DB_PREFIX_.'customer`
ADD `show_public_prices` tinyint(1) unsigned NOT NULL default "0"',
'max_payment_days' => 'ALTER TABLE `'._DB_PREFIX_.'customer`
ADD `max_payment_days` int(10) unsigned NOT NULL default "60"',
);
foreach ($missing_fields as $field => $query) {
if (!in_array($field, $current_fields)) {
$res &= $db->execute($query);
}
}
return $res;
}

View File

@@ -0,0 +1,43 @@
<?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_missing_image_key()
{
$res = true;
$key_exists = Db::getInstance()->executeS('SHOW INDEX
FROM `'._DB_PREFIX_.'image`
WHERE Key_name = \'idx_product_image\'');
if ($key_exists) {
$res &= Db::getInstance()->execute('ALTER TABLE
`'._DB_PREFIX_.'image`
DROP KEY `idx_product_image`');
}
$res &= Db::getInstance()->execute('ALTER TABLE
`'._DB_PREFIX_.'image`
ADD UNIQUE `idx_product_image` (`id_image`, `id_product`, `cover`)');
return $res;
}

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)
*/
function add_missing_rewrite_value()
{
$pages = Db::getInstance()->executeS('
SELECT *
FROM `'._DB_PREFIX_.'meta` m
LEFT JOIN `'._DB_PREFIX_.'meta_lang` ml ON (m.`id_meta` = ml.`id_meta`)
WHERE ml.`url_rewrite` = \'\'
AND m.`page` != "index"
');
if (is_array($pages) && count($pages)) {
foreach ($pages as $page) {
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'meta_lang`
SET `url_rewrite` = "'.pSQL(Tools::str2url($page['title'])).'"
WHERE `id_meta` = '.(int)$page['id_meta'].'
AND `id_lang` = '.(int)$page['id_lang']);
}
}
}

View File

@@ -0,0 +1,49 @@
<?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_missing_shop_column_pagenotfound()
{
$res = true;
$exists = Db::getInstance()->executeS('SHOW TABLES LIKE "'._DB_PREFIX_.'pagenotfound"');
if (count($exists)) {
$fields = Db::getInstance()->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.'pagenotfound`');
foreach ($fields as $k => $field) {
$fields[$k] = $field['Field'];
}
if (!in_array('id_shop_group', $fields)) {
$res &= Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'pagenotfound`
ADD `id_shop_group` INT(10) AFTER `id_pagenotfound`');
}
if (!in_array('id_shop', $fields)) {
$res &= Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'pagenotfound`
ADD `id_shop` INT(10) AFTER `id_pagenotfound`');
}
}
return $res;
}

View File

@@ -0,0 +1,64 @@
<?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_module_to_hook($module_name, $hook_name)
{
$res = true;
$id_module = Db::getInstance()->getValue(
'
SELECT `id_module` FROM `'._DB_PREFIX_.'module`
WHERE `name` = "'.$module_name.'"'
);
if ((int)$id_module > 0) {
$id_hook = Db::getInstance()->getValue('SELECT `id_hook` FROM `'._DB_PREFIX_.'hook` WHERE `name` = "'.$hook_name.'"');
if (!$id_hook) {
if (!Db::getInstance()->execute('
INSERT IGNORE INTO `'._DB_PREFIX_.'hook` (`name`, `title`)
VALUES ("'.pSQL($hook_name).'", "'.pSQL($hook_name).'")')) {
$res = false;
} else {
$id_hook = Db::getInstance()->Insert_ID();
}
}
if ((int)$id_hook > 0) {
if (!Db::getInstance()->execute('
INSERT IGNORE INTO `'._DB_PREFIX_.'hook_module` (`id_module`, `id_hook`, `position`)
VALUES (
'.(int)$id_module.',
'.(int)$id_hook.',
(SELECT IFNULL(
(SELECT max_position from (SELECT MAX(position)+1 as max_position FROM `'._DB_PREFIX_.'hook_module` WHERE `id_hook` = '.(int)$id_hook.') AS max_position), 1))
)')) {
$res = false;
}
}
}
return $res;
}

View File

@@ -0,0 +1,60 @@
<?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_groups($french, $standard)
{
$res = Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'group` (`id_group`, `date_add`, `date_upd`) VALUES (NULL, NOW(), NOW())');
$last_id = Db::getInstance()->Insert_ID();
$languages = Db::getInstance()->executeS('SELECT id_lang, iso_code FROM `'._DB_PREFIX_.'lang`');
$sql = '';
foreach ($languages as $lang) {
if (strtolower($lang['iso_code']) == 'fr') {
$sql .= '('.(int)$last_id.', '.(int)$lang['id_lang'].', "'.pSQL($french).'"),';
} else {
$sql .= '('.(int)$last_id.', '.(int)$lang['id_lang'].', "'.pSQL($standard).'"),';
}
}
$sql = substr($sql, 0, strlen($sql) - 1);
$res &= Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'group_lang` (`id_group`, `id_lang`, `name`) VALUES '.$sql);
// we add the different id_group in the configuration
if (strtolower($standard) == 'visitor') {
$res &= Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'configuration` (`id_configuration`, `name`, `value`, `date_add`, `date_upd`) VALUES (NULL, "PS_UNIDENTIFIED_GROUP", "'.(int)$last_id.'", NOW(), NOW())');
} elseif (strtolower($standard) == 'guest') {
$res &= Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'configuration` (`id_configuration`, `name`, `value`, `date_add`, `date_upd`) VALUES (NULL, "PS_GUEST_GROUP", "'.(int)$last_id.'", NOW(), NOW())');
} elseif (strtolower($standard) == 'test') {
$res &= Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'configuration` (`id_configuration`, `name`, `value`, `date_add`, `date_upd`) VALUES (NULL, "PS_TEST", "'.(int)$last_id.'", NOW(), NOW())');
}
// Add shop association
$res &= Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'group_shop` (`id_group`, `id_shop`) (SELECT '.(int)$last_id.', `value` FROM `'._DB_PREFIX_.'configuration` WHERE `name` = \'PS_SHOP_DEFAULT\')');
// Copy categories associations from the group of id 1 (default group for both visitors and customers in version 1.4) to the new group
$res &= Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'category_group` (`id_category`, `id_group`) (SELECT `id_category`, '.(int)$last_id.' FROM `'._DB_PREFIX_.'category_group` WHERE `id_group` = 1)');
return $res;
}

View File

@@ -0,0 +1,149 @@
<?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',
array(),
'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 = array(
array(
'name' => 'Customer Order',
'sign' => 1,
'conf' => 'PS_STOCK_CUSTOMER_ORDER_CANCEL_REASON',
),
array(
'name' => 'Product Return',
'sign' => 1,
'conf' => 'PS_STOCK_CUSTOMER_RETURN_REASON',
),
array(
'name' => 'Employee Edition',
'sign' => 1,
'conf' => 'PS_STOCK_MVT_INC_EMPLOYEE_EDITION',
),
array(
'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'],
array(),
'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,157 @@
<?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 = 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 prior 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($className, $name, $id_parent, $returnId = false, $parentTab = null, $module = '')
{
register_tab($className, $name, $id_parent, $returnId, $parentTab, $module);
Db::getInstance()->execute('INSERT IGNORE INTO `'._DB_PREFIX_.'access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `delete`)
(SELECT `id_profile`, (
SELECT `id_tab`
FROM `'._DB_PREFIX_.'tab`
WHERE `class_name` = \''.pSQL($className).'\' LIMIT 0,1
), 1, 1, 1, 1 FROM `'._DB_PREFIX_.'profile` )');
return get_new_tab_id($className, $returnId);
}
/**
* 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 (array(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,95 @@
<?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_order_reference_in_order_payment()
{
$res = true;
$payments = Db::getInstance()->query('
SELECT op.id_order_payment, o.reference
FROM `'._DB_PREFIX_.'order_payment` op
INNER JOIN `'._DB_PREFIX_.'orders` o
ON o.id_order = op.id_order');
if (!is_resource($payments) || !$payments) {
return true;
}
$errors = array();
// Populate "order_reference"
while ($payment = Db::getInstance()->nextRow($payments)) {
if (isset($payment['id_order_payment']) && $payment['id_order_payment']) {
$res = Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'order_payment`
SET order_reference = \''.pSQL($payment['reference']).'\'
WHERE id_order_payment = '.(int)$payment['id_order_payment']);
if (!$res) {
$errors[] = Db::getInstance()->getMsgError();
}
}
}
if (count($errors)) {
return array('error' => true, 'msg' => implode('<br/>', $errors));
}
// Get lines to merge (with multishipping on, durring the payment one line was added by order, only one is necessary by cart)
$duplicate_lines = Db::getInstance()->query('
SELECT GROUP_CONCAT(id_order_payment) as id_order_payments
FROM `'._DB_PREFIX_.'order_payment`
GROUP BY order_reference, date_add
HAVING COUNT(*) > 1');
if (!is_resource($duplicate_lines) || !$duplicate_lines) {
return true;
}
$order_payments_to_remove = array();
while ($order_payments = Db::getInstance()->nextRow($duplicate_lines)) {
$order_payments_array = array();
if (isset($order_payments['id_order_payments'])) {
$order_payments_array = explode(',', $order_payments['id_order_payments']);
}
// Remove the first item (we want to keep one line)
$id_order_payment_keep = array_shift($order_payments_array);
$res = Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'order_invoice_payment`
SET id_order_payement = '.(int)$id_order_payment_keep.'
WHERE id_order_payment IN ('.implode(',', $order_payments_array).')');
$order_payments_to_remove = array_merge($order_payments_to_remove, $order_payments_array);
}
// Remove the duplicate lines (because of the multishipping)
if (count($order_payments_to_remove)) {
$res = Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'order_payment` WHERE id_order_payment IN ('.implode(',', $order_payments_to_remove).')');
}
if (!$res) {
return array('errors' => true, 'msg' => Db::getInstance()->getMsgError());
}
return true;
}

View File

@@ -0,0 +1,72 @@
<?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_order_state($conf_name, $name, $invoice, $send_email, $color, $unremovable, $logable, $delivery, $template = null)
{
$res = true;
$name_lang = array();
$template_lang = array();
foreach (explode('|', $name) as $item) {
$temp = explode(':', $item);
$name_lang[$temp[0]] = $temp[1];
}
if ($template) {
foreach (explode('|', $template) as $item) {
$temp = explode(':', $item);
$template_lang[$temp[0]] = $temp[1];
}
}
$res &= Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'order_state` (`invoice`, `send_email`, `color`, `unremovable`, `logable`, `delivery`)
VALUES ('.(int)$invoice.', '.(int)$send_email.', "'.$color.'", '.(int)$unremovable.', '.(int)$logable.', '.(int)$delivery.')');
$id_order_state = Db::getInstance()->getValue('
SELECT MAX(`id_order_state`)
FROM `'._DB_PREFIX_.'order_state`');
$languages = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'lang`');
foreach ($languages as $lang) {
$iso_code = $lang['iso_code'];
$iso_code_name = isset($name_lang[$iso_code])?$iso_code:'en';
$iso_code_template = isset($template_lang[$iso_code])?$iso_code:'en';
$name = isset($name_lang[$iso_code]) ? $name_lang[$iso_code] : $name_lang['en'];
$template = isset($template_lang[$iso_code]) ? $template_lang[$iso_code] : '';
$res &= Db::getInstance()->execute('
INSERT IGNORE INTO `'._DB_PREFIX_.'order_state_lang` (`id_lang`, `id_order_state`, `name`, `template`)
VALUES ('.(int)$lang['id_lang'].', '.(int)$id_order_state.', "'. $name .'", "'. $template .'")
');
}
$exist = Db::getInstance()->getValue('SELECT `id_configuration` FROM `'._DB_PREFIX_.'configuration` WHERE `name` = \''.pSQL($conf_name).'\'');
if ($exist) {
$res &= Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'configuration` SET value = "'.(int)$id_order_state.'" WHERE `name` LIKE \''.pSQL($conf_name).'\'');
} else {
$res &= Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'configuration` (name, value) VALUES ("'.pSQL($conf_name).'", "'.(int)$id_order_state.'"');
}
}

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 add_quick_access_tab()
{
include_once __DIR__.'/add_new_tab.php';
add_new_tab_17(
'AdminQuickAccesses',
'en:Quick access|fr:Accès rapide|es:Quick access|de:Quick access|it:Quick access',
-1
);
}

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)
*/
define('_CONTAINS_REQUIRED_FIELD_', 2);
function add_required_customization_field_flag()
{
if (($result = Db::getInstance()->executeS('SELECT `id_product` FROM `'._DB_PREFIX_.'customization_field` WHERE `required` = 1')) === false) {
return false;
}
if (Db::getInstance()->numRows()) {
$productIds = array();
foreach ($result as $row) {
$productIds[] = (int)($row['id_product']);
}
if (!Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'product` SET `customizable` = '._CONTAINS_REQUIRED_FIELD_.' WHERE `id_product` IN ('.implode(', ', $productIds).')')) {
return false;
}
}
return true;
}

View File

@@ -0,0 +1,87 @@
<?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)
*/
require_once __DIR__.'/add_new_tab.php';
function add_stock_tab()
{
// Patch for the 1.0.1 sql update
Db::getInstance()->query('
DELETE
FROM `'._DB_PREFIX_.'tab`
WHERE id_parent = 1
AND class_name = "AdminStocks"');
// Create new tabs
$id_parent = add_new_tab(
'AdminStock',
'en:Stock|fr:Stock|es:Stock|de:Stock|it:Stock',
0,
true
);
add_new_tab(
'AdminWarehouses',
'en:Warehouses|fr:Entrepôts|es:Warehouses|de:Warehouses|it:Warehouses',
$id_parent
);
add_new_tab(
'AdminStockManagement',
'en:Stock Management|fr:Gestion du stock|es:Stock Management|de:Stock Management|it:Stock Management',
$id_parent
);
add_new_tab(
'AdminStockMvt',
'en:Stock Movement|fr:Mouvements de Stock|es:Stock Movement|de:Stock Movement|it:Stock Movement',
$id_parent
);
add_new_tab(
'AdminStockInstantState',
'en:Stock instant state|fr:Etat instantané du stock|es:Stock instant state|de:Stock instant state|it:Stock instant state',
$id_parent
);
add_new_tab(
'AdminStockCover',
'en:Stock cover|fr:Couverture du stock|es:Stock cover|de:Stock cover|it:Stock cover',
$id_parent
);
add_new_tab(
'AdminSupplyOrders',
'en:Supply orders|fr:Commandes fournisseurs|es:Supply orders|de:Supply orders|it:Supply orders',
$id_parent
);
add_new_tab(
'AdminStockConfiguration',
'en:Configuration|fr:Configuration|es:Configuration|de:Configuration|it:Configuration',
$id_parent
);
}

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 = array(
'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,62 @@
<?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_unknown_gender()
{
$res = true;
// creates the new gender
$id_type = 2;
$res &= Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'gender` (`type`)
VALUES ('.(int)$id_type.')');
// retrieves its id
$id_gender = Db::getInstance()->Insert_ID();
// inserts lang values
$languages = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'lang`');
$lang_names = array(
'en' => 'Unknown',
'de' => 'Unbekannte',
'es' => 'Desconocido',
'fr' => 'Inconnu',
'it' => 'Sconosciuto',
);
foreach ($languages as $lang) {
$name = (isset($lang_names[$lang['iso_code']]) ? $lang_names[$lang['iso_code']] : 'Unknown');
$res &= Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'gender_lang` (`id_gender`, `id_lang`, `name`) VALUES
('.(int)$id_gender.', '.(int)$lang['id_lang'].', \''.pSQL($name).'\')');
}
// for all clients where id gender is 0, sets the new id gender
$res &= Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'customers`
SET `id_gender` = '.(int)$id_gender.'
WHERE `id_gender` = 0');
}

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 alter_blocklink()
{
// No one will know if the table does not exist :] Thanks Damien for your solution ;)
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'blocklink_lang` CHANGE `id_link` `id_blocklink` INT( 10 ) UNSIGNED NOT NULL');
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'blocklink` CHANGE `id_link` `id_blocklink` INT( 10 ) UNSIGNED NOT NULL');
}

View File

@@ -0,0 +1,37 @@
<?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 alter_cms_block()
{
// No one will know if the table does not exist :] Thanks Damien for your solution ;)
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'cms_block_lang` CHANGE `id_block_cms` `id_cms_block` INT( 10 ) UNSIGNED NOT NULL');
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'cms_block` CHANGE `id_block_cms` `id_cms_block` INT( 10 ) UNSIGNED NOT NULL');
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'cms_block_page` CHANGE `id_block_cms` `id_cms_block` INT( 10 ) UNSIGNED NOT NULL');
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'cms_block_page` CHANGE `id_block_cms_page` `id_cms_block_page` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT');
}

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 alter_ignore_drop_key($table, $key)
{
$indexes = Db::getInstance()->executeS('
SHOW INDEX FROM `'._DB_PREFIX_.pSQL($table).'` WHERE Key_name = \''.pSQL($key).'\'
');
if (count($indexes) > 0) {
Db::getInstance()->execute('
ALTER TABLE `'._DB_PREFIX_.pSQL($table).'` DROP KEY `'.pSQL($key).'`
');
}
}

View File

@@ -0,0 +1,39 @@
<?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 alter_productcomments_guest_index()
{
$id_productcomments = Db::getInstance()->getValue('SELECT id_module
FROM `'._DB_PREFIX_.'module` WHERE name = "productcomments"');
if (!$id_productcomments) {
return;
}
Db::getInstance()->execute('
ALTER TABLE `'._DB_PREFIX_.'product_comment`
DROP INDEX `id_guest`, ADD INDEX `id_guest` (`id_guest`);');
}

View File

@@ -0,0 +1,49 @@
<?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 attribute_group_clean_combinations()
{
$attributeCombinations = Db::getInstance()->executeS('SELECT
pac.`id_attribute`, pa.`id_product_attribute`
FROM `'._DB_PREFIX_.'product_attribute` pa
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
ON (pa.`id_product_attribute` = pac.`id_product_attribute`)');
$toRemove = array();
foreach ($attributeCombinations as $attributeCombination) {
if ((int)($attributeCombination['id_attribute']) == 0) {
$toRemove[] = (int)($attributeCombination['id_product_attribute']);
}
}
if (!empty($toRemove)) {
$res = Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'product_attribute`
WHERE `id_product_attribute` IN ('.implode(', ', $toRemove).')');
return $res;
}
return true;
}

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 block_category_1521()
{
if (!Db::getInstance()->getValue('SELECT value FROM `'._DB_PREFIX_.'configuration` WHERE `name` = \'BLOCK_CATEG_MAX_DEPTH\' ')) {
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'configuration`
(`id_configuration` ,`id_shop_group` ,`id_shop` ,`name` ,`value` ,`date_add` ,`date_upd`)
VALUES (NULL, NULL, NULL, \'BLOCK_CATEG_MAX_DEPTH\', 4, NOW(), NOW())');
} elseif ($maxdepth = (int)Db::getInstance()->getValue('SELECT value FROM `'._DB_PREFIX_.'configuration` WHERE `value` IS NOT NULL AND `value` <> 0 AND `name` = \'BLOCK_CATEG_MAX_DEPTH\'')) {
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'configuration` SET `value` = '.($maxdepth + 1).' WHERE `name` = \'BLOCK_CATEG_MAX_DEPTH\'');
}
}

View File

@@ -0,0 +1,31 @@
<?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 blocknewsletter()
{
// No one will know if the table does not exist :]
Db::getInstance()->execute('ALTER TABLE '._DB_PREFIX_.'newsletter ADD `http_referer` VARCHAR(255) NULL');
}

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 blocknewsletter1530()
{
include_once __DIR__.'/generic_add_missing_column.php';
$column_to_add = array(
'id_shop' => 'INTEGER UNSIGNED NOT NULL DEFAULT \'1\' after `id`',
'id_shop_group' => 'INTEGER UNSIGNED NOT NULL DEFAULT \'1\' after `id_shop`',
'active' => 'TINYINT(1) NOT NULL DEFAULT \'0\' after http_referer',
);
return generic_add_missing_column('newsletter', $column_to_add);
}

View File

@@ -0,0 +1,43 @@
<?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 category_product_index_unique()
{
$res = true;
$key_exists = Db::getInstance()->executeS('SHOW INDEX
FROM `'._DB_PREFIX_.'category_product`
WHERE Key_name = "category_product_index"');
if ($key_exists) {
$res &= Db::getInstance()->execute('ALTER TABLE
`'._DB_PREFIX_.'category_product`
DROP INDEX `category_product_index`');
}
$res &= Db::getInstance()->execute('ALTER TABLE
`'._DB_PREFIX_.'category_product`
ADD UNIQUE `category_product_index` (`id_category`, `id_product`)');
return $res;
}

View File

@@ -0,0 +1,42 @@
<?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)
*/
/**
* Check if all needed columns in webservice_account table exists.
* These columns are used for the WebserviceRequest overriding.
*
* @return void
*/
function check_webservice_account_table()
{
$sql = 'SHOW COLUMNS FROM '._DB_PREFIX_.'webservice_account';
$return = Db::getInstance()->executeS($sql);
if (count($return) < 7) {
$sql = 'ALTER TABLE `'._DB_PREFIX_.'webservice_account` ADD `is_module` TINYINT( 2 ) NOT NULL DEFAULT \'0\' AFTER `class_name` ,
ADD `module_name` VARCHAR( 50 ) NULL DEFAULT NULL AFTER `is_module`';
Db::getInstance()->executeS($sql);
}
}

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)
*/
/* Remove duplicate entries from ps_category_product */
function clean_category_product()
{
$list = Db::getInstance()->executeS('
SELECT id_category, id_product, COUNT(*) n
FROM '._DB_PREFIX_.'category_product
GROUP BY CONCAT(id_category,\'|\',id_product)
HAVING n > 1');
$result = true;
if ($list) {
foreach ($list as $l) {
$result &= Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'category_product
WHERE id_product = '.(int)$l['id_product'].' AND id_category = '.(int)$l['id_category'].' LIMIT '.(int)($l['n'] - 1));
}
}
return $result;
}

View File

@@ -0,0 +1,384 @@
<?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 clean_tabs_15()
{
include_once __DIR__.'/migrate_tabs_15.php';
$clean_tabs_15 = array(
9 => array(
'class_name' => 'AdminCatalog',
'position' => 0,
'active' => 1,
'children' => array(
21 => array('class_name' => 'AdminProducts', 'position' => 0, 'active' => 1,
),
22 => array('class_name' => 'AdminCategories', 'position' => 1, 'active' => 1,
),
23 => array('class_name' => 'AdminTracking', 'position' => 2, 'active' => 1,
),
24 => array('class_name' => 'AdminAttributesGroups', 'position' => 3, 'active' => 1,
),
25 => array('class_name' => 'AdminFeatures', 'position' => 4, 'active' => 1,
),
26 => array('class_name' => 'AdminManufacturers', 'position' => 5, 'active' => 1,
),
27 => array('class_name' => 'AdminSuppliers', 'position' => 6, 'active' => 1,
),
28 => array('class_name' => 'AdminScenes', 'position' => 7, 'active' => 1,
),
29 => array('class_name' => 'AdminTags', 'position' => 8, 'active' => 1,
),
30 => array('class_name' => 'AdminAttachments', 'position' => 9, 'active' => 1,
),
),
),
10 => array(
'class_name' => 'AdminParentOrders',
'position' => 1,
'active' => 1,
'children' => array(
31 => array('class_name' => 'AdminOrders', 'position' => 0, 'active' => 1,
),
32 => array('class_name' => 'AdminInvoices', 'position' => 1, 'active' => 1,
),
33 => array('class_name' => 'AdminReturn', 'position' => 2, 'active' => 1,
),
34 => array('class_name' => 'AdminDeliverySlip', 'position' => 3, 'active' => 1,
),
35 => array('class_name' => 'AdminSlip', 'position' => 4, 'active' => 1,
),
36 => array('class_name' => 'AdminStatuses', 'position' => 5, 'active' => 1,
),
37 => array('class_name' => 'AdminOrderMessage', 'position' => 6, 'active' => 1,
),
),
),
11 => array(
'class_name' => 'AdminParentCustomer',
'position' => 2,
'active' => 1,
'children' => array(
38 => array('class_name' => 'AdminCustomers', 'position' => 0, 'active' => 1,
),
39 => array('class_name' => 'AdminAddresses', 'position' => 1, 'active' => 1,
),
40 => array('class_name' => 'AdminGroups', 'position' => 2, 'active' => 1,
),
41 => array('class_name' => 'AdminCarts', 'position' => 3, 'active' => 1,
),
42 => array('class_name' => 'AdminCustomerThreads', 'position' => 4, 'active' => 1,
),
43 => array('class_name' => 'AdminContacts', 'position' => 5, 'active' => 1,
),
44 => array('class_name' => 'AdminGenders', 'position' => 6, 'active' => 1,
),
45 => array('class_name' => 'AdminOutstanding', 'position' => 7, 'active' => 0,
),
),
),
12 => array(
'class_name' => 'AdminPriceRule',
'position' => 3,
'active' => 1,
'children' => array(
46 => array('class_name' => 'AdminCartRules', 'position' => 0, 'active' => 1,
),
47 => array('class_name' => 'AdminSpecificPriceRule', 'position' => 1, 'active' => 1,
),
),
),
13 => array(
'class_name' => 'AdminParentShipping',
'position' => 4,
'active' => 1,
'children' => array(
48 => array('class_name' => 'AdminShipping', 'position' => 0, 'active' => 1,
),
49 => array('class_name' => 'AdminCarriers', 'position' => 1, 'active' => 1,
),
50 => array('class_name' => 'AdminRangePrice', 'position' => 2, 'active' => 1,
),
51 => array('class_name' => 'AdminRangeWeight', 'position' => 3, 'active' => 1,
),
),
),
14 => array(
'class_name' => 'AdminParentLocalization',
'position' => 5,
'active' => 1,
'children' => array(
52 => array('class_name' => 'AdminLocalization', 'position' => 0, 'active' => 1,
),
53 => array('class_name' => 'AdminLanguages', 'position' => 1, 'active' => 1,
),
54 => array('class_name' => 'AdminZones', 'position' => 2, 'active' => 1,
),
55 => array('class_name' => 'AdminCountries', 'position' => 3, 'active' => 1,
),
56 => array('class_name' => 'AdminStates', 'position' => 4, 'active' => 1,
),
57 => array('class_name' => 'AdminCurrencies', 'position' => 5, 'active' => 1,
),
58 => array('class_name' => 'AdminTaxes', 'position' => 6, 'active' => 1,
),
59 => array('class_name' => 'AdminTaxRulesGroup', 'position' => 7, 'active' => 1,
),
60 => array('class_name' => 'AdminTranslations', 'position' => 8, 'active' => 1,
),
),
),
15 => array(
'class_name' => 'AdminParentModules',
'position' => 6,
'active' => 1,
'children' => array(
61 => array('class_name' => 'AdminModules', 'position' => 0, 'active' => 1,
),
62 => array('class_name' => 'AdminAddonsCatalog', 'position' => 1, 'active' => 1,
),
63 => array('class_name' => 'AdminModulesPositions', 'position' => 2, 'active' => 1,
),
64 => array('class_name' => 'AdminPayment', 'position' => 3, 'active' => 1,
),
),
),
16 => array(
'class_name' => 'AdminParentPreferences',
'position' => 7,
'active' => 1,
'children' => array(
65 => array('class_name' => 'AdminPreferences', 'position' => 0, 'active' => 1,
),
66 => array('class_name' => 'AdminOrderPreferences', 'position' => 1, 'active' => 1,
),
67 => array('class_name' => 'AdminPPreferences', 'position' => 2, 'active' => 1,
),
68 => array('class_name' => 'AdminCustomerPreferences', 'position' => 3, 'active' => 1,
),
69 => array('class_name' => 'AdminThemes', 'position' => 4, 'active' => 1,
),
70 => array('class_name' => 'AdminMeta', 'position' => 5, 'active' => 1,
),
71 => array('class_name' => 'AdminCmsContent', 'position' => 6, 'active' => 1,
),
72 => array('class_name' => 'AdminImages', 'position' => 7, 'active' => 1,
),
73 => array('class_name' => 'AdminStores', 'position' => 8, 'active' => 1,
),
74 => array('class_name' => 'AdminSearchConf', 'position' => 9, 'active' => 1,
),
75 => array('class_name' => 'AdminMaintenance', 'position' => 10, 'active' => 1,
),
76 => array('class_name' => 'AdminGeolocation', 'position' => 11, 'active' => 1,
),
),
),
17 => array(
'class_name' => 'AdminTools',
'position' => 8,
'active' => 1,
'children' => array(
77 => array('class_name' => 'AdminInformation', 'position' => 0, 'active' => 1,
),
78 => array('class_name' => 'AdminPerformance', 'position' => 1, 'active' => 1,
),
79 => array('class_name' => 'AdminEmails', 'position' => 2, 'active' => 1,
),
80 => array('class_name' => 'AdminShopGroup', 'position' => 3, 'active' => 0,
),
81 => array('class_name' => 'AdminImport', 'position' => 4, 'active' => 1,
),
82 => array('class_name' => 'AdminBackup', 'position' => 5, 'active' => 1,
),
83 => array('class_name' => 'AdminRequestSql', 'position' => 6, 'active' => 1,
),
84 => array('class_name' => 'AdminLogs', 'position' => 7, 'active' => 1,
),
85 => array('class_name' => 'AdminWebservice', 'position' => 8, 'active' => 1,
),
),
),
18 => array(
'class_name' => 'AdminAdmin',
'position' => 9,
'active' => 1,
'children' => array(
86 => array('class_name' => 'AdminAdminPreferences', 'position' => 0, 'active' => 1,
),
87 => array('class_name' => 'AdminQuickAccesses', 'position' => 1, 'active' => 1,
),
88 => array('class_name' => 'AdminEmployees', 'position' => 2, 'active' => 1,
),
89 => array('class_name' => 'AdminProfiles', 'position' => 3, 'active' => 1,
),
90 => array('class_name' => 'AdminAccess', 'position' => 4, 'active' => 1,
),
91 => array('class_name' => 'AdminTabs', 'position' => 5, 'active' => 1,
),
),
),
19 => array(
'class_name' => 'AdminParentStats',
'position' => 10,
'active' => 1,
'children' => array(
92 => array('class_name' => 'AdminStats', 'position' => 0, 'active' => 1,
),
93 => array('class_name' => 'AdminSearchEngines', 'position' => 1, 'active' => 1,
),
94 => array('class_name' => 'AdminReferrers', 'position' => 2, 'active' => 1,
),
),
),
20 => array(
'class_name' => 'AdminStock',
'position' => 11,
'active' => 1,
'children' => array(
95 => array('class_name' => 'AdminWarehouses', 'position' => 0, 'active' => 1,
),
96 => array('class_name' => 'AdminStockManagement', 'position' => 1, 'active' => 1,
),
97 => array('class_name' => 'AdminStockMvt', 'position' => 2, 'active' => 1,
),
98 => array('class_name' => 'AdminStockInstantState', 'position' => 3, 'active' => 1,
),
99 => array('class_name' => 'AdminStockCover', 'position' => 4, 'active' => 1,
),
100 => array('class_name' => 'AdminSupplyOrders', 'position' => 5, 'active' => 1,
),
101 => array('class_name' => 'AdminStockConfiguration', 'position' => 6, 'active' => 1,
),
),
),
);
//===== step 1 disabled all useless native tabs in 1.5 =====/
$remove_tabs = array(
2 => 'AdminAddonsMyAccount', 4 => 'AdminAliases', 5 => 'AdminAppearance', 12 => 'AdminCMSContent',
13 => 'AdminContact', 16 => 'AdminCounty', 20 => 'AdminDb', 22 => 'AdminDiscounts', 26 => 'AdminGenerator',
38 => 'AdminMessages', 45 => 'AdminPDF', 63 => 'AdminStatsConf', 67 => 'AdminSubDomains',
);
$ids = array();
foreach ($remove_tabs as $tab) {
if ($id = get_tab_id($tab)) {
$ids[] = $id;
}
}
if ($ids) {
Db::getInstance()->update('tab', array('active' => 0), 'id_tab IN ('.implode(', ', $ids).')');
}
//=====================================/
//===== step 2 move all no native tabs in AdminTools =====/
$id_admin_tools = get_tab_id('AdminTools');
$tab_to_move = get_simple_clean_tab15($clean_tabs_15);
$ids = array();
foreach ($tab_to_move as $tab) {
if ($id = get_tab_id($tab)) {
$ids[] = $id;
}
}
if ($ids) {
Db::getInstance()->update('tab', array('id_parent' => $id_admin_tools), 'id_tab NOT IN ('.implode(', ', $ids).') AND `id_parent` <> -1');
}
//=====================================/
//===== step 3 sort all 1.5 tabs =====/
updatePositionAndActive15($clean_tabs_15);
//=====================================/
//specific case for AdminStockMvt in AdminStock
$id_AdminStockMvt = get_tab_id('AdminStockMvt');
$id_AdminStock = get_tab_id('AdminStock');
Db::getInstance()->update('tab', array('id_parent' => $id_AdminStock), 'id_tab ='.$id_AdminStockMvt);
//rename some tabs
renameTab(get_tab_id('AdminCartRules'), array('fr' => 'Règles paniers', 'es' => 'Reglas de cesta', 'en' => 'Cart Rules', 'de' => 'Warenkorb Preisregein', 'it' => 'Regole Carrello'));
renameTab(get_tab_id('AdminPreferences'), array('fr' => 'Générales', 'es' => 'General', 'en' => 'General', 'de' => 'Allgemein', 'it' => 'Generale'));
renameTab(get_tab_id('AdminThemes'), array('fr' => 'Thèmes', 'es' => 'Temas', 'en' => 'Themes', 'de' => 'Themen', 'it' => 'Temi'));
renameTab(get_tab_id('AdminStores'), array('fr' => 'Coordonnées & magasins', 'es' => 'Contacto y tiendas', 'en' => 'Store Contacts', 'de' => 'Shopadressen', 'it' => 'Contatti e Negozi'));
renameTab(get_tab_id('AdminTools'), array('fr' => 'Paramètres avancés', 'es' => 'Parametros avanzados', 'en' => 'Advanced Parameters', 'de' => 'Erweiterte Parameter', 'it' => 'Parametri Avanzati'));
renameTab(get_tab_id('AdminTools'), array('fr' => 'Paramètres avancés', 'es' => 'Parametros avanzados', 'en' => 'Advanced Parameters', 'de' => 'Erweiterte Parameter', 'it' => 'Parametri Avanzati'));
renameTab(get_tab_id('AdminTabs'), array('fr' => 'Menus', 'es' => 'Pestañas', 'en' => 'Menus', 'de' => 'Tabs', 'it' => 'Tabs'));
}
//==== functions =====/
function get_simple_clean_tab15($clean_tabs_15)
{
$light_tab = array();
foreach ($clean_tabs_15 as $tab) {
$light_tab[] = $tab['class_name'];
if (isset($tab['children'])) {
$light_tab = array_merge($light_tab, get_simple_clean_tab15($tab['children']));
}
}
return $light_tab;
}
function updatePositionAndActive15($clean_tabs_15)
{
foreach ($clean_tabs_15 as $id => $tab) {
Db::getInstance()->update('tab', array('position' => $tab['position'], 'active' => $tab['active']), '`id_tab`= '.get_tab_id($tab['class_name']));
if (isset($tab['children'])) {
updatePositionAndActive15($tab['children']);
}
}
}
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', array('name' => $names[$lang['iso_code']]), '`id_tab`= '.$id_tab.' AND `id_lang` ='.$lang['id_lang']);
}
}
}

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)
*/
function cms_block()
{
if (!Db::getInstance()->execute('SELECT `display_store` FROM `'._DB_PREFIX_.'cms_block` LIMIT 1')) {
return Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'cms_block` ADD `display_store` TINYINT NOT NULL DEFAULT \'1\'');
}
return true;
}

View File

@@ -0,0 +1,90 @@
<?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 cms_multishop()
{
$shops = Db::getInstance()->executeS('
SELECT `id_shop`
FROM `'._DB_PREFIX_.'shop`
');
$cms_lang = Db::getInstance()->executeS('
SELECT *
FROM `'._DB_PREFIX_.'cms_lang`
');
foreach ($cms_lang as $value) {
$data = array();
$cms = array(
'id_cms' => $value['id_cms'],
'id_lang' => $value['id_lang'],
'content' => pSQL($value['content'], true),
'link_rewrite' => pSQL($value['link_rewrite']),
'meta_title' => pSQL($value['meta_title']),
'meta_keywords' => pSQL($value['meta_keywords']),
'meta_description' => pSQL($value['meta_description']),
);
foreach ($shops as $shop) {
if ($shop['id_shop'] != 1) {
$cms['id_shop'] = $shop['id_shop'];
$data[] = $cms;
}
}
Db::getInstance()->insert('cms_lang', $data);
}
$cms_category_lang = Db::getInstance()->executeS('
SELECT *
FROM `'._DB_PREFIX_.'cms_category_lang`
');
foreach ($cms_category_lang as $value) {
$data = array();
$data_bis = array();
$cms_category_shop = array(
'id_cms_category' => $value['id_cms_category'],
);
$cms_category = array(
'id_cms_category' => $value['id_cms_category'],
'id_lang' => $value['id_lang'],
'name' => pSQL($value['name']),
'description' => pSQL($value['description']),
'link_rewrite' => pSQL($value['link_rewrite']),
'meta_title' => pSQL($value['meta_title']),
'meta_keywords' => pSQL($value['meta_keywords']),
'meta_description' => pSQL($value['meta_description']),
);
foreach ($shops as $shop) {
if ($shop['id_shop'] != 1) {
$cms_category['id_shop'] = $shop['id_shop'];
$data[] = $cms_category;
}
$cms_category_shop['id_shop'] = $shop['id_shop'];
$data_bis[] = $cms_category_shop;
}
Db::getInstance()->insert('cms_category_lang', $data, false, true, Db::INSERT_IGNORE);
Db::getInstance()->insert('cms_category_shop', $data_bis, false, true, Db::INSERT_IGNORE);
}
}

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)
*/
function configuration_double_cleaner()
{
$result = Db::getInstance()->executeS('
SELECT name, MIN(id_configuration) AS minid
FROM '._DB_PREFIX_.'configuration
GROUP BY name
HAVING count(name) > 1');
foreach ($result as $row) {
Db::getInstance()->execute('
DELETE FROM '._DB_PREFIX_.'configuration
WHERE name = \''.addslashes($row['name']).'\'
AND id_configuration != '.(int)($row['minid']));
}
Db::getInstance()->execute('
DELETE FROM '._DB_PREFIX_.'configuration_lang
WHERE id_configuration NOT IN (
SELECT id_configuration
FROM '._DB_PREFIX_.'configuration)');
}

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)
*/
/* Convert product prices from the PS < 1.3 wrong rounding system to the new 1.3 one */
function convert_product_price()
{
$taxes = Db::getInstance()->executeS('SELECT * FROM '._DB_PREFIX_.'tax');
$taxRates = array();
foreach ($taxes as $data) {
$taxRates[$data['id_tax']] = (float)($data['rate']) / 100;
}
$resource = Db::getInstance()->executeS('SELECT `id_product`, `price`, `id_tax`
FROM `'._DB_PREFIX_.'product`', false);
if (!$resource) {
return array('error' => 1, 'msg' => Db::getInstance()->getMsgError());
} // was previously die(mysql_error())
while ($row = Db::getInstance()->nextRow($resource)) {
if ($row['id_tax']) {
$price = $row['price'] * (1 + $taxRates[$row['id_tax']]);
$decimalPart = $price - (int)$price;
if ($decimalPart < 0.000001) {
$newPrice = (float)(number_format($price, 6, '.', ''));
$newPrice = Tools::floorf($newPrice / (1 + $taxRates[$row['id_tax']]), 6);
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'product` SET `price` = '.$newPrice.' WHERE `id_product` = '.(int)$row['id_product']);
}
}
}
}

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 (array(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,277 @@
<?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)
*/
$timezones = array(
'AD' => 'Europe/Andorra',
'AE' => 'Asia/Dubai',
'AF' => 'Asia/Kabul',
'AG' => 'America/Antigua',
'AI' => 'America/Anguilla',
'AL' => 'Europe/Tirane',
'AM' => 'Asia/Yerevan',
'AN' => 'America/Curacao',
'AO' => 'Africa/Luanda',
'AQ' => 'Antarctica/McMurdo',
'AR' => 'America/Argentina/Buenos_Aires',
'AS' => 'Pacific/Pago_Pago',
'AT' => 'Europe/Vienna',
'AU' => 'Australia/Lord_Howe',
'AW' => 'America/Aruba',
'AX' => 'Europe/Mariehamn',
'AZ' => 'Asia/Baku',
'BA' => 'Europe/Sarajevo',
'BB' => 'America/Barbados',
'BD' => 'Asia/Dhaka',
'BE' => 'Europe/Brussels',
'BF' => 'Africa/Ouagadougou',
'BG' => 'Europe/Sofia',
'BH' => 'Asia/Bahrain',
'BI' => 'Africa/Bujumbura',
'BJ' => 'Africa/Porto-Novo',
'BL' => 'America/St_Barthelemy',
'BM' => 'Atlantic/Bermuda',
'BN' => 'Asia/Brunei',
'BO' => 'America/La_Paz',
'BR' => 'America/Noronha',
'BS' => 'America/Nassau',
'BT' => 'Asia/Thimphu',
'BV' => '',
'BW' => 'Africa/Gaborone',
'BY' => 'Europe/Minsk',
'BZ' => 'America/Belize',
'CA' => 'America/Toronto',
'CC' => 'Indian/Cocos',
'CD' => 'Africa/Kinshasa',
'CF' => 'Africa/Bangui',
'CG' => 'Africa/Brazzaville',
'CH' => 'Europe/Zurich',
'CI' => 'Africa/Abidjan',
'CK' => 'Pacific/Rarotonga',
'CL' => 'America/Santiago',
'CM' => 'Africa/Douala',
'CN' => 'Asia/Shanghai',
'CO' => 'America/Bogota',
'CR' => 'America/Costa_Rica',
'CU' => 'America/Havana',
'CV' => 'Atlantic/Cape_Verde',
'CX' => 'Indian/Christmas',
'CY' => 'Asia/Nicosia',
'CZ' => 'Europe/Prague',
'DE' => 'Europe/Berlin',
'DJ' => 'Africa/Djibouti',
'DK' => 'Europe/Copenhagen',
'DM' => 'America/Dominica',
'DO' => 'America/Santo_Domingo',
'DZ' => 'Africa/Algiers',
'EC' => 'America/Guayaquil',
'EE' => 'Europe/Tallinn',
'EG' => 'Africa/Cairo',
'EH' => 'Africa/El_Aaiun',
'ER' => 'Africa/Asmara',
'ES' => 'Europe/Madrid',
'ET' => 'Africa/Addis_Ababa',
'FI' => 'Europe/Helsinki',
'FJ' => 'Pacific/Fiji',
'FK' => 'Atlantic/Stanley',
'FM' => 'Pacific/Chuuk',
'FO' => 'Atlantic/Faroe',
'FR' => 'Europe/Paris',
'GA' => 'Africa/Libreville',
'GB' => 'Europe/London',
'GD' => 'America/Grenada',
'GE' => 'Asia/Tbilisi',
'GF' => 'America/Cayenne',
'GG' => 'Europe/Guernsey',
'GH' => 'Africa/Accra',
'GI' => 'Europe/Gibraltar',
'GL' => 'America/Godthab',
'GM' => 'Africa/Banjul',
'GN' => 'Africa/Conakry',
'GP' => 'America/Guadeloupe',
'GQ' => 'Africa/Malabo',
'GR' => 'Europe/Athens',
'GS' => 'Atlantic/South_Georgia',
'GT' => 'America/Guatemala',
'GU' => 'Pacific/Guam',
'GW' => 'Africa/Bissau',
'GY' => 'America/Guyana',
'HK' => 'Asia/Hong_Kong',
'HM' => '',
'HN' => 'America/Tegucigalpa',
'HR' => 'Europe/Zagreb',
'HT' => 'America/Port-au-Prince',
'HU' => 'Europe/Budapest',
'ID' => 'Asia/Jakarta',
'IE' => 'Europe/Dublin',
'IL' => 'Asia/Jerusalem',
'IM' => 'Europe/Isle_of_Man',
'IN' => 'Asia/Kolkata',
'IO' => 'Indian/Chagos',
'IQ' => 'Asia/Baghdad',
'IR' => 'Asia/Tehran',
'IS' => 'Atlantic/Reykjavik',
'IT' => 'Europe/Rome',
'JE' => 'Europe/Jersey',
'JM' => 'America/Jamaica',
'JO' => 'Asia/Amman',
'JP' => 'Asia/Tokyo',
'KE' => 'Africa/Nairobi',
'KG' => 'Asia/Bishkek',
'KH' => 'Asia/Phnom_Penh',
'KI' => 'Pacific/Tarawa',
'KM' => 'Indian/Comoro',
'KN' => 'America/St_Kitts',
'KP' => 'Asia/Pyongyang',
'KR' => 'Asia/Seoul',
'KW' => 'Asia/Kuwait',
'KY' => 'America/Cayman',
'KZ' => 'Asia/Almaty',
'LA' => 'Asia/Vientiane',
'LB' => 'Asia/Beirut',
'LC' => 'America/St_Lucia',
'LI' => 'Europe/Vaduz',
'LK' => 'Asia/Colombo',
'LR' => 'Africa/Monrovia',
'LS' => 'Africa/Maseru',
'LT' => 'Europe/Vilnius',
'LU' => 'Europe/Luxembourg',
'LV' => 'Europe/Riga',
'LY' => 'Africa/Tripoli',
'MA' => 'Africa/Casablanca',
'MC' => 'Europe/Monaco',
'MD' => 'Europe/Chisinau',
'ME' => 'Europe/Podgorica',
'MF' => 'America/Marigot',
'MG' => 'Indian/Antananarivo',
'MH' => 'Pacific/Majuro',
'MK' => 'Europe/Skopje',
'ML' => 'Africa/Bamako',
'MM' => 'Asia/Rangoon',
'MN' => 'Asia/Ulaanbaatar',
'MO' => 'Asia/Macau',
'MP' => 'Pacific/Saipan',
'MQ' => 'America/Martinique',
'MR' => 'Africa/Nouakchott',
'MS' => 'America/Montserrat',
'MT' => 'Europe/Malta',
'MU' => 'Indian/Mauritius',
'MV' => 'Indian/Maldives',
'MW' => 'Africa/Blantyre',
'MX' => 'America/Mexico_City',
'MY' => 'Asia/Kuala_Lumpur',
'MZ' => 'Africa/Maputo',
'NA' => 'Africa/Windhoek',
'NC' => 'Pacific/Noumea',
'NE' => 'Africa/Niamey',
'NF' => 'Pacific/Norfolk',
'NG' => 'Africa/Lagos',
'NI' => 'America/Managua',
'NL' => 'Europe/Amsterdam',
'NO' => 'Europe/Oslo',
'NP' => 'Asia/Kathmandu',
'NR' => 'Pacific/Nauru',
'NU' => 'Pacific/Niue',
'NZ' => 'Pacific/Auckland',
'OM' => 'Asia/Muscat',
'PA' => 'America/Panama',
'PE' => 'America/Lima',
'PF' => 'Pacific/Tahiti',
'PG' => 'Pacific/Port_Moresby',
'PH' => 'Asia/Manila',
'PK' => 'Asia/Karachi',
'PL' => 'Europe/Warsaw',
'PM' => 'America/Miquelon',
'PN' => 'Pacific/Pitcairn',
'PR' => 'America/Puerto_Rico',
'PS' => 'Asia/Gaza',
'PT' => 'Europe/Lisbon',
'PW' => 'Pacific/Palau',
'PY' => 'America/Asuncion',
'QA' => 'Asia/Qatar',
'RE' => 'Indian/Reunion',
'RO' => 'Europe/Bucharest',
'RS' => 'Europe/Belgrade',
'RU' => 'Europe/Moscow',
'RW' => 'Africa/Kigali',
'SA' => 'Asia/Riyadh',
'SB' => 'Pacific/Guadalcanal',
'SC' => 'Indian/Mahe',
'SD' => 'Africa/Khartoum',
'SE' => 'Europe/Stockholm',
'SG' => 'Asia/Singapore',
'SI' => 'Europe/Ljubljana',
'SJ' => 'Arctic/Longyearbyen',
'SK' => 'Europe/Bratislava',
'SL' => 'Africa/Freetown',
'SM' => 'Europe/San_Marino',
'SN' => 'Africa/Dakar',
'SO' => 'Africa/Mogadishu',
'SR' => 'America/Paramaribo',
'ST' => 'Africa/Sao_Tome',
'SV' => 'America/El_Salvador',
'SY' => 'Asia/Damascus',
'SZ' => 'Africa/Mbabane',
'TC' => 'America/Grand_Turk',
'TD' => 'Africa/Ndjamena',
'TF' => 'Indian/Kerguelen',
'TG' => 'Africa/Lome',
'TH' => 'Asia/Bangkok',
'TJ' => 'Asia/Dushanbe',
'TK' => 'Pacific/Fakaofo',
'TL' => 'Asia/Dili',
'TM' => 'Asia/Ashgabat',
'TN' => 'Africa/Tunis',
'TO' => 'Pacific/Tongatapu',
'TR' => 'Europe/Istanbul',
'TT' => 'America/Port_of_Spain',
'TV' => 'Pacific/Funafuti',
'TW' => 'Asia/Taipei',
'TZ' => 'Africa/Dar_es_Salaam',
'UA' => 'Europe/Kiev',
'UG' => 'Africa/Kampala',
'US' => 'US/Eastern',
'UY' => 'America/Montevideo',
'UZ' => 'Asia/Samarkand',
'VA' => 'Europe/Vatican',
'VC' => 'America/St_Vincent',
'VE' => 'America/Caracas',
'VG' => 'America/Tortola',
'VI' => 'America/St_Thomas',
'VN' => 'Asia/Ho_Chi_Minh',
'VU' => 'Pacific/Efate',
'WF' => 'Pacific/Wallis',
'WS' => 'Pacific/Apia',
'YE' => 'Asia/Aden',
'YT' => 'Indian/Mayotte',
'ZA' => 'Africa/Johannesburg',
'ZM' => 'Africa/Lusaka',
'ZW' => 'Africa/Harare',
);
if (isset($timezones[$_GET['country']]) && $timezones[$_GET['country']]) {
die($timezones[$_GET['country']]);
}
die('');

View File

@@ -0,0 +1,95 @@
<?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)
*/
require_once __DIR__.'/add_new_tab.php';
function create_multistore()
{
$res = true;
if (!defined('_THEME_NAME_')) {
define('_THEME_NAME_', 'default');
}
// @todo : use _PS_ROOT_DIR_
if (defined('__PS_BASE_URI__')) {
$INSTALLER__PS_BASE_URI = __PS_BASE_URI__;
} else {
// note: create_multistore is called for 1.5.0.0 upgrade
// so, __PS_BASE_URI__ should be always defined in settings.inc.php
// @todo generate __PS_BASE_URI__ using $_SERVER['REQUEST_URI'], just in case
return false;
}
$all_themes_dir = _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'themes';
$themes = scandir($all_themes_dir, SCANDIR_SORT_NONE);
foreach ($themes as $theme) {
if (!is_file($all_themes_dir.DIRECTORY_SEPARATOR.$theme) && is_dir($all_themes_dir.DIRECTORY_SEPARATOR.$theme.DIRECTORY_SEPARATOR) && $theme[0] != '.' && $theme != 'prestashop' && $theme != 'default-bootstrap' && $theme != _THEME_NAME_) {
$res &= Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'theme (name) VALUES("'.Db::getInstance()->escape($theme).'")');
}
}
$res &= Db::getInstance()->execute('
UPDATE '._DB_PREFIX_.'shop
SET
name = (SELECT value FROM '._DB_PREFIX_.'configuration WHERE name = "PS_SHOP_NAME"),
id_theme = (SELECT id_theme FROM '._DB_PREFIX_.'theme WHERE name = "'.Db::getInstance()->escape(_THEME_NAME_).'")
WHERE id_shop = 1');
$shop_domain = Db::getInstance()->getValue('SELECT `value` FROM `'._DB_PREFIX_.'configuration` WHERE `name` = "PS_SHOP_DOMAIN"');
$shop_domain_ssl = Db::getInstance()->getValue('SELECT `value` FROM `'._DB_PREFIX_.'configuration` WHERE `name` = "PS_SHOP_DOMAIN_SSL"');
if (empty($shop_domain)) {
$shop_domain = $shop_domain_ssl = create_multistore_getHttpHost();
}
if (empty($shop_domain_ssl)) {
$shop_domain_ssl = create_multistore_getHttpHost();
}
$physical_uri = str_replace(' ', '%20', $INSTALLER__PS_BASE_URI);
$physical_uri = trim($physical_uri, '/\\');
$physical_uri = ($physical_uri ? '/'.$physical_uri.'/' : '/');
$res &= Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'shop_url` (`id_shop`, `domain`, `domain_ssl`, `physical_uri`, `virtual_uri`, `main`, `active`)
VALUES(1, \''.pSQL($shop_domain).'\', \''.pSQL($shop_domain_ssl).'\', \''.pSQL($physical_uri).'\', \'\', 1, 1)');
// Stock conversion
$sql = 'INSERT INTO `'._DB_PREFIX_.'stock` (`id_product`, `id_product_attribute`, `id_group_shop`, `id_shop`, `quantity`)
VALUES (SELECT p.`id_product`, 0, 1, 1, p.`quantity` FROM `'._DB_PREFIX_.'product` p);';
$res &= Db::getInstance()->execute($sql);
$sql = 'INSERT INTO `'._DB_PREFIX_.'stock` (`id_product`, `id_product_attribute`, `id_group_shop`, `id_shop`, `quantity`)
VALUES (SELECT `id_product`, `id_product_attribute`, 1, 1, `quantity` FROM `'._DB_PREFIX_.'product_attribute` p);';
$res &= Db::getInstance()->execute($sql);
// Add admin tabs
$shop_tab_id = add_new_tab('AdminShop', 'it:Shops|es:Shops|fr:Boutiques|de:Shops|en:Shops', 0, true);
add_new_tab('AdminGroupShop', 'it:Group Shops|es:Group Shops|fr:Groupes de boutique|de:Group Shops|en:Group Shops', $shop_tab_id);
add_new_tab('AdminShopUrl', 'it:Shop Urls|es:Shop Urls|fr:URLs de boutique|de:Shop Urls|en:Shop Urls', $shop_tab_id);
return $res;
}
function create_multistore_getHttpHost()
{
$host = (isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']);
return $host;
}

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 customization_field_multishop_lang()
{
$shops = Db::getInstance()->executeS('
SELECT `id_shop`
FROM `'._DB_PREFIX_.'shop`
WHERE `id_shop` != 1
');
$customization_field_lang = Db::getInstance()->executeS('
SELECT *
FROM `'._DB_PREFIX_.'customization_field_lang`
');
foreach ($customization_field_lang as $value) {
$data = array();
$customization_lang = array(
'id_customization_field' => $value['id_customization_field'],
'id_lang' => $value['id_lang'],
'name' => pSQL($value['name']),
);
foreach ($shops as $shop) {
$customization_lang['id_shop'] = $shop['id_shop'];
$data[] = $customization_lang;
}
Db::getInstance()->insert('customization_field_lang', $data);
}
}

View File

@@ -0,0 +1,98 @@
<?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()
{
$db = Db::getInstance();
$modulesDirOnDisk = array();
$modules = scandir(_PS_MODULE_DIR_, SCANDIR_SORT_NONE);
foreach ($modules as $name) {
if (!in_array($name, array('.', '..', '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)) {
die(Tools::displayError().' (Module '.$name.')');
}
$modulesDirOnDisk[] = $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 = array();
if (is_array($nativeModules)) {
foreach ($nativeModules as $nativeModulesType) {
if (in_array($nativeModulesType['type'], array('native', 'partner'))) {
$arrNativeModules[] = '""';
foreach ($nativeModulesType->module as $module) {
$arrNativeModules[] = '"'.pSQL($module['name']).'"';
}
}
}
}
$arrNonNative = array();
if ($arrNativeModules) {
$arrNonNative = $db->executeS('
SELECT *
FROM `'._DB_PREFIX_.'module` m
WHERE name NOT IN ('.implode(',', $arrNativeModules).') ');
}
$uninstallMe = array("undefined-modules");
if (is_array($arrNonNative)) {
foreach ($arrNonNative as $k => $aModule) {
$uninstallMe[(int)$aModule['id_module']] = $aModule['name'];
}
}
if (!is_array($uninstallMe)) {
$uninstallMe = array($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;
}

View File

@@ -0,0 +1,42 @@
<?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 delete_hook($hook)
{
$modules = Hook::getHookModuleExecList($hook);
if (is_array($modules)) {
foreach ($modules as $module) {
$moduleInstance = Module::getInstanceByName($module['module']);
if ($moduleInstance instanceof Module) {
Hook::unregisterHook($moduleInstance, $hook);
}
}
}
return (bool) Db::getInstance()->execute(
'DELETE FROM `' . _DB_PREFIX_ . 'hook` WHERE `name` = "' . pSQL($hook) . '"'
);
}

View File

@@ -0,0 +1,51 @@
<?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 delivery_number_set()
{
Configuration::loadConfiguration();
$number = 1;
// Update each order with a number
$result = Db::getInstance()->executeS('
SELECT id_order
FROM '._DB_PREFIX_.'orders
ORDER BY id_order');
foreach ($result as $row) {
$order = new Order((int)($row['id_order']));
$history = $order->getHistory(false);
foreach ($history as $row2) {
$oS = new OrderState((int)($row2['id_order_state']), Configuration::get('PS_LANG_DEFAULT'));
if ($oS->delivery) {
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'orders SET delivery_number = '.(int)($number++).', `delivery_date` = `date_add` WHERE id_order = '.(int)($order->id));
break ;
}
}
}
// Add configuration var
Configuration::updateValue('PS_DELIVERY_NUMBER', (int)($number));
}

View File

@@ -0,0 +1,37 @@
<?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,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 drop_image_type_non_unique_index()
{
$index = Db::getInstance()->executeS('SHOW INDEX FROM `'._DB_PREFIX_.'image_type` WHERE column_name="name" AND non_unique=1');
if (is_array($index) && count($index)) {
foreach ($index as $ind) {
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'image_type` DROP INDEX `'.pSQL($ind['Key_name']).'`');
}
}
}

View File

@@ -0,0 +1,40 @@
<?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_module_non_unique_index()
{
$index = Db::getInstance()->executeS('SHOW INDEX FROM `'._DB_PREFIX_.'module` WHERE Key_name = "name"');
if (is_array($index) && count($index)) {
Db::getInstance()->execute('ALTER IGNORE TABLE `'._DB_PREFIX_.'module` DROP INDEX `name`');
}
$tmp = Db::getInstance()->executeS('SHOW SESSION VARIABLES WHERE Variable_Name LIKE "old_alter_table" AND Value like "OFF"');
if (is_array($tmp) && $tmp) {
Db::getInstance()->execute('SET SESSION old_alter_table="ON"');
}
Db::getInstance()->execute('ALTER IGNORE TABLE `'._DB_PREFIX_.'module` ADD UNIQUE `name` (`name`)');
if (is_array($tmp) && $tmp) {
Db::getInstance()->execute('SET SESSION old_alter_table="OFF"');
}
}

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)
*/
function ecotax_tax_application_fix()
{
if (!Db::getInstance()->execute('SELECT `ecotax_tax_rate` FROM `'._DB_PREFIX_.'order_detail` LIMIT 1')) {
return Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'order_detail` ADD `ecotax_tax_rate` DECIMAL(5, 3) NOT NULL AFTER `ecotax`');
}
return true;
}

View File

@@ -0,0 +1,72 @@
<?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 editorial_update()
{
/*Table creation*/
if (Db::getInstance()->getValue('SELECT `id_module` FROM `'._DB_PREFIX_.'module` WHERE `name`="editorial"')) {
Db::getInstance()->execute('
CREATE TABLE `'._DB_PREFIX_.'editorial` (
`id_editorial` int(10) unsigned NOT NULL auto_increment,
`body_home_logo_link` varchar(255) NOT NULL,
PRIMARY KEY (`id_editorial`))
ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8');
Db::getInstance()->execute('
CREATE TABLE `'._DB_PREFIX_.'editorial_lang` (
`id_editorial` int(10) unsigned NOT NULL,
`id_lang` int(10) unsigned NOT NULL,
`body_title` varchar(255) NOT NULL,
`body_subheading` varchar(255) NOT NULL,
`body_paragraph` text NOT NULL,
`body_logo_subheading` varchar(255) NOT NULL,
PRIMARY KEY (`id_editorial`, `id_lang`))
ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8');
if (file_exists(dirname(__FILE__).'/../../../modules/editorial/editorial.xml')) {
$xml = @simplexml_load_file(dirname(__FILE__).'/../../../modules/editorial/editorial.xml');
if (!$xml) {
return false;
}
Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'editorial`(`id_editorial`, `body_home_logo_link`) VALUES(1, "'.(isset($xml->body->home_logo_link) ? pSQL($xml->body->home_logo_link) : '').'")');
$languages = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'lang`');
foreach ($languages as $language) {
Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'editorial_lang` (`id_editorial`, `id_lang`, `body_title`, `body_subheading`, `body_paragraph`, `body_logo_subheading`)
VALUES (1, '.(int)($language['id_lang']).',
"'.(isset($xml->body->{'title_'.$language['id_lang']}) ? pSQL($xml->body->{'title_'.$language['id_lang']}) : '').'",
"'.(isset($xml->body->{'subheading_'.$language['id_lang']}) ? pSQL($xml->body->{'subheading_'.$language['id_lang']}) : '').'",
"'.(isset($xml->body->{'paragraph_'.$language['id_lang']}) ? pSQL($xml->body->{'paragraph_'.$language['id_lang']}, true) : '').'",
"'.(isset($xml->body->{'logo_subheading_'.$language['id_lang']}) ? pSQL($xml->body->{'logo_subheading_'.$language['id_lang']}) : '').'")');
}
unlink(dirname(__FILE__).'/../../../modules/editorial/editorial.xml');
}
}
}

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 editorial_update_multishop()
{
$res = true;
if (Db::getInstance()->getValue('SELECT `id_module` FROM `'._DB_PREFIX_.'module` WHERE `name`="editorial"')) {
$res = Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'editorial` ADD `id_shop` INT(10) UNSIGNED NOT NULL AFTER `id_editorial`');
$res &= Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'editorial` SET `id_shop` = 1');
}
return $res;
}

View File

@@ -0,0 +1,68 @@
<?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 fix_cms_shop_1520()
{
$res = true;
$db = Db::getInstance();
//test if cms_shop with 2 underscore is present to rename it.
$result = $db->executeS('SHOW TABLES LIKE "'._DB_PREFIX_.'_cms_shop"');
if (!is_array($result) || !count($result) || !$result) {
$res &= create_table_cms_shop();
if ($res) {
insert_table_cms_to_cms_shop();
}
}
//test if cms_shop with 1 underscore is present and create if not.
$result = $db->executeS('SHOW TABLES LIKE "'._DB_PREFIX_.'cms_shop"');
if (!is_array($result) || !count($result) || !$result) {
$res &= create_table_cms_shop();
if ($res) {
insert_table_cms_to_cms_shop();
}
}
}
function insert_table_cms_to_cms_shop()
{
// /!\ : _cms_shop and _cms are wrong tables name (fixed in 1.5.0.12.sql : upgrade_cms_15_rename() )
$res &= Db::getInstance()->execute(
'INSERT INTO `'._DB_PREFIX_.'cms_shop` (id_shop, id_cms)
(SELECT 1, id_cms FROM '._DB_PREFIX_.'_cms)'
);
}
function create_table_cms_shop()
{
return Db::getInstance()->execute(
'CREATE TABLE `'._DB_PREFIX_.'cms_shop` (
`id_cms` INT( 11 ) UNSIGNED NOT NULL,
`id_shop` INT( 11 ) UNSIGNED NOT NULL ,
PRIMARY KEY (`id_cms`, `id_shop`),
KEY `id_shop` (`id_shop`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8;'
);
}

View File

@@ -0,0 +1,32 @@
<?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 fix_download_product_feature_active()
{
if (Db::getInstance()->getValue('SELECT COUNT(id_product_download) FROM `'._DB_PREFIX_.'product_download` WHERE `active` = 1') > 0) {
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'configuration` SET `value` = 1 WHERE `name` = \'PS_VIRTUAL_PROD_FEATURE_ACTIVE\'');
}
}

View File

@@ -0,0 +1,46 @@
<?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 fix_unique_specific_price()
{
$result = Db::getInstance()->executeS('
SELECT MIN(id_specific_price) id_specific_price
FROM '._DB_PREFIX_.'specific_price
GROUP BY `id_product`, `id_shop`, `id_currency`, `id_country`, `id_group`, `from_quantity`, `from`, `to`');
if (!$result || !count($result)) {
return true;
} // return tru if there is not any specific price in the database
$sql = '';
foreach ($result as $row) {
$sql .= (int)$row['id_specific_price'].',';
}
$sql = rtrim($sql, ',');
return Db::getInstance()->execute('
DELETE FROM '._DB_PREFIX_.'specific_price
WHERE id_specific_price NOT IN ('.$sql.')');
}

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 generate_ntree()
{
$categories = Db::getInstance()->executeS('SELECT id_category, id_parent FROM '._DB_PREFIX_.'category ORDER BY id_parent ASC, position ASC');
$categoriesArray = array();
if (is_array($categories)) {
foreach ($categories as $category) {
$categoriesArray[(int)$category['id_parent']]['subcategories'][(int)$category['id_category']] = 1;
}
}
$n = 1;
generate_ntree_subTree($categoriesArray, 1, $n);
}
function generate_ntree_subTree(&$categories, $id_category, &$n)
{
$left = (int)$n++;
if (isset($categories[(int)$id_category]['subcategories'])) {
foreach (array_keys($categories[(int)$id_category]['subcategories']) as $id_subcategory) {
generate_ntree_subTree($categories, (int)$id_subcategory, $n);
}
}
$right = (int)$n++;
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'category
SET nleft = '.(int)$left.', nright = '.(int)$right.'
WHERE id_category = '.(int)$id_category.' LIMIT 1');
}

View File

@@ -0,0 +1,101 @@
<?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)
*/
require_once 'generate_ntree.php';
function generate_root_category_for_multishop()
{
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'category` SET `level_depth`=`level_depth`+1
');
Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'category` (`id_parent`, `level_depth`, `active`, `date_add`, `date_upd`, `is_root_category`) VALUES
(0, 0, 1, NOW(), NOW(), 0)
');
$id = Db::getInstance()->Insert_ID();
// set vars config
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'configuration` (`name`, `value`, `date_add`, `date_upd`) VALUES
(\'PS_ROOT_CATEGORY\', '.(int)$id.', NOW(), NOW()),
(\'PS_HOME_CATEGORY\', 1, NOW(), NOW())
');
$langs = Db::getInstance()->executeS('
SELECT `id_lang`
FROM `'._DB_PREFIX_.'lang`
');
$shops = Db::getInstance()->executeS('
SELECT `id_shop`
FROM `'._DB_PREFIX_.'shop`
');
$data = array();
if (is_array($shops) && is_array($langs)) {
foreach ($langs as $lang) {
foreach ($shops as $shop) {
$data[] = array(
'id_lang' => $lang['id_lang'],
'id_shop' => $shop['id_shop'],
'id_category' => $id,
'name' => 'Root',
'link_rewrite' => '',
);
}
}
Db::getInstance()->insert('category_lang', $data);
}
$categories = Db::getInstance()->executeS('
SELECT `id_category`
FROM `'._DB_PREFIX_.'category`
');
$data = array();
if (is_array($shops) && is_array($categories)) {
foreach ($categories as $category) {
foreach ($shops as $shop) {
$data[] = array(
'id_category' => $category['id_category'],
'id_shop' => $shop['id_shop'],
);
}
}
Db::getInstance()->insert('category_shop', $data);
}
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'category`
SET `id_parent` = '.(int)$id.'
WHERE `id_parent` = 0 AND `id_category` <> '.(int)$id.'
');
Db::getInstance()->execute('
UPDATE `'._DB_PREFIX_.'shop`
SET `id_category` = 1
WHERE `id_shop` = 1
');
generate_ntree();
}

View File

@@ -0,0 +1,112 @@
<?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 generate_tax_rules()
{
$res = true;
$taxes = Db::getInstance()->executeS('SELECT * from `'._DB_PREFIX_.'tax` WHERE active = 1');
// if no tax found, nothing to do, return true
if (!is_array($taxes)) {
return true;
}
foreach ($taxes as $tax) {
$id_tax = $tax['id_tax'];
$row = array(
'active' => 1,
'id_tax_rules_group' => $id_tax,
'name' => 'Rule '.$tax['rate'].'%',
);
$res &= Db::getInstance()->insert('tax_rules_group', $row);
$id_tax_rules_group = Db::getInstance()->Insert_ID();
$countries = Db::getInstance()->executeS(
'
SELECT * FROM `'._DB_PREFIX_.'country` c
LEFT JOIN `'._DB_PREFIX_.'zone` z ON (c.`id_zone` = z.`id_zone`)
LEFT JOIN `'._DB_PREFIX_.'tax_zone` tz ON (tz.`id_zone` = z.`id_zone`)
WHERE `id_tax` = '.(int)$id_tax
);
if ($countries) {
foreach ($countries as $country) {
$res &= Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'tax_rule`
(`id_tax_rules_group`, `id_country`, `id_state`, `state_behavior`, `id_tax`)
VALUES
('.$id_tax_rules_group.', '.(int)$country['id_country'].', 0, 0, '.(int)$id_tax. ')');
}
}
$states = Db::getInstance()->executeS('
SELECT * FROM `'._DB_PREFIX_.'states` s
LEFT JOIN `'._DB_PREFIX_.'tax_state` ts ON (ts.`id_state` = s.`id_state`)
WHERE `id_tax` = '.(int)$id_tax);
if ($states) {
foreach ($states as $state) {
if (!in_array($state['tax_behavior'], array(PS_PRODUCT_TAX, PS_STATE_TAX, PS_BOTH_TAX))) {
$tax_behavior = PS_PRODUCT_TAX;
} else {
$tax_behavior = $state['tax_behavior'];
}
$res &= Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'tax_rule`
(`id_tax_rules_group`, `id_country`, `id_state`, `state_behavior`, `id_tax`)
VALUES (
'.$id_tax_rules_group.',
'.(int)$state['id_country'].',
'.(int)$state['id_state'].',
'.(int)$tax_behavior.',
'.(int)$id_tax.
')');
}
}
$res &= Db::getInstance()->execute(
'
UPDATE `'._DB_PREFIX_.'product`
SET `id_tax_rules_group` = '.$id_tax_rules_group.'
WHERE `id_tax` = '.(int)$id_tax
);
$res &= Db::getInstance()->execute(
'
UPDATE `'._DB_PREFIX_.'carrier`
SET `id_tax_rules_group` = '.$id_tax_rules_group.'
WHERE `id_tax` = '.(int)$id_tax
);
$socolissimo_overcost_tax = Db::getInstance()->getValue('SELECT value
FROM `'._DB_PREFIX_.'configuration`
WHERE name="SOCOLISSIMO_OVERCOST_TAX"');
if ($socolissimo_overcost_tax == $id_tax) {
$res &= Db::getInstance()->getValue('UPDATE `'._DB_PREFIX_.'configuration`
set value="'.$id_tax_rules_group.'" WHERE name="SOCOLISSIMO_OVERCOST_TAX"');
}
}
return $res;
}

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)
*/
function generic_add_missing_column($table, $column_to_add)
{
$column_exist = Db::getInstance()->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.$table.'`');
$column_formated = array();
$res = true;
if ($column_exist) {
foreach ($column_exist as $c) {
$column_formated[] = $c['Field'] ;
}
foreach ($column_to_add as $name => $details) {
if (!in_array($name, $column_formated)) {
$res &= Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.$table.'` ADD COLUMN `'.$name.'` '.$details);
}
}
}
return $res;
}

View File

@@ -0,0 +1,46 @@
<?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)
*/
/** remove the uncompatible module gridextjs (1.4.0.8 upgrade)
*/
function gridextjs_deprecated()
{
// if exists, use _PS_MODULE_DIR_ or _PS_ROOT_DIR_
// instead of guessing the modules dir
if (defined('_PS_MODULE_DIR_')) {
$gridextjs_path = _PS_MODULE_DIR_ . 'gridextjs';
} elseif (defined('_PS_ROOT_DIR_')) {
$gridextjs_path = _PS_ROOT_DIR_ . '/modules/gridextjs';
} else {
$gridextjs_path = dirname(__FILE__).'/../../../modules/gridextjs';
}
if (file_exists($gridextjs_path)) {
return rename($gridextjs_path, str_replace('gridextjs', 'gridextjs.deprecated', $gridextjs_path));
}
return true;
}

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)
*/
function group_reduction_column_fix()
{
if (!Db::getInstance()->execute('SELECT `group_reduction` FROM `'._DB_PREFIX_.'order_detail` LIMIT 1')) {
return Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'order_detail` ADD `group_reduction` DECIMAL(10, 2) NOT NULL AFTER `reduction_amount`');
}
return true;
}

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 hook_blocksearch_on_header()
{
if ($id_module = Db::getInstance()->getValue('SELECT `id_module` FROM `'._DB_PREFIX_.'module` WHERE `name` = \'blocksearch\'')) {
$id_hook = Db::getInstance()->getValue('
SELECT `id_hook`
FROM `'._DB_PREFIX_.'hook`
WHERE `name` = \'header\'
');
$position = Db::getInstance()->getValue('
SELECT MAX(`position`)
FROM `'._DB_PREFIX_.'hook_module`
WHERE `id_hook` = '.(int)$id_hook.'
');
Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'hook_module` (`id_module`, `id_hook`, `position`)
VALUES ('.(int)$id_module.', '.(int)$id_hook.', '.($position+1).')
');
}
}

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)
*/
function id_currency_country_fix()
{
if (!Db::getInstance()->execute('SELECT `id_currency` FROM `'._DB_PREFIX_.'country` LIMIT 1')) {
return Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'country` ADD `id_currency` INT NOT NULL DEFAULT \'0\' AFTER `id_zone`');
}
return true;
}

View File

@@ -0,0 +1,37 @@
<?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 image_shop1510()
{
include_once __DIR__.'/generic_add_missing_column.php';
$column_to_add = array(
'cover' => 'TINYINT(1) UNSIGNED NOT NULL AFTER `id_shop`',
);
return generic_add_missing_column('image_shop', $column_to_add);
}

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)
*/
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,51 @@
<?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 invoice_number_set()
{
Configuration::loadConfiguration();
$number = 1;
// Update each order with a number
$result = Db::getInstance()->executeS('
SELECT id_order
FROM '._DB_PREFIX_.'orders
ORDER BY id_order');
foreach ($result as $row) {
$order = new Order((int)($row['id_order']));
$history = $order->getHistory(false);
foreach ($history as $row2) {
$oS = new OrderState((int)($row2['id_order_state']), Configuration::get('PS_LANG_DEFAULT'));
if ($oS->invoice) {
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'orders SET invoice_number = '.(int)($number++).', `invoice_date` = `date_add` WHERE id_order = '.(int)($order->id));
break ;
}
}
}
// Add configuration var
Configuration::updateValue('PS_INVOICE_NUMBER', (int)($number));
}

View File

@@ -0,0 +1,137 @@
<?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)
*/
if (!defined('_PS_MYSQL_REAL_ESCAPE_STRING_')) {
define('_PS_MYSQL_REAL_ESCAPE_STRING_', function_exists('mysql_real_escape_string'));
}
function latin1_database_to_utf8()
{
global $requests, $warningExist;
$tables = array(
array('name' => 'address', 'id' => 'id_address', 'fields' => array('alias', 'company', 'name', 'surname', 'address1', 'address2', 'postcode', 'city', 'other', 'phone', 'phone_mobile')),
array('name' => 'alias', 'id' => 'id_alias', 'fields' => array('alias', 'search')),
array('name' => 'attribute_group_lang', 'id' => 'id_attribute_group', 'lang' => true, 'fields' => array('name', 'public_name')),
array('name' => 'attribute_lang', 'id' => 'id_attribute', 'lang' => true, 'fields' => array('name')),
array('name' => 'carrier', 'id' => 'id_carrier', 'fields' => array('name', 'url')),
array('name' => 'carrier_lang', 'id' => 'id_carrier', 'lang' => true, 'fields' => array('delay')),
array('name' => 'cart', 'id' => 'id_cart', 'fields' => array('gift_message')),
array('name' => 'category_lang', 'id' => 'id_category', 'lang' => true, 'fields' => array('name', 'description', 'link_rewrite', 'meta_title', 'meta_keywords', 'meta_description')),
array('name' => 'configuration', 'id' => 'id_configuration', 'fields' => array('name', 'value')),
array('name' => 'configuration_lang', 'id' => 'id_configuration', 'lang' => true, 'fields' => array('value')),
array('name' => 'contact', 'id' => 'id_contact', 'fields' => array('email')),
array('name' => 'contact_lang', 'id' => 'id_contact', 'lang' => true, 'fields' => array('name', 'description')),
array('name' => 'country', 'id' => 'id_country', 'fields' => array('iso_code')),
array('name' => 'country_lang', 'id' => 'id_country', 'lang' => true, 'fields' => array('name')),
array('name' => 'currency', 'id' => 'id_currency', 'fields' => array('name', 'iso_code', 'sign')),
array('name' => 'customer', 'id' => 'id_customer', 'fields' => array('email', 'passwd', 'name', 'surname')),
array('name' => 'discount', 'id' => 'id_discount', 'fields' => array('name')),
array('name' => 'discount_lang', 'id' => 'id_discount', 'lang' => true, 'fields' => array('description')),
array('name' => 'discount_type_lang', 'id' => 'id_discount_type', 'lang' => true, 'fields' => array('name')),
array('name' => 'employee', 'id' => 'id_employee', 'fields' => array('name', 'surname', 'email', 'passwd')),
array('name' => 'feature_lang', 'id' => 'id_feature', 'lang' => true, 'fields' => array('name')),
array('name' => 'feature_value_lang', 'id' => 'id_feature_value', 'lang' => true, 'fields' => array('value')),
array('name' => 'hook', 'id' => 'id_hook', 'fields' => array('name', 'title', 'description')),
array('name' => 'hook_module_exceptions', 'id' => 'id_hook_module_exceptions', 'fields' => array('file_name')),
array('name' => 'image_lang', 'id' => 'id_image', 'lang' => true, 'fields' => array('legend')),
array('name' => 'image_type', 'id' => 'id_image_type', 'fields' => array('name')),
array('name' => 'lang', 'id' => 'id_lang', 'fields' => array('name', 'iso_code')),
array('name' => 'manufacturer', 'id' => 'id_manufacturer', 'fields' => array('name')),
array('name' => 'message', 'id' => 'id_message', 'fields' => array('message')),
array('name' => 'module', 'id' => 'id_module', 'fields' => array('name')),
array('name' => 'orders', 'id' => 'id_order', 'fields' => array('payment', 'module', 'gift_message', 'shipping_number')),
array('name' => 'order_detail', 'id' => 'id_order_detail', 'fields' => array('product_name', 'product_reference', 'tax_name', 'download_hash')),
array('name' => 'order_discount', 'id' => 'id_order_discount', 'fields' => array('name')),
array('name' => 'order_state', 'id' => 'id_order_state', 'fields' => array('color')),
array('name' => 'order_state_lang', 'id' => 'id_order_state', 'lang' => true, 'fields' => array('name', 'template')),
array('name' => 'product', 'id' => 'id_product', 'fields' => array('ean13', 'reference')),
array('name' => 'product_attribute', 'id' => 'id_product_attribute', 'fields' => array('reference', 'ean13')),
array('name' => 'product_download', 'id' => 'id_product_download', 'fields' => array('display_filename', 'physically_filename')),
array('name' => 'product_lang', 'id' => 'id_product', 'lang' => true, 'fields' => array('description', 'description_short', 'link_rewrite', 'meta_description', 'meta_keywords', 'meta_title', 'name', 'availability')),
array('name' => 'profile_lang', 'id' => 'id_profile', 'lang' => true, 'fields' => array('name')),
array('name' => 'quick_access', 'id' => 'id_quick_access', 'fields' => array('link')),
array('name' => 'quick_access_lang', 'id' => 'id_quick_access', 'lang' => true, 'fields' => array('name')),
array('name' => 'supplier', 'id' => 'id_supplier', 'fields' => array('name')),
array('name' => 'tab', 'id' => 'id_tab', 'fields' => array('class_name')),
array('name' => 'tab_lang', 'id' => 'id_tab', 'lang' => true, 'fields' => array('name')),
array('name' => 'tag', 'id' => 'id_tag', 'fields' => array('name')),
array('name' => 'tax_lang', 'id' => 'id_tax', 'lang' => true, 'fields' => array('name')),
array('name' => 'zone', 'id' => 'id_zone', 'fields' => array('name')),
);
foreach ($tables as $table) {
/* Latin1 datas' selection */
if (!Db::getInstance()->execute('SET NAMES latin1')) {
echo 'Cannot change the sql encoding to latin1!';
}
$query = 'SELECT `'.$table['id'].'`';
foreach ($table['fields'] as $field) {
$query .= ', `'.$field.'`';
}
if (isset($table['lang']) && $table['lang']) {
$query .= ', `id_lang`';
}
$query .= ' FROM `'._DB_PREFIX_.$table['name'].'`';
$latin1Datas = Db::getInstance()->executeS($query);
if ($latin1Datas === false) {
$warningExist = true;
$requests .= '
<request result="fail">
<sqlQuery><![CDATA['.htmlentities($query).']]></sqlQuery>
<sqlMsgError><![CDATA['.htmlentities(Db::getInstance()->getMsgError()).']]></sqlMsgError>
<sqlNumberError><![CDATA['.htmlentities(Db::getInstance()->getNumberError()).']]></sqlNumberError>
</request>'."\n";
}
if (Db::getInstance()->numRows()) {
/* Utf-8 datas' restitution */
if (!Db::getInstance()->execute('SET NAMES utf8')) {
echo 'Cannot change the sql encoding to utf8!';
}
foreach ($latin1Datas as $latin1Data) {
$query = 'UPDATE `'._DB_PREFIX_.$table['name'].'` SET';
foreach ($table['fields'] as $field) {
$query .= ' `'.$field.'` = \''.pSQL($latin1Data[$field]).'\',';
}
$query = rtrim($query, ',');
$query .= ' WHERE `'.$table['id'].'` = '.(int)($latin1Data[$table['id']]);
if (isset($table['lang']) && $table['lang']) {
$query .= ' AND `id_lang` = '.(int)($latin1Data['id_lang']);
}
if (!Db::getInstance()->execute($query)) {
$warningExist = true;
$requests .= '
<request result="fail">
<sqlQuery><![CDATA['.htmlentities($query).']]></sqlQuery>
<sqlMsgError><![CDATA['.htmlentities(Db::getInstance()->getMsgError()).']]></sqlMsgError>
<sqlNumberError><![CDATA['.htmlentities(Db::getInstance()->getNumberError()).']]></sqlNumberError>
</request>'."\n";
}
}
}
}
}

View File

@@ -0,0 +1,135 @@
<?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 migrate_block_info_to_cms_block()
{
$res = true;
$languages = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'lang`');
//get ids cms of block information
$id_blockinfos = Db::getInstance()->getValue('SELECT id_module FROM `'._DB_PREFIX_.'module` WHERE name = \'blockinfos\'');
//get ids cms of block information
$ids_cms = Db::getInstance()->executeS('SELECT id_cms FROM `'._DB_PREFIX_.'block_cms` WHERE `id_block` = '.(int)$id_blockinfos);
//check if block info is installed and active
if (is_array($ids_cms)) {
//install module blockcms
// Module::getInstanceByName('blockcms')->install()
// 1) from module
$ps_lang_default = Db::getInstance()->getValue('SELECT value
FROM `'._DB_PREFIX_.'configuration`
WHERE name="PS_LANG_DEFAULT"');
// 2) parent::install()
$result = Db::getInstance()->insert(
'module',
array('name' => 'blockcms', 'active' => 1)
);
$id_module = Db::getInstance()->Insert_ID();
// 3) hooks
$hooks = array('leftColumn', 'rightColumn', 'footer', 'header');
foreach ($hooks as $hook_name) {
// do not pSql hook_name
$row = Db::getInstance()->getRow('SELECT h.id_hook, '.$id_module.' as id_module, MAX(hm.position)+1 as position
FROM `'._DB_PREFIX_.'hook_module` hm
LEFT JOIN `'._DB_PREFIX_.'hook` h on hm.id_hook=h.id_hook
WHERE h.name = "'.$hook_name.'" group by id_hook');
$res &= Db::getInstance()->insert('hook_module', $row);
}
// module install
$res &= Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block`(
`id_cms_block` int(10) unsigned NOT NULL auto_increment,
`id_cms_category` int(10) unsigned NOT NULL,
`location` tinyint(1) unsigned NOT NULL,
`position` int(10) unsigned NOT NULL default \'0\',
`display_store` tinyint(1) unsigned NOT NULL default \'1\',
PRIMARY KEY (`id_cms_block`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8');
$res &= Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'cms_block` (`id_cms_category`, `location`, `position`) VALUES(1, 0, 0)');
$res &= Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_lang`(
`id_cms_block` int(10) unsigned NOT NULL,
`id_lang` int(10) unsigned NOT NULL,
`name` varchar(40) NOT NULL default \'\',
PRIMARY KEY (`id_cms_block`, `id_lang`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8');
$query_lang = 'INSERT INTO `'._DB_PREFIX_.'cms_block_lang` (`id_cms_block`, `id_lang`) VALUES';
foreach ($languages as $language) {
$query_lang .= '(1, '.(int)($language['id_lang']).'),';
}
$query_lang = rtrim($query_lang, ',');
$res &= Db::getInstance()->execute($query_lang);
$res &= Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'cms_block_page`(
`id_cms_block_page` int(10) unsigned NOT NULL auto_increment,
`id_cms_block` int(10) unsigned NOT NULL,
`id_cms` int(10) unsigned NOT NULL,
`is_category` tinyint(1) unsigned NOT NULL,
PRIMARY KEY (`id_cms_block_page`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8');
$exist = Db::getInstance()->getValue('SELECT `id_configuration` FROM `'._DB_PREFIX_.'configuration` WHERE `name` = \'FOOTER_CMS\'');
if ($exist) {
$res &= Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'configuration` SET value = "" WHERE `name` = \'FOOTER_CMS\'');
} else {
$res &= Db::getInstance()->getValue('INSERT INTO `'._DB_PREFIX_.'configuration` (name, value) VALUES ("FOOTER_CMS", "")');
}
$exist = Db::getInstance()->getValue('SELECT `id_configuration` FROM `'._DB_PREFIX_.'configuration` WHERE `name` = \'FOOTER_BLOCK_ACTIVATION\'');
if ($exist) {
$res &= Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'configuration` SET value = "1" WHERE `name` = \'FOOTER_BLOCK_ACTIVATION\'');
} else {
$res &= Db::getInstance()->getValue('INSERT INTO `'._DB_PREFIX_.'configuration` (name, value) VALUES ("FOOTER_BLOCK_ACTIVATION", "1")');
}
$exist = Db::getInstance()->getValue('SELECT `id_configuration` FROM `'._DB_PREFIX_.'configuration` WHERE `name` = \'FOOTER_POWEREDBY\'');
if ($exist) {
$res &= Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'configuration` SET value = "1" WHERE `name` = \'FOOTER_POWEREDBY\'');
} else {
$res &= Db::getInstance()->getValue('INSERT INTO `'._DB_PREFIX_.'configuration` (name, value) VALUES ("FOOTER_POWEREDBY", "1")');
}
//add new block in new cms block
$res &= Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'cms_block`
(`id_cms_category`, `name`, `location`, `position`)
VALUES( 1, "", 0, 0)');
$id_block = Db::getInstance()->Insert_ID();
foreach ($languages as $language) {
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'cms_block_lang` (`id_cms_block`, `id_lang`, `name`) VALUES ('.(int)$id_block.', '.(int)$language['id_lang'].', \'Information\')');
}
//save ids cms of block information in new module cms bloc
foreach ($ids_cms as $id_cms) {
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'cms_block_page` (`id_cms_block`, `id_cms`, `is_category`) VALUES ('.(int)$id_block.', '.(int)$id_cms['id_cms'].', 0)');
}
} else {
return true;
}
}

View File

@@ -0,0 +1,343 @@
<?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 migrate_orders()
{
$array_errors = array();
$res = true;
if (!defined('PS_TAX_EXC')) {
define('PS_TAX_EXC', 1);
}
if (!defined('PS_TAX_INC')) {
define('PS_TAX_INC', 0);
}
$col_order_detail_old = Db::getInstance()->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.'order_detail`');
foreach ($col_order_detail_old as $k => $field) {
if ($field['Field'] != 'id_order_invoice') {
$col_order_detail[$k] = $field['Field'];
}
}
if (!$col_order_detail_old) {
return array('error' => 1, 'msg' => 'unable to get fields list from order_detail table');
}
$insert_order_detail = 'INSERT INTO `'._DB_PREFIX_.'order_detail_2` (`'.implode('`, `', $col_order_detail).'`) VALUES ';
$col_orders = array();
$col_orders_old = Db::getInstance()->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.'orders`');
if (!$col_orders_old) {
return array('error' => 1, 'msg' => 'unable to get fields list from orders table');
}
foreach ($col_orders_old as $k => $field) {
$col_orders[$k] = $field['Field'];
}
$insert_order = 'INSERT INTO `'._DB_PREFIX_.'orders_2` (`'.implode('`, `', $col_orders).'`) VALUES ';
// create temporary tables
$res = mo_duplicateTables();
if (!$res) {
$array_errors[] = 'unable to duplicate tables orders and order_detail';
}
// this was done like that previously
$wrapping_tax_rate = 1 + ((float)Db::getInstance()->getValue('SELECT value
FROM `'._DB_PREFIX_.'configuration`
WHERE name = "PS_GIFT_WRAPPING_TAX"') / 100);
$step = 3000;
$count_orders = Db::getInstance()->getValue('SELECT count(id_order) FROM '._DB_PREFIX_.'orders');
$nb_loop = $start = 0;
if ($count_orders > 0) {
$nb_loop = ceil($count_orders / $step);
}
for ($i = 0; $i < $nb_loop; $i++) {
$order_res = Db::getInstance()->query('SELECT * FROM `'._DB_PREFIX_.'orders` LIMIT '.(int)$start.', '.(int)$step);
$start = (int) (($i+1) * $step);
$cpt = 0;
$flush_limit = 200;
while ($order = Db::getInstance()->nextRow($order_res)) {
$sum_total_products = 0;
$sum_tax_amount = 0;
$default_group_id = mo_getCustomerDefaultGroup((int)$order['id_customer']);
$price_display_method = mo_getPriceDisplayMethod((int)$default_group_id);
$order_details_list = Db::getInstance()->query('
SELECT od.*
FROM `'._DB_PREFIX_.'order_detail` od
WHERE od.`id_order` = '.(int)$order['id_order']);
while ($order_details = Db::getInstance()->nextRow($order_details_list)) {
// we don't want to erase order_details data in order to create the insert query
$products = mo_setProductPrices($order_details, $price_display_method);
$tax_rate = 1 + ((float)$products['tax_rate'] / 100);
$reduction_amount_tax_incl = (float)$products['reduction_amount'];
// cart::getTaxesAverageUsed equivalent
$sum_total_products += $products['total_price'];
$sum_tax_amount += $products['total_wt'] - $products['total_price'];
$order_details['reduction_amount_tax_incl'] = $reduction_amount_tax_incl;
$order_details['reduction_amount_tax_excl'] = (float)mo_ps_round($reduction_amount_tax_incl / $tax_rate);
$order_details['total_price_tax_incl'] = (float)$products['total_wt'];
$order_details['total_price_tax_excl'] = (float)$products['total_price'];
$order_details['unit_price_tax_incl'] = (float)$products['product_price_wt'];
$order_details['unit_price_tax_excl'] = (float)$products['product_price'];
foreach (array_keys($order_details) as $k) {
if (!in_array($k, $col_order_detail)) {
unset($order_details[$k]);
} else {
if (in_array($order_details[$k], array('product_price', 'reduction_percent', 'reduction_amount', 'group_reduction', 'product_quantity_discount', 'tax_rate', 'ecotax', 'ecotax_tax_rate'))) {
$order_details[$k] = (float)$order_details[$k];
} else {
$order_details[$k] = Db::getInstance()->escape($order_details[$k]);
}
}
}
if (count($order_details)) {
$values_order_detail[] = '(\''.implode('\', \'', $order_details).'\')';
}
unset($order_details);
}
$average_tax_used = 1;
if ($sum_total_products > 0) {
$average_tax_used += $sum_tax_amount / $sum_total_products;
}
$average_tax_used = round($average_tax_used, 4);
$carrier_tax_rate = 1;
if (isset($order['carrier_tax_rate'])) {
$carrier_tax_rate + ((float)$order['carrier_tax_rate'] / 100);
}
$total_discount_tax_excl = $order['total_discounts'] / $average_tax_used;
$order['total_discounts_tax_incl'] = (float)$order['total_discounts'];
$order['total_discounts_tax_excl'] = (float)$total_discount_tax_excl;
$order['total_shipping_tax_incl'] = (float)$order['total_shipping'];
$order['total_shipping_tax_excl'] = (float)($order['total_shipping'] / $carrier_tax_rate);
$shipping_taxes = $order['total_shipping_tax_incl'] - $order['total_shipping_tax_excl'];
$order['total_wrapping_tax_incl'] = (float)$order['total_wrapping'];
$order['total_wrapping_tax_excl'] = ((float)$order['total_wrapping'] / $wrapping_tax_rate);
$wrapping_taxes = $order['total_wrapping_tax_incl'] - $order['total_wrapping_tax_excl'];
$product_taxes = $order['total_products_wt'] - $order['total_products'];
$order['total_paid_tax_incl'] = (float)$order['total_paid'];
$order['total_paid_tax_excl'] = (float)$order['total_paid'] - $shipping_taxes - $wrapping_taxes - $product_taxes;
// protect text and varchar fields
$order['gift_message'] = Db::getInstance()->escape($order['gift_message']);
$order['payment'] = Db::getInstance()->escape($order['payment']);
$order['module'] = Db::getInstance()->escape($order['module']);
$values_order[] = '(\''.implode('\', \'', $order).'\')';
unset($order);
$cpt++;
// limit to $cpt
if ($cpt >= $flush_limit) {
$cpt = 0;
if (isset($values_order_detail) && count($values_order_detail) && !Db::getInstance()->execute($insert_order_detail. implode(',', $values_order_detail))) {
$res = false;
$array_errors[] = '[insert order detail 1] - '.Db::getInstance()->getMsgError();
}
if (isset($values_order) && count($values_order) && !Db::getInstance()->execute($insert_order. implode(',', $values_order))) {
$res = false;
$array_errors[] = '[insert order 2] - '.Db::getInstance()->getMsgError();
}
if (isset($values_order)) {
unset($values_order);
}
if (isset($values_order_detail)) {
unset($values_order_detail);
}
}
}
}
if (isset($values_order_detail) && count($values_order_detail) && !Db::getInstance()->execute($insert_order_detail. implode(',', $values_order_detail))) {
$res = false;
$array_errors[] = '[insert order detail 3] - '.Db::getInstance()->getMsgError();
}
if (isset($values_order) && count($values_order) && !Db::getInstance()->execute($insert_order. implode(',', $values_order))) {
$res = false;
$array_errors[] = '[insert order 4] - '.Db::getInstance()->getMsgError();
}
if (isset($values_order)) {
unset($values_order);
}
if (isset($values_order_detail)) {
unset($values_order_detail);
}
if (!mo_renameTables()) {
$res = false;
$array_errors[] = 'unable to rename tables orders_2 and order_detail_2 to orders and order_detail';
}
if (!$res) {
return array('error' => 1, 'msg' => count($array_errors).' error(s) : <br/>'.implode('<br/>', $array_errors));
}
}
/**
* mo_ps_round is a simplification of Tools::ps_round:
* - round is always 2
* - no call to Configuration class
*
* @param mixed $val
* @return void
*/
function mo_ps_round($val)
{
static $ps_price_round_mode;
if (empty($ps_price_round_mode)) {
$ps_price_round_mode = Db::getInstance()->getValue('SELECT value
FROM `'._DB_PREFIX_.'configuration`
WHERE name = "PS_PRICE_ROUND_MODE"');
}
switch ($ps_price_round_mode) {
case 0:
return ceil($val * 100)/100;
case 1:
return floor($val * 100)/100;
default:
return round($val, 2);
}
}
function mo_duplicateTables()
{
$res = true;
$res &= Db::getInstance()->execute('CREATE TABLE
`'._DB_PREFIX_.'orders_2` LIKE `'._DB_PREFIX_.'orders`');
$res &= Db::getInstance()->execute('CREATE TABLE
`'._DB_PREFIX_.'order_detail_2` LIKE `'._DB_PREFIX_.'order_detail`');
return $res;
}
function mo_renameTables()
{
$res = true;
$res &= Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'orders`');
$res &= Db::getInstance()->execute('DROP TABLE `'._DB_PREFIX_.'order_detail`');
$res &= Db::getInstance()->execute('RENAME TABLE `'._DB_PREFIX_.'orders_2` TO `'._DB_PREFIX_.'orders`');
$res &= Db::getInstance()->execute('RENAME TABLE `'._DB_PREFIX_.'order_detail_2` TO `'._DB_PREFIX_.'order_detail`');
return $res;
}
function mo_getCustomerDefaultGroup($id_customer)
{
static $cache;
if (!isset($cache[$id_customer])) {
$cache[$id_customer] = Db::getInstance()->getValue('SELECT `id_default_group` FROM `'._DB_PREFIX_.'customer` WHERE `id_customer` = '.(int)$id_customer);
}
return $cache[$id_customer];
}
function mo_getPriceDisplayMethod($id_group)
{
static $cache;
if (!isset($cache[$id_group])) {
$cache[$id_group] = Db::getInstance()->getValue('
SELECT `price_display_method`
FROM `'._DB_PREFIX_.'group`
WHERE `id_group` = '.(int)$id_group);
}
return $cache[$id_group];
}
function mo_setProductPrices($row, $tax_calculation_method)
{
if ($tax_calculation_method == PS_TAX_EXC) {
$row['product_price'] = mo_ps_round($row['product_price']);
} else {
$row['product_price_wt'] = mo_ps_round($row['product_price'] * (1 + $row['tax_rate'] / 100));
}
$group_reduction = 1;
if ($row['group_reduction'] > 0) {
$group_reduction = 1 - $row['group_reduction'] / 100;
}
if ($row['reduction_percent'] != 0) {
if ($tax_calculation_method == PS_TAX_EXC) {
$row['product_price'] = ($row['product_price'] - $row['product_price'] * ($row['reduction_percent'] * 0.01));
} else {
$reduction = mo_ps_round($row['product_price_wt'] * ($row['reduction_percent'] * 0.01));
$row['product_price_wt'] = mo_ps_round(($row['product_price_wt'] - $reduction));
}
}
if ($row['reduction_amount'] != 0) {
if ($tax_calculation_method == PS_TAX_EXC) {
$row['product_price'] = ($row['product_price'] - ($row['reduction_amount'] / (1 + $row['tax_rate'] / 100)));
} else {
$row['product_price_wt'] = mo_ps_round(($row['product_price_wt'] - $row['reduction_amount']));
}
}
if ($row['group_reduction'] > 0) {
if ($tax_calculation_method == PS_TAX_EXC) {
$row['product_price'] = $row['product_price'] * $group_reduction;
} else {
$row['product_price_wt'] = mo_ps_round($row['product_price_wt'] * $group_reduction);
}
}
if (($row['reduction_percent'] || $row['reduction_amount'] || $row['group_reduction']) && $tax_calculation_method == PS_TAX_EXC) {
$row['product_price'] = mo_ps_round($row['product_price']);
}
if ($tax_calculation_method == PS_TAX_EXC) {
$row['product_price_wt'] = mo_ps_round($row['product_price'] * (1 + ($row['tax_rate'] * 0.01))) + mo_ps_round($row['ecotax'] * (1 + $row['ecotax_tax_rate'] / 100));
} else {
$row['product_price_wt_but_ecotax'] = $row['product_price_wt'];
$row['product_price_wt'] = mo_ps_round($row['product_price_wt'] + $row['ecotax'] * (1 + $row['ecotax_tax_rate'] / 100));
}
if ($tax_calculation_method != PS_TAX_EXC) {
$row['product_price'] = $row['product_price_wt'] / (1 + $row['tax_rate'] / 100);
}
$row['total_wt'] = $row['product_quantity'] * $row['product_price_wt'];
$row['total_price'] = $row['product_quantity'] * $row['product_price'];
return $row;
}

View File

@@ -0,0 +1,208 @@
<?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)
*/
/**
* Migrate BO tabs for 1.5 (new reorganization of BO)
*/
function migrate_tabs_15()
{
include_once __DIR__.'/add_new_tab.php';
// ===== Remove deleted tabs =====
$remove_tabs = array(
'AdminAliases',
'AdminContact',
'AdminDb',
'AdminGenerator',
'AdminPdf',
'AdminSubDomains',
'AdminStatsConf',
);
$ids = array();
foreach ($remove_tabs as $tab) {
if ($id = get_tab_id($tab)) {
$ids[] = $id;
}
}
if ($ids) {
Db::getInstance()->delete('tab', 'id_tab IN ('.implode(', ', $ids).')');
Db::getInstance()->delete('tab_lang', 'id_tab IN ('.implode(', ', $ids).')');
}
// ===== Create new parent tabs =====
$parent = array(
'AdminCatalog' => get_tab_id('AdminCatalog'),
'AdminParentOrders' => add_new_tab('AdminParentOrders', 'en:Orders|fr:Commandes|es:Pedidos|de:Bestellungen|it:Ordini', 0, true),
'AdminParentCustomer' => add_new_tab('AdminParentCustomer', 'en:Customers|fr:Clients|es:Clientes|de:Kunden|it:Clienti', 0, true),
'AdminPriceRule' => add_new_tab('AdminPriceRule', 'en:Price rules|fr:Promotions|es:Price rules|de:Price rules|it:Price rules', 0, true),
'AdminParentShipping' => add_new_tab('AdminParentShipping', 'en:Shipping|fr:Transport|es:Transporte|de:Versandkosten|it:Spedizione', 0, true),
'AdminParentLocalization' =>add_new_tab('AdminParentLocalization', 'en:Localization|fr:Localisation|es:Ubicación|de:Lokalisierung|it:Localizzazione', 0, true),
'AdminParentModules' => add_new_tab('AdminParentModules', 'en:Modules|fr:Modules|es:Módulos|de:Module|it:Moduli', 0, true),
'AdminParentPreferences' => add_new_tab('AdminParentPreferences', 'en:Preferences|fr:Préférences|es:Preferencias|de:Voreinstellungen|it:Preferenze', 0, true),
'AdminTools' => get_tab_id('AdminTools'),
'AdminAdmin' => add_new_tab('AdminAdmin', 'en:Administration|fr:Administration|es:Administration|de:Administration|it:Administration', 0, true),
'AdminParentStats' => add_new_tab('AdminParentStats', 'en:Stats|fr:Stats|es:Estadísticas|de:Statistik|it:Stat', 0, true),
'AdminParentShop' => add_new_tab('AdminParentShop', 'en:Shops|fr:Boutiques|es:Shops|de:Shops|it:Shops', 0, true),
'AdminStock' => get_tab_id('AdminStock'),
);
// ===== Move tabs from old parents to new parents =====
$move_association = array(
'AdminParentOrders' => 'AdminOrders',
'AdminParentCustomer' => 'AdminCustomers',
'AdminParentShipping' => 'AdminShipping',
'AdminParentLocalization' => 'AdminLocalization',
'AdminParentModules' => 'AdminModules',
'AdminParentPreferences' => 'AdminPreferences',
'AdminAdmin' => 'AdminEmployees',
'AdminParentStats' => 'AdminStats',
'AdminParentShop' => 'AdminShop',
);
foreach ($move_association as $to => $from) {
if (empty($parent[$to])) {
continue;
}
$id_parent = get_tab_id($from);
if ($id_parent) {
Db::getInstance()->execute('
UPDATE '._DB_PREFIX_.'tab
SET id_parent = '.$parent[$to].'
WHERE id_parent = '.$id_parent.'
OR id_tab = '.$id_parent.'
');
}
}
// ===== Move tabs to their new parents =====
$move_to = array(
'AdminContacts' => 'AdminParentCustomer',
'AdminCustomerThreads' => 'AdminParentCustomer',
'AdminCurrencies' => 'AdminParentLocalization',
'AdminTaxes' => 'AdminParentLocalization',
'AdminTaxRulesGroup' => 'AdminParentLocalization',
'AdminLanguages' => 'AdminParentLocalization',
'AdminTranslations' => 'AdminParentLocalization',
'AdminZones' => 'AdminParentLocalization',
'AdminCountries' => 'AdminParentLocalization',
'AdminStates' => 'AdminParentLocalization',
'AdminCartRules' => 'AdminPriceRule',
'AdminSpecificPriceRule' => 'AdminPriceRule',
'AdminQuickAccesses' => 'AdminAdmin',
'AdminPayment' => 'AdminParentModules',
'AdminCmsContent' => 'AdminParentPreferences',
'AdminStores' => 'AdminParentPreferences',
'AdminEmails' => 'AdminTools',
'AdminPerformance' => 'AdminTools',
'AdminAccountingConfiguration' => 'AdminTools',
'AdminAccountingRegisteredNumber' => 'AdminTools',
'AdminAccountingExport' => 'AdminStats',
);
foreach ($move_to as $from => $to) {
if (empty($parent[$to])) {
continue;
}
$id_tab = get_tab_id($from);
if ($id_tab) {
Db::getInstance()->execute('
UPDATE '._DB_PREFIX_.'tab
SET id_parent = '.$parent[$to].'
WHERE id_tab = '.$id_tab.'
');
}
}
// ===== Remove AdminThemes from Modules parent =====
$id_tab_theme = Db::getInstance()->getValue(
'SELECT id_tab FROM '._DB_PREFIX_.'tab
WHERE class_name = \'AdminThemes\'
AND id_parent = '.$parent['AdminParentModules'].'
'
);
if ($id_tab_theme) {
Db::getInstance()->delete('tab', 'id_tab = '.$id_tab_theme);
}
// ===== Create new tabs (but not parents this time) =====
add_new_tab('AdminOrderPreferences', 'en:Orders|fr:Commandes|es:Pedidos|de:Bestellungen|it:Ordini', $parent['AdminParentPreferences']);
add_new_tab('AdminCustomerPreferences', 'en:Customers|fr:Clients|es:Clientes|de:Kunden|it:Clienti', $parent['AdminParentPreferences']);
add_new_tab('AdminMaintenance', 'en:Maintenance|fr:Maintenance|es:Maintenance|de:Maintenance|it:Maintenance', $parent['AdminParentPreferences']);
add_new_tab('AdminAdminPreferences', 'en:Preferences|fr:Préférences|es:Preferencias|de:Voreinstellungen|it:Preferenze', $parent['AdminAdmin']);
// ===== Sort parent tabs =====
$position = 0;
foreach ($parent as $id) {
Db::getInstance()->update('tab', array('position' => $position++), 'id_tab = '.(int)$id);
}
$sql = 'SELECT id_tab FROM '._DB_PREFIX_.'tab
WHERE id_tab NOT IN ('.implode(', ', $parent).')
AND id_parent = 0';
$id_tabs = Db::getInstance()->executeS($sql);
if (is_array($id_tabs) && count($id_tabs)) {
foreach (Db::getInstance()->executeS($sql) as $row) {
Db::getInstance()->update('tab', array('position' => $position++), 'id_tab = '.$row['id_tab']);
}
}
}
function get_tab_id($class_name)
{
static $cache = array();
if (!isset($cache[$class_name])) {
$cache[$class_name] = Db::getInstance()->getValue('SELECT id_tab FROM '._DB_PREFIX_.'tab WHERE class_name = \''.pSQL($class_name).'\'');
}
return $cache[$class_name];
}
/* DO NOT REMOVE THIS FUNCTION !
function get_tab_langs($classname)
{
$parent_xml = simplexml_load_file(_PS_INSTALL_DATA_PATH_.'xml/tab.xml');
$result = $parent_xml->xpath('entities/tab[class_name=\''.$classname.'\']');
$id = (string)$result[0]['id'];
foreach (array('en', 'fr', 'es', 'de', 'it') as $iso)
{
$xml = simplexml_load_file(_PS_INSTALL_LANGS_PATH_.$iso.'/data/tab.xml');
$result = $xml->xpath('tab[@id=\''.$id.'\']');
$values[$iso] = (string)$result[0]['name'];
}
$return = '';
foreach ($values as $iso => $lang)
$return .= $iso.':'.$lang.'|';
return utf8_decode(rtrim($return, '|'));
}
*/

View File

@@ -0,0 +1,115 @@
<?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\Entity\Language;
use PrestaShopBundle\Install\LanguageList;
use PrestaShopBundle\Install\XmlLoader;
/**
* Migrate BO tabs for 1.7 (new reorganization of BO)
*/
function migrate_tabs_17()
{
include_once __DIR__.'/add_new_tab.php';
/* first make some room for new tabs */
$moduleTabs = Db::getInstance()->executeS(
'SELECT id_parent FROM '._DB_PREFIX_.'tab WHERE module IS NOT NULL AND module != "" ORDER BY id_tab ASC'
);
$moduleParents = array();
foreach ($moduleTabs as $tab) {
$idParent = $tab['id_parent'];
$moduleParents[$idParent] = Db::getInstance()->getValue('SELECT class_name FROM '._DB_PREFIX_.'tab WHERE id_tab='.$idParent);
}
/* delete the old structure */
Db::getInstance()->execute(
'DELETE t, tl FROM '._DB_PREFIX_.'tab t JOIN '._DB_PREFIX_.'tab_lang tl ON (t.id_tab=tl.id_tab) WHERE module IS NULL OR module = ""'
);
$defaultLanguage = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
$languageList = LanguageList::getInstance();
$languageList->setLanguage($defaultLanguage->iso_code);
/* insert the new structure */
ProfileCore::resetCacheAccesses();
LanguageCore::resetCache();
if (!populateTab()) {
return false;
}
/* update remaining idParent */
foreach($moduleParents as $idParent => $className) {
if (!empty($className)) {
$idTab = Db::getInstance()->getValue('SELECT id_tab FROM '._DB_PREFIX_.'tab WHERE class_name="'.pSQL($className).'"');
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'tab SET id_parent='.(int)$idTab.' WHERE id_parent='.(int)$idParent);
}
}
return true;
}
function populateTab()
{
$languages = [];
foreach (Language::getLanguages() as $lang) {
$languages[$lang['id_lang']] = $lang['iso_code'];
}
// Because we use 1.7.7+ files but with a not-yet migrated Tab entity, we need to use
// a custom XmlLoader to remove the `enabled` key before inserting to the DB
$xml_loader = new \XmlLoader1700();
$xml_loader->setTranslator(Context::getContext()->getTranslator());
$xml_loader->setLanguages($languages);
try {
$xml_loader->populateEntity('tab');
} catch (PrestashopInstallerException $e) {
return false;
}
return true;
}
class XmlLoader1700 extends XmlLoader
{
public function createEntityTab($identifier, array $data, array $data_lang): void
{
if (isset($data['enabled'])) {
unset($data['enabled']);
}
if (isset($data['wording'])) {
unset($data['wording']);
}
if (isset($data['wording_domain'])) {
unset($data['wording_domain']);
}
parent::createEntityTab($identifier, $data, $data_lang);
}
}

View File

@@ -0,0 +1,56 @@
<?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)
*/
/**
* Migrate BO tabs for multi-shop new reorganization
*/
function migrate_tabs_multi_shop()
{
include_once __DIR__.'/add_new_tab.php';
include_once __DIR__.'/migrate_tabs_15.php';
$nbr_shop = Db::getInstance()->getValue('SELECT count(id_shop) FROM '._DB_PREFIX_.'shop');
$tab_shop_group_active = false;
//check if current configuration has more than one shop
if ($nbr_shop > 1) {
Db::getInstance()->update('configuration', array('value' => true), 'name = \'PS_MULTISHOP_FEATURE_ACTIVE\'');
$tab_shop_group_active = true;
}
// ===== remove AdminParentShop from BO menu =====
$admin_parent_shop_id = get_tab_id('AdminParentShop');
$admin_shop_group_id = get_tab_id('AdminShopGroup');
Db::getInstance()->delete('tab', 'id_tab IN ('.(int)$admin_shop_group_id.', '.(int)$admin_parent_shop_id.')');
Db::getInstance()->delete('tab_lang', 'id_tab IN ('.(int)$admin_shop_group_id.', '.(int)$admin_parent_shop_id.')');
// ===== add AdminShopGroup to parent AdminTools =====
$admin_shop_group_id = add_new_tab('AdminShopGroup', 'en:Multi-shop|fr:Multiboutique|es:Multi-tienda|de:Multi-shop|it:Multi-shop', get_tab_id('AdminTools'), true);
Db::getInstance()->update('tab', array('active' => $tab_shop_group_active), 'id_tab = '.(int)$admin_shop_group_id);
// ===== hide AdminShopUrl and AdminShop =====
Db::getInstance()->update('tab', array('id_parent' => '-1'), 'id_tab IN ('.get_tab_id('AdminShop').', '.get_tab_id('AdminShopUrl').')');
}

View File

@@ -0,0 +1,39 @@
<?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 module_blockwishlist_multishop()
{
$id_module = Db::getInstance()->getValue('SELECT id_module FROM '._DB_PREFIX_.'module where name="blockwishlist"');
if ($id_module) {
$res = Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'wishlist`
ADD `id_shop` INTEGER NOT NULL default \'1\' AFTER `counter`,
ADD `id_group_shop` INTEGER NOT NULL default \'1\' AFTER `id_shop`');
return $res;
}
return true;
}

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)
*/
function module_reinstall_blockmyaccount()
{
$res = true;
$id_module = Db::getInstance()->getValue('SELECT id_module FROM '._DB_PREFIX_.'module where name="blockmyaccount"');
if ($id_module) {
$res &= Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'hook`
(`name`, `title`, `description`, `position`) VALUES
("displayMyAccountBlock", "My account block", "Display extra informations inside the \"my account\" block", 1)');
// register left column, and header, and addmyaccountblockhook
$hooks = array('leftColumn', 'header');
foreach ($hooks as $hook_name) {
// do not pSql hook_name
$row = Db::getInstance()->getRow('SELECT h.id_hook, '.$id_module.' as id_module, MAX(hm.position)+1 as position
FROM `'._DB_PREFIX_.'hook_module` hm
LEFT JOIN `'._DB_PREFIX_.'hook` h on hm.id_hook=h.id_hook
WHERE h.name = "'.$hook_name.'" group by id_hook');
$res &= Db::getInstance()->insert('hook_module', $row);
}
return $res;
}
return true;
}

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)
*/
function module_reinstall_blocksearch()
{
$res = true;
$id_module = Db::getInstance()->getValue('SELECT id_module FROM '._DB_PREFIX_.'module where name="blocksearch"');
if ($id_module) {
$res &= Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'hook`
(`name`, `title`, `description`, `position`) VALUES
("displayMyAccountBlock", "My account block", "Display extra informations inside the \"my account\" block", 1)');
// register left column, and header, and addmyaccountblockhook
$hooks = array('top', 'header');
foreach ($hooks as $hook_name) {
// do not pSql hook_name
$row = Db::getInstance()->getRow('SELECT h.id_hook, '.$id_module.' as id_module, MAX(hm.position)+1 as position
FROM `'._DB_PREFIX_.'hook_module` hm
LEFT JOIN `'._DB_PREFIX_.'hook` h on hm.id_hook=h.id_hook
WHERE h.name = "'.$hook_name.'" group by id_hook');
$res &= Db::getInstance()->insert('hook_module', $row);
}
return $res;
}
return true;
}

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)
*/
function move_crossselling()
{
if (Db::getInstance()->executeS('SELECT FROM `'._DB_PREFIX_.'module` WHERE `name` = \'crossselling\'')) {
Db::getInstance()->execute('
INSERT INTO `'._DB_PREFIX_.'hook_module` (`id_module`, `id_hook`, `position`)
VALUES ((SELECT `id_module` FROM `'._DB_PREFIX_.'module` WHERE `name` = \'crossselling\'), 9, (SELECT max_position FROM (SELECT MAX(position)+1 as max_position FROM `'._DB_PREFIX_.'hook_module` WHERE `id_hook` = 9) tmp))');
}
}

View File

@@ -0,0 +1,77 @@
<?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)
*/
/**
* Move all translation modules files 1.4 for a good architecture in 1.5
*/
function move_translations_module_file()
{
$res = true;
// Get all languages
$languages = Db::getInstance()->executeS('
SELECT *
FROM `'._DB_PREFIX_.'lang`
');
// Get the list of modules
$modules = scandir(_PS_MODULE_DIR_, SCANDIR_SORT_NONE);
$error_list = array();
// Scan all modules and check if translation file exists
foreach ($modules as $module_name) {
// Check if is a good module
if (in_array($module_name, array('.', '..', '.svn', '.htaccess', 'index.php', 'autoupgrade')) || !is_dir(_PS_MODULE_DIR_.'/'.$module_name)) {
continue;
}
foreach ($languages as $lang) {
// Name for the old file and the new file
$old_file = _PS_MODULE_DIR_.$module_name.'/'.$lang['iso_code'].'.php';
if (!@file_exists($old_file)) {
continue;
}
$dir_translations = _PS_MODULE_DIR_.$module_name.'/translations/';
$new_file = $dir_translations.$lang['iso_code'].'.php';
// Create folder if no exist
if (!is_dir($dir_translations)) {
$res &= mkdir($dir_translations, 0777);
}
if (!@rename($old_file, $new_file)) {
$error_list[] = $module_name.' - '.$lang['iso_code']."<br/>\r\n";
$res &= false;
}
}
}
if (!$res||(count($error_list)>0)) {
return array('error' => 1, 'msg' => implode("\r\n<br/>", $error_list));
} else {
return true;
}
}

View File

@@ -0,0 +1,43 @@
<?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 outstanding_allow_amount1530()
{
$column_exist = Db::getInstance()->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.'address`');
$column_formated = array();
$res = true;
if ($column_exist) {
foreach ($column_exist as $c) {
$column_formated[] = $c['Field'] ;
}
if (in_array('outstanding_allow_amount', $column_formated)) {
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'address` CHANGE `outstanding_allow_amount` `outstanding_allow_amount` DECIMAL(20, 6) NOT NULL DEFAULT 0.000000');
}
}
return $res;
}

View File

@@ -0,0 +1,44 @@
<?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 p15010_drop_column_id_address_if_exists()
{
$res = true;
$exists = Db::getInstance()->executeS('SHOW TABLES LIKE "'._DB_PREFIX_.'supplier"');
if (count($exists)) {
$fields = Db::getInstance()->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.'supplier`');
foreach ($fields as $k => $field) {
$fields[$k] = $field['Field'];
}
if (in_array('id_address', $fields)) {
$res &= Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'supplier`
DROP `id_address`');
}
}
return $res;
}

View File

@@ -0,0 +1,192 @@
<?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 p15012_add_missing_columns()
{
$errors = array();
$db = Db::getInstance();
$q_list = array();
// columns must exists
$q_list['carrier']['id_reference']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'carrier`
CHANGE `id_reference` `id_reference` int(10) unsigned NOT NULL';
$q_list['carrier']['id_reference']['add'] = 'ALTER TABLE `'._DB_PREFIX_.'carrier`
ADD `id_reference` int(10) unsigned NOT NULL';
$q_list['carrier']['id_tax_rules_group']['add'] = 'ALTER TABLE `'._DB_PREFIX_.'carrier`
ADD `id_tax_rules_group` INT(10) unsigned DEFAULT "0" AFTER `id_reference`';
$q_list['cart']['order_reference']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'cart`
DROP COLUMN `order_reference`';
$q_list['cart']['id_shop_group']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'cart`
CHANGE `id_shop_group` `id_shop_group` int(11) unsigned NOT NULL DEFAULT "1"';
$q_list['cart']['id_shop_group']['add'] = 'ALTER TABLE `'._DB_PREFIX_.'cart`
ADD `id_shop_group` int(11) unsigned NOT NULL DEFAULT "1"';
$q_list['cart_product']['id_shop']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'cart_product`
CHANGE `id_shop` `id_shop` int(10) unsigned NOT NULL DEFAULT "1" AFTER `id_address_delivery`';
$q_list['cart_product']['id_shop']['add'] = 'ALTER TABLE `'._DB_PREFIX_.'cart_product`
ADD `id_shop` int(10) unsigned NOT NULL DEFAULT "1" AFTER `id_address_delivery`';
$q_list['cart_product']['id_product_attribute']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'cart_product`
CHANGE `id_product_attribute` `id_product_attribute` int(10) unsigned DEFAULT NULL AFTER `id_shop`';
$q_list['cart_product']['id_product_attribute']['add'] = 'ALTER TABLE `'._DB_PREFIX_.'cart_product`
ADD `id_product_attribute` int(10) unsigned DEFAULT NULL AFTER `id_shop`';
$q_list['cart_rule_product_rule']['quantity']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'cart_rule_product_rule`
DROP COLUMN `quantity`';
$q_list['connections']['id_shop_group']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'connections`
CHANGE id_shop_group `id_shop_group` int(11) unsigned NOT NULL DEFAULT "1" AFTER id_connections';
$q_list['country']['display_tax_label']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'country`
CHANGE display_tax_label `display_tax_label` tinyint(1) NOT NULL AFTER zip_code_format';
$q_list['currency']['active']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'currency`
CHANGE active active tinyint(1) unsigned NOT NULL DEFAULT "1"';
$q_list['customer']['id_shop_group']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'customer`
CHANGE id_shop_group id_shop_group int(11) unsigned NOT NULL DEFAULT "1"';
$q_list['employee']['bo_uimode']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'employee`
DROP `bo_uimode`';
$q_list['meta_lang']['url_rewrite']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'meta_lang`
CHANGE url_rewrite url_rewrite varchar(254) NOT NULL';
$q_list['order_detail']['id_warehouse']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'order_detail`
CHANGE `id_warehouse` id_warehouse int(10) unsigned DEFAULT "0"';
$q_list['order_detail']['reduction_amount_tax_incl']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'order_detail`
CHANGE `reduction_amount_tax_incl` reduction_amount_tax_incl DEC(20,6) NOT NULL DEFAULT "0.000000"';
$q_list['order_detail']['reduction_amount_tax_excl']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'order_detail`
CHANGE `reduction_amount_tax_excl` reduction_amount_tax_excl DEC(20,6) NOT NULL DEFAULT "0.000000"';
$q_list['order_detail']['ecotax_tax_rate']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'order_detail`
CHANGE `ecotax_tax_rate` ecotax_tax_rate DEC(5,3) NOT NULL DEFAULT "0.000"';
$q_list['order_detail']['total_price_tax_incl']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'order_detail`
CHANGE `total_price_tax_incl` total_price_tax_incl DEC(20,6) NOT NULL DEFAULT "0.000000"';
$q_list['order_detail']['total_price_tax_excl']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'order_detail`
CHANGE `total_price_tax_excl` total_price_tax_excl DEC(20,6) NOT NULL DEFAULT "0.000000"';
$q_list['order_detail']['unit_price_tax_incl']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'order_detail`
CHANGE `unit_price_tax_incl` unit_price_tax_incl DEC(20,6) NOT NULL DEFAULT "0.000000"';
$q_list['order_detail']['unit_price_tax_excl']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'order_detail`
CHANGE `unit_price_tax_excl` unit_price_tax_excl DEC(20,6) NOT NULL DEFAULT "0.000000"';
$q_list['order_detail']['total_shipping_price_tax_incl']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'order_detail`
CHANGE `total_shipping_price_tax_incl` total_shipping_price_tax_incl DEC(20,6) NOT NULL DEFAULT "0.000000"';
$q_list['order_detail']['total_shipping_price_tax_excl']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'order_detail`
CHANGE `total_shipping_price_tax_excl` total_shipping_price_tax_excl DEC(20,6) NOT NULL DEFAULT "0.000000"';
$q_list['order_detail']['purchase_supplier_price']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'order_detail`
CHANGE `purchase_supplier_price` purchase_supplier_price DEC(20,6) NOT NULL DEFAULT "0.000000"';
$q_list['order_detail']['original_product_price']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'order_detail`
CHANGE `original_product_price` original_product_price DEC(20,6) NOT NULL DEFAULT "0.000000"';
$q_list['order_detail_tax']['unit_amount']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'order_detail_tax`
CHANGE `unit_amount` unit_amount DEC(10,6) NOT NULL DEFAULT "0.000000"';
$q_list['order_detail_tax']['total_amount']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'order_detail_tax`
CHANGE `total_amount` total_amount DEC(10,6) NOT NULL DEFAULT "0.000000"';
$q_list['order_invoice']['note']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'order_invoice`
CHANGE `note` note text';
$q_list['order_payment']['id_order_invoice']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'order_payment`
CHANGE `id_order_invoice` id_order_invoice int(10) unsigned NOT NULL DEFAULT 0';
$q_list['orders']['reference']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'orders`
CHANGE `reference` reference varchar(9) DEFAULT NULL';
$q_list['orders']['id_shop_group']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'orders`
CHANGE `id_shop_group` id_shop_group int(11) unsigned NOT NULL DEFAULT "1"';
$q_list['product']['unity']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'product`
CHANGE `unity` unity varchar(255) DEFAULT NULL';
$q_list['product']['width']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'product`
CHANGE `width` `width` float NOT NULL DEFAULT "0"';
$q_list['product']['height']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'product`
CHANGE `height` `height` float NOT NULL DEFAULT "0"';
$q_list['product']['depth']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'product`
CHANGE `depth` `depth` float NOT NULL DEFAULT "0"';
$q_list['product']['minimal_quantity']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'product`
CHANGE `minimal_quantity` `minimal_quantity` int(10) unsigned NOT NULL DEFAULT "1"';
$q_list['product_attribute']['ecotax']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'product_attribute`
CHANGE `ecotax` ecotax decimal(17,6) NOT NULL DEFAULT "0.000000"';
$q_list['stock_mvt_reason']['id_stock_mvt_reason']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'stock_mvt_reason`
CHANGE `id_stock_mvt_reason` id_stock_mvt_reason int(11) unsigned NOT NULL';
$q_list['stock_mvt_reason_lang']['id_stock_mvt_reason']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'stock_mvt_reason_lang`
CHANGE `id_stock_mvt_reason` id_stock_mvt_reason int(11) unsigned NOT NULL';
$q_list['stock_mvt_reason_lang']['id_lang']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'stock_mvt_reason_lang`
CHANGE `id_lang` id_lang int(11) unsigned NOT NULL';
$q_list['supply_order']['reference']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'supply_order`
CHANGE `reference` reference varchar(64) NOT NULL';
$q_list['tax']['deleted']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'tax`
CHANGE `deleted` deleted tinyint(1) unsigned NOT NULL DEFAULT "0"';
$q_list['carrier']['need_range']['mod'] = 'ALTER TABLE `'._DB_PREFIX_.'carrier`
CHANGE `need_range` need_range tinyint(1) unsigned NOT NULL DEFAULT "0" AFTER shipping_external';
foreach ($q_list as $table => $cols) {
if (empty($table)) {
continue;
}
$list_fields = $db->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.$table.'`');
if (is_array($list_fields)) {
foreach ($list_fields as $k => $field) {
$list_fields[$k] = $field['Field'];
}
}
if (is_array($cols)) {
foreach ($cols as $col => $q) {
// do only if column exists
if (is_array($list_fields) && in_array($col, $list_fields)) {
$do = 'mod';
} else {
$do = 'add';
}
if (!empty($q[$do])) {
if (!$db->execute($q[$do])) {
$errors[] = '<subquery><query>'.$q[$do].'</query><error>'.$db->getMsgError().'</error></subquery>';
}
}
}
}
}
if (count($errors) > 0) {
$msg = implode("\r", $errors);
return array('error' => 1, 'msg' => $msg);
} else {
return true;
}
}

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 p15013_add_missing_columns()
{
$errors = array();
$db = Db::getInstance();
$id_module = $db->getValue('SELECT id_module FROM `'._DB_PREFIX_.'module` WHERE name="statssearch"');
if ($id_module) {
$list_fields = Db::getInstance()->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.'statssearch`');
foreach ($list_fields as $k => $field) {
$list_fields[$k] = $field['Field'];
}
if (!in_array('id_group_shop', $list_fields)) {
if (!Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'statssearch`
ADD `id_group_shop` INT(10) NOT NULL default "1" AFTER id_statssearch')) {
$errors[] = $db->getMsgError();
}
}
if (!in_array('id_shop', $list_fields)) {
if (!Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'statssearch`
ADD `id_shop` INT(10) NOT NULL default "1" AFTER id_statssearch')) {
$errors[] = $db->getMsgError();
}
}
}
if (count($errors)) {
return array('error' => 1, 'msg' => implode(',', $errors)) ;
}
}

View File

@@ -0,0 +1,51 @@
<?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 p15014_add_missing_columns()
{
$errors = array();
$db = Db::getInstance();
// for module statssearch
$id_module = $db->getValue('SELECT id_module FROM `'._DB_PREFIX_.'module` WHERE name="statssearch"');
if ($id_module) {
$list_fields = $db->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.'statssearch`');
foreach ($list_fields as $k => $field) {
$list_fields[$k] = $field['Field'];
}
if (in_array('id_group_shop', $list_fields)) {
if (!Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'statssearch`
CHANGE `id_group_shop` `id_shop_group` INT(10) NOT NULL default "1"')) {
$errors[] = $db->getMsgError();
}
}
}
if (count($errors)) {
return array('error' => 1, 'msg' => implode(',', $errors)) ;
}
}

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)
*/
/**
* This function copy all images located in /install/data/img/* that are missing in previous upgrade
* in the matching img dir. This does not modify images that are already present.
*
*/
function p15014_copy_missing_images_tab_from_installer()
{
$res = true;
$DIR_SEP = DIRECTORY_SEPARATOR;
if (!defined('_PS_ROOT_DIR_')) {
define('_PS_ROOT_DIR_', realpath(INSTALL_PATH.'/../'));
}
$install_dir_path = INSTALL_PATH.$DIR_SEP.'data'.$DIR_SEP.'img';
$img_dir = scandir($install_dir_path, SCANDIR_SORT_NONE);
foreach ($img_dir as $dir) {
if ($dir[0] == '.' || !is_dir($install_dir_path.$DIR_SEP.$dir)) {
continue;
}
$img_subdir = scandir($install_dir_path . $DIR_SEP . $dir, SCANDIR_SORT_NONE);
foreach ($img_subdir as $img) {
if ($img[0] == '.') {
continue;
}
if (!file_exists(_PS_ROOT_DIR_.$DIR_SEP.'img'.$DIR_SEP.$dir.$DIR_SEP.$img) && file_exists($install_dir_path.$DIR_SEP.$dir.$DIR_SEP.$img)) {
$res &= copy($install_dir_path.$DIR_SEP.$dir.$DIR_SEP.$img, _PS_ROOT_DIR_.$DIR_SEP.'img'.$DIR_SEP.$dir.$DIR_SEP.$img);
}
}
}
return $res;
}

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 p15014_upgrade_sekeywords()
{
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'sekeyword` ADD id_shop INTEGER UNSIGNED NOT NULL DEFAULT 1 AFTER id_sekeyword');
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'sekeyword` ADD id_shop_group INTEGER UNSIGNED NOT NULL DEFAULT 1 AFTER id_shop');
return true;
}

View File

@@ -0,0 +1,48 @@
<?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 p15015_blockadvertising_extension()
{
if (!defined('_PS_ROOT_DIR_')) {
define('_PS_ROOT_DIR_', realpath(INSTALL_PATH.'/../'));
}
// Try to update with the extension of the image that exists in the module directory
if (@file_exists(_PS_ROOT_DIR_.'/modules/blockadvertising')) {
foreach (@scandir(_PS_ROOT_DIR_ . '/modules/blockadvertising', SCANDIR_SORT_NONE) as $file) {
if (in_array($file, array('advertising.jpg', 'advertising.gif', 'advertising.png'))) {
$exist = Db::getInstance()->getValue('SELECT `id_configuration` FROM `'._DB_PREFIX_.'configuration` WHERE `name` = \'BLOCKADVERT_IMG_EXT\'');
if ($exist) {
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'configuration` SET value = "'.pSQL(substr($file, strrpos($file, '.') + 1)).'" WHERE `name` = \'BLOCKADVERT_IMG_EXT\'');
} else {
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'configuration` (name, value) VALUES ("BLOCKADVERT_IMG_EXT", "'.pSQL(substr($file, strrpos($file, '.') + 1)).'"');
}
}
}
}
return true;
}

View File

@@ -0,0 +1,98 @@
<?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 p15016_add_missing_columns()
{
$errors = array();
$id_module = Db::getInstance()->getValue('SELECT id_module FROM `'._DB_PREFIX_.'module` WHERE name="blockreinsurance"');
if ($id_module) {
$list_fields = Db::getInstance()->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.'reinsurance`');
foreach ($list_fields as $k => $field) {
$list_fields[$k] = $field['Field'];
}
if (in_array('id_contactinfos', $list_fields)) {
if (!Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'reinsurance` CHANGE `id_contactinfos` `id_reinsurance` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT')) {
$errors[] = Db::getInstance()->getMsgError();
}
}
if (!in_array('id_shop', $list_fields)) {
if (!Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'reinsurance` ADD `id_shop` INT(10) NOT NULL default "1" AFTER id_reinsurance')) {
$errors[] = Db::getInstance()->getMsgError();
}
}
if (in_array('filename', $list_fields)) {
if (!Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'reinsurance` CHANGE `filename` `file_name` VARCHAR(100) NOT NULL')) {
$errors[] = Db::getInstance()->getMsgError();
}
}
$list_fields = Db::getInstance()->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.'reinsurance_lang`');
if (!is_array($list_fields) || $list_fields == false) {
$return = Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'reinsurance_lang` (
`id_reinsurance` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`id_lang` int(10) unsigned NOT NULL ,
`text` VARCHAR(300) NOT NULL,
PRIMARY KEY (`id_reinsurance`, `id_lang`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 ;');
if (!$return) {
$errors[] = Db::getInstance()->getMsgError();
}
}
}
$id_module = Db::getInstance()->getValue('SELECT id_module FROM `'._DB_PREFIX_.'module` WHERE name="blocktopmenu"');
if ($id_module) {
$list_fields = Db::getInstance()->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.'linksmenutop`');
foreach ($list_fields as $k => $field) {
$list_fields[$k] = $field['Field'];
}
if (in_array('id_link', $list_fields) && !in_array('id_linksmenutop', $list_fields)) {
if (!Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'linksmenutop` CHANGE `id_link` `id_linksmenutop` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT')) {
$errors[] = Db::getInstance()->getMsgError();
}
}
$list_fields = Db::getInstance()->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.'linksmenutop_lang`');
foreach ($list_fields as $k => $field) {
$list_fields[$k] = $field['Field'];
}
if (in_array('id_link', $list_fields) && !in_array('id_linksmenutop', $list_fields)) {
if (!Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'linksmenutop_lang` CHANGE `id_link` `id_linksmenutop` INT(10) UNSIGNED NOT NULL')) {
$errors[] = Db::getInstance()->getMsgError();
}
}
}
if (count($errors)) {
return array('error' => 1, 'msg' => implode(',', $errors)) ;
}
}

View File

@@ -0,0 +1,51 @@
<?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 p15017_add_id_shop_to_primary_key()
{
// Drop old indexes
$old_indexes = array(
'category_lang_index' => 'category_lang',
'shipper_lang_index' => 'carrier_lang',
'product_lang_index' => 'product_lang',
'id_category_shop' => 'category_shop',
);
foreach ($old_indexes as $index => $table) {
if (Db::getInstance()->executeS('SHOW INDEX FROM `'._DB_PREFIX_.$table.'` WHERE Key_name = "'.$index.'"')) {
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.$table.'` DROP KEY `'.$index.'`');
}
}
// The former primary keys where set on id_object and id_lang. They must now be set on id_shop too.
foreach (array('product', 'category', 'meta', 'carrier') as $table) {
if (Db::getInstance()->executeS('SHOW INDEX FROM `'._DB_PREFIX_.$table.'` WHERE Key_name = "PRIMARY"')) {
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.$table.'_lang` DROP PRIMARY KEY');
}
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.$table.'_lang` ADD PRIMARY KEY (`id_'.$table.'`, `id_shop`, `id_lang`)');
}
return true;
}

View File

@@ -0,0 +1,149 @@
<?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 p15018_change_image_types()
{
$replace_types = array(
'products' => array(
'small' => array('small_default', '98', '98'),
'medium' => array('medium_default', '125', '125'),
'large' => array('large_default', '458', '458'),
'thickbox' => array('thickbox_default', '800', '800'),
'home' => array('home_default', '270', '270'),
),
'others' => array(
'category' => array('category_default', '870', '217'),
'large_scene' => array('scene_default', '520', '189'),
'thumb_scene' => array('m_scene_default', '161', '58'),
),
);
$new_types = array(
'products' => array(
'small' => array('cart_default', '80', '80'),
),
);
foreach ($new_types as $type => $type_array) {
foreach ($type_array as $old_type => $new_type) {
if (is_array($new_type) && count($new_type)) {
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'image_type` (
SELECT NULL, "'.$new_type[0].'", "'.$new_type[1].'", "'.$new_type[2].'", products, categories, manufacturers, suppliers, scenes, stores
FROM `'._DB_PREFIX_.'image_type` WHERE name = "'.$old_type.'" LIMIT 1)');
}
}
}
$option = (bool)Db::getInstance()->getValue('SELECT id_theme FROM `'._DB_PREFIX_.'theme` WHERE directory != "default" AND directory != "prestashop"');
// If there is another theme than the default one, duplicate
if ($option) {
foreach ($replace_types as $type => $type_array) {
foreach ($type_array as $old_type => $new_type) {
if (is_array($new_type) && count($new_type)) {
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'image_type` (
SELECT NULL, "'.$new_type[0].'", "'.$new_type[1].'", "'.$new_type[2].'", products, categories, manufacturers, suppliers, scenes, stores
FROM `'._DB_PREFIX_.'image_type` WHERE name = "'.$old_type.'" LIMIT 1)');
}
// But if there is only the default one, we can update de names
else {
foreach ($replace_types as $type => $type_array) {
foreach ($type_array as $old_type => $new_type) {
if (is_array($new_type) && count($new_type)) {
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'image_type` SET name = "'.$new_type[0].'" WHERE name = "'.$old_type.'"');
}
}
}
}
}
}
}
// If there is less than 500 images, copy to the new format (if there is more, the merchant will have to click "regenerate thumbnails")
$result = Db::getInstance()->executeS('SELECT id_image, id_product FROM `'._DB_PREFIX_.'image`');
if (Db::getInstance()->numRows() < 500) {
if (!defined('_PS_ROOT_DIR_')) {
define('_PS_ROOT_DIR_', realpath(INSTALL_PATH.'/../'));
}
foreach ($result as $row) {
if (file_exists(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.'p'.DIRECTORY_SEPARATOR.$row['id_product'].'-'.$row['id_image'].'.jpg')) {
foreach ($replace_types['products'] as $old_type => $new_type) {
if (is_array($new_type) && count($new_type)) {
p15018_copy_or_rename(
_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.'p'.DIRECTORY_SEPARATOR.$row['id_product'].'-'.$row['id_image'].'-'.$old_type.'.jpg',
_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.'p'.DIRECTORY_SEPARATOR.$row['id_product'].'-'.$row['id_image'].'-'.$new_type[0].'.jpg',
$option
);
}
}
}
$folder = implode(DIRECTORY_SEPARATOR, str_split((string)$row['id_image'])).DIRECTORY_SEPARATOR;
if (file_exists(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.'p'.DIRECTORY_SEPARATOR.$folder.$row['id_image'].'.jpg')) {
foreach ($replace_types['products'] as $old_type => $new_type) {
if (is_array($new_type) && count($new_type)) {
p15018_copy_or_rename(
_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.'p'.DIRECTORY_SEPARATOR.$folder.$row['id_image'].'-'.$old_type.'.jpg',
_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.'p'.DIRECTORY_SEPARATOR.$folder.$row['id_image'].'-'.$new_type[0].'.jpg',
$option
);
}
}
}
}
// Then the other entities (if there is less than 500 products, that should not be a problem)
$directories = array('p', 'c', 'm', 's', 'su', 'scenes', 'scenes'.DIRECTORY_SEPARATOR.'thumbs', 'st');
foreach ($directories as $directory) {
foreach (scandir(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR . $directory, SCANDIR_SORT_NONE) as $file) {
if (!preg_match('/^([0-9]+|[a-z]{2}-default)\-[a-z_-]+\.jpg$/i', $file)) {
continue;
}
foreach ($replace_types as $type => $type_array) {
foreach ($type_array as $old_type => $new_type) {
if (preg_match('/^([0-9]+|[a-z]{2}-default)\-'.$old_type.'\.jpg$/i', $file, $matches) && is_array($new_type) && count($new_type)) {
p15018_copy_or_rename(
_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.$directory.DIRECTORY_SEPARATOR.$matches[1].'-'.$old_type.'.jpg',
_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'img'.DIRECTORY_SEPARATOR.$directory.DIRECTORY_SEPARATOR.$matches[1].'-'.$new_type[0].'.jpg',
$option
);
}
}
}
}
}
}
return true;
}
function p15018_copy_or_rename($from, $to, $option)
{
if ($option) {
@copy($from, $to);
} else {
@rename($from, $to);
}
}

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 p1531_redirect_type()
{
include_once __DIR__.'/generic_add_missing_column.php';
$result = generic_add_missing_column('product', array('redirect_type' => 'ENUM(\'\', \'404\', \'301\', \'302\') NOT NULL DEFAULT \'404\' AFTER `active`'));
$result &= generic_add_missing_column('product_shop', array('redirect_type' => 'ENUM(\'\', \'404\', \'301\', \'302\') NOT NULL DEFAULT \'404\' AFTER `active`'));
return $result;
}

View File

@@ -0,0 +1,78 @@
<?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 p1540_add_missing_columns()
{
$errors = array();
$id_module = Db::getInstance()->getValue('SELECT id_module FROM `'._DB_PREFIX_.'module` WHERE name = "loyalty"');
if ($id_module) {
$list_fields = Db::getInstance()->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.'loyalty`');
foreach ($list_fields as $k => $field) {
$list_fields[$k] = $field['Field'];
}
if (in_array('id_discount', $list_fields)) {
if (!Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'loyalty` CHANGE `id_discount` `id_cart_rule` INT( 10 ) UNSIGNED NULL DEFAULT NULL')) {
$errors[] = Db::getInstance()->getMsgError();
}
}
}
$id_module = Db::getInstance()->getValue('SELECT id_module FROM `'._DB_PREFIX_.'module` WHERE name = "blocklayered"');
if ($id_module) {
$list_fields = Db::getInstance()->executeS('SHOW FIELDS FROM `'._DB_PREFIX_.'layered_product_attribute`');
if (is_array($list_fields)) {
foreach ($list_fields as $k => $field) {
$list_fields[$k] = $field['Field'];
}
if (!in_array('id_shop', $list_fields)) {
if (!Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'layered_product_attribute` ADD `id_shop` INT( 10 ) UNSIGNED NOT NULL DEFAULT "1" AFTER `id_attribute_group`')) {
$errors[] = Db::getInstance()->getMsgError();
}
}
}
}
$key_exists = Db::getInstance()->executeS('SHOW INDEX FROM `'._DB_PREFIX_.'stock_available` WHERE KEY_NAME = "product_sqlstock"');
if (is_array($key_exists) && count($key_exists)) {
if (!Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'stock_available` DROP INDEX `product_sqlstock`')) {
$errors[] = Db::getInstance()->getMsgError();
}
}
$key_exists = Db::getInstance()->executeS('SHOW INDEX FROM `'._DB_PREFIX_.'stock_available` WHERE KEY_NAME = "id_product_2"');
if (is_array($key_exists) && count($key_exists)) {
if (!Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'stock_available` DROP INDEX `id_product_2`')) {
$errors[] = Db::getInstance()->getMsgError();
}
}
if (count($errors)) {
return array('error' => 1, 'msg' => implode(',', $errors)) ;
}
}

View File

@@ -0,0 +1,48 @@
<?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 p16011_media_server()
{
$new_settings = $prev_settings = file_get_contents(_PS_ROOT_DIR_.'/config/settings.inc.php');
if (preg_match_all('/define\(\'_MEDIA_SERVER_([1-3])_\',\s*?\'(.*?)\'\s*?\)/ism', $new_settings, $matches)) {
$total = (count($matches[1]));
for ($i = 0; $i < $total; ++$i) {
Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'configuration (`name`, `value`, `date_add`, `date_upd`) VALUES (\'PS_MEDIA_SERVER_'.$matches[1][$i].'\', \''.$matches[2][$i].'\', NOW(), NOW())');
}
}
$new_settings = preg_replace('/define\(\'_MEDIA_SERVER_[1-3]_\',\s*?\'.*?\'\s*?\);/ism', '', $new_settings);
if ($new_settings == $prev_settings || (
copy(_PS_ROOT_DIR_.'/config/settings.inc.php', _PS_ROOT_DIR_.'/config/settings.old.php')
&& (bool)file_put_contents(_PS_ROOT_DIR_.'/config/settings.inc.php', $new_settings)
)) {
return true;
}
return false;
}

View File

@@ -0,0 +1,88 @@
<?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 p16012_pack_rework()
{
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'configuration` (`id_configuration`, `name`, `value`, `date_add`, `date_upd`) VALUES (NULL, "PS_PACK_STOCK_TYPE", "0", NOW(), NOW())');
$all_product_in_pack = Db::getInstance()->executeS('SELECT `id_product_item` FROM '._DB_PREFIX_.'pack GROUP BY `id_product_item`');
foreach ($all_product_in_pack as $value) {
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'pack
SET `id_product_attribute_item` = '.(getDefaultAttribute($value['id_product_item']) ? getDefaultAttribute($value['id_product_item']).' ' : '0 ').'
WHERE `id_product_item` = '.$value['id_product_item']);
}
$all_product_pack = Db::getInstance()->executeS('SELECT `id_product_pack` FROM '._DB_PREFIX_.'pack GROUP BY `id_product_pack`');
foreach ($all_product_pack as $value) {
$work_with_stock = 1;
$lang = Db::getInstance()->executeS('SELECT value FROM '._DB_PREFIX_.'configuration WHERE `id_shop` = NULL AND `id_shop_group` = NULL AND `name` = "PS_LANG_DEFAULT"');
$products = getItems($value['id_product_pack']);
foreach ($products as $product) {
if ($product != 1) {
$work_with_stock = 0;
break;
}
}
if ($work_with_stock) {
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'product SET `pack_stock_type` = 1 WHERE `id_product` = '.(int)$value['id_product_pack']);
}
}
}
function getDefaultAttribute($id_product)
{
static $combinations = array();
if (!isset($combinations[$id_product])) {
$combinations[$id_product] = array();
}
if (isset($combinations[$id_product]['default'])) {
return $combinations[$id_product]['default'];
}
$sql = 'SELECT id_product_attribute
FROM '._DB_PREFIX_.'product_attribute
WHERE default_on = 1 AND id_product = '.(int)$id_product;
$result = Db::getInstance()->getValue($sql);
$combinations[$id_product]['default'] = $result ? $result : ($result = Db::getInstance()->getValue('SELECT id_product_attribute
FROM '._DB_PREFIX_.'product_attribute
WHERE id_product = '.(int)$id_product));
return $result;
}
function getItems($id_product)
{
$result = Db::getInstance()->executeS('SELECT id_product_item, quantity FROM '._DB_PREFIX_.'pack where id_product_pack = '.(int)$id_product);
$array_result = array();
foreach ($result as $row) {
$p = Db::getInstance()->executeS('SELECT `advanced_stock_management` FROM '._DB_PREFIX_.'product WHERE `id_product` = '.(int)$row['id_product_item']);
$array_result[] = $p[0]['advanced_stock_management'];
}
return $array_result;
}

Some files were not shown because too many files have changed in this diff Show More