You are here

function cas_translated_menu_link_alter in CAS 7

Same name and namespace in other branches
  1. 6.3 cas.module \cas_translated_menu_link_alter()

Implements hook_translated_menu_item_alter().

Append dynamic query 'destination' to CAS menu links.

File

./cas.module, line 461
Enables users to authenticate via a Central Authentication Service (CAS) Cas will currently work if the auto registration is turned on and will create user accounts automatically.

Code

function cas_translated_menu_link_alter(&$item) {
  $href = strtolower($item['href']);
  $append_destination = $href == 'cas' || $href == 'caslogout' && !variable_get('cas_logout_destination', '');
  if ($append_destination) {

    // Don't overwrite existing query params that may exist in the menu link.
    if (isset($item['localized_options']['query'])) {
      $menu_link_query_params = array_merge(drupal_get_destination(), $item['localized_options']['query']);
    }
    else {
      $menu_link_query_params = drupal_get_destination();
    }
    $item['localized_options']['query'] = $menu_link_query_params;
  }
}