You are here

function template_preprocess_privatemsg_view in Privatemsg 6.2

Same name and namespace in other branches
  1. 6 privatemsg.module \template_preprocess_privatemsg_view()
  2. 7.2 privatemsg.module \template_preprocess_privatemsg_view()
  3. 7 privatemsg.module \template_preprocess_privatemsg_view()

File

./privatemsg.module, line 752
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['classes'] = $message['classes'];
  $vars['thread_id'] = isset($message['thread_id']) ? $message['thread_id'] : NULL;
  $vars['author_picture'] = theme('user_picture', $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']);
  }

  /**
   * @todo perhaps make this timestamp configurable via admin UI?
   */
  $vars['message_timestamp'] = format_date($message['timestamp'], 'small');
  $vars['message_body'] = check_markup($message['body'], $message['format'], FALSE);
  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', $vars['message_actions'], array(
    'class' => 'privatemsg-message-actions links inline',
  )) : '';
  $vars['anchors'] = '';
  foreach ($vars['message_anchors'] as $anchor) {
    $vars['anchors'] .= '<a name="' . $anchor . '"></a>';
  }
}