You are here

function masquerade_menu_alter in Masquerade 6

Same name and namespace in other branches
  1. 7 masquerade.module \masquerade_menu_alter()

Implementation of hook_menu_alter().

We need to add a token to the Masquerade paths to protect against CSRF attacks. Since menu items in Drupal do not support dynamic elements these tokens need to be added during rendering via an implementation of hook_translated_menu_link_alter. Set the 'alter'-option to TRUE to make sure the links get passed through hook_translated_menu_link_alter.

File

./masquerade.module, line 139
masquerade.module

Code

function masquerade_menu_alter(&$items) {
  $items['masquerade/unswitch']['options']['alter'] = TRUE;
  $items['masquerade/switch/%']['options']['alter'] = TRUE;
  $default_test_user = _masquerade_user_load(variable_get('masquerade_test_user', ''));
  if (isset($default_test_user->uid)) {
    $items['masquerade/switch/' . $default_test_user->uid]['options']['alter'] = TRUE;
  }
}