Esempio n. 1
0
 /**
  * Sort threaded result, using THREAD=REFS method if available.
  * If not, use any method and re-sort the result in THREAD=REFS way.
  *
  * @param rcube_result_thread $threads Threads result set
  */
 protected function sort_threads($threads)
 {
     if ($threads->is_empty()) {
         return;
     }
     // THREAD=ORDEREDSUBJECT: sorting by sent date of root message
     // THREAD=REFERENCES:     sorting by sent date of root message
     // THREAD=REFS:           sorting by the most recent date in each thread
     if ($this->threading != 'REFS' || $this->sort_field && $this->sort_field != 'date') {
         $sortby = $this->sort_field ? $this->sort_field : 'date';
         $index = $this->index($this->folder, $sortby, $this->sort_order, true, true);
         if (!$index->is_empty()) {
             $threads->sort($index);
         }
     } else {
         if ($this->sort_order != $threads->get_parameters('ORDER')) {
             $threads->revert();
         }
     }
 }
Esempio n. 2
0
 /**
  * Sort threaded result, using THREAD=REFS method
  *
  * @param rcube_result_thread $threads  Threads result set
  */
 protected function sort_threads($threads)
 {
     if ($threads->is_empty()) {
         return;
     }
     // THREAD=ORDEREDSUBJECT: sorting by sent date of root message
     // THREAD=REFERENCES:     sorting by sent date of root message
     // THREAD=REFS:           sorting by the most recent date in each thread
     if ($this->sort_field && ($this->sort_field != 'date' || $this->get_capability('THREAD') != 'REFS')) {
         $index = $this->index_direct($this->folder, $this->sort_field, $this->sort_order, false);
         if (!$index->is_empty()) {
             $threads->sort($index);
         }
     } else {
         if ($this->sort_order != $threads->get_parameters('ORDER')) {
             $threads->revert();
         }
     }
 }