From 080ea576619717e8bf44bd8f9e44d20f356b2ec9 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Fri, 6 Jun 2014 16:37:33 -0500
Subject: [PATCH] forms: Fix corruption of company name on new ticket

New ticket by staff would cause the %{company.name} variable to be
incorrectly replaced as the user's name in email templates.
---
 include/class.company.php       |  2 +-
 include/class.dynamic_forms.php | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/class.company.php b/include/class.company.php
index c9aa22f04..049ecbb21 100644
--- a/include/class.company.php
+++ b/include/class.company.php
@@ -48,7 +48,7 @@ class Company {
     }
 
     function getInfo() {
-        return $this->getForm()->getClean();
+        return $this->getForm()->getSaved();
     }
 
     function getName() {
diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php
index b49cca3a1..751db130f 100644
--- a/include/class.dynamic_forms.php
+++ b/include/class.dynamic_forms.php
@@ -546,6 +546,16 @@ class DynamicFormEntry extends VerySimpleModel {
         return $this->_clean;
     }
 
+    function getSaved() {
+        $info = array();
+        foreach ($this->getAnswers() as $a) {
+            $field = $a->getField();
+            $info[$field->get('id')]
+                = $info[$field->get('name')] = $a->getValue();
+        }
+        return $info;
+    }
+
     function forTicket($ticket_id, $force=false) {
         static $entries = array();
         if (!isset($entries[$ticket_id]) || $force)
-- 
GitLab