Secondary tabs в профиле пользователя

Написано: вторник, 2 августа 2011 г. автор shumer Ярлыки:
0

При добавлении итема MENU_LOCAL_TASK в раздел user/%/edit/ пропадали табы когда происходил переход по добавленному табу, за все отвечает функция в модуле user.module
Привожу уже исправленный вариант, по дефолту использовалась закомментированная строка.

/**
 * Return a user object after checking if any profile category in the path exists.
 */
function user_category_load($uid, &$map, $index) {
  static $user_categories, $accounts;

  // Cache $account - this load function will get called for each profile tab.
  if (!isset($accounts[$uid])) {
    $accounts[$uid] = user_load($uid);
  }
  $valid = TRUE;
  //if (($account = $accounts[$uid]) && isset($map[$index + 1]) && $map[$index + 1] == 'edit') {
  if (($account = $accounts[$uid]) && $map[0] == 'user' && $map[1] == $index && $map[2] == 'edit') {
    // Since the path is like user/%/edit/category_name, the category name will
    // be at a position 2 beyond the index corresponding to the % wildcard.
    $category_index = $index + 2;
    // Valid categories may contain slashes, and hence need to be imploded.
    $category_path = implode('/', array_slice($map, $category_index));
    if ($category_path) {
      // Check that the requested category exists.
      $valid = FALSE;
      if (!isset($user_categories)) {
        $empty_account = new stdClass();
        $user_categories = _user_categories($empty_account);
      }
      foreach ($user_categories as $category) {
        if ($category['name'] == $category_path) {
          $valid = TRUE;
          // Truncate the map array in case the category name had slashes.
          $map = array_slice($map, 0, $category_index);
          // Assign the imploded category name to the last map element.
          $map[$category_index] = $category_path;
          break;
        }
      }
    }
  }
  return $valid ? $account : FALSE;
}