diff --git a/include/class.company.php b/include/class.company.php index 2c8758259197c15c5a817005a0346842566796a0..c9aa22f04af3889ea22b564f06ffdf2dff936a71 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/class.file.php b/include/class.file.php index 5d4c9443e42c3106cb0a01be8c50b0bb721f7296..e5a3db128fd69ba4c5b1fb8dc79492144fdb9c0d 100644 --- a/include/class.file.php +++ b/include/class.file.php @@ -343,6 +343,7 @@ class AttachmentFile { .',size='.db_input($file['size']) .',name='.db_input($file['name']) .',`key`='.db_input($file['key']) + .',ft='.db_input($ft ?: 'T') .',signature='.db_input($file['signature']); if (!(db_query($sql) && ($id = db_insert_id()))) @@ -377,15 +378,9 @@ class AttachmentFile { return false; } - # XXX: ft does not exists during the upgrade when attachments are - # migrated! Neither does `bk` - if ($ft) { - $sql = 'UPDATE '.FILE_TABLE.' SET bk=' - .db_input($bk->getBkChar()) - .', ft='.db_input($ft) - .' WHERE id='.db_input($f->getId()); - db_query($sql); - } + $sql = 'UPDATE '.FILE_TABLE.' SET bk='.db_input($bk->getBkChar()) + .' WHERE id='.db_input($f->getId()); + db_query($sql); return $f->getId(); } diff --git a/include/client/footer.inc.php b/include/client/footer.inc.php index 0373eba69622e91483c7675a50344873c2ec1639..e92c7a28269a042a42db6d1dca6dce5a518b4b49 100644 --- a/include/client/footer.inc.php +++ b/include/client/footer.inc.php @@ -1,7 +1,7 @@ </div> </div> <div id="footer"> - <p>Copyright © <?php echo date('Y'); ?> <?php echo $ost->company ?: 'osTicket.com'; ?> - All rights reserved.</p> + <p>Copyright © <?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 a77bc0f4a1b2311ccfa8520ea7dbde9eaaada839..5cb94ea3d817be39355871fb783369dedd009cb9 100644 --- a/include/staff/footer.inc.php +++ b/include/staff/footer.inc.php @@ -1,6 +1,6 @@ </div> <div id="footer"> - Copyright © 2006-<?php echo date('Y'); ?> <?php echo $ost->company ?: 'osTicket.com'; ?> All Rights Reserved. + Copyright © 2006-<?php echo date('Y'); ?> <?php echo (string) $ost->company ?: 'osTicket.com'; ?> All Rights Reserved. </div> <?php if(is_object($thisstaff) && $thisstaff->isStaff()) { ?> diff --git a/include/upgrader/streams/core/15b30765-dd0022fb.task.php b/include/upgrader/streams/core/15b30765-dd0022fb.task.php index a4f39fb785021a4abf4e581f9510ecd8688d9e19..4d7eac01ff94a7622a16b118b5c567d41d3a9af0 100644 --- a/include/upgrader/streams/core/15b30765-dd0022fb.task.php +++ b/include/upgrader/streams/core/15b30765-dd0022fb.task.php @@ -108,7 +108,7 @@ class AttachmentMigrater extends MigrationTask { } # TODO: Add extension-based mime-type lookup - if (!($fileId = AttachmentFile::save($info, false))) { + if (!($fileId = $this->saveAttachment($info))) { return $this->skip($info['attachId'], sprintf('%s: Unable to migrate attachment', $info['path'])); } @@ -227,6 +227,47 @@ class AttachmentMigrater extends MigrationTask { function getErrors() { return $this->errorList; } + + // This is the AttachmentFile::save() method from osTicket 1.7.6. It's + // been ported here so that further changes to the %file table and the + // AttachmentFile::save() method do not affect upgrades from osTicket + // 1.6 to osTicket 1.8 and beyond. + function saveAttachment($file) { + + if(!$file['hash']) + $file['hash']=MD5(md5_file($file['path']).time()); + $file['data'] = file_get_contents($file['path']); + if(!$file['size']) + $file['size']=strlen($file['data']); + + $sql='INSERT INTO '.FILE_TABLE.' SET created=NOW() ' + .',type='.db_input($file['type']) + .',size='.db_input($file['size']) + .',name='.db_input($file['name']) + .',hash='.db_input($file['hash']); + + if (!(db_query($sql) && ($id=db_insert_id()))) + return false; + + $f = new CompatAttachmentFile($id); + $bk = new AttachmentChunkedData($f); + if (!$bk->write($file['data'])) + return false; + + return $id; + } +} + +class CompatAttachmentFile { + var $id; + + function __construct($id) { + $this->id = $id; + } + + function getId() { + return $this->id; + } } return 'AttachmentMigrater';