I have been asked by a site owner to implement facebook style notification for the logged in user of all comments made by others to the logged in users posts, content, or comments. Specifically I am looking for the ability to have a counter type icon in the header/banner section of the site that will provide a count of unread notifications. Along with this a mouse over dropdown list of the unread comments/responses linkable back to the actual node where the comment is located for responding.

I have researched many of the modules/methods to create this condition for/in Drupal 7 and am confused about how to proceed. Is there anyone who has done this before in Drupal 7? There appears to be modules for this in Drupal 6 but fewer for Drupal 7.

Also in conjunction with this and as a future condition of the site we will be adding the capability of forums to the site. What group of modules do in need to implement to get the notification tasks to work as described above as well as extend the functionality of advanced forums capability in the future?

Thank you for any direction.

Comments

jdugger’s picture

Since I have had no response to my post and and Googling the subject does not pick up any discussions either inside or outside of Drupal.org. I will try and request more information in a more concise way. It is likely that perhaps some of my description is either too broad or misdirected in terms and jargon. Here the specific things that need to be accomplished:

Alert Button/Badge
1. Alert button/badge with count of unread comment activity.
2. Number to go down as items are read.
3. Button to disappear when no unread activity.

Drop down /fly-out menu of unread activity showing:
1. drop down menu appears/disappears with mouse over
2. click on Button makes menu sticky.

Inside drop down menu
1. Show thumb of comment author image
2. Show like:dislike (thumbs up/down with count) for each unread activity
3. Activities read are removed from menu

Types of activities displayed:
1. Alert 1 - log threaded comments to users comments showing thumb image, author name, when posted.
2. Alert 2 - log comments on content nodes that user has commented on. same items included in alert 1.

I have looked at Heartbeat, Rules, and Views to combine these effects but don't know enough about them and how they interact with Views to know if I am using them correctly, using the right modules, or if I need different ones. I would imagine the some of these items described (removing read notifications and mouse over effects) require javascript/ajax. I am fine spending a lot of time learning to make this work myself but simply want to know if Drupal 7 has modules to do ALL this or where it falls short. If I can just get a list of the recommended modules that can do these items when used together that would be fantastic.

Thanks

Ralla’s picture

Here's how it could be done by manually doing the database lookups for new comments (D7 + Adv. forum).

Code is not performancetested, use with care :)

function _get_unread_comments($count = FALSE) {
  global $user;

  // Store new comments in here, with cid as key.
  $new_comments = array();

  // Get unread comments on own nodes.
  $result = db_query("SELECT n.nid AS nid, n.title AS node_title, c.cid AS cid, c.uid AS c_uid, c.created AS c_created
                      FROM {node} n
                      INNER JOIN {comment} c ON n.nid = c.nid
                      INNER JOIN {history} h ON n.uid = h.uid AND n.nid = h.nid AND h.timestamp < c.created
                      WHERE c.status = 1 AND n.uid = :uid", array(':uid' => $user->uid));

  foreach ($result as $new_comment) {
    $new_comments[$new_comment->cid] = $new_comment;
  }

  // Get the logged in users own comments.
  $user_comments = db_query('SELECT cid FROM {comment} WHERE status = 1 AND uid = :uid', array(':uid' => $user->uid))->fetchCol();
  $user_comments = implode(',', $user_comments);

   // Get all unread comment replies.
  $result = db_query("SELECT n.nid AS nid, n.title AS node_title, c.cid AS cid, c.uid AS c_uid, c.created AS c_created
                 FROM {comment} c
                 INNER JOIN {node} n ON n.nid = c.nid
                 INNER JOIN {history} h ON :uid = h.uid AND n.nid = h.nid AND h.timestamp < c.created
                 WHERE c.status = 1 AND c.pid IN ($user_comments)", array(':uid' => $user->uid));

  foreach ($result as $new_comment) {
    $new_comments[$new_comment->cid] = $new_comment;
  }

  var_dump($new_comments);

  die('Add some processing here...');
}