You are here

function forum_access_menu_alter in Forum Access 7

Same name and namespace in other branches
  1. 6 forum_access.module \forum_access_menu_alter()

Implements hook_menu_alter().

Remove the 'Forum' menu item if no forums are visible.

File

./forum_access.module, line 49
forum_access.module

Code

function forum_access_menu_alter(&$items) {
  $requirements = forum_access_requirements('runtime');
  if (!empty($requirements) && $requirements[0]['value'] != t('Unknown')) {

    // Fall back to obsolete Chain Menu Access API version 7.x-1.x,
    // because that's what's installed.
    chain_menu_access_chain($items['forum'], 'forum_access_view_any_forum', array());
    chain_menu_access_chain($items['node/%node'], '_forum_access_node_access_callback', array(
      1,
      'view',
    ));
    chain_menu_access_chain($items['comment/%comment/edit'], '_forum_access_comment_edit_callback', array(
      1,
    ));
    chain_menu_access_chain($items['comment/%comment/edit'], '_forum_access_comment_access_callback', array(
      1,
      2,
    ), TRUE);
    chain_menu_access_chain($items['comment/%/delete'], '_forum_access_comment_access_callback', array(
      1,
      2,
    ), TRUE);
    chain_menu_access_chain($items['comment/%/approve'], '_forum_access_comment_access_callback', array(
      1,
      2,
    ), TRUE);
    chain_menu_access_chain($items['comment/reply/%node'], '_forum_access_comment_access_callback', array(
      2,
      1,
    ));
  }
  else {
    chain_menu_access_chain($items, 'forum', 'forum_access_view_any_forum');
    chain_menu_access_chain($items, 'node/%node', '_forum_access_node_access_callback', array(
      1,
      'view',
    ));
    chain_menu_access_chain($items, 'comment/%comment/edit', '_forum_access_comment_edit_callback', array(
      1,
    ));
    chain_menu_access_chain($items, 'comment/%comment/edit', '_forum_access_comment_access_callback', array(
      1,
      2,
    ), TRUE);
    chain_menu_access_chain($items, 'comment/%/delete', '_forum_access_comment_access_callback', array(
      1,
      2,
    ), TRUE);
    chain_menu_access_chain($items, 'comment/%/approve', '_forum_access_comment_access_callback', array(
      1,
      2,
    ), TRUE);
    chain_menu_access_chain($items, 'comment/reply/%node', '_forum_access_comment_access_callback', array(
      2,
      1,
    ));
  }
}