From c8ca67eef5c424341159a9209fe3c1626896238b Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Mon, 2 Dec 2013 15:27:47 +0100 Subject: [PATCH] // Fixed upgrade to 1.6.0.1 --- classes/Tools.php | 14 +++--- install-dev/upgrade/php/create_multistore.php | 50 +++++++------------ install-dev/upgrade/sql/1.6.0.2.sql | 8 +++ modules/dashactivity/dashactivity.php | 32 ++++++------ modules/dashgoals/dashgoals.php | 4 +- modules/dashproducts/dashproducts.php | 7 +-- modules/dashtrends/dashtrends.php | 10 ++-- modules/homefeatured/homefeatured.php | 2 +- 8 files changed, 62 insertions(+), 65 deletions(-) create mode 100644 install-dev/upgrade/sql/1.6.0.2.sql diff --git a/classes/Tools.php b/classes/Tools.php index 547a3fb66..18c2a3499 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -2101,14 +2101,14 @@ exit; */ public static function displayAsDeprecated($message = null) { - $backtrace = debug_backtrace(); - $callee = next($backtrace); - $class = isset($callee['class']) ? $callee['class'] : null; - if ($message === null) - $message = 'The function '.$callee['function'].' (Line '.$callee['line'].') is deprecated and will be removed in the next major version.'; - $error = 'Function '.$callee['function'].'() is deprecated in '.$callee['file'].' on line '.$callee['line'].'
'; + $backtrace = debug_backtrace(); + $callee = next($backtrace); + $class = isset($callee['class']) ? $callee['class'] : null; + if ($message === null) + $message = 'The function '.$callee['function'].' (Line '.$callee['line'].') is deprecated and will be removed in the next major version.'; + $error = 'Function '.$callee['function'].'() is deprecated in '.$callee['file'].' on line '.$callee['line'].'
'; - Tools::throwDeprecated($error, $message, $class); + Tools::throwDeprecated($error, $message, $class); } /** diff --git a/install-dev/upgrade/php/create_multistore.php b/install-dev/upgrade/php/create_multistore.php index 0d5b0325d..3f1ed2fac 100755 --- a/install-dev/upgrade/php/create_multistore.php +++ b/install-dev/upgrade/php/create_multistore.php @@ -44,39 +44,27 @@ function create_multistore() $all_themes_dir = _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'themes'; $themes = scandir($all_themes_dir); foreach ($themes AS $theme) - if (is_dir($all_themes_dir.DIRECTORY_SEPARATOR.$theme.DIRECTORY_SEPARATOR) - && $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="'.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 = create_multistore_getHttpHost(); + if (is_dir($all_themes_dir.DIRECTORY_SEPARATOR.$theme.DIRECTORY_SEPARATOR) && $theme[0] != '.' && $theme != 'prestashop') + $res &= Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'theme (`id_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(); - } - $_PS_DIRECTORY_ = trim(str_replace(' ', '%20', $INSTALLER__PS_BASE_URI), DIRECTORY_SEPARATOR); - $_PS_DIRECTORY_ = ($_PS_DIRECTORY_) ? '/'.$_PS_DIRECTORY_.DIRECTORY_SEPARATOR : DIRECTORY_SEPARATOR; - $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)'); + $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`) diff --git a/install-dev/upgrade/sql/1.6.0.2.sql b/install-dev/upgrade/sql/1.6.0.2.sql new file mode 100644 index 000000000..55c3dfabe --- /dev/null +++ b/install-dev/upgrade/sql/1.6.0.2.sql @@ -0,0 +1,8 @@ +SET NAMES 'utf8'; + +INSERT INTO `PREFIX_hook_module` (`id_module`, `id_shop`, `id_hook`, `position`) ( + SELECT m.id_module, s.id_shop, h.id_hook, 0 + FROM `PREFIX_module` m, `PREFIX_shop` s, `PREFIX_hook` h + WHERE m.name IN ('dashgoals', 'dashactivity', 'dashtrends', 'dashproducts') + AND h.name IN ('displayBackOfficeHeader') +); diff --git a/modules/dashactivity/dashactivity.php b/modules/dashactivity/dashactivity.php index ba67e4e10..ce5939890 100644 --- a/modules/dashactivity/dashactivity.php +++ b/modules/dashactivity/dashactivity.php @@ -50,21 +50,19 @@ class Dashactivity extends Module Configuration::updateValue('DASHACTIVITY_CART_ABANDONED_MAX', 48); Configuration::updateValue('DASHACTIVITY_VISITOR_ONLINE', 24); - if (!parent::install() - || !$this->registerHook('dashboardZoneOne') - || !$this->registerHook('dashboardData') - || !$this->registerHook('actionObjectOrderAddAfter') - || !$this->registerHook('actionObjectCustomerAddAfter') - || !$this->registerHook('actionObjectCustomerMessageAddAfter') - || !$this->registerHook('actionObjectCustomerThreadAddAfter') - || !$this->registerHook('actionObjectOrderReturnAddAfter') - || !$this->registerHook('displayBackOfficeHeader') - ) - return false; - return true; + return (parent::install() + && $this->registerHook('dashboardZoneOne') + && $this->registerHook('dashboardData') + && $this->registerHook('actionObjectOrderAddAfter') + && $this->registerHook('actionObjectCustomerAddAfter') + && $this->registerHook('actionObjectCustomerMessageAddAfter') + && $this->registerHook('actionObjectCustomerThreadAddAfter') + && $this->registerHook('actionObjectOrderReturnAddAfter') + && $this->registerHook('actionAdminControllerSetMedia') + ); } - public function hookDisplayBackOfficeHeader() + public function hookActionAdminControllerSetMedia() { if (get_class($this->context->controller) == 'AdminDashboardController') { @@ -78,20 +76,20 @@ class Dashactivity extends Module public function hookDashboardZoneOne($params) { + $gapi_mode = 'configure'; if (!Module::isInstalled('gapi')) $gapi_mode = 'install'; elseif (($gapi = Module::getInstanceByName('gapi')) && Validate::isLoadedObject($gapi) && $gapi->isConfigured()) $gapi_mode = false; - else - $gapi_mode = 'configure'; - $this->context->smarty->assign(array_merge(array( + $this->context->smarty->assign($this->getConfigFieldsValues()); + $this->context->smarty->assign(array( 'gapi_mode' => $gapi_mode, 'dashactivity_config_form' => $this->renderConfigForm(), 'date_subtitle' => $this->l('(from %s to %s)'), 'date_format' => $this->context->language->date_format_lite, 'link' => $this->context->link, - ), $this->getConfigFieldsValues())); + )); return $this->display(__FILE__, 'dashboard_zone_one.tpl'); } diff --git a/modules/dashgoals/dashgoals.php b/modules/dashgoals/dashgoals.php index d3376b6f0..d412a0614 100644 --- a/modules/dashgoals/dashgoals.php +++ b/modules/dashgoals/dashgoals.php @@ -89,7 +89,7 @@ class Dashgoals extends Module && parent::install() && $this->registerHook('dashboardZoneTwo') && $this->registerHook('dashboardData') - && $this->registerHook('displayBackOfficeHeader') + && $this->registerHook('actionAdminControllerSetMedia') ); } @@ -104,7 +104,7 @@ class Dashgoals extends Module return parent::uninstall(); } - public function hookDisplayBackOfficeHeader() + public function hookActionAdminControllerSetMedia() { if (get_class($this->context->controller) == 'AdminDashboardController') $this->context->controller->addJs($this->_path.'views/js/'.$this->name.'.js'); diff --git a/modules/dashproducts/dashproducts.php b/modules/dashproducts/dashproducts.php index 86eed8f0f..47faa9500 100644 --- a/modules/dashproducts/dashproducts.php +++ b/modules/dashproducts/dashproducts.php @@ -47,9 +47,10 @@ class Dashproducts extends Module Configuration::updateValue('DASHPRODUCT_NBR_SHOW_MOST_VIEWED', 10); Configuration::updateValue('DASHPRODUCT_NBR_SHOW_TOP_SEARCH', 10); - if (!parent::install() || !$this->registerHook('dashboardZoneTwo') || !$this->registerHook('dashboardData')) - return false; - return true; + return (parent::install() + && $this->registerHook('dashboardZoneTwo') + && $this->registerHook('dashboardData') + ); } public function hookDashboardZoneTwo($params) diff --git a/modules/dashtrends/dashtrends.php b/modules/dashtrends/dashtrends.php index 015945ff4..efeff64ac 100644 --- a/modules/dashtrends/dashtrends.php +++ b/modules/dashtrends/dashtrends.php @@ -48,12 +48,14 @@ class Dashtrends extends Module public function install() { - if (!parent::install() || !$this->registerHook('dashboardZoneTwo') || !$this->registerHook('dashboardData') || !$this->registerHook('displayBackOfficeHeader')) - return false; - return true; + return (parent::install() + && $this->registerHook('dashboardZoneTwo') + && $this->registerHook('dashboardData') + && $this->registerHook('actionAdminControllerSetMedia') + ); } - public function hookDisplayBackOfficeHeader() + public function hookActionAdminControllerSetMedia() { if (get_class($this->context->controller) == 'AdminDashboardController') $this->context->controller->addJs($this->_path.'views/js/'.$this->name.'.js'); diff --git a/modules/homefeatured/homefeatured.php b/modules/homefeatured/homefeatured.php index 12bb6177f..62747320e 100644 --- a/modules/homefeatured/homefeatured.php +++ b/modules/homefeatured/homefeatured.php @@ -125,7 +125,7 @@ class HomeFeatured extends Module /* Retro Compatibility < 1.6.0.1 */ public function hookDisplayHome($params) { - return $this->hookDisplayHomeTabContent(); + return $this->hookDisplayHomeTabContent($params); } public function hookAddProduct($params)