aboutsummaryrefslogtreecommitdiff
path: root/mod/messages/start.php
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2011-10-29 08:28:10 -0400
committerCash Costello <cash.costello@gmail.com>2011-10-29 08:28:10 -0400
commit2cbfc4624135475764d6b5a53b0b95fe980793a2 (patch)
treea32ab4c32e365789514d974a4baada30d12d18d0 /mod/messages/start.php
parentfeefadb125770c0a513735ba7b3d6bea78c77d3b (diff)
downloadelgg-2cbfc4624135475764d6b5a53b0b95fe980793a2.tar.gz
elgg-2cbfc4624135475764d6b5a53b0b95fe980793a2.tar.bz2
Fixes #4015 decrementing the count before adding to the topbar
Diffstat (limited to 'mod/messages/start.php')
-rw-r--r--mod/messages/start.php43
1 files changed, 26 insertions, 17 deletions
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
*
*/