drupal_access_denied

5 common.inc drupal_access_denied()
6 common.inc drupal_access_denied()
7 common.inc drupal_access_denied()
8 common.inc drupal_access_denied()

Generates a 403 error if the request is not allowed.

Related topics

9 calls to drupal_access_denied()

File

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

Code

function drupal_access_denied() {
  drupal_set_header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');

  watchdog('access denied', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);

  // Keep old path for reference, and to allow forms to redirect to it.
  if (!isset($_REQUEST['destination'])) {
    $_REQUEST['destination'] = $_GET['q'];
  }

  $path = drupal_get_normal_path(variable_get('site_403', ''));
  if ($path && $path != $_GET['q']) {
    // Set the active item in case there are tabs to display or other
    // dependencies on the path.
    menu_set_active_item($path);
    $return = menu_execute_active_handler($path);
  }

  if (empty($return) || $return == MENU_NOT_FOUND || $return == MENU_ACCESS_DENIED) {
    drupal_set_title(t('Access denied'));
    $return = t('You are not authorized to access this page.');
  }
  print theme('page', $return);
}

Comments

---

If you want to return the error 404 page (page not found), see the function drupal_not_found().

Login or register to post comments