You are here

function _file_entity_view_mode_menu_access in File Entity (fieldable files) 7

Same name and namespace in other branches
  1. 7.3 file_entity.module \_file_entity_view_mode_menu_access()
  2. 7.2 file_entity.module \_file_entity_view_mode_menu_access()

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.module
Implements hook_menu().

File

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

Code

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

  // Deny access if the view mode isn't configured to use custom display
  // settings.
  $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);
  }
}