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

Access callback: Checks access for the Display mode pages.

See also

field_ui_menu()

File

core/modules/field_ui/field_ui.module, line 266
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 Display 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.
    $args = array_slice(func_get_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]);
      }
      else {
        return call_user_func_array($access_callback, $args);
      }
    }
  }
}