You are here

function content_language_access_menu_alter in Content Language Access 6

Implements hook_menu_alter().

File

./content_language_access.module, line 28
This module provides access checking of the current language of the site with the language of the content (language neutral are not considered).

Code

function content_language_access_menu_alter(&$items) {

  // Check if we are not overrriding the another access callback.
  $old_callback = $items['node/%node']['access callback'];
  if ($old_callback == 'node_access') {

    // Keep as null if it is already node_access callback.
    $old_callback = NULL;
  }

  // Use _content_language_access_node_access() instead of node_access().
  $items['node/%node']['access callback'] = $items['node/%node/view']['access callback'] = '_content_language_access_node_access';

  // Adding aditional parameter to the access arguments containing the old
  // callback.
  $items['node/%node']['access arguments'] = $items['node/%node/view']['access arguments'] = array(
    'view',
    1,
    NULL,
    $old_callback,
  );
}