public function action_delete() { if (!ACL::check('delete oaclient2')) { throw new HTTP_Exception_404('You have no permission to delete oauth2 clients.'); } $id = (int) $this->request->param('id'); $redirect = empty($this->redirect) ? Route::get('oauth2/client')->uri(array('action' => 'list')) : $this->redirect; $oaclient = ORM::factory('oaclient', $id); if (!$oaclient->loaded()) { Message::error(__('oaclient: doesn\'t exists!')); Kohana::$log->add(Log::ERROR, 'Attempt to delete non-existent oaclient'); $this->request->redirect(Route::get('oauth2/client')->uri(array('action' => 'list'))); } $clone_oaclient = clone $oaclient; if (!Access::oaclient('delete', $oaclient)) { // If the lead was not loaded, we return access denied. throw new HTTP_Exception_404('Attempt to non-existent oaclient.'); } $this->title = __('Delete oaclient'); $this->subtitle = Text::plain($oaclient->client_id); $form = View::factory('form/confirm')->set('action', $oaclient->delete_url)->set('title', $oaclient->client_id); // If deletion is not desired, redirect to post if (isset($_POST['no']) and $this->valid_post()) { $this->request->redirect('oauth2/client'); } // If deletion is confirmed if (isset($_POST['yes']) and $this->valid_post()) { try { $oaclient->delete(); Message::success(__('oaclient: :title deleted successfully', array(':title' => $clone_oaclient->client_id))); $this->request->redirect($redirect); } catch (Exception $e) { Message::error(__('oaclient: :title unable to delete the record', array(':title' => $clone_oaclient->client_id))); $this->request->redirect($redirect); } } $this->response->body($form); }