function _privatemsg_format_participants in Privatemsg 6
Same name and namespace in other branches
- 6.2 privatemsg.module \_privatemsg_format_participants()
- 7.2 privatemsg.module \_privatemsg_format_participants()
- 7 privatemsg.module \_privatemsg_format_participants()
Format an array of user objects.
Parameters
$part_array: Array with user objects, for example the one returnd 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 formated user objects, like user1, user2.
2 calls to _privatemsg_format_participants()
- phptemplate_privatemsg_list_field__participants in ./
privatemsg.theme.inc - Theme the participants field.
- template_preprocess_privatemsg_recipients in ./
privatemsg.module
File
- ./
privatemsg.module, line 82 - Allows users to send private messages to other users.
Code
function _privatemsg_format_participants($part_array, $limit = NULL, $no_text = FALSE) {
if (count($part_array) > 0) {
$to = array();
$limited = FALSE;
foreach ($part_array as $account) {
if (is_int($limit) && count($to) >= $limit) {
$limited = TRUE;
break;
}
$to[] = theme('username', $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 {
// Multipe participants..
$participants = implode(', ', $to);
return t('Participants: !participants and !last', array(
'!participants' => $participants,
'!last' => $last,
));
}
}
return '';
}