Menu access callback for the 'view mode display settings' pages.
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);
}
}
}
}