Skip to content
Snippets Groups Projects
Commit 84d05c61 authored by JediKev's avatar JediKev
Browse files

variable: Complete Thread ASC or DESC

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.
parent 89838c08
No related branches found
No related tags found
No related merge requests found
...@@ -2989,7 +2989,7 @@ implements TemplateVariable { ...@@ -2989,7 +2989,7 @@ implements TemplateVariable {
} }
function asVar() { function asVar() {
return $this->getVar('complete'); return new ThreadEntries($this);
} }
function getVar($name) { function getVar($name) {
...@@ -3013,21 +3013,14 @@ implements TemplateVariable { ...@@ -3013,21 +3013,14 @@ implements TemplateVariable {
break; break;
case 'complete': case 'complete':
$content = ''; return $this->asVar();
$thread = $this;
ob_start();
include INCLUDE_DIR.'client/templates/thread-export.tmpl.php';
$content = ob_get_contents();
ob_end_clean();
return $content;
break; break;
} }
} }
static function getVarScope() { static function getVarScope() {
return array( return array(
'complete' => __('Thread Correspondence'), 'complete' =>array('class' => 'ThreadEntries', 'desc' => __('Thread Correspondence')),
'original' => array('class' => 'MessageThreadEntry', 'desc' => __('Original Message')), 'original' => array('class' => 'MessageThreadEntry', 'desc' => __('Original Message')),
'lastmessage' => array('class' => 'MessageThreadEntry', 'desc' => __('Last Message')), 'lastmessage' => array('class' => 'MessageThreadEntry', 'desc' => __('Last Message')),
); );
...@@ -3047,6 +3040,43 @@ implements TemplateVariable { ...@@ -3047,6 +3040,43 @@ implements TemplateVariable {
} }
} }
class ThreadEntries {
var $thread;
function __construct($thread) {
$this->thread = $thread;
}
function asVar() {
return $this->getVar();
}
function getVar($name='') {
$order = '';
switch ($name) {
case 'reversed':
$order = '-';
default:
$content = '';
$thread = $this->thread;
ob_start();
include INCLUDE_DIR.'client/templates/thread-export.tmpl.php';
$content = ob_get_contents();
ob_end_clean();
return $content;
break;
}
}
static function getVarScope() {
return array(
'reversed' => sprintf('%s %s', __('Thread Correspondence'),
__('in reversed order')),
);
}
}
// Ticket thread class // Ticket thread class
class TicketThread extends ObjectThread { class TicketThread extends ObjectThread {
static function create($ticket=false) { static function create($ticket=false) {
......
...@@ -12,7 +12,7 @@ AttachmentFile::objects()->filter(array( ...@@ -12,7 +12,7 @@ AttachmentFile::objects()->filter(array(
))->all(); ))->all();
$entries = $thread->getEntries(); $entries = $thread->getEntries();
$entries->filter(array('type__in' => array_keys($entryTypes))); $entries->filter(array('type__in' => array_keys($entryTypes)))->order_by("{$order}id");;
?> ?>
<style type="text/css"> <style type="text/css">
div {font-family: sans-serif;} div {font-family: sans-serif;}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment