diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index 3a445717776c6f44ff6cab59ba717d0fe79876b4..94b9b786e76c6cff6afede8f44f12ba509939cdd 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -1122,9 +1122,15 @@ class SelectionField extends FormField { } function to_php($value, $id=false) { - $value = ($value && !is_array($value)) - ? JsonDataParser::parse($value) : $value; + if (is_string($value)) + $value = JsonDataParser::parse($value) ?: $value; + if (!is_array($value)) { + $config = $this->getConfiguration(); + if (!$config['multiselect']) { + // CDATA may be built with comma-list + list($value,) = explode(',', $value, 2); + } $choices = $this->getChoices(); if (isset($choices[$value])) $value = array($value => $choices[$value]); diff --git a/include/class.forms.php b/include/class.forms.php index 6e2ddffc84313ffc547ceb0387eff3c9d7c49a75..c80c34ba1567cea62f7cb38150e11b020ca39228 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -950,16 +950,22 @@ class ChoiceField extends FormField { else $array = $value; $config = $this->getConfiguration(); - if (is_array($array) && !$config['multiselect'] && count($array) < 2) { - reset($array); - return key($array); + if (!$config['multiselect']) { + if (is_array($array) && count($array) < 2) { + reset($array); + return key($array); + } + if (is_string($array) && strpos($array, ',') !== false) { + list($array,) = explode(',', $array, 2); + } } return $array; } function toString($value) { $selection = $this->getChoice($value); - return is_array($selection) ? implode(', ', array_filter($selection)) + return is_array($selection) + ? (implode(', ', array_filter($selection)) ?: $value) : (string) $selection; } diff --git a/include/client/tickets.inc.php b/include/client/tickets.inc.php index 2c1a04a97c208e2bdadc6281cca2ee0cd093e9c0..6b8e9df1af38ee40b56dcc831ad260c156d5e235 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.=' <span class="Icon file"></span>'; diff --git a/include/staff/tickets.inc.php b/include/staff/tickets.inc.php index f6c17982c7aa39e88027b0b3f46a0c171e045360..70acec9195642decac3530a7be2267fb00a176b2 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);