You are here

public function SocialPrivateMessageService::getLastMessageFromOtherUser in Open Social 8.2

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.3 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessageFromOtherUser()
  4. 8.4 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessageFromOtherUser()
  5. 8.5 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessageFromOtherUser()
  6. 8.6 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessageFromOtherUser()
  7. 8.7 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessageFromOtherUser()
  8. 8.8 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessageFromOtherUser()
  9. 10.3.x 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 $theadid: The thread id.

Return value

int The timestamp.

1 call to SocialPrivateMessageService::getLastMessageFromOtherUser()
SocialPrivateMessageService::updateUnreadCount in modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php
Update the unread thread count.

File

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

Class

SocialPrivateMessageService
Class SocialPrivateMessageService.

Namespace

Drupal\social_private_message\Service

Code

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

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