aboutsummaryrefslogtreecommitdiff
path: root/mod/messages
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
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')
-rw-r--r--mod/messages/pages/messages/read.php3
-rw-r--r--mod/messages/start.php43
-rw-r--r--mod/messages/views/default/object/messages.php4
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);