You are here

function antispam_node_view in AntiSpam 7

Implements hook_node_view().

File

./antispam.module, line 889
Primary hook implementations for the Antispam module.

Code

function antispam_node_view($node, $view_mode, $langcode) {

  // $view_mode: 'full', 'teaser'
  if (antispam_is_spam_moderator($node->type)) {
    $links = array();

    // Adding publish/unpublish links.
    if (variable_get('antispam_node_publish_links', 0)) {
      if ($node->status) {
        $links['antispam_node_unpublish'] = array(
          'title' => t('Unpublish'),
          'href' => 'antispam/node/' . $node->nid . '/unpublish',
        );
      }
      else {
        $links['antispam_node_publish'] = array(
          'title' => t('Publish'),
          'href' => 'antispam/node/' . $node->nid . '/publish',
        );
      }
    }

    // Adding submit ham/submit spam links.
    if (variable_get('antispam_node_spam_links', 0)) {
      if (antispam_content_is_spam('node', $node->nid)) {
        $links['antispam_node_ham'] = array(
          'title' => t('Not Spam'),
          'href' => 'antispam/node/' . $node->nid . '/submit-ham',
        );
      }
      else {
        $links['antispam_node_spam'] = array(
          'title' => t('Spam'),
          'href' => 'antispam/node/' . $node->nid . '/submit-spam',
        );
      }
    }
    $node->content['links']['node']['#links'] = array_merge($node->content['links']['node']['#links'], $links);
  }
}