function _privatemsg_format_participants in Privatemsg 7
Same name and namespace in other branches
- 6.2 privatemsg.module \_privatemsg_format_participants()
- 6 privatemsg.module \_privatemsg_format_participants()
- 7.2 privatemsg.module \_privatemsg_format_participants()
Format an array of user objects.
Parameters
$part_array: Array with user objects, for example the one returned by _privatemsg_generate_user_array.
$limit: Limit the number of user objects which should be displayed.
$no_text: When TRUE, don't display the Participants/From text.
Return value
String with formatted user objects, like user1, user2.
2 calls to _privatemsg_format_participants()
- template_preprocess_privatemsg_recipients in ./
privatemsg.module - theme_privatemsg_list_field__participants in ./
privatemsg.theme.inc - Theme the participants field.
File
- ./
privatemsg.module, line 145 - Allows users to send private messages to other users.
Code
function _privatemsg_format_participants($part_array, $limit = NULL, $no_text = FALSE) {
global $user;
if (count($part_array) > 0) {
$to = array();
$limited = FALSE;
foreach ($part_array as $account) {
// Directly address the current user.
if (isset($account->type) && in_array($account->type, array(
'hidden',
'user',
)) && $account->recipient == $user->uid) {
array_unshift($to, $no_text ? t('You', array(), array(
'context' => 'Dative',
)) : t('you', array(), array(
'context' => 'Dative',
)));
continue;
}
// Don't display recipients with type hidden.
if (isset($account->type) && $account->type == 'hidden') {
continue;
}
if (is_int($limit) && count($to) >= $limit) {
$limited = TRUE;
break;
}
$to[] = privatemsg_recipient_format($account);
}
$limit_string = '';
if ($limited) {
$limit_string = t(' and others');
}
if ($no_text) {
return implode(', ', $to) . $limit_string;
}
$last = array_pop($to);
if (count($to) == 0) {
// Only one participant
return t("From !last", array(
'!last' => $last,
));
}
else {
// Multiple participants..
$participants = implode(', ', $to);
return t('Between !participants and !last', array(
'!participants' => $participants,
'!last' => $last,
));
}
}
return '';
}