/** * Display a set of notices (Defaults to all non-rendered notices) * * @param mixed $type Notice type * @param boolean $rendered Whether or not a Notice has been rendered * @param boolean $persistent Whether or not a Notice is persistent * @return string */ public static function display($type = NULL, $rendered = FALSE, $persistent = NULL) { $html = ''; foreach (Notices::get_all($type, $rendered, $persistent) as $notice) { $html .= $notice->render(); } Notices::save(); return $html; }
/** * Adds a new Notice and sends the rendered HTML as a repsonse * * @ajax * @param string type * @param string message * @param string persist */ public function action_add() { if (!Request::$is_ajax) { throw new Kohana_Request_Exception('Trying to access an AJAX method without AJAX.'); } $type = strtolower(urldecode($this->request->param('type'))); $message = urldecode($this->request->param('message')); $persist = (bool) $this->request->param('persist'); $response = array('status' => 'success', 'message' => 'A Notice was added.', 'data' => NULL); try { $type = urldecode($type); $message = urldecode($message); $persist = (bool) $persist == 'TRUE'; $notice = Notices::add($type, $message, $persist); $response['message'] = 'Notice ' . $notice->hash . ' was added.'; $response['data'] = $notice->render(); Notices::save(); } catch (Exception $e) { $response['status'] = 'error'; $response['message'] = 'The was a problem adding the Notice.'; } $this->request->response = json_encode($response); }