From 1bdf9dca2780a55859b2e2ea5ce84876f9038064 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Mon, 14 Apr 2014 15:19:22 -0500
Subject: [PATCH] Accept subdomains in the organization domain box

Use .domain.tld to accept all subdomains of a parent
---
 include/class.organization.php | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/include/class.organization.php b/include/class.organization.php
index 334228955..e1e3f4435 100644
--- a/include/class.organization.php
+++ b/include/class.organization.php
@@ -159,7 +159,14 @@ class Organization extends OrganizationModel {
 
     function isMappedToDomain($domain) {
         foreach (explode(',', $this->domain) as $d) {
-            if (strcasecmp($domain, trim($d)) === 0) {
+            $d = trim($d);
+            if ($d[0] == '.') {
+                // Subdomain syntax (.osticket.com accepts all subdomains of
+                // osticket.com)
+                if (strcasecmp(mb_substr($domain, -mb_strlen($d)), $d) === 0)
+                    return true;
+            }
+            elseif (strcasecmp($domain, $d) === 0) {
                 return true;
             }
         }
-- 
GitLab