You are here

public function SocialPrivateMessageService::getLastMessagesFromOtherUsers in Open Social 10.1.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::getLastMessagesFromOtherUsers()
  2. 8.3 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessagesFromOtherUsers()
  3. 8.4 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessagesFromOtherUsers()
  4. 8.5 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessagesFromOtherUsers()
  5. 8.6 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessagesFromOtherUsers()
  6. 8.7 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessagesFromOtherUsers()
  7. 8.8 modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessagesFromOtherUsers()
  8. 10.3.x modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessagesFromOtherUsers()
  9. 10.0.x modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessagesFromOtherUsers()
  10. 10.2.x modules/social_features/social_private_message/src/Service/SocialPrivateMessageService.php \Drupal\social_private_message\Service\SocialPrivateMessageService::getLastMessagesFromOtherUsers()

Retrieves times of last message in all threads send by other users.

Parameters

int $uid: The user uid to check for.

array $threads: List of thread IDs to che check for.

Return value

array A list of timestamps linked to the thread IDs.

1 call to SocialPrivateMessageService::getLastMessagesFromOtherUsers()
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 141

Class

SocialPrivateMessageService
Class SocialPrivateMessageService.

Namespace

Drupal\social_private_message\Service

Code

public function getLastMessagesFromOtherUsers($uid, array $threads) {
  return $this->database
    ->query('SELECT MAX(pm.created), pmt.entity_id ' . 'FROM {private_message_thread__private_messages} pmt ' . 'LEFT JOIN {private_messages} pm ON pmt.private_messages_target_id = pm.id ' . 'WHERE pmt.entity_id IN (:threads[]) AND pm.owner <> :uid ' . 'GROUP BY pmt.entity_id', [
    ':threads[]' => $threads,
    ':uid' => $uid,
  ])
    ->fetchAllKeyed(1, 0);
}