function _privatemsg_load_thread_participants

1 privatemsg.module _privatemsg_load_thread_participants($thread_id)
7-1 privatemsg.module _privatemsg_load_thread_participants($thread_id, $account, $ignore_hidden = TRUE, $access = 'write')
7-2 privatemsg.module _privatemsg_load_thread_participants($thread_id, $account, $ignore_hidden = TRUE, $access = 'write')
6-2 privatemsg.module _privatemsg_load_thread_participants($thread_id, $account, $ignore_hidden = TRUE, $access = 'write')

Load all participants of a thread.

Parameters

$thread_id: Thread ID for which the participants should be loaded.

$account: For which account should the messages be loaded. *

$ignore_hidden: Ignores hidden participants.

$access: Which access permission should be checked (write or view).

Return value

Array with all visible/writable participants for that thread.

3 calls to _privatemsg_load_thread_participants()
privatemsg_new_validate in ./privatemsg.pages.inc
privatemsg_reply in ./privatemsg.module
Send a reply message
privatemsg_thread_load in ./privatemsg.module
Load a thread with all the messages and participants.

File

./privatemsg.module, line 860
Allows users to send private messages to other users.

Code

function _privatemsg_load_thread_participants($thread_id, $account, $ignore_hidden = TRUE, $access = 'write') {
  $query = _privatemsg_assemble_query('participants', $thread_id, $account);
  $participants = array();
  $to_load = array();
  foreach ($query->execute() as $participant) {
    if ($ignore_hidden && $participant->type == 'hidden') {
      continue;
    }
    elseif (privatemsg_recipient_access($participant->type, $access, $participant)) {
      $to_load[$participant->type][] = $participant->recipient;
    }
  }

  // Now, load all non-user recipients.
  foreach ($to_load as $type => $ids) {
    $type_info = privatemsg_recipient_get_type($type);
    if (isset($type_info['load']) && is_callable($type_info['load'])) {
      $loaded = $type_info['load']($ids, $type);
      if (is_array($loaded)) {
        $participants += $loaded;
      }
    }
  }
  if ($access == 'write' && $account) {
    // Remove author if loading participants for writing and when he is not the
    // only recipient.
    if (isset($participants['user_' . $account->uid]) && count($participants) > 1) {
      unset($participants['user_' . $account->uid]);
    }
  }
  return $participants;
}