You are here

function template_preprocess_privatemsg_view in Privatemsg 6

Same name and namespace in other branches
  1. 6.2 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 600
Allows users to send private messages to other users.

Code

function template_preprocess_privatemsg_view(&$vars) {

  //  drupal_set_message('<pre>'. print_r($vars,1 ) . '</pre>');
  $message = $vars['message'];
  $vars['mid'] = isset($message['mid']) ? $message['mid'] : NULL;
  $vars['thread_id'] = isset($message['thread_id']) ? $message['thread_id'] : NULL;
  $vars['author_picture'] = theme('user_picture', $message['author']);
  $vars['author_name_link'] = theme('username', $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 message'),
      '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' => 'message-actions',
  )) : '';
  $vars['anchors'] = '';
  foreach ($vars['message_anchors'] as $anchor) {
    $vars['anchors'] .= '<a name="' . $anchor . '"></a>';
  }
}