diff options
-rw-r--r-- | mod/messages/pages/messages/read.php | 3 | ||||
-rw-r--r-- | mod/messages/start.php | 43 | ||||
-rw-r--r-- | mod/messages/views/default/object/messages.php | 4 |
3 files changed, 29 insertions, 21 deletions
diff --git a/mod/messages/pages/messages/read.php b/mod/messages/pages/messages/read.php index 310485ee2..d41551be4 100644 --- a/mod/messages/pages/messages/read.php +++ b/mod/messages/pages/messages/read.php @@ -12,6 +12,9 @@ if (!$message) { forward(); } +// mark the message as read +$message->readYet = true; + elgg_set_page_owner_guid($message->getOwnerGUID()); $page_owner = elgg_get_page_owner_entity(); diff --git a/mod/messages/start.php b/mod/messages/start.php index 14fc4c3bb..4a3b0b250 100644 --- a/mod/messages/start.php +++ b/mod/messages/start.php @@ -28,25 +28,11 @@ function messages_init() { 'text' => elgg_echo('messages:sentmessages'), 'href' => "messages/sent/" . elgg_get_logged_in_user_entity()->username, 'context' => 'messages', - )); - - $class = "elgg-icon elgg-icon-mail"; - $text = "<span class='$class'></span>"; - - // get unread messages - $num_messages = (int)messages_count_unread(); - if ($num_messages != 0) { - $text .= "<span class=\"messages-new\">$num_messages</span>"; - } - - elgg_register_menu_item('topbar', array( - 'name' => 'messages', - 'href' => 'messages/inbox/' . elgg_get_logged_in_user_entity()->username, - 'text' => $text, - 'priority' => 600, - )); + )); } + elgg_register_event_handler('pagesetup', 'system', 'messages_notifier'); + // Extend system CSS with our own styles, which are defined in the messages/css view elgg_extend_view('css/elgg', 'messages/css'); elgg_extend_view('js/elgg', 'messages/js'); @@ -134,6 +120,29 @@ function messages_page_handler($page) { } /** + * Display notification of new messages in topbar + */ +function messages_notifier() { + if (elgg_is_logged_in()) { + $class = "elgg-icon elgg-icon-mail"; + $text = "<span class='$class'></span>"; + + // get unread messages + $num_messages = (int)messages_count_unread(); + if ($num_messages != 0) { + $text .= "<span class=\"messages-new\">$num_messages</span>"; + } + + elgg_register_menu_item('topbar', array( + 'name' => 'messages', + 'href' => 'messages/inbox/' . elgg_get_logged_in_user_entity()->username, + 'text' => $text, + 'priority' => 600, + )); + } +} + +/** * Override the canEditMetadata function to return true for messages * */ diff --git a/mod/messages/views/default/object/messages.php b/mod/messages/views/default/object/messages.php index 8c840dd57..e8e745e94 100644 --- a/mod/messages/views/default/object/messages.php +++ b/mod/messages/views/default/object/messages.php @@ -12,10 +12,6 @@ if (!$message) { return true; } -if ($full) { - $message->readYet = true; -} - if ($message->toId == elgg_get_page_owner_guid()) { // received $user = get_entity($message->fromId); |