diff --git a/install-dev/sql/db_settings_extends.sql b/install-dev/sql/db_settings_extends.sql index 12c7e44f3..768bff688 100644 --- a/install-dev/sql/db_settings_extends.sql +++ b/install-dev/sql/db_settings_extends.sql @@ -1663,27 +1663,27 @@ CREATE TABLE IF NOT EXISTS `PREFIX_newsletter` ( ) ENGINE=ENGINE_TYPE default CHARSET=utf8; CREATE TABLE IF NOT EXISTS `PREFIX_homeslider` ( - `id_slide` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_homeslider_slides` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_shop` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_slide`, `id_shop`) + PRIMARY KEY (`id_homeslider_slides`, `id_shop`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=UTF8; CREATE TABLE IF NOT EXISTS `PREFIX_homeslider_slides` ( - `id_slide` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_homeslider_slides` int(10) unsigned NOT NULL AUTO_INCREMENT, `position` int(10) unsigned NOT NULL DEFAULT '0', `active` tinyint(1) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`id_slide`) + PRIMARY KEY (`id_homeslider_slides`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=UTF8; CREATE TABLE IF NOT EXISTS `PREFIX_homeslider_slides_lang` ( - `id_slide` int(10) unsigned NOT NULL, + `id_homeslider_slides` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL, `title` varchar(255) NOT NULL, `description` text NOT NULL, `legend` varchar(255) NOT NULL, `url` varchar(255) NOT NULL, `image` varchar(255) NOT NULL, - PRIMARY KEY (`id_slide`,`id_lang`) + PRIMARY KEY (`id_homeslider_slides`,`id_lang`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=UTF8; INSERT INTO `PREFIX_configuration` (name, value) @@ -1693,12 +1693,12 @@ VALUES ("HOMESLIDER_SPEED", "1300"), ("HOMESLIDER_PAUSE", "7700"); -INSERT INTO `PREFIX_homeslider` (id_slide, id_shop) VALUES (1, 1),(2, 1), (3, 1), (4, 1), (5, 1); +INSERT INTO `PREFIX_homeslider` (id_homeslider_slides, id_shop) VALUES (1, 1),(2, 1), (3, 1), (4, 1), (5, 1); -INSERT INTO `PREFIX_homeslider_slides` (id_slide, position, active) +INSERT INTO `PREFIX_homeslider_slides` (id_homeslider_slides, position, active) VALUES (1, 1, 1), (2, 2, 1), (3, 3, 1), (4, 4, 1), (5, 5, 1); -INSERT INTO `PREFIX_homeslider_slides_lang` (id_slide, id_lang, title, description, legend, url, image) VALUES +INSERT INTO `PREFIX_homeslider_slides_lang` (id_homeslider_slides, id_lang, title, description, legend, url, image) VALUES (1, 1, "Add Ons", "improve your e-commerce site by adding new features", "addons", "http://addons.prestashop.com", "sample-1.jpg"), (2, 1, "PrestaBox", "Your e-shop ready to use open in 10 minutes", "prestabox", "http://www.prestabox.com", "sample-2.jpg"), (3, 1, "Support", "contact PrestaShop Support team to help you in installing or configuring your software", "support", "http://support.prestashop.com", "sample-3.jpg"), diff --git a/modules/homeslider/HomeSlide.php b/modules/homeslider/HomeSlide.php index a6451fec1..393daf4cb 100644 --- a/modules/homeslider/HomeSlide.php +++ b/modules/homeslider/HomeSlide.php @@ -61,12 +61,12 @@ class HomeSlide extends ObjectModel protected $tables = array('homeslider_slides, homeslider_slides_lang'); protected $table = 'homeslider_slides'; - protected $identifier = 'id_slide'; + protected $identifier = 'id_homeslider_slides'; public function getFields() { $this->validateFields(); - $fields['id_slide'] = (int)$this->id; + $fields['id_homeslider_slides'] = (int)$this->id; $fields['active'] = (int)$this->active; $fields['position'] = (int)$this->position; return $fields; @@ -96,7 +96,7 @@ class HomeSlide extends ObjectModel $res = parent::add($autodate, $null_values); $res &= Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'homeslider` (`id_shop`, `id_slide`) + INSERT INTO `'._DB_PREFIX_.'homeslider` (`id_shop`, `id_homeslider_slides`) VALUES('.(int)$id_shop.', '.(int)$this->id.')' ); return $res; @@ -115,7 +115,7 @@ class HomeSlide extends ObjectModel $res &= $this->reOrderPositions(); $res &= Db::getInstance()->execute(' DELETE FROM `'._DB_PREFIX_.'homeslider` - WHERE `id_slide` = '.(int)$this->id + WHERE `id_homeslider_slides` = '.(int)$this->id ); $res &= parent::delete(); @@ -131,16 +131,16 @@ class HomeSlide extends ObjectModel $max = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT MAX(hss.`position`) as position FROM `'._DB_PREFIX_.'homeslider_slides` hss, `'._DB_PREFIX_.'homeslider` hs - WHERE hss.`id_slide` = hs.`id_slide` AND hs.`id_shop` = '.(int)$id_shop + WHERE hss.`id_homeslider_slides` = hs.`id_homeslider_slides` AND hs.`id_shop` = '.(int)$id_shop ); if ((int)$max == (int)$id_slide) return true; $rows = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT hss.`position` as position, hss.`id_slide` as id_slide + SELECT hss.`position` as position, hss.`id_homeslider_slides` as id_slide FROM `'._DB_PREFIX_.'homeslider_slides` hss, `'._DB_PREFIX_.'homeslider` hs - WHERE hss.`id_slide` = hs.`id_slide` AND hs.`id_shop` = '.(int)$id_shop.' AND hss.`position` > '.(int)$this->position + WHERE hss.`id_homeslider_slides` = hs.`id_homeslider_slides` AND hs.`id_shop` = '.(int)$id_shop.' AND hss.`position` > '.(int)$this->position ); if (!$rows) diff --git a/modules/homeslider/ajax_homeslider.php b/modules/homeslider/ajax_homeslider.php index 9e39f82bd..46c34ea63 100644 --- a/modules/homeslider/ajax_homeslider.php +++ b/modules/homeslider/ajax_homeslider.php @@ -32,7 +32,7 @@ $context = Context::getContext(); $homeSlider = new HomeSlider(); $slides = array(); -if (!Tools::isSubmit('secure_key') OR Tools::getValue('secure_key') != $homeSlider->secure_key OR !Tools::getValue('action')) +if (!Tools::isSubmit('secure_key') || Tools::getValue('secure_key') != $homeSlider->secure_key || !Tools::getValue('action')) die(1); if (Tools::getValue('action') == 'updateSlidesPosition' && Tools::getValue('slides')) @@ -43,8 +43,8 @@ if (Tools::getValue('action') == 'updateSlidesPosition' && Tools::getValue('slid foreach ($slides as $position => $id_slide) { $res = Db::getInstance()->execute(' - UPDATE `'._DB_PREFIX_.'homeslider_slides` SET `position` = '.(int)($position).' - WHERE `id_slide` = '.(int)($id_slide) + UPDATE `'._DB_PREFIX_.'homeslider_slides` SET `position` = '.(int)$position.' + WHERE `id_slide` = '.(int)$id_slide ); } diff --git a/modules/homeslider/homeslider.php b/modules/homeslider/homeslider.php index 1a4d8fec5..4a794b51c 100644 --- a/modules/homeslider/homeslider.php +++ b/modules/homeslider/homeslider.php @@ -57,7 +57,7 @@ class HomeSlider extends Module public function install() { /* Adds Module */ - if (parent::install() && $this->registerHook('displayHome') && $this->registerHook('backOfficeTop') && $this->registerHook('displayHeader')) + if (parent::install() && $this->registerHook('displayHome') && $this->registerHook('displayHeader')) { /* Sets up configuration */ $res = Configuration::updateValue('HOMESLIDER_WIDTH', '535'); @@ -73,7 +73,7 @@ class HomeSlider extends Module public function uninstall() { /* Deletes Module */ - if (parent::uninstall() && $this->unregisterHook('home') && $this->unregisterHook('backOfficeTop') && $this->unregisterHook('header')) + if (parent::uninstall() && $this->unregisterHook('home') && $this->unregisterHook('header')) { /* Deletes tables */ $res = $this->deleteTables(); @@ -92,33 +92,33 @@ class HomeSlider extends Module /* Slides */ $res = (bool)Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'homeslider` ( - `id_slide` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_homeslider_slides` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_shop` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_slide`, `id_shop`) + PRIMARY KEY (`id_homeslider_slides`, `id_shop`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8; '); /* Slides configuration */ $res &= Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'homeslider_slides` ( - `id_slide` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_homeslider_slides` int(10) unsigned NOT NULL AUTO_INCREMENT, `position` int(10) unsigned NOT NULL DEFAULT \'0\', `active` tinyint(1) unsigned NOT NULL DEFAULT \'0\', - PRIMARY KEY (`id_slide`) + PRIMARY KEY (`id_homeslider_slides`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8; '); /* Slides lang configuration */ $res &= Db::getInstance()->execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'homeslider_slides_lang` ( - `id_slide` int(10) unsigned NOT NULL, + `id_homeslider_slides` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL, `title` varchar(255) NOT NULL, `description` text NOT NULL, `legend` varchar(255) NOT NULL, `url` varchar(255) NOT NULL, `image` varchar(255) NOT NULL, - PRIMARY KEY (`id_slide`,`id_lang`) + PRIMARY KEY (`id_homeslider_slides`,`id_lang`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8; '); @@ -140,6 +140,7 @@ class HomeSlider extends Module public function getContent() { + $this->_html .= $this->headerHTML(); $this->_html .= '