/** * Load the item data */ protected function loadData() { $this->id = $this->getParameter('id', 'int', null); if ($this->id == null || !BackendAddressesModel::existsGroup($this->id)) { $this->redirect(BackendModel::createURLForAction('groups') . '&error=non-existing'); } $this->record = BackendAddressesModel::getGroup($this->id); }
/** * Execute the action */ public function execute() { $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id !== null && BackendAddressesModel::existsGroup($this->id)) { parent::execute(); $this->record = (array) BackendAddressesModel::getGroup($this->id); BackendAddressesModel::deleteGroup($this->id); BackendAddressesModel::deleteAddressesFromGroup($this->id); BackendModel::triggerEvent($this->getModule(), 'after_delete_group', array('id' => $this->id)); $this->redirect(BackendModel::createURLForAction('groups') . '&report=deleted&var=' . urlencode($this->record['title'])); } else { $this->redirect(BackendModel::createURLForAction('groups') . '&error=non-existing'); } }
/** * Execute the action */ 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) { // build item $id = (int) $id; // change sequence $item['sequence'] = $i + 1; // update sequence if (BackendAddressesModel::existsGroup($id)) { BackendAddressesModel::updateGroup($id, $item); } } // success output $this->output(self::OK, null, 'sequence updated'); }