From a21adaa6e97094077ae2ae5cef7c1c340612cec0 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Wed, 26 Feb 2014 14:49:12 -0600
Subject: [PATCH] upgrade: Fix nasty message in footer on 1.6

This happens when upgrading from 1.6, the company information does not yet
exist (neither do the form tables)

Properly escape company name for display
---
 include/class.company.php     | 6 +++++-
 include/client/footer.inc.php | 2 +-
 include/staff/footer.inc.php  | 2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/include/class.company.php b/include/class.company.php
index 2c8758259..c9aa22f04 100644
--- a/include/class.company.php
+++ b/include/class.company.php
@@ -60,7 +60,11 @@ class Company {
     }
 
     function __toString() {
-        return $this->getName();
+        try {
+            if ($name = $this->getForm()->getAnswer('name'))
+                return $name->display();
+        } catch (Exception $e) {}
+        return '';
     }
 
     /**
diff --git a/include/client/footer.inc.php b/include/client/footer.inc.php
index 0373eba69..e92c7a282 100644
--- a/include/client/footer.inc.php
+++ b/include/client/footer.inc.php
@@ -1,7 +1,7 @@
         </div>
     </div>
     <div id="footer">
-        <p>Copyright &copy; <?php echo date('Y'); ?> <?php echo $ost->company ?: 'osTicket.com'; ?> - All rights reserved.</p>
+        <p>Copyright &copy; <?php echo date('Y'); ?> <?php echo (string) $ost->company :? 'osTicket.com'; ?> - All rights reserved.</p>
         <a id="poweredBy" href="http://osticket.com" target="_blank">Helpdesk software - powered by osTicket</a>
     </div>
 <div id="overlay"></div>
diff --git a/include/staff/footer.inc.php b/include/staff/footer.inc.php
index a77bc0f4a..5cb94ea3d 100644
--- a/include/staff/footer.inc.php
+++ b/include/staff/footer.inc.php
@@ -1,6 +1,6 @@
     </div>
     <div id="footer">
-        Copyright &copy; 2006-<?php echo date('Y'); ?>&nbsp;<?php echo $ost->company ?: 'osTicket.com'; ?>&nbsp;All Rights Reserved.
+        Copyright &copy; 2006-<?php echo date('Y'); ?>&nbsp;<?php echo (string) $ost->company ?: 'osTicket.com'; ?>&nbsp;All Rights Reserved.
     </div>
 <?php
 if(is_object($thisstaff) && $thisstaff->isStaff()) { ?>
-- 
GitLab