function privatemsg_sql_unread_count

1 privatemsg.module privatemsg_sql_unread_count(&$fragments, $account)
7-1 privatemsg.module privatemsg_sql_unread_count($account)
7-2 privatemsg.module privatemsg_sql_unread_count($account)
6-2 privatemsg.module privatemsg_sql_unread_count(&$fragments, $account)

Count threads with unread messages.

Parameters

$account: User account for which should be checked.

See also

hook_query_privatemsg_unread_count_alter()

Related topics

File

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

Code

function privatemsg_sql_unread_count($account) {
  $query = db_select('pm_index', 'pmi');
  $query->addExpression('COUNT(DISTINCT thread_id)', 'unread_count');
  return $query->condition('pmi.deleted', 0)->condition('pmi.is_new', 1)->condition('pmi.recipient', $account->uid)->condition('pmi.type', array('hidden', 'user'));
}