You are here

function views_handler_argument_oa_comment_paragraph_and_current_ids::query in OA Comment 7.2

Set up the query for this argument.

The argument sent may be found at $this->argument.

Parameters

bool $group_by: Whether the query uses a group-by.

Overrides views_handler_argument_numeric::query

File

views/views_handler_argument_oa_comment_paragraph_and_current_ids.inc, line 14
Definition of views_handler_argument_numeric.

Class

views_handler_argument_oa_comment_paragraph_and_current_ids
Contextural filter for Open Atrium Parent ID

Code

function query($group_by = FALSE) {
  $table = $this
    ->ensure_my_table();

  // Determine parent of the node argument if any
  $this->query
    ->set_where_group('OR', 'paragraph_and_current_ids');
  $this->query
    ->add_where_expression('paragraph_and_current_ids', "{$table}.type = 'node' AND id = {$this->argument}");
  if ($ids = oa_comment_find_paragraph_ids($this->argument)) {
    foreach ($ids as $key => $pids) {
      foreach ($pids as $id) {
        $this->query
          ->add_where_expression('paragraph_and_current_ids', "{$table}.type = 'paragraphs_item' AND id = {$id}");
      }
    }
  }
}