You are here

public function views_handler_sort_comment_thread::query in Views (for Drupal 7) 7.3

Same name and namespace in other branches
  1. 6.3 modules/comment/views_handler_sort_comment_thread.inc \views_handler_sort_comment_thread::query()
  2. 6.2 modules/comment/views_handler_sort_comment_thread.inc \views_handler_sort_comment_thread::query()

Called to add the sort to a query.

Overrides views_handler_sort::query

File

modules/comment/views_handler_sort_comment_thread.inc, line 18
Definition of views_handler_sort_comment_thread.

Class

views_handler_sort_comment_thread
Sort handler for ordering by thread.

Code

public function query() {
  $this
    ->ensure_my_table();

  // Read comment_render() in comment.module for an explanation of the
  // thinking behind this sort.
  if ($this->options['order'] == 'DESC') {
    $this->query
      ->add_orderby($this->table_alias, $this->real_field, $this->options['order']);
  }
  else {
    $alias = $this->table_alias . '_' . $this->real_field . 'asc';

    // @todo Is this secure?
    $this->query
      ->add_orderby(NULL, "SUBSTRING({$this->table_alias}.{$this->real_field}, 1, (LENGTH({$this->table_alias}.{$this->real_field}) - 1))", $this->options['order'], $alias);
  }
}