views_handler_sort_comment_thread.inc

  1. 3.x modules/comment/views_handler_sort_comment_thread.inc
  2. 2.x modules/comment/views_handler_sort_comment_thread.inc

File

modules/comment/views_handler_sort_comment_thread.inc
View source
  1. <?php
  2. /**
  3. * Sort handler for ordering by thread
  4. */
  5. class views_handler_sort_comment_thread extends views_handler_sort {
  6. function query() {
  7. $this->ensure_my_table();
  8. //Read comment_render() in comment.module for an explanation of the
  9. //thinking behind this sort.
  10. if ($this->options['order'] == 'DESC') {
  11. $this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order']);
  12. }
  13. else {
  14. $alias = $this->table_alias . '_' . $this->real_field . 'asc';
  15. //@todo is this secure?
  16. $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);
  17. }
  18. }
  19. }