You are here

function privatemsg_unread_count in Privatemsg 7

Same name and namespace in other branches
  1. 6.2 privatemsg.module \privatemsg_unread_count()
  2. 6 privatemsg.module \privatemsg_unread_count()
  3. 7.2 privatemsg.module \privatemsg_unread_count()

Return number of unread messages for an account.

Parameters

$account: Specify the user for which the unread count should be loaded.

Related topics

4 calls to privatemsg_unread_count()
privatemsg_rules_unread_count in privatemsg_rules/privatemsg_rules.rules.inc
privatemsg_title_callback in ./privatemsg.module
privatemsg_user_login in ./privatemsg.module
Implements hook_user_login().
_privatemsg_block_new in ./privatemsg.module

File

./privatemsg.module, line 848
Allows users to send private messages to other users.

Code

function privatemsg_unread_count($account = NULL) {
  $counts =& drupal_static(__FUNCTION__, array());
  if (!$account || $account->uid == 0) {
    global $user;
    $account = $user;
  }
  if (!isset($counts[$account->uid])) {
    $counts[$account->uid] = _privatemsg_assemble_query('unread_count', $account)
      ->execute()
      ->fetchField();
  }
  return $counts[$account->uid];
}