I am looking for a way to mark Messages as New until the user clicks on the message or clicks a button to "Mark All Messages Read".

I read through how Views handles New nodes, and the granularity of that approach doesn't suite all message types.

We have:

  • Messages directly related to a node or comment that can be tracked via standard Newness operations.
  • Messages related to some other, untracked change with a link to go see it.
  • Messages which, when seen in the right context, are no longer new (messages in a primary activity log, or private message listing).

#1 just needs light tweaking of existing solutions. #2 I think needs to borrow the concept of an Event ID from #1065278: Notifications/Messaging Integration, and add a special query string that a newness module would detect and use to mark the message "read".

For #3 it's a bit trickier. I don't know that anyone wants to get in the game of detecting whether an individual row in a View was actually seen by the user. I'm thinking there could be a link the user can click to confirm viewing, but maybe it would be easier to just expire newness after a week if the user has logged in (or even fancier, logged in and viewed one of several configured page paths where the activity would presumably have been listed.)

I realize this functionality might be outside the scope of Message as a project, but I wanted to get the braintrust in on the discussion ;)


Grayside’s picture

Assigned: Grayside » Unassigned
funature’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

is there already a solution? maybe it's not a bad idea to try with flag...

vkouroub’s picture

I have one question that's bugging me a lot. How does the system understand that a message has been viewed??? If it was a node then the viewing event would be the clicking the node title but i don't understand what's the event for message viewing. I need this to work some rules and i can't quite get it.

sacha05’s picture

Status: Active » Needs review

I created a notification manager by using a custom module with a table containing two columns: uid and lastaccess and two simple functions.

In my case, I had a view rendering the messages so I used hook_view_post_render but anything can be used of course.

function notifmger_views_post_render(&$view, &$output, &$cache){
    if ($view->name == "notification" && $view->current_display == "page_1"){
        global $user;
        $check = db_query("SELECT * FROM notifmger WHERE uid = :uid",
            array(':uid' => $user->uid))->fetchCol(1);
        if (!empty($check)){
            $update = db_query("UPDATE notifmger SET lastaccess = :time WHERE uid = :uid", array(":time" => time(), ":uid" => $user->uid));
        else {
            $insert = db_insert('notifmger')
              'uid' => $user->uid,
              'lastaccess' => time()

function notifmger_counter() {
    global $user;
    $msgs = db_query("SELECT count(*) FROM message LEFT JOIN notifmger ON notifmger.uid = message.uid WHERE message.uid = :uid AND message.timestamp > notifmger.lastaccess AND message.type != :type", array(
        ":uid" => $user->uid,
        ":type" => "user_tagged_self"))->fetchCol();
    if ($msgs[0] != 0){
        return $msgs[0];
    return NULL;
amitaibu’s picture

Category: feature » support
Status: Needs review » Active

No patch.

Andre-B’s picture

I am currently working on a message notification center: https://drupal.org/sandbox/baumeier.it/2078043 I have all known bugs fixed and will work on documentation and the remaining wishlist.MD entries next. There's a screencast showing the basic functionality, but it's from the earlier prototypes. The current status has more features and configuration options. Any feedback and help is appreciated. (even later when this goes into "application for full project access".

Pierre.Vriens’s picture

A pretty old issue, but still valid today I think. For anybody (still) interested in a possible solution, have a look at what I wrote in "How to allow users to manage their own Message Stack messages?", which IMO is pretty close to the question here.

I'd be interested to hear any feedback about my answer to it ... It can be summarized like so:

  1. Create a flag.
  2. Create a view Messages by user.
  3. Use Rules to flag/unflag messages.
  4. Trigger the Rules Component to mark messages (using the VBO module).
  5. Create notifications about Unread Messages (using the "Menu Badges" module).
  6. Possible variations (not just for messages).