You are here

unpublished_404.module in Unpublished 404 7

Same filename and directory in other branches
  1. 8 unpublished_404.module

Code for the unpublished 404.

File

unpublished_404.module
View source
<?php

/**
 * @file
 * Code for the unpublished 404.
 */

/**
 * Implements hook_module_implements_alter().
 */
function unpublished_404_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'menu_alter') {
    $this_imp = $implementations['unpublished_404'];
    unset($implementations['unpublished_404']);
    $implementations['unpublished_404'] = $this_imp;
  }
}

/**
 * Implements hook_menu_alter().
 */
function unpublished_404_menu_alter(&$items) {
  $items['node/%node']['access callback'] = 'unpublished_404_node_access';
  $items['node/%node']['access arguments'] = array();
  $items['node/%node']['page callback'] = 'unpublished_404_node_page_view';
}

/**
 * Access callback.
 * An access callback for all individual node pages.
 */
function unpublished_404_node_access() {
  return TRUE;
}

/**
 * Page callback.
 * A page callback for all individual node pages.
 *
 * @param object $node
 *   A node object that is being viewed.
 */
function unpublished_404_node_page_view($node) {
  $node_content = '';
  if (!node_access('view', $node)) {
    if ($node->status != NODE_PUBLISHED) {
      $node_content = MENU_NOT_FOUND;
    }
    else {
      $node_content = MENU_ACCESS_DENIED;
    }
  }
  elseif (module_exists('ds_extras') && function_exists('ds_extras_node_page_view')) {
    $node_content = ds_extras_node_page_view($node);
  }
  else {
    $node_content = node_page_view($node);
  }
  return $node_content;
}

Functions

Namesort descending Description
unpublished_404_menu_alter Implements hook_menu_alter().
unpublished_404_module_implements_alter Implements hook_module_implements_alter().
unpublished_404_node_access Access callback. An access callback for all individual node pages.
unpublished_404_node_page_view Page callback. A page callback for all individual node pages.