You are here

function entity_translation_add_access in Entity Translation 7

Access callback.

1 string reference to 'entity_translation_add_access'
entity_translation_menu_alter in ./entity_translation.module
Implements hook_menu_alter().

File

./entity_translation.module, line 670

Code

function entity_translation_add_access() {
  $args = func_get_args();
  $entity_type = array_shift($args);
  $entity = array_shift($args);
  $source = array_shift($args);
  $langcode = array_shift($args);
  $handler = entity_translation_get_handler($entity_type, $entity);
  $translations = $handler
    ->getTranslations();

  // If the translation does not exist we can show the tab.
  if (!isset($translations->data[$langcode]) && $langcode != $source) {

    // Check that the requested language is actually accessible.
    $enabled_languages = entity_translation_languages($entity_type, $entity);
    if (isset($enabled_languages[$langcode])) {
      $edit_form_item = array_shift($args);
      $access_callback = isset($edit_form_item['access callback']) ? $edit_form_item['access callback'] : 'user_access';
      return _entity_translation_callback($access_callback, $args, $edit_form_item);
    }
  }
  return FALSE;
}