public function execute() { // get parameters $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id !== null && BackendHotelsModel::exists('hotels_rooms', $this->id)) { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // get data $this->record = (array) BackendHotelsModel::getRecord('hotels_rooms', $this->id); if ($this->record['image']) { // the image path $imagePath = FRONTEND_FILES_PATH . '/rooms/images'; BackendModel::deleteThumbnails($imagePath, $this->record['image']); } // delete item BackendHotelsModel::deleteRecord('hotels_rooms', $this->id); // build redirect URL $redirectUrl = BackendModel::createURLForAction('Rooms') . '&report=deleted&var=' . urlencode($this->record['title'] . '&id=' . $this->record['id']); // item was deleted, so redirect $this->redirect($redirectUrl); } else { // something went wrong $this->redirect(BackendModel::createURLForAction('Rooms') . '&error=non-existing&id=' . $this->record['id']); } }
public function execute() { // get parameters $this->id = $this->getParameter('id', 'int'); if ($this->id !== null && BackendHotelsModel::exists('hotels', $this->id)) { parent::execute(); $this->getData(); $this->loadDatagrid(); $this->parse(); $this->display(); } else { // no item found, throw an exception, because somebody is f*****g with our URL $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing'); } }