All pastes #525940 Raw Edit

Anonymous

public text v1 · immutable
#525940 ·published 2007-05-31 16:23 UTC
rendered paste body
=== modified file 'includes/menu.inc'
--- includes/menu.inc	2007-05-31 11:54:39 +0000
+++ includes/menu.inc	2007-05-31 16:20:29 +0000
@@ -812,25 +812,27 @@ function _menu_tree_data($result = NULL,
  * Generate the HTML output for a single menu link.
  */
 function theme_menu_item_link($link) {
-  return l($link['title'], $link['href'], $link['options']);
+  return $link['title'] ? l($link['title'], $link['href'], $link['options']) : '';
 }

 /**
  * Generate the HTML output for a menu tree
  */
 function theme_menu_tree($tree) {
-  return '<ul class="menu">'. $tree .'</ul>';
+  return $tree ? '<ul class="menu">'. $tree .'</ul>' : '';
 }

 /**
  * Generate the HTML output for a menu item and submenu.
  */
 function theme_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE) {
-  $class = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
-  if ($in_active_trail) {
-    $class .= ' active-trail';
+  if ($link) {
+    $class = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
+    if ($in_active_trail) {
+      $class .= ' active-trail';
+    }
+    return '<li class="'. $class .'">'. $link . $menu .'</li>'."\n";
   }
-  return '<li class="'. $class .'">'. $link . $menu .'</li>'."\n";
 }

 function theme_menu_local_task($link, $active = FALSE) {

=== modified file 'index.php'
--- index.php	2007-04-06 13:27:20 +0000
+++ index.php	2007-05-31 15:49:47 +0000
@@ -12,6 +12,7 @@
 require_once './includes/bootstrap.inc';
 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

+menu_rebuild();
 $return = menu_execute_active_handler();

 // Menu status constants are integers; page content is a string.

=== modified file 'modules/user/user.module'
--- modules/user/user.module	2007-05-30 08:08:57 +0000
+++ modules/user/user.module	2007-05-31 16:21:06 +0000
@@ -754,6 +754,15 @@ function user_load_self($arg) {
   return $arg;
 }

+function _user_page_title() {
+  return $GLOBALS['user']->uid ? t('My account') : '';
+}
+
+function _user_page() {
+  global $user;
+  return $user->uid ? user_view($user) : drupal_get_form('user_login');
+}
+
 /**
  * Implementation of hook_menu().
  */
@@ -768,11 +777,9 @@ function user_menu() {

   // Registration and login pages.
   $items['user'] = array(
-    'title' => 'Log in',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('user_login'),
-    'access callback' => 'user_is_anonymous',
-    'type' => MENU_CALLBACK,
+    'title callback' => '_user_page_title',
+    'page callback' => '_user_page',
+    'access callback' => TRUE,
   );

   $items['user/login'] = array(
@@ -911,13 +918,14 @@ function user_menu() {
     'weight' => 10,
   );

-  $items['user/%user_current'] = array(
+  $items['user/%user'] = array(
     'title' => 'My account',
     'page callback' => 'user_view',
     'page arguments' => array(1),
     'access callback' => 'user_view_access',
     'access arguments' => array(1),
     'parent' => '',
+    'type' => MENU_CALLBACK,
   );

   $items['user/%user/view'] = array(
@@ -959,6 +967,11 @@ function user_menu() {
 }

 function user_init() {
+  global $user;
+  // We need to fix $_GET['q'] to get tabs.
+  if ($_GET['q'] == 'user') {
+    $_GET['q'] = "user/$user->uid";
+  }
   drupal_add_css(drupal_get_path('module', 'user') .'/user.css', 'module');
 }