diff --git includes/theme.inc includes/theme.inc index 9ca40fe..d2250ba 100644 --- includes/theme.inc +++ includes/theme.inc @@ -2223,6 +2223,10 @@ function template_preprocess_html(&$variables) { * @see page.tpl.php */ function template_preprocess_page(&$variables) { + + // Keep track of the last non-admin page so we can easily create a link back. + drupal_get_last_non_admin_page(); + // Move some variables to the top level for themer convenience and template cleanliness. $variables['show_messages'] = $variables['page']['#show_messages']; diff --git modules/system/system.module modules/system/system.module index b0dcb99..7d043bf 100644 --- modules/system/system.module +++ modules/system/system.module @@ -1820,7 +1820,6 @@ function system_init() { drupal_add_css(drupal_get_path('module', 'system') . '/system-menus.css', array('weight' => CSS_SYSTEM)); drupal_add_css(drupal_get_path('module', 'system') . '/system-messages.css', array('weight' => CSS_SYSTEM)); - // Ignore slave database servers for this request. // // In Drupal's distributed database structure, new data is written to the master @@ -3686,3 +3685,54 @@ function system_admin_paths() { ); return $paths; } + +/** + * Returns the last non-administrative page visited by an authenticated user. + * + * @return + * A link to the 'back' page, if one is set. + */ +function drupal_get_last_non_admin_page() { + + // Set defaults. + $last_non_admin_page = array( + 'href' => '', + 'title' => '', + ); + + // Don't bother $_SESSION unless it's a logged-in user. + if (!user_is_anonymous()) { + + $current_path = current_path(); + if (path_is_admin($current_path)) { + + // On administrative pages, set the 'back' breadcrumb link that + // takes the user back to the last visited non-administrative page. + if (!empty($_SESSION['system_last_non_admin_page'])) { + $last_non_admin_page = $_SESSION['system_last_non_admin_page']; + } + } + + // On non-administrative pages, store data about the page so that + // administrative pages which the user visits later can link back to this + // page. + else { + + // Don't do it for the front page though, as it would be redundant due to + // the 'Home' entry. + if (variable_get('site_frontpage', 'node') != $current_path) { + + $_SESSION['system_last_non_admin_page'] = array( + 'href' => $current_path, + 'title' => drupal_get_title(), + ); + } + else { + + $_SESSION['system_last_non_admin_page'] = array(); + } + } + } + + return $last_non_admin_page; +}