/** * Removes a persistent Notice * * @ajax * @param string id */ public function action_remove() { if (!Request::$is_ajax) { throw new Kohana_Request_Exception('Trying to access an AJAX method without AJAX.'); } $hash = $this->request->param('id'); $response = array('status' => 'success', 'message' => 'Notice ' . $hash . ' was removed.', 'data' => NULL); $notice = Notices::get($hash); if (!is_null($notice)) { $notice->set_rendered_state(TRUE); $notice->remove_persistence(); $response['data'] = $notice; Notices::save(); } else { $response['status'] = 'error'; $response['message'] = 'Notice ' . $hash . ' was not found.'; } $this->request->response = json_encode($response); }