You are here

function privatemsg_sql_unread_count in Privatemsg 7

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

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 1184
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',
  ));
}