You are here

m4032404.module in 403 to 404 7

403 to 404 module functions.

File

m4032404.module
View source
<?php

/**
 * @file
 * 403 to 404 module functions.
 */

/**
 * Implements hook_menu().
 */
function m4032404_menu() {
  $items = array();
  $items['m4032404'] = array(
    'title' => '403 to 404 callback',
    'page callback' => 'm4032404_callback',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  $items['admin/config/system/m40323404'] = array(
    'type' => MENU_NORMAL_ITEM,
    'title' => '403 to 404 Settings',
    'description' => 'Settings for 403 to 404',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'm4032404_admin_settings',
    ),
    'access arguments' => array(
      'administer site configuration',
    ),
  );
  return $items;
}

/**
 * The 403 to 404 callback function for outputting the error page.
 */
function m4032404_callback() {
  $admin_only = variable_get('m4032404_admin_only', FALSE);
  $is_admin_url = path_is_admin(request_path());
  if ($admin_only) {
    if (!$is_admin_url) {
      if (function_exists('r4032login_redirect')) {
        return r4032login_redirect();
      }
      drupal_access_denied();
      drupal_exit();
    }
  }
  drupal_not_found();
  drupal_exit();
}

/**
 * Custom function to display the administration form.
 */
function m4032404_admin_settings() {
  $form['m4032404_admin_only'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enforce on Admin Only'),
    '#description' => t('Check the box to enforce the 404 behavior only on admin paths'),
    '#default_value' => variable_get('m4032404_admin_only', FALSE),
  );
  return system_settings_form($form);
}

Functions

Namesort descending Description
m4032404_admin_settings Custom function to display the administration form.
m4032404_callback The 403 to 404 callback function for outputting the error page.
m4032404_menu Implements hook_menu().