You are here

function quote_comment_view in Quote 7.2

Same name and namespace in other branches
  1. 7 quote.module \quote_comment_view()

Implements hook_comment_view().

File

./quote.module, line 81
Allows users to quote posts or comments.

Code

function quote_comment_view($comment) {
  $node = node_load($comment->nid);
  if (user_access('post comments') && user_access('use quote') && in_array($node->type, array_filter(variable_get('quote_allow_types'))) && $node->comment == COMMENT_NODE_OPEN && variable_get('quote_allow_comments')) {
    drupal_add_js(drupal_get_path('module', 'quote') . '/js/quote.js');
    drupal_add_js([
      'quote' => [
        'quote_selector' => variable_get('quote_selector', '#edit-comment-body textarea'),
        'quote_limit' => variable_get('quote_limit', '400'),
        'quote_selector_comment_quote_all' => variable_get('quote_selector_comment_quote_all', '.field-name-comment-body'),
        'quote_selector_node_quote_all' => variable_get('quote_selector_node_quote_all', '.field-name-body'),
        'quote_ckeditor_support' => variable_get('quote_ckeditor_support', 'FALSE'),
      ],
    ], [
      'type' => 'setting',
    ]);
    if (variable_get('quote_modes_quote_sel', TRUE)) {
      $links['comment-quote-sel'] = [
        'title' => t('quote selected'),
        'href' => '#',
        'query' => '',
        'fragment' => '',
      ];
      $comment->content['links']['comment']['#links']['comment-quote-sel'] = $links['comment-quote-sel'];
    }
    if (variable_get('quote_modes_quote_all', TRUE)) {
      $links['comment-quote-all'] = [
        'title' => t('quote all'),
        'href' => '#',
        'query' => '',
        'fragment' => '',
      ];
      $comment->content['links']['comment']['#links']['comment-quote-all'] = $links['comment-quote-all'];
    }
    if (variable_get('quote_modes_quote_reply_all', TRUE)) {
      $links['comment-quote-all-reply'] = [
        'title' => t('reply and quote all'),
        'href' => "comment/reply/{$node->nid}/{$comment->cid}",
        'query' => [
          'comment-quote-all-reply' => $comment->cid,
        ],
        'fragment' => '',
      ];
      $comment->content['links']['comment']['#links']['comment-quote-all-reply'] = $links['comment-quote-all-reply'];
    }
  }
}