From ef2b91a92faff6f9eac617c262bac7aa5ca0dcde Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Mon, 2 Jun 2014 10:40:48 -0500 Subject: [PATCH] Implement default help topic Use the topic associated with the email if any, and the topic defined as the system default as the last resort. In either case, the form associated with the help topic will be added to the ticket, but no data will be put into the form fields. --- include/class.config.php | 4 ++++ include/class.email.php | 10 ++++++++++ include/class.ticket.php | 9 +++++++++ include/staff/email.inc.php | 2 +- 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/include/class.config.php b/include/class.config.php index c70a21d88..e886ad749 100644 --- a/include/class.config.php +++ b/include/class.config.php @@ -432,6 +432,10 @@ class OsticketConfig extends Config { return $this->get('default_help_topic'); } + function getDefaultTopic() { + return Topic::lookup($this->getDefaultTopicId()); + } + function getTopicSortMode() { return $this->get('help_topic_sort_mode'); } diff --git a/include/class.email.php b/include/class.email.php index aa6facef4..79b307dca 100644 --- a/include/class.email.php +++ b/include/class.email.php @@ -86,6 +86,16 @@ class Email { return $this->dept; } + function getTopicId() { + return $this->ht['topic_id']; + } + + function getTopic() { + // Topic::lookup will do validation on the ID, no need to duplicate + // code here + return Topic::lookup($this->getTopicId()); + } + function autoRespond() { return (!$this->ht['noautoresp']); } diff --git a/include/class.ticket.php b/include/class.ticket.php index c3f492469..805f3d1a2 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -2403,6 +2403,10 @@ class Ticket { $form->setAnswer('priority', null, $email->getPriorityId()); if ($autorespond) $autorespond = $email->autoRespond(); + if (!isset($topic)) { + // This may return NULL. No big deal + $topic = $email->getTopic(); + } $email = null; $source = 'Email'; } @@ -2416,6 +2420,11 @@ class Ticket { $vars['teamId'] = substr($code, 1); } + if (!isset($topic)) { + // This may return NULL, no big deal + $topic = $cfg->getDefaultTopic(); + } + // Intenal mapping magic...see if we need to override anything if (isset($topic)) { $deptId = $deptId ?: $topic->getDeptId(); diff --git a/include/staff/email.inc.php b/include/staff/email.inc.php index acfcb4c64..8f8e68312 100644 --- a/include/staff/email.inc.php +++ b/include/staff/email.inc.php @@ -127,7 +127,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); <td> <span> <select name="topic_id"> - <option value="0" selected="selected">— None —</option> + <option value="0" selected="selected">— System Default —</option> <?php $topics = Topic::getHelpTopics(); while (list($id,$topic) = each($topics)) { ?> -- GitLab