diff options
author | Bharat Mediratta <bharat@menalto.com> | 2008-12-29 00:35:31 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2008-12-29 00:35:31 +0000 |
commit | b46bfdd4921e27ed472aabfd06ab7c95f30e7e62 (patch) | |
tree | e522d493e45bf30514566e8da4f0f1d268f706e1 /core/helpers/message.php | |
parent | ed8689f768f81d2c3ed8bee70c43d4f7c71c108e (diff) |
Separate permanent messages out of the message helper and put them
into site_status. Show site status in the header in the admin theme.
Diffstat (limited to 'core/helpers/message.php')
-rw-r--r-- | core/helpers/message.php | 60 |
1 files changed, 13 insertions, 47 deletions
diff --git a/core/helpers/message.php b/core/helpers/message.php index 25d7c150..206ba212 100644 --- a/core/helpers/message.php +++ b/core/helpers/message.php @@ -26,36 +26,32 @@ class message_Core { /** * Report a successful event. * @param string $msg a detailed message - * @param string $permanent_key make this message permanent and store it under this key */ - public static function success($msg, $permanent_key=null) { - self::add($msg, self::SUCCESS, $permanent_key); + public static function success($msg) { + self::add($msg, self::SUCCESS); } /** * Report an informational event. * @param string $msg a detailed message - * @param string $permanent_key make this message permanent and store it under this key */ - public static function info($msg, $permanent_key=null) { + public static function info($msg) { self::add($msg, self::INFO, $permanent_key); } /** * Report that something went wrong, not fatal, but worth investigation. * @param string $msg a detailed message - * @param string $permanent_key make this message permanent and store it under this key */ - public static function warning($msg, $permanent_key=null) { + public static function warning($msg) { self::add($msg, self::WARNING, $permanent_key); } /** * Report that something went wrong that should be fixed. * @param string $msg a detailed message - * @param string $permanent_key make this message permanent and store it under this key */ - public static function error($msg, $permanent_key=null) { + public static function error($msg) { self::add($msg, self::ERROR, $permanent_key); } @@ -63,36 +59,12 @@ class message_Core { * Save a message in the session for our next page load. * @param string $msg a detailed message * @param integer $severity one of the severity constants - * @param string $permanent_key make this message permanent and store it under this key */ - private function add($msg, $severity, $permanent_key=null) { - if ($permanent_key) { - $message = ORM::factory("message") - ->where("key", $permanent_key) - ->find(); - if (!$message->loaded) { - $message->key = $permanent_key; - } - $message->severity = $severity; - $message->value = $msg; - $message->save(); - } else { - $session = Session::instance(); - $status = $session->get("messages"); - $status[] = array($msg, $severity); - $session->set("messages", $status); - } - } - - /** - * Remove any permanent message by key. - * @param string $permanent_key - */ - public function clear_permanent($permanent_key) { - $message = ORM::factory("message")->where("key", $permanent_key)->find(); - if ($message->loaded) { - $message->delete(); - } + private function add($msg, $severity) { + $session = Session::instance(); + $status = $session->get("messages"); + $status[] = array($msg, $severity); + $session->set("messages", $status); } /** @@ -104,18 +76,12 @@ class message_Core { public function get() { $buf = array(); - foreach (Session::instance()->get_once("messages", array()) as $msg) { + $messages = Session::instance()->get_once("messages", array()); + foreach ($messages as $msg) { $buf[] = "<li class=\"" . self::severity_class($msg[1]) . "\">$msg[0]</li>"; } - - if (user::active()->admin) { - foreach (ORM::factory("message")->find_all() as $msg) { - $buf[] = "<li class=\"" . self::severity_class($msg->severity) . "\">$msg->value</li>"; - } - } - if ($buf) { - return "<ul id=\"gMessages\">" . implode("", $buf) . "</ul>"; + return "<ul id=\"gMessage\">" . implode("", $buf) . "</ul>"; } } |