function ctools_term_parent_ctools_access_check

Check for access.

1 string reference to 'ctools_term_parent_ctools_access_check'
term_parent.inc in plugins/access/term_parent.inc
Plugin to provide access control based upon a parent term.

File

plugins/access/term_parent.inc, line 61

Code

function ctools_term_parent_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) || empty($context->data->vid) || empty($context->data->tid)) {
        return FALSE;
    }
    // Get the $vid.
    if (!isset($conf['vid'])) {
        return FALSE;
    }
    $vid = $conf['vid'];
    $count = db_query('SELECT COUNT(*) FROM {taxonomy_term_hierarchy} th INNER JOIN {taxonomy_term_data} td ON th.parent = td.tid WHERE th.tid = :tid AND td.vid = :vid', array(
        ':tid' => $context->data->tid,
        ':vid' => $vid,
    ))
        ->fetchField();
    return $count ? TRUE : FALSE;
}