From 0925320ed4c2f0e9e2fef1d8bd531cb605490378 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Tue, 3 Feb 2015 17:03:44 -0600 Subject: [PATCH] thread: Fixup Threadable interface --- include/class.thread.php | 14 +++++--------- include/class.ticket.php | 12 ++++++++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/include/class.thread.php b/include/class.thread.php index 63d8fb6f1..8a7e1f744 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -171,7 +171,7 @@ class Thread extends VerySimpleModel { $vars['origin'] = 'Email'; if ($object instanceof Threadable) - return $object->postMessage($vars, $vars['origin']); + return $object->postThreadEntry('M', $vars); elseif ($this instanceof ObjectThread) $this->addMessage($vars, $errors); else @@ -185,7 +185,7 @@ class Thread extends VerySimpleModel { $vars['note'] = $body; if ($object instanceof Threadable) - return $object->postNote($vars, $errors); + return $object->postThreadEntry('N', $vars); elseif ($this instanceof ObjectThread) return $this->addNote($vars, $errors); else @@ -202,7 +202,7 @@ class Thread extends VerySimpleModel { $vars['note'] = $body; $vars['poster'] = $poster; if ($object instanceof Threadable) - return $object->postNote($vars, $errors); + return $object->postThreadEntry('N', $vars); elseif ($this instanceof ObjectThread) return $this->addNote($vars, $errors); else @@ -219,7 +219,7 @@ class Thread extends VerySimpleModel { $vars['userId'] = 0; //Unknown user! //XXX: Assume ticket owner? $vars['origin'] = 'Email'; if ($object instanceof Threadable) - return $object->postMessage($vars, $errors); + return $object->postThreadEntry('M', $vars); elseif ($this instanceof ObjectThread) return $this->addMessage($vars, $errors); else @@ -1611,10 +1611,6 @@ abstract class ThreadEntryAction { } interface Threadable { - /* - function postMessage($vars, $errors); - function postNote($vars, $errors); - function postReply($vars, $errors); - */ + function postThreadEntry($type, $vars); } ?> diff --git a/include/class.ticket.php b/include/class.ticket.php index 626e2265f..2225baada 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -2319,6 +2319,18 @@ implements RestrictedAccess, Threadable { return $note; } + // Threadable interface + function postThreadEntry($type, $vars) { + switch ($type) { + case 'M': + return $this->postMessage($vars, $vars['origin']); + case 'N': + return $this->postNote($vars); + case 'R': + return $this->postReply($vars); + } + } + //Print ticket... export the ticket thread as PDF. function pdfExport($psize='Letter', $notes=false) { global $thisstaff; -- GitLab