function _field_ui_view_mode_menu_access

7.x field_ui.module _field_ui_view_mode_menu_access($entity_type, $bundle, $view_mode, $access_callback)

Menu access callback for the 'view mode display settings' pages.

1 string reference to '_field_ui_view_mode_menu_access'
field_ui_menu in drupal-7.x/modules/field_ui/field_ui.module
Implements hook_menu().

File

drupal-7.x/modules/field_ui/field_ui.module, line 257
Allows administrators to attach custom fields to fieldable types.

Code

function _field_ui_view_mode_menu_access($entity_type, $bundle, $view_mode, $access_callback) {
  // First, determine visibility according to the 'use custom display'
  // setting for the view mode.
  $bundle = field_extract_bundle($entity_type, $bundle);
  $view_mode_settings = field_view_mode_settings($entity_type, $bundle);
  $visibility = ($view_mode == 'default') || !empty($view_mode_settings[$view_mode]['custom_settings']);

  // Then, determine access according to the $access parameter. This duplicates
  // part of _menu_check_access().
  if ($visibility) {
    // Grab the variable 'access arguments' part.
    $all_args = func_get_args();
    $args = array_slice($all_args, 4);
    $callback = empty($access_callback) ? 0 : trim($access_callback);
    if (is_numeric($callback)) {
      return (bool) $callback;
    }
    else {
      // As call_user_func_array() is quite slow and user_access is a very
      // common callback, it is worth making a special case for it.
      if ($access_callback == 'user_access') {
        return (count($args) == 1) ? user_access($args[0]) : user_access($args[0], $args[1]);
      }
      elseif (function_exists($access_callback)) {
        return call_user_func_array($access_callback, $args);
      }
    }
  }
}