You are here

function advanced_forum_link in Advanced Forum 6.2

Implementation of hook_link().

File

./advanced_forum.module, line 393
Enables the look and feel of other popular forum software.

Code

function advanced_forum_link($type, $node = NULL, $teaser = FALSE) {
  $links = array();
  if ($type == 'node' && !isset($node->comment_target_nid)) {
    if (advanced_forum_is_styled($node, $teaser, $type)) {

      // Add edit / delete links to the node links to match replies.
      if (node_access('update', $node)) {
        $links['post_edit'] = array(
          'title' => t('edit'),
          'href' => 'node/' . $node->nid . '/edit',
          'query' => drupal_get_destination(),
        );
      }
      if (node_access('delete', $node)) {
        $links['post_delete'] = array(
          'title' => t('delete'),
          'href' => 'node/' . $node->nid . '/delete',
        );
      }

      // Core only adds the link if the comment form is on a separate page
      // but we want the link there regardless for consistancy.
      // Nodecomment already handles this so only run if that's not enabled.
      if (!module_exists('nodecomment')) {
        if ($node->comment == COMMENT_NODE_READ_WRITE) {
          if (user_access('post comments')) {
            if (variable_get('comment_form_location_' . $node->type, COMMENT_FORM_SEPARATE_PAGE) != COMMENT_FORM_SEPARATE_PAGE) {
              $links['comment_add'] = array(
                'title' => t('Add new comment'),
                'href' => "comment/reply/{$node->nid}",
                'attributes' => array(
                  'title' => t('Reply to this topic.'),
                ),
                'fragment' => 'comment-form',
              );
            }
          }
        }
      }
    }
  }
  return $links;
}