diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index f924b0724020e4b9f11d995132b64591f3f22982..8648019504c5125444976e10abda7075258c01cc 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -4,6 +4,11 @@ Drupal x.x.x, xxxx-xx-xx
 - profile module:
     * made it possible to administer profile fields.
     * made it possible to browse the profiles by field.
+- menu module:
+    * made it possible to customize menus.
+- refactored 403 (forbidden) handling and added support for custom 403 pages.
+- usability:
+    * slightly reorganized navigation menus.
 
 Drupal 4.4.0, 2004-04-01 (release candidate)
 --------------------------------------------
@@ -40,7 +45,7 @@ Drupal 4.4.0, 2004-04-01 (release candidate)
     * made themes degrade gracefully in absence of CSS.
     * grouped form elements using '<fieldset>' and '<legend>' tags.
     * added '<label>' tags to form elements.
-- refactored 404 (file not found) handling to support custom 404 pages.
+- refactored 404 (file not found) handling and added support for custom 404 pages.
 - documentation:
     * added PHPDoc/Doxygen comments.
 - improved the filter system to prevent conflicts between filters:
diff --git a/includes/common.inc b/includes/common.inc
index 4433791b8099a0214c349d2bd97f35eec1509098..7af2e13b04ccd9c861fd646b87ab821c27c98dd8 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -80,7 +80,6 @@ function drupal_get_breadcrumb() {
 
   if (!isset($breadcrumb)) {
     $breadcrumb = menu_get_active_breadcrumb();
-    array_pop($breadcrumb);
   }
 
   return $breadcrumb;
@@ -253,23 +252,39 @@ function drupal_goto($url = NULL, $query = NULL, $fragment = NULL) {
  * Generates a 404 error if the request can not be handled.
  */
 function drupal_not_found() {
-  header("HTTP/1.0 404 Not Found");
-  watchdog("httpd", "404 error: '". check_query($_GET["q"]) ."' not found");
+  header('HTTP/1.0 404 Not Found');
+  watchdog('httpd', '404 error: "'. check_query($_GET['q']) .'" not found');
 
   $path = drupal_get_normal_path(variable_get('site_404', ''));
-
+  $status = MENU_FALLTHROUGH;
   if ($path) {
     menu_set_active_item($path);
+    $status = menu_execute_active_handler();
   }
 
-  if ($path && menu_active_handler_exists()) {
-    menu_execute_active_handler();
-  }
-  else {
+  if ($status != MENU_FOUND) {
     print theme('page', '', t('Page not found'));
   }
 }
 
+/**
+ * Generates a 403 error if the request is not allowed.
+ */
+function drupal_access_denied() {
+  header('HTTP/1.0 403 Forbidden');
+
+  $path = drupal_get_normal_path(variable_get('site_403', ''));
+  $status = MENU_FALLTHROUGH;
+  if ($path) {
+    menu_set_active_item($path);
+    $status = menu_execute_active_handler();
+  }
+
+  if ($status != MENU_FOUND) {
+    print theme('page', message_access(), t('Access denied'));
+  }
+}
+
 /**
  * Flexible and powerful HTTP client implementation. Allows to GET, POST, PUT
  * or any other HTTP requests. Handles redirects.
diff --git a/includes/file.inc b/includes/file.inc
index d3f6344a3bd91554a256ed21bf0dbc8e012c9d7e..5c6994330adba486655afd6290983aa7797b4977 100644
--- a/includes/file.inc
+++ b/includes/file.inc
@@ -307,7 +307,7 @@ function file_transfer($source, $headers) {
   // Transfer file in 1024 byte chunks to save memory usage.
   $fd = fopen($source, 'rb');
   while (!feof($fd)) {
-    print fgets($fd, 1024);
+    print fread($fd, 1024);
   }
   fclose($fd);
   exit();
@@ -323,7 +323,7 @@ function file_download() {
     foreach ($list as $module) {
       $headers = module_invoke($module, 'file_download', $file);
       if ($headers === -1) {
-        print theme('page', message_access());
+        drupal_access_denied();
       }
       elseif (is_array($headers)) {
         file_transfer($file, $headers);
diff --git a/includes/menu.inc b/includes/menu.inc
index 9a7c7234db707e2c4d1ce21190b3abd4c905b2ec..4ccd126cbdfb7739154b75aed985a93539e2b369 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -15,6 +15,10 @@
 define('MENU_LOCKED', 2);
 define('MENU_CUSTOM', 3);
 
+define('MENU_FALLTHROUGH', 0);
+define('MENU_DENIED', 1);
+define('MENU_FOUND', 2);
+
 /** @} */
 
 /**
@@ -23,7 +27,10 @@
  * @ingroup menu
  * @param $path Location then menu item refers to.
  * @param $title The title of the menu item to show in the rendered menu.
- * @param $callback The function to call when this is the active menu item.
+ * @param $callback
+ * - string - The function to call when this is the active menu item.
+ * - MENU_FALLTHROUGH - Use the callback defined by the menu item's parent.
+ * - MENU_DENIED - Deny access to this menu item by this user.
  * @param $weight Heavier menu items sink down the menu.
  * @param $visibility
  * - MENU_SHOW - Show the menu item (default).
@@ -31,11 +38,9 @@
  * - MENU_HIDE_NOCHILD - Hide the menu item when it has no children.
  * @param $status
  * - MENU_NORMAL - The menu item can be moved (default).
- * - MENU_MODIFIED - The administrator has moved or otherwise changed the menu item.
  * - MENU_LOCKED - The administrator may not modify the item.
- * - MENU_CUSTOM - The menu item was created by the administrator.
  */
-function menu($path, $title, $callback = NULL, $weight = 0, $visibility = MENU_SHOW, $status = MENU_NORMAL) {
+function menu($path, $title, $callback = MENU_FALLTHROUGH, $weight = 0, $visibility = MENU_SHOW, $status = MENU_NORMAL) {
   global $_menu;
 
   // add the menu to the flat list of menu items:
@@ -90,7 +95,13 @@ function menu_get_trail($path) {
 
   $trail = array();
 
-  $mid = menu_get_active_item();
+  // Find the ID of the given path.
+  while ($path && !$menu['path index'][$path]) {
+    $path = substr($path, 0, strrpos($path, '/'));
+  }
+  $mid = $menu['path index'][$path];
+
+  // Follow the parents up the chain to get the trail.
   while ($mid && $menu['items'][$mid]) {
     array_unshift($trail, $mid);
     $mid = $menu['items'][$mid]['pid'];
@@ -171,9 +182,13 @@ function menu_get_active_breadcrumb() {
   $links[] = l(t('Home'), '');
 
   $trail = menu_get_trail($_GET['q']);
+
+  // The last item in the trail is the page title; don't display it here.
+  array_pop($trail);
+
   foreach ($trail as $mid) {
-    // Don't show menu items without valid link targets.
-    if ($menu['items'][$mid]['path'] != '') {
+    // Don't show hidden menu items or items without valid link targets.
+    if (isset($menu['visible'][$mid]) && $menu['items'][$mid]['path'] != '') {
       $links[] = _menu_render_item($mid);
     }
   }
@@ -188,20 +203,26 @@ function menu_execute_active_handler() {
   $menu = menu_get_menu();
 
   $path = $_GET['q'];
-  while ($path && (!$menu['path index'][$path] || !$menu['items'][$menu['path index'][$path]]['callback'])) {
+  while ($path && (!$menu['path index'][$path] || $menu['items'][$menu['path index'][$path]]['callback'] === MENU_FALLTHROUGH)) {
     $path = substr($path, 0, strrpos($path, '/'));
   }
   $mid = $menu['path index'][$path];
+  if ($menu['items'][$mid]['callback'] === MENU_DENIED) {
+    return MENU_DENIED;
+  }
 
-  if ($menu['items'][$mid]['callback']) {
+  if (is_string($menu['items'][$mid]['callback'])) {
     $arg = substr($_GET['q'], strlen($menu['items'][$mid]['path']) + 1);
     if (isset($arg)) {
-      return call_user_func_array($menu['items'][$mid]['callback'], explode('/', $arg));
+      call_user_func_array($menu['items'][$mid]['callback'], explode('/', $arg));
     }
     else {
-      return call_user_func($menu['items'][$mid]['callback']);
+      call_user_func($menu['items'][$mid]['callback']);
     }
+    return MENU_FOUND;
   }
+
+  return MENU_FALLTHROUGH;
 }
 
 /**
@@ -211,11 +232,18 @@ function menu_active_handler_exists() {
   $menu = menu_get_menu();
 
   $path = $_GET['q'];
-  while ($path && (!$menu['path index'][$path] || !$menu['items'][$menu['path index'][$path]]['callback'])) {
+  while ($path && (!$menu['path index'][$path] || $menu['items'][$menu['path index'][$path]]['callback'] === MENU_FALLTHROUGH)) {
     $path = substr($path, 0, strrpos($path, '/'));
   }
   $mid = $menu['path index'][$path];
 
+  if ($menu['items'][$mid]['callback'] === MENU_FALLTHROUGH) {
+    return FALSE;
+  }
+  if ($menu['items'][$mid]['callback'] === MENU_DENIED) {
+    return FALSE;
+  }
+
   return function_exists($menu['items'][$mid]['callback']);
 }
 
@@ -298,7 +326,7 @@ function menu_build() {
     while ($item = db_fetch_object($result)) {
       // First, add any custom items added by the administrator.
       if ($item->status == MENU_CUSTOM) {
-        $_menu['items'][$item->mid] = array('pid' => $item->pid, 'path' => $item->path, 'title' => $item->title, 'callback' => NULL, 'weight' => $item->weight, 'visibility' => MENU_SHOW, 'status' => MENU_CUSTOM);
+        $_menu['items'][$item->mid] = array('pid' => $item->pid, 'path' => $item->path, 'title' => $item->title, 'callback' => MENU_FALLTHROUGH, 'weight' => $item->weight, 'visibility' => MENU_SHOW, 'status' => MENU_CUSTOM);
         $_menu['path index'][$item->path] = $item->mid;
       }
       // Don't display non-custom menu items if no module declared them.
@@ -371,9 +399,12 @@ function menu_build_visible_tree($pid = 0) {
         $children = array_merge($children, menu_build_visible_tree($mid));
       }
     }
-    if (($parent['visibility'] == MENU_SHOW) ||
-        ($parent['visibility'] == MENU_HIDE_NOCHILD && count($children) > 1)) {
+    if ((($parent['visibility'] == MENU_SHOW) ||
+        ($parent['visibility'] == MENU_HIDE_NOCHILD && count($children) > 1)) && $parent['callback'] !== MENU_DENIED) {
       $_menu['visible'][$pid] = array('title' => $parent['title'], 'path' => $parent['path'], 'children' => $children);
+      foreach ($children as $mid) {
+        $_menu['visible'][$mid]['pid'] = $pid;
+      }
       return array($pid);
     }
     else {
diff --git a/index.php b/index.php
index 24b787cd56ac1a557ac892e4368acd0f07f62ca2..9ab6e663835520d14ebe5d83267f148b5867c4fe 100644
--- a/index.php
+++ b/index.php
@@ -7,11 +7,15 @@
 
 fix_gpc_magic();
 
-if (menu_active_handler_exists()) {
-  menu_execute_active_handler();
-}
-else {
-  drupal_not_found();
+$status = menu_execute_active_handler();
+switch ($status) {
+  case MENU_FOUND:
+    break;
+  case MENU_DENIED:
+    drupal_access_denied();
+    break;
+  default:
+    drupal_not_found();
 }
 
 drupal_page_footer();
diff --git a/modules/admin.module b/modules/admin.module
index 23fdb6c8a6151350bdfbf169a986cf04133ede37..6d10699470aa50cfb55e2459170b916124d6307b 100644
--- a/modules/admin.module
+++ b/modules/admin.module
@@ -12,9 +12,12 @@ function admin_help($section) {
   }
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function admin_link($type) {
-  if ($type == "system" && user_access("access administration pages")) {
-    menu("admin", t("administer"), "admin_admin", 9);
+  if ($type == 'system') {
+    menu('admin', t('administer'), user_access('access administration pages') ? 'admin_admin' : MENU_DENIED, 9);
   }
 }
 
diff --git a/modules/aggregator.module b/modules/aggregator.module
index 8b78b71fdae63a8269a9af5faca46b4fdd29d5b7..180569fdfe1a45c5c3f09d5ba9ec53519105d4a7 100644
--- a/modules/aggregator.module
+++ b/modules/aggregator.module
@@ -85,27 +85,28 @@ function aggregator_perm() {
   return array('administer news feeds', 'access news feeds');
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function aggregator_link($type) {
   if ($type == 'page' && user_access('access news feeds')) {
     return array(l(t('news feeds'), 'aggregator', array('title' => t('Read the latest news from syndicated web sites.'))));
   }
 
   if ($type == 'system') {
-    if (user_access('administer news feeds')) {
-      menu('admin/syndication', t('syndication'), 'aggregator_help_page', 5);
-      menu('admin/syndication/news', t('RSS/RDF'), 'aggregator_admin');
-      menu('admin/syndication/news/add/feed', t('new feed'), 'aggregator_admin', 2);
-      menu('admin/syndication/news/add/bundle', t('new bundle'), 'aggregator_admin', 3);
-      menu('admin/syndication/news/tag', t('tag items'), 'aggregator_admin', 4);
-      menu('admin/syndication/news/help', t('help'), 'aggregator_help_page', 9);
-    }
-
-    if (user_access('access news feeds')) {
-      menu('aggregator', t('news aggregator'), 'aggregator_page', 5);
-      menu('aggregator/feeds', t('news by source'), 'aggregator_page');
-      menu('aggregator/bundles', t('news by topic'), 'aggregator_page');
-      menu('aggregator/sources', t('news sources'), 'aggregator_page');
-    }
+    $access = user_access('administer news feeds');
+    menu('admin/syndication', t('syndication'), $access ? 'aggregator_help_page' : MENU_DENIED, 5);
+    menu('admin/syndication/news', t('RSS/RDF'), $access ? 'aggregator_admin' : MENU_DENIED);
+    menu('admin/syndication/news/add/feed', t('new feed'), $access ? 'aggregator_admin' : MENU_DENIED, 2);
+    menu('admin/syndication/news/add/bundle', t('new bundle'), $access ? 'aggregator_admin' : MENU_DENIED, 3);
+    menu('admin/syndication/news/tag', t('tag items'), $access ? 'aggregator_admin' : MENU_DENIED, 4);
+    menu('admin/syndication/news/help', t('help'), $access ? 'aggregator_help_page' : MENU_DENIED, 9);
+
+    $access = user_access('access news feeds');
+    menu('aggregator', t('news aggregator'), $access ? 'aggregator_page' : MENU_DENIED, 5);
+    menu('aggregator/feeds', t('news by source'), $access ? 'aggregator_page' : MENU_DENIED);
+    menu('aggregator/bundles', t('news by topic'), $access ? 'aggregator_page' : MENU_DENIED);
+    menu('aggregator/sources', t('news sources'), $access ? 'aggregator_page' : MENU_DENIED);
   }
 }
 
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module
index 8b78b71fdae63a8269a9af5faca46b4fdd29d5b7..180569fdfe1a45c5c3f09d5ba9ec53519105d4a7 100644
--- a/modules/aggregator/aggregator.module
+++ b/modules/aggregator/aggregator.module
@@ -85,27 +85,28 @@ function aggregator_perm() {
   return array('administer news feeds', 'access news feeds');
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function aggregator_link($type) {
   if ($type == 'page' && user_access('access news feeds')) {
     return array(l(t('news feeds'), 'aggregator', array('title' => t('Read the latest news from syndicated web sites.'))));
   }
 
   if ($type == 'system') {
-    if (user_access('administer news feeds')) {
-      menu('admin/syndication', t('syndication'), 'aggregator_help_page', 5);
-      menu('admin/syndication/news', t('RSS/RDF'), 'aggregator_admin');
-      menu('admin/syndication/news/add/feed', t('new feed'), 'aggregator_admin', 2);
-      menu('admin/syndication/news/add/bundle', t('new bundle'), 'aggregator_admin', 3);
-      menu('admin/syndication/news/tag', t('tag items'), 'aggregator_admin', 4);
-      menu('admin/syndication/news/help', t('help'), 'aggregator_help_page', 9);
-    }
-
-    if (user_access('access news feeds')) {
-      menu('aggregator', t('news aggregator'), 'aggregator_page', 5);
-      menu('aggregator/feeds', t('news by source'), 'aggregator_page');
-      menu('aggregator/bundles', t('news by topic'), 'aggregator_page');
-      menu('aggregator/sources', t('news sources'), 'aggregator_page');
-    }
+    $access = user_access('administer news feeds');
+    menu('admin/syndication', t('syndication'), $access ? 'aggregator_help_page' : MENU_DENIED, 5);
+    menu('admin/syndication/news', t('RSS/RDF'), $access ? 'aggregator_admin' : MENU_DENIED);
+    menu('admin/syndication/news/add/feed', t('new feed'), $access ? 'aggregator_admin' : MENU_DENIED, 2);
+    menu('admin/syndication/news/add/bundle', t('new bundle'), $access ? 'aggregator_admin' : MENU_DENIED, 3);
+    menu('admin/syndication/news/tag', t('tag items'), $access ? 'aggregator_admin' : MENU_DENIED, 4);
+    menu('admin/syndication/news/help', t('help'), $access ? 'aggregator_help_page' : MENU_DENIED, 9);
+
+    $access = user_access('access news feeds');
+    menu('aggregator', t('news aggregator'), $access ? 'aggregator_page' : MENU_DENIED, 5);
+    menu('aggregator/feeds', t('news by source'), $access ? 'aggregator_page' : MENU_DENIED);
+    menu('aggregator/bundles', t('news by topic'), $access ? 'aggregator_page' : MENU_DENIED);
+    menu('aggregator/sources', t('news sources'), $access ? 'aggregator_page' : MENU_DENIED);
   }
 }
 
diff --git a/modules/archive.module b/modules/archive.module
index 8fd216d493ecd8920f56b09512ad8b772bb7e2d9..ed4be574f2bac953e2fcc688681b5c20065b7b3a 100644
--- a/modules/archive.module
+++ b/modules/archive.module
@@ -182,18 +182,18 @@ function archive_block($op = "list", $delta = 0) {
   }
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function archive_link($type) {
-
   $links = array();
 
-  if ($type == "page" && user_access("access content")) {
-    $links[] = l(t("archives"), "archive", array("title" => t("Read the older content in our archive.")));
+  if ($type == 'page' && user_access('access content')) {
+    $links[] = l(t('archives'), 'archive', array('title' => t('Read the older content in our archive.')));
   }
 
-  if ($type == "system") {
-    if (user_access("access content")) {
-      menu("archive", t("archives"), "archive_page", 0, MENU_HIDE);
-    }
+  if ($type == 'system') {
+    menu('archive', t('archives'), user_access('access content') ? 'archive_page' : MENU_DENIED, 0, MENU_HIDE);
   }
 
   return $links;
diff --git a/modules/archive/archive.module b/modules/archive/archive.module
index 8fd216d493ecd8920f56b09512ad8b772bb7e2d9..ed4be574f2bac953e2fcc688681b5c20065b7b3a 100644
--- a/modules/archive/archive.module
+++ b/modules/archive/archive.module
@@ -182,18 +182,18 @@ function archive_block($op = "list", $delta = 0) {
   }
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function archive_link($type) {
-
   $links = array();
 
-  if ($type == "page" && user_access("access content")) {
-    $links[] = l(t("archives"), "archive", array("title" => t("Read the older content in our archive.")));
+  if ($type == 'page' && user_access('access content')) {
+    $links[] = l(t('archives'), 'archive', array('title' => t('Read the older content in our archive.')));
   }
 
-  if ($type == "system") {
-    if (user_access("access content")) {
-      menu("archive", t("archives"), "archive_page", 0, MENU_HIDE);
-    }
+  if ($type == 'system') {
+    menu('archive', t('archives'), user_access('access content') ? 'archive_page' : MENU_DENIED, 0, MENU_HIDE);
   }
 
   return $links;
diff --git a/modules/block.module b/modules/block.module
index 63ad283a0bd45ea256bcfa0ddb6d440d5d98d2b8..a2f79c0e7dcdf09713e1c9e969bbb20f4be9e23a 100644
--- a/modules/block.module
+++ b/modules/block.module
@@ -61,13 +61,15 @@ function block_perm() {
   return array("administer blocks");
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function block_link($type) {
-  if ($type == "system" && user_access("administer blocks")) {
-
-    menu("admin/system/block", t("blocks"), "block_admin", 3);
-    menu("admin/system/block/add", t("new block"), "block_admin", 2);
-    menu("admin/system/block/preview", t("preview placement"), "block_admin", 3);
-    menu("admin/system/block/help", t("help"), "block_help_page", 9);
+  if ($type == 'system') {
+    menu('admin/system/block', t('blocks'), user_access('administer blocks') ? 'block_admin' : MENU_DENIED, 3);
+    menu('admin/system/block/add', t('new block'), user_access('administer blocks') ? 'block_admin' : MENU_DENIED, 2);
+    menu('admin/system/block/preview', t('preview placement'), user_access('administer blocks') ? 'block_admin' : MENU_DENIED, 3);
+    menu('admin/system/block/help', t('help'), user_access('administer blocks') ? 'block_help_page' : MENU_DENIED, 9);
   }
 }
 
diff --git a/modules/block/block.module b/modules/block/block.module
index 63ad283a0bd45ea256bcfa0ddb6d440d5d98d2b8..a2f79c0e7dcdf09713e1c9e969bbb20f4be9e23a 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -61,13 +61,15 @@ function block_perm() {
   return array("administer blocks");
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function block_link($type) {
-  if ($type == "system" && user_access("administer blocks")) {
-
-    menu("admin/system/block", t("blocks"), "block_admin", 3);
-    menu("admin/system/block/add", t("new block"), "block_admin", 2);
-    menu("admin/system/block/preview", t("preview placement"), "block_admin", 3);
-    menu("admin/system/block/help", t("help"), "block_help_page", 9);
+  if ($type == 'system') {
+    menu('admin/system/block', t('blocks'), user_access('administer blocks') ? 'block_admin' : MENU_DENIED, 3);
+    menu('admin/system/block/add', t('new block'), user_access('administer blocks') ? 'block_admin' : MENU_DENIED, 2);
+    menu('admin/system/block/preview', t('preview placement'), user_access('administer blocks') ? 'block_admin' : MENU_DENIED, 3);
+    menu('admin/system/block/help', t('help'), user_access('administer blocks') ? 'block_help_page' : MENU_DENIED, 9);
   }
 }
 
diff --git a/modules/blog.module b/modules/blog.module
index 796df58abe529ae2dee660de9869c1c6ff122d06..48fdb5847ac4698090d9ef5eca000d0eb3773b87 100644
--- a/modules/blog.module
+++ b/modules/blog.module
@@ -211,31 +211,30 @@ function blog_view($node, $main = 0, $page = 0) {
   return theme("node", $node, $main, $page);
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function blog_link($type, $node = 0, $main) {
   global $user;
 
   $links = array();
 
-  if ($type == "system") {
-    if (user_access("maintain personal blog")) {
-      menu("node/add/blog", t("blog entry"), "node_page", 0);
-      menu("blog/". $user->uid, t("my blog"), "blog_page", 1, MENU_SHOW, MENU_LOCKED);
-    }
-    if (user_access("access content")) {
-      menu("blog", t("blogs"), "blog_page", 0, MENU_HIDE);
-    }
+  if ($type == 'system') {
+    menu('node/add/blog', t('blog entry'), user_access('maintain personal blog') ? 'node_page' : MENU_DENIED, 0);
+    menu('blog/'. $user->uid, t('my blog'), user_access('maintain personal blog') ? 'blog_page' : MENU_DENIED, 1, MENU_SHOW, MENU_LOCKED);
+    menu('blog', t('blogs'), user_access('access content') ? 'blog_page' : MENU_DENIED, 0, MENU_HIDE);
   }
 
-  if ($type == "page" && user_access("access content")) {
-    $links[] = l(t("blogs"), "blog", array("title" => t("Read the latest blog entries.")));
+  if ($type == 'page' && user_access('access content')) {
+    $links[] = l(t('blogs'), 'blog', array('title' => t('Read the latest blog entries.')));
   }
 
-  if ($type == "node" && $node->type == "blog") {
-    if (blog_access("update", $node)) {
-      $links[] = l(t("edit this blog entry"), "node/edit/$node->nid", array("title" => t("Edit this blog entry.")));
+  if ($type == 'node' && $node->type == 'blog') {
+    if (blog_access('update', $node)) {
+      $links[] = l(t('edit this blog entry'), "node/edit/$node->nid", array('title' => t('Edit this blog entry.')));
     }
     elseif (arg(0) != 'blog' && arg(1) != $node->uid) {
-      $links[] = l(t("%username's blog", array("%username" => $node->name)), "blog/$node->uid", array("title" => t("Read %username's latest blog entries.", array("%username" => $node->name))));
+      $links[] = l(t("%username's blog", array('%username' => $node->name)), "blog/$node->uid", array('title' => t("Read %username's latest blog entries.", array('%username' => $node->name))));
     }
   }
 
diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index 796df58abe529ae2dee660de9869c1c6ff122d06..48fdb5847ac4698090d9ef5eca000d0eb3773b87 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -211,31 +211,30 @@ function blog_view($node, $main = 0, $page = 0) {
   return theme("node", $node, $main, $page);
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function blog_link($type, $node = 0, $main) {
   global $user;
 
   $links = array();
 
-  if ($type == "system") {
-    if (user_access("maintain personal blog")) {
-      menu("node/add/blog", t("blog entry"), "node_page", 0);
-      menu("blog/". $user->uid, t("my blog"), "blog_page", 1, MENU_SHOW, MENU_LOCKED);
-    }
-    if (user_access("access content")) {
-      menu("blog", t("blogs"), "blog_page", 0, MENU_HIDE);
-    }
+  if ($type == 'system') {
+    menu('node/add/blog', t('blog entry'), user_access('maintain personal blog') ? 'node_page' : MENU_DENIED, 0);
+    menu('blog/'. $user->uid, t('my blog'), user_access('maintain personal blog') ? 'blog_page' : MENU_DENIED, 1, MENU_SHOW, MENU_LOCKED);
+    menu('blog', t('blogs'), user_access('access content') ? 'blog_page' : MENU_DENIED, 0, MENU_HIDE);
   }
 
-  if ($type == "page" && user_access("access content")) {
-    $links[] = l(t("blogs"), "blog", array("title" => t("Read the latest blog entries.")));
+  if ($type == 'page' && user_access('access content')) {
+    $links[] = l(t('blogs'), 'blog', array('title' => t('Read the latest blog entries.')));
   }
 
-  if ($type == "node" && $node->type == "blog") {
-    if (blog_access("update", $node)) {
-      $links[] = l(t("edit this blog entry"), "node/edit/$node->nid", array("title" => t("Edit this blog entry.")));
+  if ($type == 'node' && $node->type == 'blog') {
+    if (blog_access('update', $node)) {
+      $links[] = l(t('edit this blog entry'), "node/edit/$node->nid", array('title' => t('Edit this blog entry.')));
     }
     elseif (arg(0) != 'blog' && arg(1) != $node->uid) {
-      $links[] = l(t("%username's blog", array("%username" => $node->name)), "blog/$node->uid", array("title" => t("Read %username's latest blog entries.", array("%username" => $node->name))));
+      $links[] = l(t("%username's blog", array('%username' => $node->name)), "blog/$node->uid", array('title' => t("Read %username's latest blog entries.", array('%username' => $node->name))));
     }
   }
 
diff --git a/modules/book.module b/modules/book.module
index eea1f73c930c0726ca27fd68f314f045c65eb66f..bd7881e74a3c3a895b62d4a522cdfa2cfb90af85 100644
--- a/modules/book.module
+++ b/modules/book.module
@@ -47,40 +47,38 @@ function book_access($op, $node) {
   }
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function book_link($type, $node = 0, $main = 0) {
 
   $links = array();
 
-  if ($type == "page" && user_access("access content")) {
-    $links[] = l(t("books"), "book", array("title" => t("Read and contribute to the collaborative books.")));
+  if ($type == 'page' && user_access('access content')) {
+    $links[] = l(t('books'), 'book', array('title' => t('Read and contribute to the collaborative books.')));
   }
 
-  if ($type == "node" && $node->type == "book") {
-    if (book_access("update", $node)) {
-      $links[] = l(t("edit this page"), "node/edit/$node->nid", array("title" => t("Suggest an update for this book page.")));
+  if ($type == 'node' && $node->type == 'book') {
+    if (book_access('update', $node)) {
+      $links[] = l(t('edit this page'), "node/edit/$node->nid", array('title' => t('Suggest an update for this book page.')));
     }
     if (!$main) {
-      $links[] = l(t("printer-friendly version"), "book/print/$node->nid", array("title" => t("Show a printer-friendly version of this book page and its sub-pages.")));
+      $links[] = l(t('printer-friendly version'), "book/print/$node->nid", array('title' => t('Show a printer-friendly version of this book page and its sub-pages.')));
     }
   }
 
-  if ($type == "system") {
-    if (user_access("maintain books")) {
-      menu("node/add/book", t("book page"), "node_page", 0);
-    }
-    if (user_access("administer nodes")) {
-      menu("admin/node/book", t("books"), "book_admin", 4);
-      menu("admin/node/book/orphan", t("orphan pages"), "book_admin_orphan", 8);
-      menu("admin/node/book/help", t("help"), "book_help_page", 9);
+  if ($type == 'system') {
+    menu('node/add/book', t('book page'), user_access('maintain books') ? 'node_page' : MENU_DENIED, 0);
 
-      $result = db_query("SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = 0 ORDER BY b.weight, n.title");
-      while ($book = db_fetch_object($result)) {
-        menu("admin/node/book/$book->nid", t("'%title' book", array("%title" => $book->title)), "book_admin");
-      }
-    }
-    if (user_access("access content")) {
-      menu("book", t("books"), "book_page", 0, MENU_HIDE);
+    menu('admin/node/book', t('books'), user_access('administer nodes') ? 'book_admin' : MENU_DENIED, 4);
+    menu('admin/node/book/orphan', t('orphan pages'), user_access('administer nodes') ? 'book_admin_orphan' : MENU_DENIED, 8);
+    menu('admin/node/book/help', t('help'), user_access('administer nodes') ? 'book_help_page' : MENU_DENIED, 9);
+
+    $result = db_query("SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = 0 ORDER BY b.weight, n.title");
+    while ($book = db_fetch_object($result)) {
+      menu("admin/node/book/$book->nid", t('"%title" book', array('%title' => $book->title)), user_access('administer nodes') ? 'book_admin' : MENU_DENIED);
     }
+    menu('book', t('books'), user_access('access content') ? 'book_page' : MENU_DENIED, 0, MENU_HIDE);
   }
 
   return $links;
@@ -677,7 +675,7 @@ function book_page() {
     }
   }
   else {
-    print theme("page", message_access());
+    drupal_access_denied();
   }
 }
 
diff --git a/modules/book/book.module b/modules/book/book.module
index eea1f73c930c0726ca27fd68f314f045c65eb66f..bd7881e74a3c3a895b62d4a522cdfa2cfb90af85 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -47,40 +47,38 @@ function book_access($op, $node) {
   }
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function book_link($type, $node = 0, $main = 0) {
 
   $links = array();
 
-  if ($type == "page" && user_access("access content")) {
-    $links[] = l(t("books"), "book", array("title" => t("Read and contribute to the collaborative books.")));
+  if ($type == 'page' && user_access('access content')) {
+    $links[] = l(t('books'), 'book', array('title' => t('Read and contribute to the collaborative books.')));
   }
 
-  if ($type == "node" && $node->type == "book") {
-    if (book_access("update", $node)) {
-      $links[] = l(t("edit this page"), "node/edit/$node->nid", array("title" => t("Suggest an update for this book page.")));
+  if ($type == 'node' && $node->type == 'book') {
+    if (book_access('update', $node)) {
+      $links[] = l(t('edit this page'), "node/edit/$node->nid", array('title' => t('Suggest an update for this book page.')));
     }
     if (!$main) {
-      $links[] = l(t("printer-friendly version"), "book/print/$node->nid", array("title" => t("Show a printer-friendly version of this book page and its sub-pages.")));
+      $links[] = l(t('printer-friendly version'), "book/print/$node->nid", array('title' => t('Show a printer-friendly version of this book page and its sub-pages.')));
     }
   }
 
-  if ($type == "system") {
-    if (user_access("maintain books")) {
-      menu("node/add/book", t("book page"), "node_page", 0);
-    }
-    if (user_access("administer nodes")) {
-      menu("admin/node/book", t("books"), "book_admin", 4);
-      menu("admin/node/book/orphan", t("orphan pages"), "book_admin_orphan", 8);
-      menu("admin/node/book/help", t("help"), "book_help_page", 9);
+  if ($type == 'system') {
+    menu('node/add/book', t('book page'), user_access('maintain books') ? 'node_page' : MENU_DENIED, 0);
 
-      $result = db_query("SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = 0 ORDER BY b.weight, n.title");
-      while ($book = db_fetch_object($result)) {
-        menu("admin/node/book/$book->nid", t("'%title' book", array("%title" => $book->title)), "book_admin");
-      }
-    }
-    if (user_access("access content")) {
-      menu("book", t("books"), "book_page", 0, MENU_HIDE);
+    menu('admin/node/book', t('books'), user_access('administer nodes') ? 'book_admin' : MENU_DENIED, 4);
+    menu('admin/node/book/orphan', t('orphan pages'), user_access('administer nodes') ? 'book_admin_orphan' : MENU_DENIED, 8);
+    menu('admin/node/book/help', t('help'), user_access('administer nodes') ? 'book_help_page' : MENU_DENIED, 9);
+
+    $result = db_query("SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = 0 ORDER BY b.weight, n.title");
+    while ($book = db_fetch_object($result)) {
+      menu("admin/node/book/$book->nid", t('"%title" book', array('%title' => $book->title)), user_access('administer nodes') ? 'book_admin' : MENU_DENIED);
     }
+    menu('book', t('books'), user_access('access content') ? 'book_page' : MENU_DENIED, 0, MENU_HIDE);
   }
 
   return $links;
@@ -677,7 +675,7 @@ function book_page() {
     }
   }
   else {
-    print theme("page", message_access());
+    drupal_access_denied();
   }
 }
 
diff --git a/modules/comment.module b/modules/comment.module
index 0b2d1f7f728775a3e50593a35514b3f8bb3be2bf..08afd3c180b0ae2babc8fca12020cfa2c85bc9db 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -716,10 +716,13 @@ function comment_perm() {
   return array("access comments", "post comments", "administer comments", "moderate comments", "post comments without approval", "administer moderation");
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function comment_link($type, $node = 0, $main = 0) {
   $links = array();
 
-  if ($type == "node" && $node->comment) {
+  if ($type == 'node' && $node->comment) {
 
     if ($main) {
 
@@ -727,24 +730,24 @@ function comment_link($type, $node = 0, $main = 0) {
       ** Main page: display the number of comments that have been posted.
       */
 
-      if (user_access("access comments")) {
+      if (user_access('access comments')) {
         $all = comment_num_all($node->nid);
         $new = comment_num_new($node->nid);
 
         if ($all) {
-          $links[] = l(format_plural($all, "1 comment", "%count comments"), "node/view/$node->nid", array("title" => t("Jump to the first comment of this posting.")), NULL, "comment");
+          $links[] = l(format_plural($all, '1 comment', '%count comments'), "node/view/$node->nid", array('title' => t('Jump to the first comment of this posting.')), NULL, 'comment');
 
           if ($new) {
-            $links[] = l(format_plural($new, "1 new comment", "%count new comments"), "node/view/$node->nid", array("title" => t("Jump to the first new comment of this posting.")), NULL, "new");
+            $links[] = l(format_plural($new, '1 new comment', '%count new comments'), "node/view/$node->nid", array('title' => t('Jump to the first new comment of this posting.')), NULL, 'new');
           }
         }
         else {
           if ($node->comment == 2) {
-            if (user_access("post comments")) {
-              $links[] = l(t("add new comment"), "comment/reply/$node->nid", array("title" => t("Add a new comment to this page.")));
+            if (user_access('post comments')) {
+              $links[] = l(t('add new comment'), "comment/reply/$node->nid", array('title' => t('Add a new comment to this page.')));
             }
             else {
-              $links[] = theme("comment_post_forbidden");
+              $links[] = theme('comment_post_forbidden');
             }
           }
         }
@@ -757,44 +760,42 @@ function comment_link($type, $node = 0, $main = 0) {
       */
 
       if ($node->comment == 2) {
-        if (user_access("post comments")) {
-          $links[] = l(t("add new comment"), "comment/reply/$node->nid", array("title" => t("Share your thoughts and opinions related to this posting.")), NULL, "comment");
+        if (user_access('post comments')) {
+          $links[] = l(t('add new comment'), "comment/reply/$node->nid", array('title' => t('Share your thoughts and opinions related to this posting.')), NULL, 'comment');
         }
         else {
-          $links[] = theme("comment_post_forbidden");
+          $links[] = theme('comment_post_forbidden');
         }
       }
     }
   }
 
-  if ($type == "comment") {
+  if ($type == 'comment') {
     $links = comment_links($node, $main);
   }
 
-  if ($type == "system") {
-    if (user_access("administer comments")) {
+  if ($type == 'system') {
+    $access = user_access('administer comments');
+    menu('admin/comment', t('comments'), $access ? 'comment_admin' : MENU_DENIED, 1);
+    menu('admin/comment/comments', t('overview'), $access ? 'comment_admin' : MENU_DENIED, 2);
+    menu('admin/comment/comments/0', t('new/updated'), $access ? 'comment_admin' : MENU_DENIED, 1);
+    menu('admin/comment/comments/1', t('approval queue'), $access ? 'comment_admin' : MENU_DENIED, 2);
+    menu('admin/comment/help', t('help'), $access ? 'comment_help_page' : MENU_DENIED, 9);
+    menu('admin/comment/edit', t('edit comment'), $access ? 'comment_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    menu('admin/comment/delete', t('delete comment'), $access ? 'comment_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    if (module_exist('search')) {
+      menu('admin/comment/search', t('search'), $access ? 'comment_admin' : MENU_DENIED, 8);
+    }
 
-      menu("admin/comment", t("comments"), "comment_admin", 1);
-      menu("admin/comment/comments", t("overview"), "comment_admin", 2);
-      menu("admin/comment/comments/0", t("new/updated"), "comment_admin", 1);
-      menu("admin/comment/comments/1", t("approval queue"), "comment_admin", 2);
-      menu("admin/comment/help", t("help"), "comment_help_page", 9);
-      menu("admin/comment/edit", t("edit comment"), "comment_admin", 0, MENU_HIDE, MENU_LOCKED);
-      menu("admin/comment/delete", t("delete comment"), "comment_admin", 0, MENU_HIDE, MENU_LOCKED);
-      if (module_exist('search')) {
-        menu("admin/comment/search", t("search"), "comment_admin", 8);
-      }
+    // comment settings:
+    $access = user_access('administer comments') && user_access('administer moderation');
+    menu('admin/comment/moderation', t('moderation'), $access ? 'comment_admin' : MENU_DENIED, 3);
+    menu('admin/comment/moderation/votes', t('votes'), $access ? 'comment_admin' : MENU_DENIED);
+    menu('admin/comment/moderation/matrix', t('matrix'), $access ? 'comment_admin' : MENU_DENIED);
+    menu('admin/comment/moderation/filters', t('thresholds'), $access ? 'comment_admin' : MENU_DENIED);
+    menu('admin/comment/moderation/roles', t('initial scores'), $access ? 'comment_admin' : MENU_DENIED, 6);
 
-      // comment settings:
-      if (user_access("administer moderation")) {
-        menu("admin/comment/moderation", t("moderation"), "comment_admin", 3);
-        menu("admin/comment/moderation/votes", t("votes"), "comment_admin");
-        menu("admin/comment/moderation/matrix", t("matrix"), "comment_admin");
-        menu("admin/comment/moderation/filters", t("thresholds"), "comment_admin");
-        menu("admin/comment/moderation/roles", t("initial scores"), "comment_admin", 6);
-      }
-    }
-    menu("comment", t("comments"), "comment_page", 0, MENU_HIDE, MENU_LOCKED);
+    menu('comment', t('comments'), 'comment_page', 0, MENU_HIDE, MENU_LOCKED);
   }
 
   return $links;
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 0b2d1f7f728775a3e50593a35514b3f8bb3be2bf..08afd3c180b0ae2babc8fca12020cfa2c85bc9db 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -716,10 +716,13 @@ function comment_perm() {
   return array("access comments", "post comments", "administer comments", "moderate comments", "post comments without approval", "administer moderation");
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function comment_link($type, $node = 0, $main = 0) {
   $links = array();
 
-  if ($type == "node" && $node->comment) {
+  if ($type == 'node' && $node->comment) {
 
     if ($main) {
 
@@ -727,24 +730,24 @@ function comment_link($type, $node = 0, $main = 0) {
       ** Main page: display the number of comments that have been posted.
       */
 
-      if (user_access("access comments")) {
+      if (user_access('access comments')) {
         $all = comment_num_all($node->nid);
         $new = comment_num_new($node->nid);
 
         if ($all) {
-          $links[] = l(format_plural($all, "1 comment", "%count comments"), "node/view/$node->nid", array("title" => t("Jump to the first comment of this posting.")), NULL, "comment");
+          $links[] = l(format_plural($all, '1 comment', '%count comments'), "node/view/$node->nid", array('title' => t('Jump to the first comment of this posting.')), NULL, 'comment');
 
           if ($new) {
-            $links[] = l(format_plural($new, "1 new comment", "%count new comments"), "node/view/$node->nid", array("title" => t("Jump to the first new comment of this posting.")), NULL, "new");
+            $links[] = l(format_plural($new, '1 new comment', '%count new comments'), "node/view/$node->nid", array('title' => t('Jump to the first new comment of this posting.')), NULL, 'new');
           }
         }
         else {
           if ($node->comment == 2) {
-            if (user_access("post comments")) {
-              $links[] = l(t("add new comment"), "comment/reply/$node->nid", array("title" => t("Add a new comment to this page.")));
+            if (user_access('post comments')) {
+              $links[] = l(t('add new comment'), "comment/reply/$node->nid", array('title' => t('Add a new comment to this page.')));
             }
             else {
-              $links[] = theme("comment_post_forbidden");
+              $links[] = theme('comment_post_forbidden');
             }
           }
         }
@@ -757,44 +760,42 @@ function comment_link($type, $node = 0, $main = 0) {
       */
 
       if ($node->comment == 2) {
-        if (user_access("post comments")) {
-          $links[] = l(t("add new comment"), "comment/reply/$node->nid", array("title" => t("Share your thoughts and opinions related to this posting.")), NULL, "comment");
+        if (user_access('post comments')) {
+          $links[] = l(t('add new comment'), "comment/reply/$node->nid", array('title' => t('Share your thoughts and opinions related to this posting.')), NULL, 'comment');
         }
         else {
-          $links[] = theme("comment_post_forbidden");
+          $links[] = theme('comment_post_forbidden');
         }
       }
     }
   }
 
-  if ($type == "comment") {
+  if ($type == 'comment') {
     $links = comment_links($node, $main);
   }
 
-  if ($type == "system") {
-    if (user_access("administer comments")) {
+  if ($type == 'system') {
+    $access = user_access('administer comments');
+    menu('admin/comment', t('comments'), $access ? 'comment_admin' : MENU_DENIED, 1);
+    menu('admin/comment/comments', t('overview'), $access ? 'comment_admin' : MENU_DENIED, 2);
+    menu('admin/comment/comments/0', t('new/updated'), $access ? 'comment_admin' : MENU_DENIED, 1);
+    menu('admin/comment/comments/1', t('approval queue'), $access ? 'comment_admin' : MENU_DENIED, 2);
+    menu('admin/comment/help', t('help'), $access ? 'comment_help_page' : MENU_DENIED, 9);
+    menu('admin/comment/edit', t('edit comment'), $access ? 'comment_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    menu('admin/comment/delete', t('delete comment'), $access ? 'comment_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    if (module_exist('search')) {
+      menu('admin/comment/search', t('search'), $access ? 'comment_admin' : MENU_DENIED, 8);
+    }
 
-      menu("admin/comment", t("comments"), "comment_admin", 1);
-      menu("admin/comment/comments", t("overview"), "comment_admin", 2);
-      menu("admin/comment/comments/0", t("new/updated"), "comment_admin", 1);
-      menu("admin/comment/comments/1", t("approval queue"), "comment_admin", 2);
-      menu("admin/comment/help", t("help"), "comment_help_page", 9);
-      menu("admin/comment/edit", t("edit comment"), "comment_admin", 0, MENU_HIDE, MENU_LOCKED);
-      menu("admin/comment/delete", t("delete comment"), "comment_admin", 0, MENU_HIDE, MENU_LOCKED);
-      if (module_exist('search')) {
-        menu("admin/comment/search", t("search"), "comment_admin", 8);
-      }
+    // comment settings:
+    $access = user_access('administer comments') && user_access('administer moderation');
+    menu('admin/comment/moderation', t('moderation'), $access ? 'comment_admin' : MENU_DENIED, 3);
+    menu('admin/comment/moderation/votes', t('votes'), $access ? 'comment_admin' : MENU_DENIED);
+    menu('admin/comment/moderation/matrix', t('matrix'), $access ? 'comment_admin' : MENU_DENIED);
+    menu('admin/comment/moderation/filters', t('thresholds'), $access ? 'comment_admin' : MENU_DENIED);
+    menu('admin/comment/moderation/roles', t('initial scores'), $access ? 'comment_admin' : MENU_DENIED, 6);
 
-      // comment settings:
-      if (user_access("administer moderation")) {
-        menu("admin/comment/moderation", t("moderation"), "comment_admin", 3);
-        menu("admin/comment/moderation/votes", t("votes"), "comment_admin");
-        menu("admin/comment/moderation/matrix", t("matrix"), "comment_admin");
-        menu("admin/comment/moderation/filters", t("thresholds"), "comment_admin");
-        menu("admin/comment/moderation/roles", t("initial scores"), "comment_admin", 6);
-      }
-    }
-    menu("comment", t("comments"), "comment_page", 0, MENU_HIDE, MENU_LOCKED);
+    menu('comment', t('comments'), 'comment_page', 0, MENU_HIDE, MENU_LOCKED);
   }
 
   return $links;
diff --git a/modules/drupal.module b/modules/drupal.module
index b6392a501d4b24e72ba12abc87c2687182250eb5..084fb96d1d0f8a0c3e1aba653528bac66daf396c 100644
--- a/modules/drupal.module
+++ b/modules/drupal.module
@@ -160,9 +160,12 @@ function drupal_auth($username, $password, $server) {
   return $login;
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function drupal_link($type) {
-  if ($type == "system") {
-    menu("drupal", t("Drupal"), "drupal_page", 0, MENU_HIDE);
+  if ($type == 'system') {
+    menu('drupal', t('Drupal'), 'drupal_page', 0, MENU_HIDE);
   }
 }
 
diff --git a/modules/drupal/drupal.module b/modules/drupal/drupal.module
index b6392a501d4b24e72ba12abc87c2687182250eb5..084fb96d1d0f8a0c3e1aba653528bac66daf396c 100644
--- a/modules/drupal/drupal.module
+++ b/modules/drupal/drupal.module
@@ -160,9 +160,12 @@ function drupal_auth($username, $password, $server) {
   return $login;
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function drupal_link($type) {
-  if ($type == "system") {
-    menu("drupal", t("Drupal"), "drupal_page", 0, MENU_HIDE);
+  if ($type == 'system') {
+    menu('drupal', t('Drupal'), 'drupal_page', 0, MENU_HIDE);
   }
 }
 
diff --git a/modules/filter.module b/modules/filter.module
index 4fa0547e521bc22ff6a960cf51a6077ede883379..275f85fbb83024180df8c09478854f3da3fcb984 100644
--- a/modules/filter.module
+++ b/modules/filter.module
@@ -41,13 +41,14 @@ function filter_help($section = "admin/help#filter") {
   }
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function filter_link($type) {
-  if ($type == "system") {
-    if (user_access("administer site configuration")) {
-      menu("admin/system/filters", t("filters"), "filter_admin", 5);
-      menu("admin/system/filters/order", t("ordering"), "filter_admin", 5);
-    }
-    menu("filter/tips", t("compose tips"), "filter_tips_long", 0, MENU_HIDE);
+  if ($type == 'system') {
+    menu('admin/system/filters', t('filters'), user_access('administer site configuration') ? 'filter_admin' : MENU_DENIED, 5);
+    menu('admin/system/filters/order', t('ordering'), user_access('administer site configuration') ? 'filter_admin' : MENU_DENIED, 5);
+    menu('filter/tips', t('compose tips'), 'filter_tips_long', 0, MENU_HIDE);
   }
 }
 
diff --git a/modules/filter/filter.module b/modules/filter/filter.module
index 4fa0547e521bc22ff6a960cf51a6077ede883379..275f85fbb83024180df8c09478854f3da3fcb984 100644
--- a/modules/filter/filter.module
+++ b/modules/filter/filter.module
@@ -41,13 +41,14 @@ function filter_help($section = "admin/help#filter") {
   }
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function filter_link($type) {
-  if ($type == "system") {
-    if (user_access("administer site configuration")) {
-      menu("admin/system/filters", t("filters"), "filter_admin", 5);
-      menu("admin/system/filters/order", t("ordering"), "filter_admin", 5);
-    }
-    menu("filter/tips", t("compose tips"), "filter_tips_long", 0, MENU_HIDE);
+  if ($type == 'system') {
+    menu('admin/system/filters', t('filters'), user_access('administer site configuration') ? 'filter_admin' : MENU_DENIED, 5);
+    menu('admin/system/filters/order', t('ordering'), user_access('administer site configuration') ? 'filter_admin' : MENU_DENIED, 5);
+    menu('filter/tips', t('compose tips'), 'filter_tips_long', 0, MENU_HIDE);
   }
 }
 
diff --git a/modules/forum.module b/modules/forum.module
index 3cf75c707df80bff47c844f2acb8fdd7f87095af..09dc707f62f904622780fd933b76d6665aea5e39 100644
--- a/modules/forum.module
+++ b/modules/forum.module
@@ -119,6 +119,9 @@ function forum_block($op = 'list', $delta = 0) {
   return $blocks;
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function forum_link($type, $node = 0, $main = 0) {
   global $user;
 
@@ -129,12 +132,8 @@ function forum_link($type, $node = 0, $main = 0) {
   }
 
   if ($type == 'system') {
-    if (user_access('create forum topics')) {
-      menu('node/add/forum', t('forum topic'), 'node_page');
-    }
-    if (user_access('access content')) {
-      menu('forum', t('forums'), 'forum_page', 0, MENU_HIDE);
-    }
+    menu('node/add/forum', t('forum topic'), user_access('create forum topics') ? 'node_page' : MENU_DENIED);
+    menu('forum', t('forums'), user_access('access content') ? 'forum_page' : MENU_DENIED, 0, MENU_HIDE);
   }
 
   if (!$main && $type == 'node' && $node->type == 'forum') {
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index 3cf75c707df80bff47c844f2acb8fdd7f87095af..09dc707f62f904622780fd933b76d6665aea5e39 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -119,6 +119,9 @@ function forum_block($op = 'list', $delta = 0) {
   return $blocks;
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function forum_link($type, $node = 0, $main = 0) {
   global $user;
 
@@ -129,12 +132,8 @@ function forum_link($type, $node = 0, $main = 0) {
   }
 
   if ($type == 'system') {
-    if (user_access('create forum topics')) {
-      menu('node/add/forum', t('forum topic'), 'node_page');
-    }
-    if (user_access('access content')) {
-      menu('forum', t('forums'), 'forum_page', 0, MENU_HIDE);
-    }
+    menu('node/add/forum', t('forum topic'), user_access('create forum topics') ? 'node_page' : MENU_DENIED);
+    menu('forum', t('forums'), user_access('access content') ? 'forum_page' : MENU_DENIED, 0, MENU_HIDE);
   }
 
   if (!$main && $type == 'node' && $node->type == 'forum') {
diff --git a/modules/help.module b/modules/help.module
index 56fd28d47faa8030d10701018260741bd4949e6c..927b93cdf6dd0a8bfe860d13e1df0ce7955bd408 100644
--- a/modules/help.module
+++ b/modules/help.module
@@ -1,10 +1,13 @@
 <?php
 // $Id$
 
+/**
+ * Implementation of hook_link().
+ */
 function help_link($type) {
-  if ($type == "system" && user_access("access administration pages")) {
-    menu("admin/help/glossary", t("glossary"), "help_glossary", 8);
-    menu("admin/help", t("help"), "help_help_page", 9);
+  if ($type == 'system') {
+    menu('admin/help/glossary', t('glossary'), user_access('access administration pages') ? 'help_glossary' : MENU_DENIED, 8);
+    menu('admin/help', t('help'), user_access('access administration pages') ? 'help_help_page' : MENU_DENIED, 9);
   }
 }
 
diff --git a/modules/help/help.module b/modules/help/help.module
index 56fd28d47faa8030d10701018260741bd4949e6c..927b93cdf6dd0a8bfe860d13e1df0ce7955bd408 100644
--- a/modules/help/help.module
+++ b/modules/help/help.module
@@ -1,10 +1,13 @@
 <?php
 // $Id$
 
+/**
+ * Implementation of hook_link().
+ */
 function help_link($type) {
-  if ($type == "system" && user_access("access administration pages")) {
-    menu("admin/help/glossary", t("glossary"), "help_glossary", 8);
-    menu("admin/help", t("help"), "help_help_page", 9);
+  if ($type == 'system') {
+    menu('admin/help/glossary', t('glossary'), user_access('access administration pages') ? 'help_glossary' : MENU_DENIED, 8);
+    menu('admin/help', t('help'), user_access('access administration pages') ? 'help_help_page' : MENU_DENIED, 9);
   }
 }
 
diff --git a/modules/locale.module b/modules/locale.module
index 47706292ff5610ea670680631379c7d51c033de1..a86ad5d654a5d202afd4558cb88a070f869eb27b 100644
--- a/modules/locale.module
+++ b/modules/locale.module
@@ -51,23 +51,24 @@ function locale_perm() {
   return array('administer locales');
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function locale_link($type) {
   global $languages;
 
-  if ($type == "system") {
-    if (user_access('administer locales')) {
+  if ($type == 'system') {
+    $access = user_access('administer locales');
+    menu('admin/locale', t('localization'), $access ? 'locale_admin' : MENU_DENIED, 5);
+    menu('admin/locale/search', t('search string'), $access ? 'locale_admin' : MENU_DENIED, 8);
+    menu('admin/locale/help', t('help'), $access ? 'locale_help_page' : MENU_DENIED, 9);
+    menu('admin/locale/edit', t('edit string'), $access ? 'locale_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    menu('admin/locale/delete', t('delete string'), $access ? 'locale_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
 
-      menu("admin/locale", t("localization"), "locale_admin", 5);
-      menu("admin/locale/search", t("search string"), "locale_admin", 8);
-      menu("admin/locale/help", t("help"), "locale_help_page", 9);
-      menu("admin/locale/edit", t("edit string"), "locale_admin", 0, MENU_HIDE, MENU_LOCKED);
-      menu("admin/locale/delete", t("delete string"), "locale_admin", 0, MENU_HIDE, MENU_LOCKED);
-
-      foreach ($languages as $key => $value) {
-        menu("admin/locale/$key", "$value", "locale_admin");
-        menu("admin/locale/$key/translated", t("translated strings"), "locale_admin");
-        menu("admin/locale/$key/untranslated", t("untranslated strings"), "locale_admin");
-      }
+    foreach ($languages as $key => $value) {
+      menu("admin/locale/$key", "$value", $access ? 'locale_admin' : MENU_DENIED);
+      menu("admin/locale/$key/translated", t('translated strings'), $access ? 'locale_admin' : MENU_DENIED);
+      menu("admin/locale/$key/untranslated", t('untranslated strings'), $access ? 'locale_admin' : MENU_DENIED);
     }
   }
 }
diff --git a/modules/locale/locale.module b/modules/locale/locale.module
index 47706292ff5610ea670680631379c7d51c033de1..a86ad5d654a5d202afd4558cb88a070f869eb27b 100644
--- a/modules/locale/locale.module
+++ b/modules/locale/locale.module
@@ -51,23 +51,24 @@ function locale_perm() {
   return array('administer locales');
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function locale_link($type) {
   global $languages;
 
-  if ($type == "system") {
-    if (user_access('administer locales')) {
+  if ($type == 'system') {
+    $access = user_access('administer locales');
+    menu('admin/locale', t('localization'), $access ? 'locale_admin' : MENU_DENIED, 5);
+    menu('admin/locale/search', t('search string'), $access ? 'locale_admin' : MENU_DENIED, 8);
+    menu('admin/locale/help', t('help'), $access ? 'locale_help_page' : MENU_DENIED, 9);
+    menu('admin/locale/edit', t('edit string'), $access ? 'locale_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    menu('admin/locale/delete', t('delete string'), $access ? 'locale_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
 
-      menu("admin/locale", t("localization"), "locale_admin", 5);
-      menu("admin/locale/search", t("search string"), "locale_admin", 8);
-      menu("admin/locale/help", t("help"), "locale_help_page", 9);
-      menu("admin/locale/edit", t("edit string"), "locale_admin", 0, MENU_HIDE, MENU_LOCKED);
-      menu("admin/locale/delete", t("delete string"), "locale_admin", 0, MENU_HIDE, MENU_LOCKED);
-
-      foreach ($languages as $key => $value) {
-        menu("admin/locale/$key", "$value", "locale_admin");
-        menu("admin/locale/$key/translated", t("translated strings"), "locale_admin");
-        menu("admin/locale/$key/untranslated", t("untranslated strings"), "locale_admin");
-      }
+    foreach ($languages as $key => $value) {
+      menu("admin/locale/$key", "$value", $access ? 'locale_admin' : MENU_DENIED);
+      menu("admin/locale/$key/translated", t('translated strings'), $access ? 'locale_admin' : MENU_DENIED);
+      menu("admin/locale/$key/untranslated", t('untranslated strings'), $access ? 'locale_admin' : MENU_DENIED);
     }
   }
 }
diff --git a/modules/menu.module b/modules/menu.module
index 23627895047beae5b7897c963ccc02c839dfdade..23b6058b2f80c4110b1294a4ac2d6adfd641f527 100644
--- a/modules/menu.module
+++ b/modules/menu.module
@@ -5,15 +5,15 @@
  * Implementation of hook_link().
  */
 function menu_link($type, $node = 0, $main) {
-  if ($type == 'system' && user_access('administer menu')) {
-    menu('admin/menu', t('menus'), 'menu_overview', 0, MENU_SHOW);
-    menu('admin/menu/reset', t('reset all menus'), 'menu_reset', 0, MENU_SHOW);
-    menu('admin/menu/menu/add', t('add menu'), 'menu_add_menu', 0, MENU_SHOW);
-    menu('admin/menu/item/add', t('add menu item'), 'menu_edit_item', 0, MENU_SHOW);
-    menu('admin/menu/item/edit', t('edit menu item'), 'menu_edit_item', 0, MENU_HIDE, MENU_LOCKED);
-    menu('admin/menu/item/reset', t('reset menu item'), 'menu_reset_item', 0, MENU_HIDE, MENU_LOCKED);
-    menu('admin/menu/item/disable', t('disable menu item'), 'menu_disable_item', 0, MENU_HIDE, MENU_LOCKED);
-    menu('admin/menu/item/delete', t('delete menu item'), 'menu_delete_item', 0, MENU_HIDE, MENU_LOCKED);
+  if ($type == 'system') {
+    menu('admin/menu', t('menus'), user_access('administer menu') ? 'menu_overview' : MENU_DENIED, 0, MENU_SHOW);
+    menu('admin/menu/reset', t('reset all menus'), user_access('administer menu') ? 'menu_reset' : MENU_DENIED, 0, MENU_SHOW);
+    menu('admin/menu/menu/add', t('add menu'), user_access('administer menu') ? 'menu_add_menu' : MENU_DENIED, 0, MENU_SHOW);
+    menu('admin/menu/item/add', t('add menu item'), user_access('administer menu') ? 'menu_edit_item' : MENU_DENIED, 0, MENU_SHOW);
+    menu('admin/menu/item/edit', t('edit menu item'), user_access('administer menu') ? 'menu_edit_item' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    menu('admin/menu/item/reset', t('reset menu item'), user_access('administer menu') ? 'menu_reset_item' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    menu('admin/menu/item/disable', t('disable menu item'), user_access('administer menu') ? 'menu_disable_item' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    menu('admin/menu/item/delete', t('delete menu item'), user_access('administer menu') ? 'menu_delete_item' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
   }
 }
 
diff --git a/modules/menu/menu.module b/modules/menu/menu.module
index 23627895047beae5b7897c963ccc02c839dfdade..23b6058b2f80c4110b1294a4ac2d6adfd641f527 100644
--- a/modules/menu/menu.module
+++ b/modules/menu/menu.module
@@ -5,15 +5,15 @@
  * Implementation of hook_link().
  */
 function menu_link($type, $node = 0, $main) {
-  if ($type == 'system' && user_access('administer menu')) {
-    menu('admin/menu', t('menus'), 'menu_overview', 0, MENU_SHOW);
-    menu('admin/menu/reset', t('reset all menus'), 'menu_reset', 0, MENU_SHOW);
-    menu('admin/menu/menu/add', t('add menu'), 'menu_add_menu', 0, MENU_SHOW);
-    menu('admin/menu/item/add', t('add menu item'), 'menu_edit_item', 0, MENU_SHOW);
-    menu('admin/menu/item/edit', t('edit menu item'), 'menu_edit_item', 0, MENU_HIDE, MENU_LOCKED);
-    menu('admin/menu/item/reset', t('reset menu item'), 'menu_reset_item', 0, MENU_HIDE, MENU_LOCKED);
-    menu('admin/menu/item/disable', t('disable menu item'), 'menu_disable_item', 0, MENU_HIDE, MENU_LOCKED);
-    menu('admin/menu/item/delete', t('delete menu item'), 'menu_delete_item', 0, MENU_HIDE, MENU_LOCKED);
+  if ($type == 'system') {
+    menu('admin/menu', t('menus'), user_access('administer menu') ? 'menu_overview' : MENU_DENIED, 0, MENU_SHOW);
+    menu('admin/menu/reset', t('reset all menus'), user_access('administer menu') ? 'menu_reset' : MENU_DENIED, 0, MENU_SHOW);
+    menu('admin/menu/menu/add', t('add menu'), user_access('administer menu') ? 'menu_add_menu' : MENU_DENIED, 0, MENU_SHOW);
+    menu('admin/menu/item/add', t('add menu item'), user_access('administer menu') ? 'menu_edit_item' : MENU_DENIED, 0, MENU_SHOW);
+    menu('admin/menu/item/edit', t('edit menu item'), user_access('administer menu') ? 'menu_edit_item' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    menu('admin/menu/item/reset', t('reset menu item'), user_access('administer menu') ? 'menu_reset_item' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    menu('admin/menu/item/disable', t('disable menu item'), user_access('administer menu') ? 'menu_disable_item' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    menu('admin/menu/item/delete', t('delete menu item'), user_access('administer menu') ? 'menu_delete_item' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
   }
 }
 
diff --git a/modules/node.module b/modules/node.module
index 12209ca0d24c843f59a98f58f1a3096baa52f5ff..7ecb248e6af9672adcacb6bde4588763927ac33d 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -589,6 +589,9 @@ function node_comment_mode($nid) {
   return $comment_mode[$nid];
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function node_link($type, $node = 0, $main = 0) {
 
   $links = array();
@@ -614,19 +617,15 @@ function node_link($type, $node = 0, $main = 0) {
   if ($type == 'system') {
     menu('node/add', t('create content'), 'node_page', 1, MENU_HIDE_NOCHILD);
 
-    if (user_access('administer nodes')) {
-      menu('admin/node', t('content'), 'node_admin');
-      menu('admin/node/help', t('help'), 'node_help_page', 9);
-      menu('admin/node/edit', t('edit post'), 'node_admin', 0, MENU_HIDE, MENU_LOCKED);
-      menu('admin/node/settings', t('settings'), 'node_admin', 8);
-      if (module_exist('search')) {
-        menu('admin/node/search', t('search'), 'node_admin', 8);
-      }
+    menu('admin/node', t('content'), user_access('administer nodes') ? 'node_admin' : MENU_DENIED);
+    menu('admin/node/help', t('help'), user_access('administer nodes') ? 'node_help_page' : MENU_DENIED, 9);
+    menu('admin/node/edit', t('edit post'), user_access('administer nodes') ? 'node_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    menu('admin/node/settings', t('settings'), user_access('administer nodes') ? 'node_admin' : MENU_DENIED, 8);
+    if (module_exist('search')) {
+      menu('admin/node/search', t('search'), user_access('administer nodes') ? 'node_admin' : MENU_DENIED, 8);
     }
 
-    if (user_access('access content')) {
-      menu('node', t('content'), 'node_page', 0, MENU_HIDE);
-    }
+    menu('node', t('content'), user_access('access content') ? 'node_page' : MENU_DENIED, 0, MENU_HIDE);
   }
 
   return $links;
@@ -1274,7 +1273,6 @@ function node_add($type) {
     }
     $output = node_form($node);
     drupal_set_title(t('Submit %name', array('%name' => node_invoke($node, 'node_name'))));
-    drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('create content'), 'node/add')));
   }
   else {
 
@@ -1292,7 +1290,6 @@ function node_add($type) {
     }
 
     $output = t('Choose the appropriate item from the list:') ."<ul>$output</ul>";
-    drupal_set_breadcrumb(array(l(t('Home'), NULL)));
   }
 
   return $output;
diff --git a/modules/node/node.module b/modules/node/node.module
index 12209ca0d24c843f59a98f58f1a3096baa52f5ff..7ecb248e6af9672adcacb6bde4588763927ac33d 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -589,6 +589,9 @@ function node_comment_mode($nid) {
   return $comment_mode[$nid];
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function node_link($type, $node = 0, $main = 0) {
 
   $links = array();
@@ -614,19 +617,15 @@ function node_link($type, $node = 0, $main = 0) {
   if ($type == 'system') {
     menu('node/add', t('create content'), 'node_page', 1, MENU_HIDE_NOCHILD);
 
-    if (user_access('administer nodes')) {
-      menu('admin/node', t('content'), 'node_admin');
-      menu('admin/node/help', t('help'), 'node_help_page', 9);
-      menu('admin/node/edit', t('edit post'), 'node_admin', 0, MENU_HIDE, MENU_LOCKED);
-      menu('admin/node/settings', t('settings'), 'node_admin', 8);
-      if (module_exist('search')) {
-        menu('admin/node/search', t('search'), 'node_admin', 8);
-      }
+    menu('admin/node', t('content'), user_access('administer nodes') ? 'node_admin' : MENU_DENIED);
+    menu('admin/node/help', t('help'), user_access('administer nodes') ? 'node_help_page' : MENU_DENIED, 9);
+    menu('admin/node/edit', t('edit post'), user_access('administer nodes') ? 'node_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    menu('admin/node/settings', t('settings'), user_access('administer nodes') ? 'node_admin' : MENU_DENIED, 8);
+    if (module_exist('search')) {
+      menu('admin/node/search', t('search'), user_access('administer nodes') ? 'node_admin' : MENU_DENIED, 8);
     }
 
-    if (user_access('access content')) {
-      menu('node', t('content'), 'node_page', 0, MENU_HIDE);
-    }
+    menu('node', t('content'), user_access('access content') ? 'node_page' : MENU_DENIED, 0, MENU_HIDE);
   }
 
   return $links;
@@ -1274,7 +1273,6 @@ function node_add($type) {
     }
     $output = node_form($node);
     drupal_set_title(t('Submit %name', array('%name' => node_invoke($node, 'node_name'))));
-    drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('create content'), 'node/add')));
   }
   else {
 
@@ -1292,7 +1290,6 @@ function node_add($type) {
     }
 
     $output = t('Choose the appropriate item from the list:') ."<ul>$output</ul>";
-    drupal_set_breadcrumb(array(l(t('Home'), NULL)));
   }
 
   return $output;
diff --git a/modules/page.module b/modules/page.module
index 04e989ee761ae55b190d7c63223473cd7bbf8077..63e8a5084cbdc60e953af4be458cc084d383cd4c 100644
--- a/modules/page.module
+++ b/modules/page.module
@@ -94,21 +94,19 @@ function page_load($node) {
 }
 
 /**
- * Define internal Drupal links.
+ * Implementation of hook_link().
  */
 function page_link($type, $node = 0, $main) {
 
   $links = array();
 
   if ($type == 'system') {
-    if (page_access('create', $node)) {
-      menu("node/add/page", t("page"), "node_page", 0);
-    }
+    menu('node/add/page', t('page'), page_access('create', $node) ? 'node_page' : MENU_DENIED, 0);
   }
 
   if ($type == 'node' && $node->type == 'page') {
     /* Don't display a redundant edit link if they are node administrators */
-    if (page_access("update", $node) && !user_access('administer nodes')) {
+    if (page_access('update', $node) && !user_access('administer nodes')) {
       $links[] = l(t('edit this page'), "node/edit/$node->nid");
     }
   }
diff --git a/modules/page/page.module b/modules/page/page.module
index 04e989ee761ae55b190d7c63223473cd7bbf8077..63e8a5084cbdc60e953af4be458cc084d383cd4c 100644
--- a/modules/page/page.module
+++ b/modules/page/page.module
@@ -94,21 +94,19 @@ function page_load($node) {
 }
 
 /**
- * Define internal Drupal links.
+ * Implementation of hook_link().
  */
 function page_link($type, $node = 0, $main) {
 
   $links = array();
 
   if ($type == 'system') {
-    if (page_access('create', $node)) {
-      menu("node/add/page", t("page"), "node_page", 0);
-    }
+    menu('node/add/page', t('page'), page_access('create', $node) ? 'node_page' : MENU_DENIED, 0);
   }
 
   if ($type == 'node' && $node->type == 'page') {
     /* Don't display a redundant edit link if they are node administrators */
-    if (page_access("update", $node) && !user_access('administer nodes')) {
+    if (page_access('update', $node) && !user_access('administer nodes')) {
       $links[] = l(t('edit this page'), "node/edit/$node->nid");
     }
   }
diff --git a/modules/path.module b/modules/path.module
index cbd85e34c6c62d6f71c29632f4e9d9e935711d5c..5908d6ab53ff68b326983eff25c84f5ae54a54cc 100644
--- a/modules/path.module
+++ b/modules/path.module
@@ -143,11 +143,14 @@ function conf_url_rewrite(\$path, \$mode = 'incoming') {
   return $output;
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function path_link($type, $node = NULL) {
-  if ($type == "system" && user_access("administer url aliases")) {
-    menu("admin/path", t("url aliasing"), "path_admin", 4);
-    menu("admin/path/add", t("new alias"), "path_admin");
-    menu("admin/path/help", t("help"), "path_admin", 9);
+  if ($type == 'system') {
+    menu('admin/path', t('url aliasing'), user_access('administer url aliases') ? 'path_admin' : MENU_DENIED, 4);
+    menu('admin/path/add', t('new alias'), user_access('administer url aliases') ? 'path_admin' : MENU_DENIED);
+    menu('admin/path/help', t('help'), user_access('administer url aliases') ? 'path_admin' : MENU_DENIED, 9);
   }
 }
 
diff --git a/modules/path/path.module b/modules/path/path.module
index cbd85e34c6c62d6f71c29632f4e9d9e935711d5c..5908d6ab53ff68b326983eff25c84f5ae54a54cc 100644
--- a/modules/path/path.module
+++ b/modules/path/path.module
@@ -143,11 +143,14 @@ function conf_url_rewrite(\$path, \$mode = 'incoming') {
   return $output;
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function path_link($type, $node = NULL) {
-  if ($type == "system" && user_access("administer url aliases")) {
-    menu("admin/path", t("url aliasing"), "path_admin", 4);
-    menu("admin/path/add", t("new alias"), "path_admin");
-    menu("admin/path/help", t("help"), "path_admin", 9);
+  if ($type == 'system') {
+    menu('admin/path', t('url aliasing'), user_access('administer url aliases') ? 'path_admin' : MENU_DENIED, 4);
+    menu('admin/path/add', t('new alias'), user_access('administer url aliases') ? 'path_admin' : MENU_DENIED);
+    menu('admin/path/help', t('help'), user_access('administer url aliases') ? 'path_admin' : MENU_DENIED, 9);
   }
 }
 
diff --git a/modules/poll.module b/modules/poll.module
index 99cba5646a8ba1f580173519ad9b514a00c905c4..1a9a57121ac9253c73840d8ed570614a3810efa2 100644
--- a/modules/poll.module
+++ b/modules/poll.module
@@ -163,16 +163,15 @@ function poll_insert($node) {
   }
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function poll_link($type, $node = 0, $main) {
   $links = array();
 
   if ($type == 'system') {
-    if (user_access("create polls")) {
-      menu('node/add/poll', t('poll'), 'node_page', 0);
-    }
-    if (user_access('access content')) {
-      menu('poll', t('polls'), 'poll_page', 0, MENU_HIDE);
-    }
+    menu('node/add/poll', t('poll'), user_access('create polls') ? 'node_page' : MENU_DENIED, 0);
+    menu('poll', t('polls'), user_access('access content') ? 'poll_page' : MENU_DENIED, 0, MENU_HIDE);
   }
   else if ($type == 'page' && user_access('access content')) {
     $links[] = l(t('polls'), 'poll', array('title' => t('View the list of polls on this site.')));
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index 99cba5646a8ba1f580173519ad9b514a00c905c4..1a9a57121ac9253c73840d8ed570614a3810efa2 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -163,16 +163,15 @@ function poll_insert($node) {
   }
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function poll_link($type, $node = 0, $main) {
   $links = array();
 
   if ($type == 'system') {
-    if (user_access("create polls")) {
-      menu('node/add/poll', t('poll'), 'node_page', 0);
-    }
-    if (user_access('access content')) {
-      menu('poll', t('polls'), 'poll_page', 0, MENU_HIDE);
-    }
+    menu('node/add/poll', t('poll'), user_access('create polls') ? 'node_page' : MENU_DENIED, 0);
+    menu('poll', t('polls'), user_access('access content') ? 'poll_page' : MENU_DENIED, 0, MENU_HIDE);
   }
   else if ($type == 'page' && user_access('access content')) {
     $links[] = l(t('polls'), 'poll', array('title' => t('View the list of polls on this site.')));
diff --git a/modules/profile.module b/modules/profile.module
index cbeaccd1e3b89794fd0f0bad3cce1052b9a13ba7..2b782b3cfa30e9478ad65b9433be818cccce5e49 100644
--- a/modules/profile.module
+++ b/modules/profile.module
@@ -14,16 +14,17 @@ function profile_help($section) {
 
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function profile_link($type) {
   if ($type == 'system') {
     menu('profile', t('browse'), 'profile_browse', 0, MENU_HIDE);
 
-    if (user_access('administer users')) {
-      menu('admin/system/modules/profile', t('profile'), 'profile_admin_overview');
-      menu('admin/system/modules/profile/add', NULL, 'profile_admin_add', 0, MENU_HIDE, MENU_LOCKED);
-      menu('admin/system/modules/profile/edit', NULL, 'profile_admin_edit', 0, MENU_HIDE, MENU_LOCKED);
-      menu('admin/system/modules/profile/delete', NULL, 'profile_admin_delete', 0, MENU_HIDE, MENU_LOCKED);
-    }
+    menu('admin/system/modules/profile', t('profile'), user_access('administer users') ? 'profile_admin_overview' : MENU_DENIED);
+    menu('admin/system/modules/profile/add', NULL, user_access('administer users') ? 'profile_admin_add' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    menu('admin/system/modules/profile/edit', NULL, user_access('administer users') ? 'profile_admin_edit' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    menu('admin/system/modules/profile/delete', NULL, user_access('administer users') ? 'profile_admin_delete' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
   }
 }
 
diff --git a/modules/profile/profile.module b/modules/profile/profile.module
index cbeaccd1e3b89794fd0f0bad3cce1052b9a13ba7..2b782b3cfa30e9478ad65b9433be818cccce5e49 100644
--- a/modules/profile/profile.module
+++ b/modules/profile/profile.module
@@ -14,16 +14,17 @@ function profile_help($section) {
 
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function profile_link($type) {
   if ($type == 'system') {
     menu('profile', t('browse'), 'profile_browse', 0, MENU_HIDE);
 
-    if (user_access('administer users')) {
-      menu('admin/system/modules/profile', t('profile'), 'profile_admin_overview');
-      menu('admin/system/modules/profile/add', NULL, 'profile_admin_add', 0, MENU_HIDE, MENU_LOCKED);
-      menu('admin/system/modules/profile/edit', NULL, 'profile_admin_edit', 0, MENU_HIDE, MENU_LOCKED);
-      menu('admin/system/modules/profile/delete', NULL, 'profile_admin_delete', 0, MENU_HIDE, MENU_LOCKED);
-    }
+    menu('admin/system/modules/profile', t('profile'), user_access('administer users') ? 'profile_admin_overview' : MENU_DENIED);
+    menu('admin/system/modules/profile/add', NULL, user_access('administer users') ? 'profile_admin_add' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    menu('admin/system/modules/profile/edit', NULL, user_access('administer users') ? 'profile_admin_edit' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    menu('admin/system/modules/profile/delete', NULL, user_access('administer users') ? 'profile_admin_delete' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
   }
 }
 
diff --git a/modules/queue.module b/modules/queue.module
index 1ebeb2ba321a8e8378acc055253aa80a15b7a4cf..803f5d70ee6f91362d643478111bf7a211f26b01 100644
--- a/modules/queue.module
+++ b/modules/queue.module
@@ -31,13 +31,14 @@ function queue_perm() {
   return array("access submission queue");
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function queue_link($type) {
   $links = array();
 
-  if ($type == "system") {
-    if (user_access("access submission queue")) {
-      menu("queue", t("submission queue"), "queue_page", 1);
-    }
+  if ($type == 'system') {
+    menu('queue', t('submission queue'), user_access('access submission queue') ? 'queue_page' : MENU_DENIED, 1);
   }
 
   return $links;
diff --git a/modules/search.module b/modules/search.module
index 7d0b40c65954690e08e5282dbc313048f3922f8f..dec843da3c4fe458a8f7f84aa864973049dfab2d 100644
--- a/modules/search.module
+++ b/modules/search.module
@@ -30,20 +30,17 @@ function search_perm() {
 }
 
 /**
- * Return an array of links to be displayed
- *
- * @param $type The type of page requesting the link
- *
+ * Implementation of hook_link().
  */
 function search_link($type) {
   $links = array();
 
-  if ($type == "page" && user_access("search content")) {
-    $links[] = l(t("search"), "search", array("title" => t("Search for older content.")));
+  if ($type == 'page' && user_access('search content')) {
+    $links[] = l(t('search'), 'search', array('title' => t('Search for older content.')));
   }
 
-  if ($type == "system" && user_access("search content")) {
-    menu("search", t("search"), "search_page", 0, MENU_HIDE);
+  if ($type == 'system') {
+    menu('search', t('search'), user_access('search content') ? 'search_page' : MENU_DENIED, 0, MENU_HIDE);
   }
 
   return $links;
@@ -360,7 +357,7 @@ function search_view($keys) {
     print theme("page", $output, t("Search"));
   }
   else {
-    print theme("page", message_access());
+    drupal_access_denied();
   }
 
 }
diff --git a/modules/search/search.module b/modules/search/search.module
index 7d0b40c65954690e08e5282dbc313048f3922f8f..dec843da3c4fe458a8f7f84aa864973049dfab2d 100644
--- a/modules/search/search.module
+++ b/modules/search/search.module
@@ -30,20 +30,17 @@ function search_perm() {
 }
 
 /**
- * Return an array of links to be displayed
- *
- * @param $type The type of page requesting the link
- *
+ * Implementation of hook_link().
  */
 function search_link($type) {
   $links = array();
 
-  if ($type == "page" && user_access("search content")) {
-    $links[] = l(t("search"), "search", array("title" => t("Search for older content.")));
+  if ($type == 'page' && user_access('search content')) {
+    $links[] = l(t('search'), 'search', array('title' => t('Search for older content.')));
   }
 
-  if ($type == "system" && user_access("search content")) {
-    menu("search", t("search"), "search_page", 0, MENU_HIDE);
+  if ($type == 'system') {
+    menu('search', t('search'), user_access('search content') ? 'search_page' : MENU_DENIED, 0, MENU_HIDE);
   }
 
   return $links;
@@ -360,7 +357,7 @@ function search_view($keys) {
     print theme("page", $output, t("Search"));
   }
   else {
-    print theme("page", message_access());
+    drupal_access_denied();
   }
 
 }
diff --git a/modules/statistics.module b/modules/statistics.module
index f79f24553c3bf25a30970775bc911a36eb5bf264..333f27c73ae1d919173672436172e47d2f5ccd35 100644
--- a/modules/statistics.module
+++ b/modules/statistics.module
@@ -119,46 +119,44 @@ function statistics_perm() {
   return array("administer statistics module", "administer statistics", "access statistics");
 }
 
-/* Link hook, defines module's links */
+/**
+ * Implementation of hook_link().
+ */
 function statistics_link($type, $node = 0, $main = 0) {
   global $id;
 
   $links = array();
 
-  if ($type == "node" && user_access("access statistics") && variable_get("statistics_display_counter", 0)) {
+  if ($type == 'node' && user_access('access statistics') && variable_get('statistics_display_counter', 0)) {
     $statistics = statistics_get($node->nid);
     if ($statistics) {
-      if (user_access("administer statistics")) {
-        $links[] = l(format_plural($statistics["totalcount"], "1 read", "%count reads"), "admin/logs/access/node/$node->nid");
+      if (user_access('administer statistics')) {
+        $links[] = l(format_plural($statistics['totalcount'], '1 read', '%count reads'), "admin/logs/access/node/$node->nid");
       }
       else {
-        $links[] = format_plural($statistics["totalcount"], "1 read", "%count reads");
+        $links[] = format_plural($statistics['totalcount'], '1 read', '%count reads');
       }
     }
   }
 
-  if ($type == "page" && user_access("access content")) {
-    $userlink = variable_get("statistics_userpage_link", "");
+  if ($type == 'page' && user_access('access content')) {
+    $userlink = variable_get('statistics_userpage_link', '');
     if ($userlink) {
-      $links[] = l(t($userlink), "statistics", array("title" => t("View this site's most popular content.")));
+      $links[] = l(t($userlink), 'statistics', array('title' => t("View this site's most popular content.")));
     }
   }
 
-  if ($type == "system") {
-    if ((user_access("administer statistics module") || (user_access("administer statistics")))) {
-      menu("admin/logs/topnodes", t("top nodes"), "statistics_admin", 1);
-      menu("admin/logs/referrer", t("referrer"), "statistics_admin", 2);
-      menu("admin/logs/referrer/internal", t("internal referrers only"), "statistics_admin");
-      menu("admin/logs/referrer/external", t("external referrers only"), "statistics_admin");
-      menu("admin/logs/access", t("access"), "statistics_admin", 3);
-      menu("admin/logs/access/node", t("track node"), "statistics_admin", 0, MENU_HIDE);
-      menu("admin/logs/access/user", t("track user"), "statistics_admin", 0, MENU_HIDE);
-      menu("admin/logs/access/host", t("track host"), "statistics_admin", 0, MENU_HIDE);
-    }
-
-    if (user_access("access content")) {
-      menu("statistics", t("view most popular content"), "statistics_page", 0, MENU_HIDE);
-    }
+  if ($type == 'system') {
+    $access = user_access('administer statistics module') || user_access('administer statistics');
+
+    menu('admin/logs/topnodes', t('top nodes'), $access ? 'statistics_admin' : MENU_DENIED, 1);
+    menu('admin/logs/referrer', t('referrer'), $access ? 'statistics_admin' : MENU_DENIED, 2);
+    menu('admin/logs/referrer/internal', t('internal referrers only'), $access ? 'statistics_admin' : MENU_DENIED);
+    menu('admin/logs/referrer/external', t('external referrers only'), $access ? 'statistics_admin' : MENU_DENIED);
+    menu('admin/logs/access', t('access'), $access ? 'statistics_admin' : MENU_DENIED, 3);
+    menu('admin/logs/access/node', t('track node'), $access ? 'statistics_admin' : MENU_DENIED, 0, MENU_HIDE);
+    menu('admin/logs/access/user', t('track user'), $access ? 'statistics_admin' : MENU_DENIED, 0, MENU_HIDE);
+    menu('admin/logs/access/host', t('track host'), $access ? 'statistics_admin' : MENU_DENIED, 0, MENU_HIDE);
   }
 
   return $links;
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index f79f24553c3bf25a30970775bc911a36eb5bf264..333f27c73ae1d919173672436172e47d2f5ccd35 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -119,46 +119,44 @@ function statistics_perm() {
   return array("administer statistics module", "administer statistics", "access statistics");
 }
 
-/* Link hook, defines module's links */
+/**
+ * Implementation of hook_link().
+ */
 function statistics_link($type, $node = 0, $main = 0) {
   global $id;
 
   $links = array();
 
-  if ($type == "node" && user_access("access statistics") && variable_get("statistics_display_counter", 0)) {
+  if ($type == 'node' && user_access('access statistics') && variable_get('statistics_display_counter', 0)) {
     $statistics = statistics_get($node->nid);
     if ($statistics) {
-      if (user_access("administer statistics")) {
-        $links[] = l(format_plural($statistics["totalcount"], "1 read", "%count reads"), "admin/logs/access/node/$node->nid");
+      if (user_access('administer statistics')) {
+        $links[] = l(format_plural($statistics['totalcount'], '1 read', '%count reads'), "admin/logs/access/node/$node->nid");
       }
       else {
-        $links[] = format_plural($statistics["totalcount"], "1 read", "%count reads");
+        $links[] = format_plural($statistics['totalcount'], '1 read', '%count reads');
       }
     }
   }
 
-  if ($type == "page" && user_access("access content")) {
-    $userlink = variable_get("statistics_userpage_link", "");
+  if ($type == 'page' && user_access('access content')) {
+    $userlink = variable_get('statistics_userpage_link', '');
     if ($userlink) {
-      $links[] = l(t($userlink), "statistics", array("title" => t("View this site's most popular content.")));
+      $links[] = l(t($userlink), 'statistics', array('title' => t("View this site's most popular content.")));
     }
   }
 
-  if ($type == "system") {
-    if ((user_access("administer statistics module") || (user_access("administer statistics")))) {
-      menu("admin/logs/topnodes", t("top nodes"), "statistics_admin", 1);
-      menu("admin/logs/referrer", t("referrer"), "statistics_admin", 2);
-      menu("admin/logs/referrer/internal", t("internal referrers only"), "statistics_admin");
-      menu("admin/logs/referrer/external", t("external referrers only"), "statistics_admin");
-      menu("admin/logs/access", t("access"), "statistics_admin", 3);
-      menu("admin/logs/access/node", t("track node"), "statistics_admin", 0, MENU_HIDE);
-      menu("admin/logs/access/user", t("track user"), "statistics_admin", 0, MENU_HIDE);
-      menu("admin/logs/access/host", t("track host"), "statistics_admin", 0, MENU_HIDE);
-    }
-
-    if (user_access("access content")) {
-      menu("statistics", t("view most popular content"), "statistics_page", 0, MENU_HIDE);
-    }
+  if ($type == 'system') {
+    $access = user_access('administer statistics module') || user_access('administer statistics');
+
+    menu('admin/logs/topnodes', t('top nodes'), $access ? 'statistics_admin' : MENU_DENIED, 1);
+    menu('admin/logs/referrer', t('referrer'), $access ? 'statistics_admin' : MENU_DENIED, 2);
+    menu('admin/logs/referrer/internal', t('internal referrers only'), $access ? 'statistics_admin' : MENU_DENIED);
+    menu('admin/logs/referrer/external', t('external referrers only'), $access ? 'statistics_admin' : MENU_DENIED);
+    menu('admin/logs/access', t('access'), $access ? 'statistics_admin' : MENU_DENIED, 3);
+    menu('admin/logs/access/node', t('track node'), $access ? 'statistics_admin' : MENU_DENIED, 0, MENU_HIDE);
+    menu('admin/logs/access/user', t('track user'), $access ? 'statistics_admin' : MENU_DENIED, 0, MENU_HIDE);
+    menu('admin/logs/access/host', t('track host'), $access ? 'statistics_admin' : MENU_DENIED, 0, MENU_HIDE);
   }
 
   return $links;
diff --git a/modules/story.module b/modules/story.module
index 2fdedee59e18333145e5e1ed6d5e14607212a649..23b34a0052d6689e7fa2283a9ec02904e5b2e5bd 100644
--- a/modules/story.module
+++ b/modules/story.module
@@ -82,20 +82,18 @@ function story_access($op, $node) {
 }
 
 /**
- * Define internal Drupal links.
+ * Implementation of hook_link().
  */
 function story_link($type, $node = 0, $main) {
   $links = array();
 
-  if ($type == "system") {
-    if (story_access('create', $node)) {
-      menu("node/add/story", t("story"), "node_page", 0);
-    }
+  if ($type == 'system') {
+    menu('node/add/story', t('story'), story_access('create', $node) ? 'node_page' : MENU_DENIED, 0);
   }
 
   if ($type == 'node' && $node->type == 'story') {
     /* Don't display a redundant edit link if they are node administrators */
-    if (story_access("update", $node) && !user_access('administer nodes')) {
+    if (story_access('update', $node) && !user_access('administer nodes')) {
       $links[] = l(t('edit this story'), "node/edit/$node->nid");
     }
   }
diff --git a/modules/story/story.module b/modules/story/story.module
index 2fdedee59e18333145e5e1ed6d5e14607212a649..23b34a0052d6689e7fa2283a9ec02904e5b2e5bd 100644
--- a/modules/story/story.module
+++ b/modules/story/story.module
@@ -82,20 +82,18 @@ function story_access($op, $node) {
 }
 
 /**
- * Define internal Drupal links.
+ * Implementation of hook_link().
  */
 function story_link($type, $node = 0, $main) {
   $links = array();
 
-  if ($type == "system") {
-    if (story_access('create', $node)) {
-      menu("node/add/story", t("story"), "node_page", 0);
-    }
+  if ($type == 'system') {
+    menu('node/add/story', t('story'), story_access('create', $node) ? 'node_page' : MENU_DENIED, 0);
   }
 
   if ($type == 'node' && $node->type == 'story') {
     /* Don't display a redundant edit link if they are node administrators */
-    if (story_access("update", $node) && !user_access('administer nodes')) {
+    if (story_access('update', $node) && !user_access('administer nodes')) {
       $links[] = l(t('edit this story'), "node/edit/$node->nid");
     }
   }
diff --git a/modules/system.module b/modules/system.module
index 1c5e7b95f20d614b39fa64a8c437bc9e97b68810..a76242a59da3fe2cbe64dd09e67477cbe9948434 100644
--- a/modules/system.module
+++ b/modules/system.module
@@ -45,34 +45,36 @@ function system_perm() {
   return array("administer site configuration", "access administration pages", "bypass input data check", "create php content");
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function system_link($type) {
-  if ($type == "system") {
-    menu("system/files", t("file download"), "file_download", 0, MENU_HIDE);
-    if (user_access("administer site configuration")) {
-
-      menu("admin/system", t("configuration"), "system_admin", 3);
-      menu("admin/system/themes", t("themes"), "system_admin", 2);
-
-      foreach (list_themes() as $theme) {
-        // TODO: reenable 'forced refresh' once we move the menu_build() later in the request. it added overhead with no benefit
-        // NOTE: refresh the list because some themes might have been enabled/disabled.
-        include_once "$theme->filename";
-        $function = $theme->name ."_settings";
-        if (function_exists($function)) {
-          menu("admin/system/themes/$theme->name", $theme->name, "system_admin");
-        }
+  if ($type == 'system') {
+    menu('system/files', t('file download'), 'file_download', 0, MENU_HIDE, MENU_LOCKED);
+    $access = user_access('administer site configuration');
+
+    menu('admin/system', t('configuration'), $access ? 'system_admin' : MENU_DENIED, 3);
+    menu('admin/system/themes', t('themes'), $access ? 'system_admin' : MENU_DENIED, 2);
+
+    foreach (list_themes() as $theme) {
+      // TODO: reenable 'forced refresh' once we move the menu_build() later in the request. it added overhead with no benefit
+      // NOTE: refresh the list because some themes might have been enabled/disabled.
+      include_once "$theme->filename";
+      $function = $theme->name .'_settings';
+      if (function_exists($function)) {
+        menu("admin/system/themes/$theme->name", $theme->name, $access ? 'system_admin' : MENU_DENIED);
       }
+    }
 
-      menu("admin/system/modules", t("modules"), "system_admin", 3);
-      foreach (module_list() as $name) {
-        // TODO: reenable 'forced refresh' once we move the menu_build() later in the request.  it added overhead with no benefit
-        // NOTE: refresh the list because some modules might have been enabled/disabled.
-        if (module_hook($name, "settings")) {
-          menu("admin/system/modules/$name", t($name), "system_admin");
-        }
+    menu('admin/system/modules', t('modules'), $access ? 'system_admin' : MENU_DENIED, 3);
+    foreach (module_list() as $name) {
+      // TODO: reenable 'forced refresh' once we move the menu_build() later in the request.  it added overhead with no benefit
+      // NOTE: refresh the list because some modules might have been enabled/disabled.
+      if (module_hook($name, 'settings')) {
+        menu("admin/system/modules/$name", t($name), $access ? 'system_admin' : MENU_DENIED);
       }
-      menu("admin/system/help", t("help"), "system_help_page", 9);
     }
+    menu('admin/system/help', t('help'), $access ? 'system_help_page' : MENU_DENIED, 9);
   }
 }
 
@@ -114,6 +116,7 @@ function system_view_general() {
   $group .= form_textarea(t("Footer message"), "site_footer", variable_get("site_footer", ""), 70, 5, t("This text will be displayed at the bottom of each page.  Useful for adding a copyright notice to your pages."));
   $group .= form_textfield(t("Anonymous user"), "anonymous", variable_get("anonymous", "Anonymous"), 70, 70, t("The name used to indicate anonymous users."));
   $group .= form_textfield(t("Default front page"), "site_frontpage", variable_get("site_frontpage", "node"), 70, 70, t("The home page displays content from this relative URL.  If you are not using clean URLs, specify the part after '?q='.  If unsure, specify 'node'."));
+  $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_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_radios(t("Clean URLs"), "clean_url", variable_get("clean_url", 0), array(t("Disabled"), t("Enabled")), t("Enable or disable clean URLs.  If enabled, you'll need <code>ModRewrite</code> support.  See also the <code>.htaccess</code> file in Drupal's top-level directory."));
 
diff --git a/modules/system/system.module b/modules/system/system.module
index 1c5e7b95f20d614b39fa64a8c437bc9e97b68810..a76242a59da3fe2cbe64dd09e67477cbe9948434 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -45,34 +45,36 @@ function system_perm() {
   return array("administer site configuration", "access administration pages", "bypass input data check", "create php content");
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function system_link($type) {
-  if ($type == "system") {
-    menu("system/files", t("file download"), "file_download", 0, MENU_HIDE);
-    if (user_access("administer site configuration")) {
-
-      menu("admin/system", t("configuration"), "system_admin", 3);
-      menu("admin/system/themes", t("themes"), "system_admin", 2);
-
-      foreach (list_themes() as $theme) {
-        // TODO: reenable 'forced refresh' once we move the menu_build() later in the request. it added overhead with no benefit
-        // NOTE: refresh the list because some themes might have been enabled/disabled.
-        include_once "$theme->filename";
-        $function = $theme->name ."_settings";
-        if (function_exists($function)) {
-          menu("admin/system/themes/$theme->name", $theme->name, "system_admin");
-        }
+  if ($type == 'system') {
+    menu('system/files', t('file download'), 'file_download', 0, MENU_HIDE, MENU_LOCKED);
+    $access = user_access('administer site configuration');
+
+    menu('admin/system', t('configuration'), $access ? 'system_admin' : MENU_DENIED, 3);
+    menu('admin/system/themes', t('themes'), $access ? 'system_admin' : MENU_DENIED, 2);
+
+    foreach (list_themes() as $theme) {
+      // TODO: reenable 'forced refresh' once we move the menu_build() later in the request. it added overhead with no benefit
+      // NOTE: refresh the list because some themes might have been enabled/disabled.
+      include_once "$theme->filename";
+      $function = $theme->name .'_settings';
+      if (function_exists($function)) {
+        menu("admin/system/themes/$theme->name", $theme->name, $access ? 'system_admin' : MENU_DENIED);
       }
+    }
 
-      menu("admin/system/modules", t("modules"), "system_admin", 3);
-      foreach (module_list() as $name) {
-        // TODO: reenable 'forced refresh' once we move the menu_build() later in the request.  it added overhead with no benefit
-        // NOTE: refresh the list because some modules might have been enabled/disabled.
-        if (module_hook($name, "settings")) {
-          menu("admin/system/modules/$name", t($name), "system_admin");
-        }
+    menu('admin/system/modules', t('modules'), $access ? 'system_admin' : MENU_DENIED, 3);
+    foreach (module_list() as $name) {
+      // TODO: reenable 'forced refresh' once we move the menu_build() later in the request.  it added overhead with no benefit
+      // NOTE: refresh the list because some modules might have been enabled/disabled.
+      if (module_hook($name, 'settings')) {
+        menu("admin/system/modules/$name", t($name), $access ? 'system_admin' : MENU_DENIED);
       }
-      menu("admin/system/help", t("help"), "system_help_page", 9);
     }
+    menu('admin/system/help', t('help'), $access ? 'system_help_page' : MENU_DENIED, 9);
   }
 }
 
@@ -114,6 +116,7 @@ function system_view_general() {
   $group .= form_textarea(t("Footer message"), "site_footer", variable_get("site_footer", ""), 70, 5, t("This text will be displayed at the bottom of each page.  Useful for adding a copyright notice to your pages."));
   $group .= form_textfield(t("Anonymous user"), "anonymous", variable_get("anonymous", "Anonymous"), 70, 70, t("The name used to indicate anonymous users."));
   $group .= form_textfield(t("Default front page"), "site_frontpage", variable_get("site_frontpage", "node"), 70, 70, t("The home page displays content from this relative URL.  If you are not using clean URLs, specify the part after '?q='.  If unsure, specify 'node'."));
+  $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_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_radios(t("Clean URLs"), "clean_url", variable_get("clean_url", 0), array(t("Disabled"), t("Enabled")), t("Enable or disable clean URLs.  If enabled, you'll need <code>ModRewrite</code> support.  See also the <code>.htaccess</code> file in Drupal's top-level directory."));
 
diff --git a/modules/taxonomy.module b/modules/taxonomy.module
index 725bfe1f6a83c8cd246fded6230752ad59d93c1f..5e2f343a58f33793cb2fdae2651326f69ffc715f 100644
--- a/modules/taxonomy.module
+++ b/modules/taxonomy.module
@@ -21,18 +21,26 @@ function taxonomy_perm() {
   return array("administer taxonomy");
 }
 
+/**
+ * Implementation of hook_link().
+ *
+ * This hook is extended with $type = 'taxonomy terms' to allow themes to
+ * print lists of terms associated with a node. Themes can print taxonomy
+ * links with:
+ *
+ * if (module_exist('taxonomy')) {
+ *   $this->links(taxonomy_link('taxonomy terms', $node));
+ * }
+ */
 function taxonomy_link($type, $node = NULL) {
-  if ($type == "system") {
-    if (user_access("administer taxonomy")) {
-      menu("admin/taxonomy", t("categories"), "taxonomy_admin", 3);
-      menu("admin/taxonomy/add/vocabulary", t("create new vocabulary"), "taxonomy_admin");
-      menu("admin/taxonomy/help", t("help"), "taxonomy_admin", 9);
-    }
-    if (user_access("access content")) {
-      menu("taxonomy", t("taxonomy"), "taxonomy_page", 0, MENU_HIDE, MENU_LOCKED);
-    }
+  if ($type == 'system') {
+      menu('admin/taxonomy', t('categories'), user_access('administer taxonomy') ? 'taxonomy_admin' : MENU_DENIED, 3);
+      menu('admin/taxonomy/add/vocabulary', t('create new vocabulary'), user_access('administer taxonomy') ? 'taxonomy_admin' : MENU_DENIED);
+      menu('admin/taxonomy/help', t('help'), user_access('administer taxonomy') ? 'taxonomy_admin' : MENU_DENIED, 9);
+
+      menu('taxonomy', t('taxonomy'), user_access('access content') ? 'taxonomy_page' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
   }
-  else if ($type == "taxonomy terms" && $node != NULL) {
+  else if ($type == 'taxonomy terms' && $node != NULL) {
     $links = array();
     if ($node->taxonomy) {
       foreach ($node->taxonomy as $tid) {
@@ -41,15 +49,6 @@ function taxonomy_link($type, $node = NULL) {
       }
     }
     else {
-
-    /*
-    ** Themes can print taxonomy links with:
-    **
-    ** if (module_exist("taxonomy")) {
-    **   $this->links(taxonomy_link("taxonomy terms", $node));
-    ** }
-    */
-
       $links = array();
       foreach (taxonomy_node_get_terms($node->nid) as $term) {
         $links[] = l($term->name, "taxonomy/page/or/$term->tid");
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 725bfe1f6a83c8cd246fded6230752ad59d93c1f..5e2f343a58f33793cb2fdae2651326f69ffc715f 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -21,18 +21,26 @@ function taxonomy_perm() {
   return array("administer taxonomy");
 }
 
+/**
+ * Implementation of hook_link().
+ *
+ * This hook is extended with $type = 'taxonomy terms' to allow themes to
+ * print lists of terms associated with a node. Themes can print taxonomy
+ * links with:
+ *
+ * if (module_exist('taxonomy')) {
+ *   $this->links(taxonomy_link('taxonomy terms', $node));
+ * }
+ */
 function taxonomy_link($type, $node = NULL) {
-  if ($type == "system") {
-    if (user_access("administer taxonomy")) {
-      menu("admin/taxonomy", t("categories"), "taxonomy_admin", 3);
-      menu("admin/taxonomy/add/vocabulary", t("create new vocabulary"), "taxonomy_admin");
-      menu("admin/taxonomy/help", t("help"), "taxonomy_admin", 9);
-    }
-    if (user_access("access content")) {
-      menu("taxonomy", t("taxonomy"), "taxonomy_page", 0, MENU_HIDE, MENU_LOCKED);
-    }
+  if ($type == 'system') {
+      menu('admin/taxonomy', t('categories'), user_access('administer taxonomy') ? 'taxonomy_admin' : MENU_DENIED, 3);
+      menu('admin/taxonomy/add/vocabulary', t('create new vocabulary'), user_access('administer taxonomy') ? 'taxonomy_admin' : MENU_DENIED);
+      menu('admin/taxonomy/help', t('help'), user_access('administer taxonomy') ? 'taxonomy_admin' : MENU_DENIED, 9);
+
+      menu('taxonomy', t('taxonomy'), user_access('access content') ? 'taxonomy_page' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
   }
-  else if ($type == "taxonomy terms" && $node != NULL) {
+  else if ($type == 'taxonomy terms' && $node != NULL) {
     $links = array();
     if ($node->taxonomy) {
       foreach ($node->taxonomy as $tid) {
@@ -41,15 +49,6 @@ function taxonomy_link($type, $node = NULL) {
       }
     }
     else {
-
-    /*
-    ** Themes can print taxonomy links with:
-    **
-    ** if (module_exist("taxonomy")) {
-    **   $this->links(taxonomy_link("taxonomy terms", $node));
-    ** }
-    */
-
       $links = array();
       foreach (taxonomy_node_get_terms($node->nid) as $term) {
         $links[] = l($term->name, "taxonomy/page/or/$term->tid");
diff --git a/modules/title.module b/modules/title.module
index df7e20b9e6d0840eceddd3ce8a08ae6a2207bd82..38bba8e10376de8471db284c2dbe8e098bde66d1 100644
--- a/modules/title.module
+++ b/modules/title.module
@@ -13,11 +13,12 @@ function title_help($section) {
   return $output;
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function title_link($type) {
-  if ($type == "system") {
-    if (user_access("access content")) {
-      menu("title", t("search"), "title_page", 0, MENU_HIDE, MENU_LOCKED);
-    }
+  if ($type == 'system') {
+    menu('title', t('search'), user_access('access content') ? 'title_page' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
   }
 }
 
diff --git a/modules/tracker.module b/modules/tracker.module
index d1c4d6b1d8560b18a779bae642605f42bbc39434..7de682055def0f85cf67c236a517aa922d2dcc09 100644
--- a/modules/tracker.module
+++ b/modules/tracker.module
@@ -10,9 +10,12 @@ function tracker_help($section = 'admin/help#tracker') {
   }
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function tracker_link($type) {
-  if ($type == 'system' && user_access('access content')) {
-    menu('tracker', t('recent posts'), 'tracker_page', 1);
+  if ($type == 'system') {
+    menu('tracker', t('recent posts'), user_access('access content') ? 'tracker_page' : MENU_DENIED, 1);
   }
 }
 
diff --git a/modules/tracker/tracker.module b/modules/tracker/tracker.module
index d1c4d6b1d8560b18a779bae642605f42bbc39434..7de682055def0f85cf67c236a517aa922d2dcc09 100644
--- a/modules/tracker/tracker.module
+++ b/modules/tracker/tracker.module
@@ -10,9 +10,12 @@ function tracker_help($section = 'admin/help#tracker') {
   }
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function tracker_link($type) {
-  if ($type == 'system' && user_access('access content')) {
-    menu('tracker', t('recent posts'), 'tracker_page', 1);
+  if ($type == 'system') {
+    menu('tracker', t('recent posts'), user_access('access content') ? 'tracker_page' : MENU_DENIED, 1);
   }
 }
 
diff --git a/modules/user.module b/modules/user.module
index ab319459986acb3e3d2042552a4ab04c02d6c591..c26311e1ede531a90c771bcf1c1a0aab9ac48932 100644
--- a/modules/user.module
+++ b/modules/user.module
@@ -532,34 +532,36 @@ function theme_user_list($items, $title = NULL) {
   return theme("item_list", $items, $title);
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function user_link($type) {
   global $user;
 
-  if ($type == "system") {
-    if ($user->uid) {
-      menu('user', t("my account"), "user_page", 8);
-      menu("user/edit", t("edit account"), "user_page", 0);
-      menu("logout", t("log out"), "user_logout", 10);
-    }
-    else {
-      menu("user/login", t("log in"), "user_page", 0, MENU_HIDE);
+  if ($type == 'system') {
+    $access = $user->uid;
+    menu('user', t('my account'), $access ? 'user_page' : MENU_DENIED, 8);
+    menu('user/edit', t('edit account'), $access ? 'user_page' : MENU_DENIED, 0);
+    menu('logout', t('log out'), $access ? 'user_logout' : MENU_DENIED, 10);
+
+    if (!$user->uid) {
+      menu('user/login', t('log in'), 'user_page', 0, MENU_HIDE);
+      menu('user/password', t('e-mail new password'), 'user_page', 0, MENU_HIDE);
+      menu('user/register', t('create new account'), 'user_page', 0, MENU_HIDE);
     }
-    menu("user/password", t("e-mail new password"), "user_page", 0, MENU_HIDE);
-    menu("user/register", t("create new account"), "user_page", 0, MENU_HIDE);
-
-    if (user_access("administer users")) {
-      menu("admin/user", t("accounts"), "user_admin", 2);
-      menu("admin/user/create", t("new user"), "user_admin", 1);
-      menu("admin/user/access", t("access rules"), "user_admin", 3);
-      menu("admin/user/access/mail", t("e-mail rules"), "user_admin");
-      menu("admin/user/access/user", t("name rules"), "user_admin");
-      menu("admin/user/role", t("roles"), "user_admin", 4);
-      menu("admin/user/permission", t("permissions"), "user_admin", 5);
-      menu("admin/user/help", t("help"), "user_help_page", 9);
-      menu("admin/user/edit", t("edit user account"), "user_admin", 0, MENU_HIDE, MENU_LOCKED);
-      if (module_exist('search')) {
-        menu("admin/user/search", t("search"), "user_admin", 8);
-      }
+
+    $access = user_access('administer users');
+    menu('admin/user', t('accounts'), $access ? 'user_admin' : MENU_DENIED, 2);
+    menu('admin/user/create', t('new user'), $access ? 'user_admin' : MENU_DENIED, 1);
+    menu('admin/user/access', t('access rules'), $access ? 'user_admin' : MENU_DENIED, 3);
+    menu('admin/user/access/mail', t('e-mail rules'), $access ? 'user_admin' : MENU_DENIED);
+    menu('admin/user/access/user', t('name rules'), $access ? 'user_admin' : MENU_DENIED);
+    menu('admin/user/role', t('roles'), $access ? 'user_admin' : MENU_DENIED, 4);
+    menu('admin/user/permission', t('permissions'), $access ? 'user_admin' : MENU_DENIED, 5);
+    menu('admin/user/help', t('help'), $access ? 'user_help_page' : MENU_DENIED, 9);
+    menu('admin/user/edit', t('edit user account'), $access ? 'user_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    if (module_exist('search')) {
+      menu('admin/user/search', t('search'), $access ? 'user_admin' : MENU_DENIED, 8);
     }
   }
 }
@@ -1175,7 +1177,7 @@ function user_page() {
         print theme('page', $output, t("Create new account"));
       }
       else {
-        print theme('page', message_access());
+        drupal_access_denied();
       }
       break;
     case t("Log in"):
diff --git a/modules/user/user.module b/modules/user/user.module
index ab319459986acb3e3d2042552a4ab04c02d6c591..c26311e1ede531a90c771bcf1c1a0aab9ac48932 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -532,34 +532,36 @@ function theme_user_list($items, $title = NULL) {
   return theme("item_list", $items, $title);
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function user_link($type) {
   global $user;
 
-  if ($type == "system") {
-    if ($user->uid) {
-      menu('user', t("my account"), "user_page", 8);
-      menu("user/edit", t("edit account"), "user_page", 0);
-      menu("logout", t("log out"), "user_logout", 10);
-    }
-    else {
-      menu("user/login", t("log in"), "user_page", 0, MENU_HIDE);
+  if ($type == 'system') {
+    $access = $user->uid;
+    menu('user', t('my account'), $access ? 'user_page' : MENU_DENIED, 8);
+    menu('user/edit', t('edit account'), $access ? 'user_page' : MENU_DENIED, 0);
+    menu('logout', t('log out'), $access ? 'user_logout' : MENU_DENIED, 10);
+
+    if (!$user->uid) {
+      menu('user/login', t('log in'), 'user_page', 0, MENU_HIDE);
+      menu('user/password', t('e-mail new password'), 'user_page', 0, MENU_HIDE);
+      menu('user/register', t('create new account'), 'user_page', 0, MENU_HIDE);
     }
-    menu("user/password", t("e-mail new password"), "user_page", 0, MENU_HIDE);
-    menu("user/register", t("create new account"), "user_page", 0, MENU_HIDE);
-
-    if (user_access("administer users")) {
-      menu("admin/user", t("accounts"), "user_admin", 2);
-      menu("admin/user/create", t("new user"), "user_admin", 1);
-      menu("admin/user/access", t("access rules"), "user_admin", 3);
-      menu("admin/user/access/mail", t("e-mail rules"), "user_admin");
-      menu("admin/user/access/user", t("name rules"), "user_admin");
-      menu("admin/user/role", t("roles"), "user_admin", 4);
-      menu("admin/user/permission", t("permissions"), "user_admin", 5);
-      menu("admin/user/help", t("help"), "user_help_page", 9);
-      menu("admin/user/edit", t("edit user account"), "user_admin", 0, MENU_HIDE, MENU_LOCKED);
-      if (module_exist('search')) {
-        menu("admin/user/search", t("search"), "user_admin", 8);
-      }
+
+    $access = user_access('administer users');
+    menu('admin/user', t('accounts'), $access ? 'user_admin' : MENU_DENIED, 2);
+    menu('admin/user/create', t('new user'), $access ? 'user_admin' : MENU_DENIED, 1);
+    menu('admin/user/access', t('access rules'), $access ? 'user_admin' : MENU_DENIED, 3);
+    menu('admin/user/access/mail', t('e-mail rules'), $access ? 'user_admin' : MENU_DENIED);
+    menu('admin/user/access/user', t('name rules'), $access ? 'user_admin' : MENU_DENIED);
+    menu('admin/user/role', t('roles'), $access ? 'user_admin' : MENU_DENIED, 4);
+    menu('admin/user/permission', t('permissions'), $access ? 'user_admin' : MENU_DENIED, 5);
+    menu('admin/user/help', t('help'), $access ? 'user_help_page' : MENU_DENIED, 9);
+    menu('admin/user/edit', t('edit user account'), $access ? 'user_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+    if (module_exist('search')) {
+      menu('admin/user/search', t('search'), $access ? 'user_admin' : MENU_DENIED, 8);
     }
   }
 }
@@ -1175,7 +1177,7 @@ function user_page() {
         print theme('page', $output, t("Create new account"));
       }
       else {
-        print theme('page', message_access());
+        drupal_access_denied();
       }
       break;
     case t("Log in"):
diff --git a/modules/watchdog.module b/modules/watchdog.module
index b32baa6bed8b424d1661971dbc3a1b903de2fb09..6ca1cd3ba335f4d978747fffe2675e660f5853ab 100644
--- a/modules/watchdog.module
+++ b/modules/watchdog.module
@@ -49,14 +49,16 @@ function watchdog_perm() {
   return array("administer watchdog");
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function watchdog_link($type) {
-  if ($type == "system") {
-    if (user_access("administer watchdog")) {
-      menu("admin/logs", t("logs"), "watchdog_admin", 7);
-      menu("admin/logs/view", t("view details"), "watchdog_admin", 0, MENU_HIDE, MENU_LOCKED);
-      foreach (_watchdog_get_message_types() as $type) {
-        menu("admin/logs/$type", t($type), "watchdog_admin");
-      }
+  if ($type == 'system') {
+    menu('admin/logs', t('logs'), user_access('administer watchdog') ? 'watchdog_admin' : MENU_DENIED, 7);
+    menu('admin/logs/view', t('view details'), user_access('administer watchdog') ? 'watchdog_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+
+    foreach (_watchdog_get_message_types() as $type) {
+      menu("admin/logs/$type", t($type), user_access('administer watchdog') ? 'watchdog_admin' : MENU_DENIED);
     }
   }
 }
diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module
index b32baa6bed8b424d1661971dbc3a1b903de2fb09..6ca1cd3ba335f4d978747fffe2675e660f5853ab 100644
--- a/modules/watchdog/watchdog.module
+++ b/modules/watchdog/watchdog.module
@@ -49,14 +49,16 @@ function watchdog_perm() {
   return array("administer watchdog");
 }
 
+/**
+ * Implementation of hook_link().
+ */
 function watchdog_link($type) {
-  if ($type == "system") {
-    if (user_access("administer watchdog")) {
-      menu("admin/logs", t("logs"), "watchdog_admin", 7);
-      menu("admin/logs/view", t("view details"), "watchdog_admin", 0, MENU_HIDE, MENU_LOCKED);
-      foreach (_watchdog_get_message_types() as $type) {
-        menu("admin/logs/$type", t($type), "watchdog_admin");
-      }
+  if ($type == 'system') {
+    menu('admin/logs', t('logs'), user_access('administer watchdog') ? 'watchdog_admin' : MENU_DENIED, 7);
+    menu('admin/logs/view', t('view details'), user_access('administer watchdog') ? 'watchdog_admin' : MENU_DENIED, 0, MENU_HIDE, MENU_LOCKED);
+
+    foreach (_watchdog_get_message_types() as $type) {
+      menu("admin/logs/$type", t($type), user_access('administer watchdog') ? 'watchdog_admin' : MENU_DENIED);
     }
   }
 }