function entity_translation_translation_exists_ctools_access_check in Entity Translation 7
Grant access based on the which translations are available.
1 string reference to 'entity_translation_translation_exists_ctools_access_check'
- translation_exists.inc in plugins/
access/ translation_exists.inc - Plugin to provide access control on entities based on translations.
File
- plugins/
access/ translation_exists.inc, line 88 - Plugin to provide access control on entities based on translations.
Code
function entity_translation_translation_exists_ctools_access_check($conf, $context) {
// Check that the context exists.
if (empty($context) || empty($context->data)) {
return FALSE;
}
$entity = $context->data;
$handler = entity_translation_get_handler($context->keyword, $entity);
if (!empty($handler)) {
$translations = $handler
->getTranslations();
global $language_content;
foreach ($conf['language'] as $lang) {
if ($lang) {
switch ($lang) {
case ENTITY_TRANSLATION_LANGUAGE_CURRENT:
$lang = $language_content->language;
break;
case ENTITY_TRANSLATION_LANGUAGE_DEFAULT:
$lang = language_default('language');
break;
}
if (isset($translations->data[$lang]) && $translations->data[$lang]['status']) {
return TRUE;
}
}
}
}
return FALSE;
}