From b46bfdd4921e27ed472aabfd06ab7c95f30e7e62 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 29 Dec 2008 00:35:31 +0000 Subject: Separate permanent messages out of the message helper and put them into site_status. Show site status in the header in the admin theme. --- core/helpers/message.php | 60 +++++++++++------------------------------------- 1 file changed, 13 insertions(+), 47 deletions(-) (limited to 'core/helpers/message.php') 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[] = "
  • $msg[0]
  • "; } - - if (user::active()->admin) { - foreach (ORM::factory("message")->find_all() as $msg) { - $buf[] = "
  • severity) . "\">$msg->value
  • "; - } - } - if ($buf) { - return ""; + return ""; } } -- cgit v1.2.3