From d20e627652c0609f523fde893d207d87b5438c75 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Tue, 16 Dec 2014 14:40:28 -0600
Subject: [PATCH] orgs: Add support for organization variables

Allow usage of something like `%{ticket.user.organization.var}`
---
 include/class.organization.php | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/include/class.organization.php b/include/class.organization.php
index 785b6d36b..991952bd9 100644
--- a/include/class.organization.php
+++ b/include/class.organization.php
@@ -243,6 +243,20 @@ class Organization extends OrganizationModel {
         return (string) $this->getName();
     }
 
+    function asVar() {
+        return (string) $this->getName();
+    }
+
+    function getVar($tag) {
+        if($tag && is_callable(array($this, 'get'.ucfirst($tag))))
+            return call_user_func(array($this, 'get'.ucfirst($tag)));
+
+        $tag = mb_strtolower($tag);
+        foreach ($this->getDynamicData() as $e)
+            if ($a = $e->getAnswer($tag))
+                return $a;
+    }
+
     function update($vars, &$errors) {
 
         $valid = true;
-- 
GitLab