Skip to content

Commit

Permalink
variable: Complete Thread ASC or DESC
Browse files Browse the repository at this point in the history
This pull adds the ability to choose between ASC or DESC order for the
complete thread variable. If `complete_asc` is chosen the system will order
the thread in ASC order, if `complete_desc` is chosen the system will order
the thread in DESC order. This keeps backwards compatibility with just
`complete` as some people might forget to update this for a while.
  • Loading branch information
JediKev committed Feb 14, 2019
1 parent eafb34d commit 3f79e2c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions include/class.thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -2989,7 +2989,7 @@ function __toString() {
}

function asVar() {
return $this->getVar('complete');
return $this->getVar('complete_asc');
}

function getVar($name) {
Expand All @@ -3012,7 +3012,10 @@ function getVar($name) {
return $entry->getBody();

break;
case 'complete_desc':
$desc = true;
case 'complete':
case 'complete_asc':
$content = '';
$thread = $this;
ob_start();
Expand All @@ -3027,7 +3030,8 @@ function getVar($name) {

static function getVarScope() {
return array(
'complete' => __('Thread Correspondence'),
'complete_asc' => __('Thread Correspondence Ascending'),
'complete_desc' => __('Thread Correspondence Descending'),
'original' => array('class' => 'MessageThreadEntry', 'desc' => __('Original Message')),
'lastmessage' => array('class' => 'MessageThreadEntry', 'desc' => __('Last Message')),
);
Expand Down
3 changes: 2 additions & 1 deletion include/client/templates/thread-export.tmpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
'attachments__thread_entry__type__in' => array_keys($entryTypes)
))->all();

$order = $desc ? QuerySet::DESC : QuerySet::ASC;
$entries = $thread->getEntries();
$entries->filter(array('type__in' => array_keys($entryTypes)));
$entries->filter(array('type__in' => array_keys($entryTypes)))->order_by('id', $order);
?>
<style type="text/css">
div {font-family: sans-serif;}
Expand Down

0 comments on commit 3f79e2c

Please sign in to comment.