function privatemsg_sql_unread_count in Privatemsg 6.2
Same name and namespace in other branches
- 6 privatemsg.module \privatemsg_sql_unread_count()
- 7.2 privatemsg.module \privatemsg_sql_unread_count()
- 7 privatemsg.module \privatemsg_sql_unread_count()
Query definition to count unread messages.
Parameters
$fragments: Query fragments array.
$account: User object for which the messages are being counted.
Related topics
File
- ./
privatemsg.module, line 1226 - Allows users to send private messages to other users.
Code
function privatemsg_sql_unread_count(&$fragments, $account) {
$fragments['primary_table'] = '{pm_index} pmi';
$fragments['select'][] = 'COUNT(DISTINCT thread_id) as unread_count';
// Only count new messages that have not been deleted.
$fragments['where'][] = 'pmi.deleted = 0';
$fragments['where'][] = 'pmi.is_new = 1';
$fragments['where'][] = "pmi.recipient = %d AND pmi.type IN ('user', 'hidden')";
$fragments['query_args']['where'][] = $account->uid;
}