function ctools_node_language_ctools_access_check

Check for access.

1 string reference to 'ctools_node_language_ctools_access_check'
node_language.inc in plugins/access/node_language.inc
Plugin to provide access control based upon node type.

File

plugins/access/node_language.inc, line 48

Code

function ctools_node_language_ctools_access_check($conf, $context) {
    // As far as I know there should always be a context at this point, but this
    // is safe.
    if (empty($context) || empty($context->data) || !isset($context->data->language)) {
        return FALSE;
    }
    global $language;
    // Specialcase: if 'no language' is checked, return TRUE if the language field is
    // empty.
    if (!empty($conf['language']['no_language'])) {
        if (empty($context->data->language)) {
            return TRUE;
        }
    }
    // Specialcase: if 'current' is checked, return TRUE if the current site language
    // matches the node language.
    if (!empty($conf['language']['current'])) {
        if ($context->data->language == $language->language) {
            return TRUE;
        }
    }
    // Specialcase: If 'default' is checked, return TRUE if the default site language
    // matches the node language.
    if (!empty($conf['language']['default'])) {
        if ($context->data->language == language_default('language')) {
            return TRUE;
        }
    }
    if (array_filter($conf['language']) && empty($conf['language'][$context->data->language])) {
        return FALSE;
    }
    return TRUE;
}