You are here

public function PrivateMessageMapper::getUnreadThreadCount in Private Message 8

Same name and namespace in other branches
  1. 8.2 src/Mapper/PrivateMessageMapper.php \Drupal\private_message\Mapper\PrivateMessageMapper::getUnreadThreadCount()

Get the current user's unread thread count.

Retrieves the number of the current user's threads that have been updated since the last time this number was checked.

Parameters

int $uid: The user ID of the user whose count should be retrieved.

int $lastCheckTimestamp: A UNIX timestamp indicating the time after which to check.

Return value

int The number of threads updated since the given timestamp

Overrides PrivateMessageMapperInterface::getUnreadThreadCount

File

src/Mapper/PrivateMessageMapper.php, line 251

Class

PrivateMessageMapper
Interface for the Private Message Mapper class.

Namespace

Drupal\private_message\Mapper

Code

public function getUnreadThreadCount($uid, $lastCheckTimestamp) {
  return $this->database
    ->query('SELECT COUNT(thread.id) FROM {private_message_threads} AS thread JOIN ' . '{private_message_thread__members} AS member ' . 'ON member.entity_id = thread.id AND member.members_target_id = :uid ' . 'WHERE thread.updated > :timestamp', [
    ':uid' => $uid,
    ':timestamp' => $lastCheckTimestamp,
  ])
    ->fetchField();
}