public function OpignoMessageThread::getUserThreads in Opigno messaging 3.x
Gets message tread IDs of current user.
Parameters
int $uid: User ID. Leave empty to get the data for the current user.
Return value
array The list of user thread IDs.
File
- src/
Services/ OpignoMessageThread.php, line 136
Class
- OpignoMessageThread
- The private messages manager service.
Namespace
Drupal\opigno_messaging\ServicesCode
public function getUserThreads(int $uid = 0) : array {
if (!$uid) {
$uid = (int) $this->account
->id();
}
$query = $this->database
->select('pm_thread_history', 'pth');
$query
->join('private_message_threads', 'pmt', 'pmt.id = pth.thread_id');
$query
->fields('pth', [
'thread_id',
])
->condition('pth.uid', $uid);
$or_condition = $query
->orConditionGroup()
->condition('pth.delete_timestamp', 0)
->where('pmt.updated > pth.delete_timestamp');
$query
->condition($or_condition);
$result = $query
->execute()
->fetchCol();
return is_array($result) ? $result : [];
}