diff --git a/install-new/upgrade/php/convert_product_price.php b/install-new/upgrade/php/convert_product_price.php index 903b153b9..183a9ded5 100644 --- a/install-new/upgrade/php/convert_product_price.php +++ b/install-new/upgrade/php/convert_product_price.php @@ -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; diff --git a/install-new/upgrade/php/create_multistore.php b/install-new/upgrade/php/create_multistore.php index 0938100da..c5a1687fe 100755 --- a/install-new/upgrade/php/create_multistore.php +++ b/install-new/upgrade/php/create_multistore.php @@ -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; +} diff --git a/install-new/upgrade/php/module_reinstall_blockmyaccount.php b/install-new/upgrade/php/module_reinstall_blockmyaccount.php new file mode 100644 index 000000000..1160fd549 --- /dev/null +++ b/install-new/upgrade/php/module_reinstall_blockmyaccount.php @@ -0,0 +1,53 @@ + +* @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; +} + + diff --git a/install-new/upgrade/php/moduleReinstaller.php b/install-new/upgrade/php/module_reinstall_blocksearch.php similarity index 50% rename from install-new/upgrade/php/moduleReinstaller.php rename to install-new/upgrade/php/module_reinstall_blocksearch.php index d54c5dbfd..879699e4b 100644 --- a/install-new/upgrade/php/moduleReinstaller.php +++ b/install-new/upgrade/php/module_reinstall_blocksearch.php @@ -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; } + diff --git a/install-new/upgrade/sql/1.1.0.3.sql b/install-new/upgrade/sql/1.1.0.3.sql index 5fb70c0ab..69e362b29 100644 --- a/install-new/upgrade/sql/1.1.0.3.sql +++ b/install-new/upgrade/sql/1.1.0.3.sql @@ -7,4 +7,4 @@ SET NAMES 'utf8'; DROP TABLE IF EXISTS PREFIX_product_picture; /* PHP */ -/* PHP:moduleReinstaller('blockmyaccount'); */; +/* PHP:module_reinstall_blockmyaccount(); */; diff --git a/install-new/upgrade/sql/1.2.1.0.sql b/install-new/upgrade/sql/1.2.1.0.sql index d11032a29..fc62c7f4d 100644 --- a/install-new/upgrade/sql/1.2.1.0.sql +++ b/install-new/upgrade/sql/1.2.1.0.sql @@ -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(); */;