You are here

function og_handler_filter_post_og_type in Organic groups 5.8

Same name and namespace in other branches
  1. 5 og_views.inc \og_handler_filter_post_og_type()
  2. 5.2 og_views.inc \og_handler_filter_post_og_type()
  3. 5.3 og_views.inc \og_handler_filter_post_og_type()
  4. 5.7 og_views.inc \og_handler_filter_post_og_type()
1 string reference to 'og_handler_filter_post_og_type'
og_views_tables in ./og_views.inc
Implementation of the hook_views_tables()

File

./og_views.inc, line 1371

Code

function og_handler_filter_post_og_type($op, $filter, $filterinfo, &$query) {
  $query
    ->ensure_table('og_ancestry');
  $query
    ->add_table('og_node_data');
  $types = $filter['value'];
  $placeholders = array_fill(0, count($types), "'%s'");

  // If we don't want to list posts assiciated with groups of this type then
  // we need to both exclude them and also include unaffiliated posts.
  if ($filter['operator'] == 'NOR') {
    $not = 'NOT';
    $ornull = ' OR (og_node_data.type IS NULL)';
  }
  $query
    ->add_where("(og_node_data.type " . $not . " IN (" . implode(", ", $placeholders) . "))" . $ornull, $types);
}