/** * Load the item data */ protected function loadData() { $this->id = $this->getParameter('id', 'int', null); if ($this->id == null || !BackendBlocksModel::exists($this->id)) { $this->redirect(Model::createURLForAction('Index') . '&error=non-existing'); } $this->record = BackendBlocksModel::get($this->id); }
/** * Execute the action */ public function execute() { $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id !== null && BackendBlocksModel::exists($this->id)) { parent::execute(); $this->record = (array) BackendBlocksModel::get($this->id); BackendBlocksModel::delete($this->id); Model::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id)); $this->redirect(Model::createURLForAction('Index') . '&report=deleted&var=' . urlencode($this->record['title'])); } else { $this->redirect(Model::createURLForAction('Index') . '&error=non-existing'); } }
public function execute() { parent::execute(); // get parameters $newIdSequence = trim(\SpoonFilter::getPostValue('new_id_sequence', null, '', 'string')); // list id $ids = (array) explode(',', rtrim($newIdSequence, ',')); // loop id's and set new sequence foreach ($ids as $i => $id) { $item['id'] = $id; $item['sequence'] = $i + 1; // update sequence if (BackendBlocksModel::exists($id)) { BackendBlocksModel::update($item); } } // success output $this->output(self::OK, null, 'sequence updated'); }