/** * Get the data */ private function getData() { $this->id = $this->getParameter('id', 'int'); if ($this->id == null || !BackendBlocksModel::existsCategory($this->id)) { $this->redirect(Model::createURLForAction('categories') . '&error=non-existing'); } $this->record = BackendBlocksModel::getCategory($this->id); }
/** * Execute the action */ public function execute() { $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id == null || !BackendBlocksModel::existsCategory($this->id)) { $this->redirect(Model::createURLForAction('categories') . '&error=non-existing'); } // fetch the category $this->record = (array) BackendBlocksModel::getCategory($this->id); // delete item BackendBlocksModel::deleteCategory($this->id); Model::triggerEvent($this->getModule(), 'after_delete_category', array('item' => $this->record)); // category was deleted, so redirect $this->redirect(Model::createURLForAction('categories') . '&report=deleted-category&var=' . urlencode($this->record['title'])); }
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::existsCategory($id)) { BackendBlocksModel::updateCategory($item); } } // success output $this->output(self::OK, null, 'sequence updated'); }