diff --git a/modules/homeslider/HomeSlide.php b/modules/homeslider/HomeSlide.php index 393daf4cb..b73999914 100644 --- a/modules/homeslider/HomeSlide.php +++ b/modules/homeslider/HomeSlide.php @@ -104,15 +104,17 @@ class HomeSlide extends ObjectModel public function delete() { - $res = null; + $res = true; + $images = $this->image; foreach ($images as $image) { - if (file_exists(dirname(__FILE__).'/images/'.$image)) + if ($image && file_exists(dirname(__FILE__).'/images/'.$image)) $res &= @unlink(dirname(__FILE__).'/images/'.$image); } $res &= $this->reOrderPositions(); + $res &= Db::getInstance()->execute(' DELETE FROM `'._DB_PREFIX_.'homeslider` WHERE `id_homeslider_slides` = '.(int)$this->id @@ -139,13 +141,11 @@ class HomeSlide extends ObjectModel $rows = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' 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_homeslider_slides` = hs.`id_homeslider_slides` AND hs.`id_shop` = '.(int)$id_shop.' AND hss.`position` > '.(int)$this->position + FROM `'._DB_PREFIX_.'homeslider_slides` hss + LEFT JOIN `'._DB_PREFIX_.'homeslider` hs ON (hss.`id_homeslider_slides` = hs.`id_homeslider_slides`) + WHERE hs.`id_shop` = '.(int)$id_shop.' AND hss.`position` > '.(int)$this->position ); - if (!$rows) - return false; - foreach ($rows as $row) { $current_slide = new HomeSlide($row['id_slide']); diff --git a/modules/homeslider/ajax_homeslider.php b/modules/homeslider/ajax_homeslider.php index 46c34ea63..bf449ea66 100644 --- a/modules/homeslider/ajax_homeslider.php +++ b/modules/homeslider/ajax_homeslider.php @@ -44,7 +44,7 @@ if (Tools::getValue('action') == 'updateSlidesPosition' && Tools::getValue('slid { $res = Db::getInstance()->execute(' UPDATE `'._DB_PREFIX_.'homeslider_slides` SET `position` = '.(int)$position.' - WHERE `id_slide` = '.(int)$id_slide + WHERE `id_homeslider_slides` = '.(int)$id_slide ); } diff --git a/modules/homeslider/homeslider.php b/modules/homeslider/homeslider.php index 4a794b51c..d6f96a7a3 100644 --- a/modules/homeslider/homeslider.php +++ b/modules/homeslider/homeslider.php @@ -258,7 +258,7 @@ class HomeSlider extends Module $defaultLanguage = (int)Configuration::get('PS_LANG_DEFAULT'); $languages = Language::getLanguages(false); $divLangName = 'image¤title¤url¤legend¤description'; - $this->_html = ''; + $this->_html .= ''; /* Form */ $this->_html .= '