Projet

Général

Profil

Paste
Télécharger (1,11 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / modules / comment / views_handler_sort_ncs_last_comment_name.inc @ 7547bb19

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of views_handler_sort_ncs_last_comment_name.
6
 */
7

    
8
/**
9
 * Sort handler to sort by last comment name which might be in 2 different
10
 * fields.
11
 *
12
 * @ingroup views_sort_handlers
13
 */
14
class views_handler_sort_ncs_last_comment_name extends views_handler_sort {
15
  function query() {
16
    $this->ensure_my_table();
17
    $join = new views_join();
18
    $join->construct('users', $this->table_alias, 'last_comment_uid', 'uid');
19

    
20
    // @todo this might be safer if we had an ensure_relationship rather than guessing
21
    // the table alias. Though if we did that we'd be guessing the relationship name
22
    // so that doesn't matter that much.
23
//    $this->user_table = $this->query->add_relationship(NULL, $join, 'users', $this->relationship);
24
    $this->user_table = $this->query->ensure_table('ncs_users', $this->relationship, $join);
25
    $this->user_field = $this->query->add_field($this->user_table, 'name');
26

    
27
    // Add the field.
28
    $this->query->add_orderby(NULL, "LOWER(COALESCE($this->user_table.name, $this->table_alias.$this->field))", $this->options['order'], $this->table_alias . '_' . $this->field);
29
  }
30
}