You are here

public function SocialPrivateMessageService::getLastMessageFromOtherUser in Open Social 10.3.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessageFromOtherUser()
  2. 8 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessageFromOtherUser()
  3. 8.2 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessageFromOtherUser()
  4. 8.3 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessageFromOtherUser()
  5. 8.4 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessageFromOtherUser()
  6. 8.5 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessageFromOtherUser()
  7. 8.6 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessageFromOtherUser()
  8. 8.7 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessageFromOtherUser()
  9. 8.8 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessageFromOtherUser()
  10. 10.0.x modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessageFromOtherUser()
  11. 10.1.x modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessageFromOtherUser()
  12. 10.2.x modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessageFromOtherUser()

Last time a message was added to the thread by another user than current.

Parameters

int $uid: The user id.

int $thread_id: The thread id.

Return value

int The timestamp or 0 if nothing was found.

File

modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php, line 166

Class

SocialPrivateMessageService
Class SocialPrivateMessageService.

Namespace

Drupal\social_private_message\Service

Code

public function getLastMessageFromOtherUser($uid, $thread_id) {
  $timestamp = $this->database
    ->query('SELECT MAX(pm.created) ' . 'FROM {private_message_thread__private_messages} pmt ' . 'JOIN {private_messages} pm ON pmt.private_messages_target_id = pm.id ' . 'WHERE pmt.entity_id = :thread AND pm.owner <> :uid', [
    ':thread' => $thread_id,
    ':uid' => $uid,
  ])
    ->fetchCol();

  // Chop of the head.
  if (is_array($timestamp)) {
    $timestamp = $timestamp[0] !== NULL ? $timestamp[0] : 0;
  }
  return $timestamp;
}