From 7ed57113976716add69790f086c311fd342f0975 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Fri, 24 Oct 2014 13:22:52 -0500
Subject: [PATCH] Fix subject display when a ChoiceField is used

---
 include/client/tickets.inc.php | 5 ++++-
 include/staff/tickets.inc.php  | 7 ++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/client/tickets.inc.php b/include/client/tickets.inc.php
index 2c1a04a97..6b8e9df1a 100644
--- a/include/client/tickets.inc.php
+++ b/include/client/tickets.inc.php
@@ -157,11 +157,14 @@ $negorder=$order=='DESC'?'ASC':'DESC'; //Negate the sorting
     </thead>
     <tbody>
     <?php
+     $subject_field = TicketForm::objects()->one()->getField('subject');
      if($res && ($num=db_num_rows($res))) {
         $defaultDept=Dept::getDefaultDeptName(); //Default public dept.
         while ($row = db_fetch_array($res)) {
             $dept= $row['ispublic']? $row['dept_name'] : $defaultDept;
-            $subject=Format::htmlchars(Format::truncate($row['subject'],40));
+            $subject = Format::truncate($subject_field->display(
+                $subject_field->to_php($row['subject']) ?: $row['subject']
+            ), 40);
             if($row['attachments'])
                 $subject.='  &nbsp;&nbsp;<span class="Icon file"></span>';
 
diff --git a/include/staff/tickets.inc.php b/include/staff/tickets.inc.php
index f6c17982c..70acec919 100644
--- a/include/staff/tickets.inc.php
+++ b/include/staff/tickets.inc.php
@@ -406,6 +406,8 @@ if ($results) {
      </thead>
      <tbody>
         <?php
+        // Setup Subject field for display
+        $subject_field = TicketForm::objects()->one()->getField('subject');
         $class = "row1";
         $total=0;
         if($res && ($num=count($results))):
@@ -430,7 +432,10 @@ if ($results) {
                     $lc=Format::truncate($row['dept_name'],40);
                 }
                 $tid=$row['number'];
-                $subject = Format::htmlchars(Format::truncate($row['subject'],40));
+
+                $subject = Format::truncate($subject_field->display(
+                    $subject_field->to_php($row['subject']) ?: $row['subject']
+                ), 40);
                 $threadcount=$row['thread_count'];
                 if(!strcasecmp($row['state'],'open') && !$row['isanswered'] && !$row['lock_id']) {
                     $tid=sprintf('<b>%s</b>',$tid);
-- 
GitLab