You are here

function privatemsg_comment_view in Privatemsg 7

Same name and namespace in other branches
  1. 7.2 privatemsg.module \privatemsg_comment_view()

Implements hook_comment_view().

File

./privatemsg.module, line 2408
Allows users to send private messages to other users.

Code

function privatemsg_comment_view($comment) {
  $types = array_filter(variable_get('privatemsg_link_node_types', array()));
  if (in_array(node_load($comment->nid)->type, $types) && variable_get('privatemsg_display_on_comments', 0)) {
    $url = privatemsg_get_link(user_load($comment->uid));
    if (!empty($url)) {
      $links['privatemsg_link'] = array(
        'title' => t('Send author a message'),
        'href' => $url . '/' . t('Message regarding @comment', array(
          '@comment' => trim($comment->subject),
        )),
        'query' => drupal_get_destination(),
      );
      $comment->content['links']['privatemsg'] = array(
        '#theme' => 'links',
        '#links' => $links,
        '#attributes' => array(
          'class' => array(
            'privatemsg-send-link',
            'privatemsg-send-link-node',
            'links',
            'inline',
          ),
        ),
      );
    }
  }
}