You are here

function termstatus_query_term_access_alter in Taxonomy Term Status 7

Implements hook_query_TAG_alter().

File

./termstatus.module, line 206
Hook implementations and API for the taxonomy term status module.

Code

function termstatus_query_term_access_alter(QueryAlterableInterface $query) {
  $tables =& $query
    ->getTables();
  if (variable_get('termstatus_enable', FALSE) && !user_access('administer taxonomy') && !user_access('view unpublished taxonomy terms') && !$query
    ->hasTag('status_unpublished')) {

    // Extract taxonomy_term_data tables.
    foreach ($tables as $alias => $table) {
      if ($table['table'] == 'taxonomy_term_data') {

        // Add one inner join to termstatus for each taxonomy_term_data
        // instance.
        $query
          ->leftjoin('termstatus', 'termstatus_' . $alias, $alias . '.tid = termstatus_' . $alias . '.tid');
        $query
          ->condition('termstatus_' . $alias . '.status', 1, '=');
      }
    }
  }
}