public function reOrderPositions() { $id_slide = $this->id; $context = Context::getContext(); $id_shop = $context->shop->id; $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_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_homeslider_slides` as id_slide 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); foreach ($rows as $row) { $current_slide = new Ps_HomeSlide($row['id_slide']); --$current_slide->position; $current_slide->update(); unset($current_slide); } return true; }
public function renderList() { $slides = $this->getSlides(); foreach ($slides as $key => $slide) { $slides[$key]['status'] = $this->displayStatus($slide['id_slide'], $slide['active']); $associated_shop_ids = Ps_HomeSlide::getAssociatedIdsShop((int) $slide['id_slide']); if ($associated_shop_ids && count($associated_shop_ids) > 1) { $slides[$key]['is_shared'] = true; } else { $slides[$key]['is_shared'] = false; } } $this->context->smarty->assign(array('link' => $this->context->link, 'slides' => $slides, 'image_baseurl' => $this->_path . 'images/')); return $this->display(__FILE__, 'list.tpl'); }