function template_preprocess_privatemsg_view in Privatemsg 7
Same name and namespace in other branches
- 6.2 privatemsg.module \template_preprocess_privatemsg_view()
- 6 privatemsg.module \template_preprocess_privatemsg_view()
- 7.2 privatemsg.module \template_preprocess_privatemsg_view()
File
- ./
privatemsg.module, line 750 - Allows users to send private messages to other users.
Code
function template_preprocess_privatemsg_view(&$vars) {
global $user;
$message = $vars['message'];
$vars['mid'] = isset($message->mid) ? $message->mid : NULL;
$vars['message_classes'] = isset($message->classes) ? $message->classes : array();
$vars['thread_id'] = isset($message->thread_id) ? $message->thread_id : NULL;
$vars['author_picture'] = theme('user_picture', array(
'account' => $message->author,
));
// Directly address the current user if he is the author.
if ($user->uid == $message->author->uid) {
$vars['author_name_link'] = t('You');
}
else {
$vars['author_name_link'] = privatemsg_recipient_format($message->author);
}
$vars['message_timestamp'] = privatemsg_format_date($message->timestamp);
$message->content = array(
'#view_mode' => 'message',
'body' => array(
'#markup' => check_markup($message->body, $message->format),
'#weight' => -4,
),
);
if ($message->has_tokens) {
// Replace tokens including option to add a notice if the user is not a
// recipient.
$message->content['body']['#markup'] = privatemsg_token_replace($message->content['body']['#markup'], array(
'privatemsg_message' => $message,
), array(
'privatemsg-token-notice' => TRUE,
'sanitize' => TRUE,
));
}
// Build fields content.
field_attach_prepare_view('privatemsg_message', array(
$vars['mid'] => $message,
), 'message');
$message->content += field_attach_view('privatemsg_message', $message, 'message');
// Render message body.
$vars['message_body'] = drupal_render($message->content);
if (isset($vars['mid']) && isset($vars['thread_id']) && privatemsg_user_access('delete privatemsg')) {
$vars['message_actions'][] = array(
'title' => t('Delete'),
'href' => 'messages/delete/' . $vars['thread_id'] . '/' . $vars['mid'],
);
}
$vars['message_anchors'][] = 'privatemsg-mid-' . $vars['mid'];
if (!empty($message->is_new)) {
$vars['message_anchors'][] = 'new';
$vars['new'] = drupal_ucfirst(t('new'));
}
// call hook_privatemsg_message_view_alter
drupal_alter('privatemsg_message_view', $vars);
$vars['message_actions'] = !empty($vars['message_actions']) ? theme('links', array(
'links' => $vars['message_actions'],
'attributes' => array(
'class' => array(
'privatemsg-message-actions',
'links',
'inline',
),
),
)) : '';
$vars['anchors'] = '';
foreach ($vars['message_anchors'] as $anchor) {
$vars['anchors'] .= '<a name="' . $anchor . '"></a>';
}
}