/**
  * override parent class method, because we may want to specify a default sort
  *
  * @return xxx
  */
 function get_sql_sort()
 {
     // if user has specified a sort column, use that
     if ($sort = parent::get_sql_sort()) {
         return $sort;
     }
     // if there is a "fullname" column, sort by first/last name
     if ($this->has_column('fullname')) {
         $sort = 'u.firstname, u.lastname';
         if ($this->has_column('attempt')) {
             $sort .= ', ha.attempt ASC';
         }
         return $sort;
     }
     // no sort column, and no "fullname" column
     return '';
 }
Exemple #2
0
 /**
  * Get the SQL fragment to sort by.
  *
  * This is overridden to sort by timemodified and ID by default. Many items happen at the same time
  * and a second sorting by ID is valuable to distinguish the order in which the history happened.
  *
  * @return string SQL fragment.
  */
 public function get_sql_sort()
 {
     $columns = $this->get_sort_columns();
     if (count($columns) == 1 && isset($columns['timemodified']) && $columns['timemodified'] == SORT_DESC) {
         // Add the 'id' column when we are using the default sorting.
         $columns['id'] = SORT_DESC;
         return self::construct_order_by($columns);
     }
     return parent::get_sql_sort();
 }