summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/comment/views_handler_sort_comment_thread.inc
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.15/sites/all/modules/views/modules/comment/views_handler_sort_comment_thread.inc')
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/views/modules/comment/views_handler_sort_comment_thread.inc20
1 files changed, 20 insertions, 0 deletions
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/comment/views_handler_sort_comment_thread.inc b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/comment/views_handler_sort_comment_thread.inc
new file mode 100644
index 0000000..e529b2a
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/views/modules/comment/views_handler_sort_comment_thread.inc
@@ -0,0 +1,20 @@
+<?php
+/**
+ * Sort handler for ordering by thread
+ */
+class views_handler_sort_comment_thread extends views_handler_sort {
+ 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);
+ }
+ }
+}