From 678b9cb3dd088d3206a48a50482e3683b6225ab1 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Mon, 31 Mar 2014 12:53:37 -0500
Subject: [PATCH] Fixup variables for custom list properties

---
 include/class.dynamic_forms.php | 15 +++++++++++++--
 include/class.ticket.php        |  2 +-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php
index 424e6ebb1..89e209ef5 100644
--- a/include/class.dynamic_forms.php
+++ b/include/class.dynamic_forms.php
@@ -765,7 +765,13 @@ class DynamicFormEntryAnswer extends VerySimpleModel {
     }
 
     function asVar() {
-        return $this->toString();
+        return (is_object($this->getValue()))
+            ? $this->getValue() : $this->toString();
+    }
+
+    function getVar($tag) {
+        if (is_object($this->getValue()) && method_exists($this->getValue(), 'getVar'))
+            return $this->getValue()->getVar($tag);
     }
 
     function __toString() {
@@ -938,8 +944,9 @@ class DynamicListItem extends VerySimpleModel {
 
     function getVar($name) {
         $config = $this->getConfiguration();
+        $name = mb_strtolower($name);
         foreach ($this->getConfigurationForm()->getFields() as $field) {
-            if (strcasecmp($field->get('name'), $name) === 0)
+            if (mb_strtolower($field->get('name')) == $name)
                 return $config[$field->get('id')];
         }
     }
@@ -948,6 +955,10 @@ class DynamicListItem extends VerySimpleModel {
         return $this->get('value');
     }
 
+    function __toString() {
+        return $this->toString();
+    }
+
     function delete() {
         # Don't really delete, just unset the list_id to un-associate it with
         # the list
diff --git a/include/class.ticket.php b/include/class.ticket.php
index a69109204..6580a8088 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -1278,7 +1278,7 @@ class Ticket {
                     // The answer object is retrieved here which will
                     // automatically invoke the toString() method when the
                     // answer is coerced into text
-                    return (string)$this->_answers[$tag];
+                    return $this->_answers[$tag];
         }
 
         return false;
-- 
GitLab