You are here

function context_admin_term_childless_access_check in Contextual Administration 7

Same name and namespace in other branches
  1. 6 plugins/access/term_childless.inc \context_admin_term_childless_access_check()

Check for access.

1 string reference to 'context_admin_term_childless_access_check'
term_childless.inc in plugins/access/term_childless.inc
Provides access handler based upon the lack of child terms for the term we're on.

File

plugins/access/term_childless.inc, line 39
Provides access handler based upon the lack of child terms for the term we're on.

Code

function context_admin_term_childless_access_check($conf, $context) {

  // Per the example in node type in core ctools
  if (empty($context) || empty($context->data) || empty($context->data->tid)) {
    return FALSE;
  }
  $query = db_select('taxonomy_term_hierarchy', 'th')
    ->fields('th', array(
    'tid',
  ))
    ->condition('parent', $context->data->tid, '=');
  $result = $query
    ->execute()
    ->fetchObject();
  if ($result) {
    return FALSE;
  }
  else {
    return TRUE;
  }
  return FALSE;
}