function _privatemsg_load_thread_participants in Privatemsg 7
Same name and namespace in other branches
- 6.2 privatemsg.module \_privatemsg_load_thread_participants()
- 6 privatemsg.module \_privatemsg_load_thread_participants()
- 7.2 privatemsg.module \_privatemsg_load_thread_participants()
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 877 - 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);
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;
}