You are here

function quote_link in Quote 6.2

Same name and namespace in other branches
  1. 5 quote.module \quote_link()
  2. 6 quote.module \quote_link()

Implementation of hook_link().

File

./quote.module, line 58
The quote module provides a filter and appropriate links that allow users to quote nodes and other comments in their own comments.

Code

function quote_link($type, $post, $teaser = FALSE) {
  $links = array();
  if (user_access('post comments')) {
    $link = array(
      'title' => t('Quote'),
      'attributes' => array(
        'title' => t('Quote this post in your reply.'),
      ),
      'query' => 'quote=1',
      'fragment' => 'comment-form',
    );

    // $post can be either a node or a comment.
    if ($type == 'comment') {

      // Display quote link for comments only if the parent node is accepting
      // comments and has the quote filter enabled.
      $node = node_load($post->nid);
      if (in_array($node->type, _quote_variable_get('node_types')) && $node->comment == COMMENT_NODE_READ_WRITE) {
        $link['href'] = "comment/reply/{$post->nid}/{$post->cid}";
        $link['title'] = t('quote');
        $links['quote'] = $link;
      }
    }
    elseif ($type == 'node' && in_array($post->type, _quote_variable_get('node_types')) && $post->comment == COMMENT_NODE_READ_WRITE && _quote_variable_get('node_link_display')) {

      // Display quote link for nodes only if the node is accepting comments,
      // has the quote filter enabled and has quote_link_display set.
      $link['href'] = "comment/reply/{$post->nid}";
      $links['quote'] = $link;
    }
  }
  return $links;
}