Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.452 diff -u -F^f -r1.452 common.inc --- includes/common.inc 31 May 2005 21:14:25 -0000 1.452 +++ includes/common.inc 5 Jun 2005 00:17:44 -0000 @@ -237,19 +237,27 @@ function drupal_not_found() { * Generates a 403 error if the request is not allowed. */ function drupal_access_denied() { + global $user; + 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) { - menu_set_active_item($path); - $return = menu_execute_active_handler(); + if ($user->uid == 0 && variable_get('site_403_login', 0)) { + drupal_set_title(t('Access denied')); + $return = user_login(); } + else { + $path = drupal_get_normal_path(variable_get('site_403', '')); + $status = MENU_NOT_FOUND; + if ($path) { + menu_set_active_item($path); + $return = menu_execute_active_handler(); + } - if (empty($return)) { - drupal_set_title(t('Access denied')); - $return = message_access(); + if (empty($return)) { + drupal_set_title(t('Access denied')); + $return = message_access(); + } } print theme('page', $return); } Index: modules/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system.module,v retrieving revision 1.213 diff -u -F^f -r1.213 system.module --- modules/system.module 1 Jun 2005 04:17:37 -0000 1.213 +++ modules/system.module 5 Jun 2005 00:17:55 -0000 @@ -209,6 +209,7 @@ function system_view_general() { $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval'); $period['1000000000'] = t('Never'); $group = form_textfield(t('Default 403 (access denied) page'), 'site_403', variable_get('site_403', ''), 70, 70, t('This page is displayed when the requested document is denied to the current user. If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.')); + $group .= form_checkbox(t('Show anonymous user login page'), 'site_403_login', 1, variable_get('site_403_login', false), t('If the user is an anonymous user and they try to access a page that is denined to them, then the user will be presented with the login page')); $group .= form_textfield(t('Default 404 (not found) page'), 'site_404', variable_get('site_404', ''), 70, 70, t('This page is displayed when no other content matches the requested document. If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.')); $group .= form_select(t('Error reporting'), 'error_level', variable_get('error_level', 1), array(t('Write errors to the log'), t('Write errors to the log and to the screen')), t('Where Drupal, PHP and SQL errors are logged. On a production server it is recommended that errors are only written to the error log. On a test server it can be helpful to write logs to the screen.')); $group .= form_select(t('Discard log entries older than'), 'watchdog_clear', variable_get('watchdog_clear', 604800), $period, t('The time log entries should be kept. Older entries will be automatically discarded. Requires crontab.'));