Same name and namespace in other branches
  1. 4.7.x includes/common.inc \drupal_access_denied()
  2. 5.x includes/common.inc \drupal_access_denied()
  3. 6.x includes/common.inc \drupal_access_denied()
  4. 7.x includes/common.inc \drupal_access_denied()

Generates a 403 error if the request is not allowed.

3 calls to drupal_access_denied()
file_download in includes/file.inc
Call modules to find out if a file is accessible for a given user.
page_example_baz in developer/examples/page_example.module
A more complex page callback that takes arguments.
profile_browse in modules/profile.module
Menu callback; display a list of user information.

File

includes/common.inc, line 222
Common functions that many Drupal modules will need to reference.

Code

function drupal_access_denied() {
  drupal_set_header('HTTP/1.0 403 Forbidden');
  watchdog('access denied', t('%page denied access.', array(
    '%page' => theme('placeholder', $_GET['q']),
  )), WATCHDOG_WARNING, l(t('view'), $_GET['q']));
  $path = drupal_get_normal_path(variable_get('site_403', ''));
  $status = MENU_NOT_FOUND;
  if ($path && $path != $_GET['q']) {
    menu_set_active_item($path);
    $status = menu_execute_active_handler();
  }
  if ($status != MENU_FOUND) {
    drupal_set_title(t('Access denied'));
    print theme('page', message_access());
  }
}