/** * Method to cancel an edit. * * @param string $key The name of the primary key of the URL variable. * @return boolean True if access level checks pass, false otherwise. */ public function cancelTask() { Session::checkToken() or exit(Lang::txt('JINVALID_TOKEN')); // Initialise variables. $model = new Models\Plugin(); $table = $model->getTable(); $checkin = property_exists($table, 'checked_out'); $context = "{$this->_option}.edit.plugin"; $key = $table->getKeyName(); $recordId = Request::getInt($key); // Attempt to check-in the current record. if ($recordId) { // Check we are holding the id in the edit list. if (!$this->checkEditId($context, $recordId)) { // Somehow the person just went to the form - we don't allow that. App::redirect(Route::url('index.php?option=' . $this->_option . $this->getRedirectToListAppend(), false), Lang::txt('JLIB_APPLICATION_ERROR_UNHELD_ID', $recordId), 'error'); } if ($checkin) { if ($model->checkin($recordId) === false) { // Check-in failed, go back to the record and display a notice. App::redirect(Route::url('index.php?option=' . $this->_option . $this->getRedirectToItemAppend($recordId, $key), false), Lang::txt('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError()), 'error'); } } } // Clean the session data and redirect. $this->releaseEditId($context, $recordId); User::setState($context . '.data', null); if ($component = Request::getVar('component', '')) { // Redirect to the list screen. App::redirect(Route::url('index.php?option=com_' . $component . '&controller=plugins', false)); } App::redirect(Route::url('index.php?option=' . $this->_option . $this->getRedirectToListAppend(), false)); }
/** * Override method to save the form data. * * @param array $data The form data. * @return boolean True on success. */ public function save($data) { // Load the extension plugin group. \Plugin::import('extension'); // Setup type $data['type'] = 'plugin'; return parent::save($data); }