You are here

function _file_entity_view_mode_menu_access in D7 Media 7

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

Based on _field_ui_view_mode_menu_access(), but the Field UI module might not be enabled.

1 string reference to '_file_entity_view_mode_menu_access'
file_entity_menu in file_entity/file_entity.module
Implements hook_menu().

File

file_entity/file_entity.module, line 503
Extends Drupal file entities to be fieldable and viewable.

Code

function _file_entity_view_mode_menu_access($bundle, $view_mode, $access_callback) {

  // Deny access if the view mode isn't configured to use custom display
  // settings.
  $file_type = field_extract_bundle('file', $bundle);
  $view_mode_settings = field_view_mode_settings('file', $file_type);
  $visibility = $view_mode == 'default' || !empty($view_mode_settings[$view_mode]['custom_settings']);
  if (!$visibility) {
    return FALSE;
  }

  // Otherwise, continue to an $access_callback check.
  $args = array_slice(func_get_args(), 3);
  $callback = empty($access_callback) ? 0 : trim($access_callback);
  if (is_numeric($callback)) {
    return (bool) $callback;
  }
  elseif (function_exists($access_callback)) {
    return call_user_func_array($access_callback, $args);
  }
}