You are here

function ctools_access_menu in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 ctools.module \ctools_access_menu()

Determine if the current user has access via a plugin.

This function is meant to be embedded in the Drupal menu system, and therefore is in the .module file since sub files can't be loaded, and takes arguments a little bit more haphazardly than ctools_access().

Parameters

$access: An access control array which contains the following information:

  • 'logic': and or or. Whether all tests must pass or one must pass.
  • 'plugins': An array of access plugins. Each contains:
  • - 'name': The name of the plugin
  • - 'settings': The settings from the plugin UI.
  • - 'context': Which context to use.

...: zero or more context arguments generated from argument plugins. These contexts must have an 'id' attached to them so that they can be properly associated. The argument plugin system should set this, but if the context is coming from elsewhere it will need to be set manually.

Return value

TRUE if access is granted, false if otherwise.

1 string reference to 'ctools_access_menu'
page_manager_page_menu_item in page_manager/plugins/tasks/page.admin.inc
Create a menu item for page manager pages.

File

./ctools.module, line 905
CTools primary module file.

Code

function ctools_access_menu($access) {
  $func_args = func_get_args();

  // Short circuit everything if there are no access tests.
  if (empty($access['plugins'])) {
    return TRUE;
  }
  $contexts = array();
  foreach ($func_args as $arg) {
    if (is_object($arg) && get_class($arg) == 'ctools_context') {
      $contexts[$arg->id] = $arg;
    }
  }
  ctools_include('context');
  return ctools_access($access, $contexts);
}