You are here

function ctools_term_ctools_access_check in Chaos Tool Suite (ctools) 7

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

Check for access.

1 string reference to 'ctools_term_ctools_access_check'
term.inc in plugins/access/term.inc
Plugin to provide access control based upon specific terms.

File

plugins/access/term.inc, line 82
Plugin to provide access control based upon specific terms.

Code

function ctools_term_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'];

  // Get the terms.
  if (!isset($conf[$vid])) {
    return FALSE;
  }
  $return = FALSE;
  $terms = array_filter($conf[$vid]);

  // For multi-term if any terms coincide, let's call that good enough:
  if (isset($context->tids)) {
    return (bool) array_intersect($terms, $context->tids);
  }
  else {
    return in_array($context->data->tid, $terms);
  }
}