// various fix in upgrader (for 1.2.1.0 and 1.1.0.3 + convert_product_price ObjectModel no more used)

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12546 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
mMarinetti
2012-01-18 17:35:32 +00:00
parent 37ac5620e0
commit 34e6e95d8e
6 changed files with 112 additions and 19 deletions
@@ -28,7 +28,7 @@
/* Convert product prices from the PS < 1.3 wrong rounding system to the new 1.3 one */
function convert_product_price()
{
$taxes = Tax::getTaxes();
$taxes = Db::getInstance()->executeS('SELECT * FROM '._DB_PREFIX_.'tax');
$taxRates = array();
foreach ($taxes as $data)
$taxRates[$data['id_tax']] = (float)($data['rate']) / 100;
+33 -9
View File
@@ -6,31 +6,49 @@ function create_multistore()
{
$res = true;
$themes = scandir(dirname(__FILE__).'/../../themes');
// @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_.'/themes';
$themes = scandir($all_themes_dir);
foreach ($themes AS $theme)
if (is_dir(dirname(__FILE__).'/../../themes/'.$theme) && $theme[0] != '.' && $theme != 'prestashop')
$res &= Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'theme (`id_theme`, `name`) VALUES(\'\', \''.pSQL($theme).'\')');
if (is_dir($all_themes_dir.'/'.$theme)
&& $theme[0] != '.'
&& $theme != 'prestashop')
{
$sql = 'INSERT INTO
'._DB_PREFIX_.'theme (`id_theme`, name)
VALUES("", "'.Db::getInstance()->escape($theme).'")';
$res &= Db::getInstance()->execute($sql);
}
$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=\''.pSQL(_THEME_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\'');
WHERE `name`="PS_SHOP_DOMAIN"');
$shop_domain_ssl = Db::getInstance()->getValue('SELECT `value`
FROM `'._DB_PREFIX_.'_configuration`
WHERE `name`=\'PS_SHOP_DOMAIN_SSL\'');
WHERE `name`="PS_SHOP_DOMAIN_SSL"');
if(empty($shop_domain))
{
$shop_domain = Tools::getHttpHost();
$shop_domain_ssl = Tools::getHttpHost();
$shop_domain = create_multistore_getHttpHost();
$shop_domain_ssl = create_multistore_getHttpHost();
}
$_PS_DIRECTORY_ = trim(str_replace(' ', '%20', INSTALLER__PS_BASE_URI), '/');
$_PS_DIRECTORY_ = trim(str_replace(' ', '%20', $INSTALLER__PS_BASE_URI), '/');
$_PS_DIRECTORY_ = ($_PS_DIRECTORY_) ? '/'.$_PS_DIRECTORY_.'/' : '/';
$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($_PS_DIRECTORY_).'\', \'\', 1, 1)');
@@ -51,3 +69,9 @@ function create_multistore()
return $res;
}
function create_multistore_getHttpHost()
{
$host = (isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']);
return $host;
}
@@ -0,0 +1,53 @@
<?php
/*
* 2007-2011 PrestaShop
*
* 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.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-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-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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
("myAccountBlock", "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()->AutoExecute(_DB_PREFIX_.'hook_module', $row, 'INSERT');
}
return $res;
}
return true;
}
@@ -25,13 +25,29 @@
* International Registered Trademark & Property of PrestaShop SA
*/
function moduleReinstaller($moduleName, $force = false)
function module_reinstall_blocksearch()
{
$module = Module::getInstanceByName($moduleName);
if (!is_object($module))
die(Tools::displayError());
if ($module->uninstall() OR $force)
return $module->install();
return false;
$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
("myAccountBlock", "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()->AutoExecute(_DB_PREFIX_.'hook_module', $row, 'INSERT');
}
return $res;
}
return true;
}
+1 -1
View File
@@ -7,4 +7,4 @@ SET NAMES 'utf8';
DROP TABLE IF EXISTS PREFIX_product_picture;
/* PHP */
/* PHP:moduleReinstaller('blockmyaccount'); */;
/* PHP:module_reinstall_blockmyaccount(); */;
+1 -1
View File
@@ -13,4 +13,4 @@ INSERT INTO PREFIX_configuration (name, value, date_add, date_upd) VALUES ('PS_T
/* PHP */
/* PHP:update_carrier_url(); */;
/* PHP:moduleReinstaller('blocksearch'); */;
/* PHP:module_reinstall_blocksearch(); */;