diff --git a/include/class.forms.php b/include/class.forms.php index 9ef27efb5e8385b313159ef4505edd625ffa14b0..db227a922e162abd06931d2aff6c0b6971fcc600 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -1794,6 +1794,8 @@ class ChoiceField extends FormField { $deleted = array_diff($B, $A); $added = array_map(array($this, 'display'), $added); $deleted = array_map(array($this, 'display'), $deleted); + $added = array_filter($added); + $deleted = array_filter($deleted); if ($added && $deleted) { $desc = sprintf( @@ -2734,23 +2736,52 @@ class DepartmentField extends ChoiceField { } function to_php($value, $id=false) { - if (is_array($id)) { - reset($id); - $id = key($id); + if ($id) { + if (is_array($id)) { + reset($id); + $id = key($id); + } + return $id; + } else { + return $value; } - return $id; } function to_database($dept) { - return ($dept instanceof Dept) - ? array($dept->getName(), $dept->getId()) - : $dept; + if ($dept instanceof Dept) + return array($dept->getName(), $dept->getId()); + + if (!is_array($dept)) { + $choices = $this->getChoices(); + if (isset($choices[$dept])) + $dept = array($choices[$dept], $dept); + } + if (!$dept) + $dept = array(); + + return $dept; } function toString($value) { + if (!is_array($value)) + $value = $this->getChoice($value); + if (is_array($value)) + return implode(', ', $value); return (string) $value; } + function getChoice($value) { + $choices = $this->getChoices(); + $selection = array(); + if ($value && is_array($value)) { + $selection = $value; + } elseif (isset($choices[$value])) { + $selection[] = $choices[$value]; + } + + return $selection; + } + function searchable($value) { return null; } diff --git a/include/staff/templates/queue-columns.tmpl.php b/include/staff/templates/queue-columns.tmpl.php index feaf7cd4ef6163d89d99289bd23b294c01515540..6088c925de0233116b5e39d457741dcb9d3ec9d6 100644 --- a/include/staff/templates/queue-columns.tmpl.php +++ b/include/staff/templates/queue-columns.tmpl.php @@ -58,7 +58,7 @@ $hidden_cols = $queue->inheritColumns() || $queue->useStandardColumns(); </div> <?php } else { ?> - <input type="text" style="border:none;background:transparent" data-name="name" /> + <input readonly type="text" style="border:none;background:transparent" data-name="name" /> <?php } ?> </td> <td> diff --git a/include/staff/ticket-edit.inc.php b/include/staff/ticket-edit.inc.php index f77e02b8715cf9ce690b56777163b743c39551f7..71d8871e65af1f9ff1b73959b0c0bb043a464c0b 100644 --- a/include/staff/ticket-edit.inc.php +++ b/include/staff/ticket-edit.inc.php @@ -94,8 +94,7 @@ if ($_POST) <option value="" selected >— <?php echo __('Select Help Topic');?> —</option> <?php if($topics=Topic::getHelpTopics()) { - if(!array_key_exists($ticket->topic_id, $topics)) - { + if($ticket->topic_id && !array_key_exists($ticket->topic_id, $topics)) { $topics[$ticket->topic_id] = $ticket->topic; $warn = sprintf(__('%s selected must be active'), __('Help Topic')); } diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php index 591442462ffc72772c684e119a35295506a93581..2606bb736fb852d5b66329257ecf6b70231c36af 100644 --- a/include/staff/ticket-open.inc.php +++ b/include/staff/ticket-open.inc.php @@ -9,11 +9,10 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); // Use thread entry to seed the ticket if (!$user && $_GET['tid'] && ($entry = ThreadEntry::lookup($_GET['tid']))) { + $_SESSION[':form-data']['message'] = Format::htmlchars($entry->getBody()); if ($entry->user_id) $user = User::lookup($entry->user_id); - else - $_SESSION[':form-data']['message'] = Format::htmlchars($entry->getBody()); if (($m= TicketForm::getInstance()->getField('message'))) { $k = 'attach:'.$m->getId(); foreach ($entry->getAttachments() as $a)