You are here

function spaces_features_menu_links_alter in Spaces 6.2

Implementation of hook_features_menu_links_alter(). This function is deprecated and is no longer a real drupal_alter() callback. It is invoked directly from spaces_preprocess_page().

1 call to spaces_features_menu_links_alter()
spaces_preprocess_page in ./spaces.module
theme_page() preprocessor.

File

./spaces.module, line 1235

Code

function spaces_features_menu_links_alter(&$links) {
  $space = spaces_get_space();
  if ($space) {

    // Load up the spaces menu links
    spaces_customizers();
    space_customizer_menu::customize($space, $links);

    // Retrieve the menu cache for a path to feature mapping
    $map = spaces_features_map('menu');

    // Sort the menu by feature weight & hide any items for features
    // that are not available (this **should**) be handled by access
    // control on the links' respective menu callbacks, but awkward
    // permissioning (e.g. user 1)  makes it nice for these to be
    // hidden manually.
    $weights = array_flip(array_keys($space->features));
    $weighted = array();
    foreach ($links as $k => $item) {
      $feature = '';
      if (!empty($map[$item['href']])) {
        $feature = $map[$item['href']];
      }
      if (!empty($feature) && $space
        ->feature_access($feature)) {

        // Retrieve path > feature > weight
        $links[$k]['#weight'] = $weights[$feature];
      }
      else {
        unset($links[$k]);
      }
    }
    uasort($links, 'element_sort');
  }
}