From 016a50878df484f5666b21d4573a67dc3aa4105b Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Mon, 11 Sep 2017 21:03:03 -0400 Subject: [PATCH] Add a BaseClass/BaseException for 5.4 compatibility --- api/BaseClass.php | 7 +++ api/BaseException.php | 7 +++ api/BusinessLogic/Attachments/Attachment.php | 2 +- .../Attachments/AttachmentHandler.php | 2 +- .../Attachments/AttachmentRetriever.php | 2 +- .../Attachments/AttachmentType.php | 2 +- .../Attachments/CreateAttachmentModel.php | 2 +- api/BusinessLogic/Categories/Category.php | 2 +- .../Categories/CategoryHandler.php | 2 +- .../Categories/CategoryRetriever.php | 2 +- api/BusinessLogic/Emails/Addressees.php | 2 +- api/BusinessLogic/Emails/BasicEmailSender.php | 2 +- api/BusinessLogic/Emails/EmailBuilder.php | 2 +- .../Emails/EmailSenderHelper.php | 2 +- api/BusinessLogic/Emails/EmailTemplate.php | 2 +- .../Emails/EmailTemplateParser.php | 2 +- .../Emails/EmailTemplateRetriever.php | 2 +- .../Emails/MailgunEmailSender.php | 2 +- .../Emails/ParsedEmailProperties.php | 2 +- .../Exceptions/ApiFriendlyException.php | 2 +- api/BusinessLogic/Helpers.php | 2 +- .../Navigation/CustomNavElement.php | 2 +- .../Navigation/CustomNavElementHandler.php | 2 +- .../Navigation/CustomNavElementPlace.php | 2 +- api/BusinessLogic/Navigation/Direction.php | 2 +- api/BusinessLogic/Security/BanRetriever.php | 2 +- api/BusinessLogic/Security/BannedEmail.php | 2 +- api/BusinessLogic/Security/BannedIp.php | 2 +- .../Security/PermissionChecker.php | 2 +- api/BusinessLogic/Security/UserContext.php | 2 +- .../Security/UserContextBuilder.php | 2 +- .../Security/UserContextNotifications.php | 2 +- .../Security/UserContextPreferences.php | 2 +- api/BusinessLogic/Security/UserPrivilege.php | 2 +- .../Security/UserToTicketChecker.php | 2 +- api/BusinessLogic/Settings/ApiChecker.php | 2 +- .../Settings/SettingsRetriever.php | 2 +- api/BusinessLogic/Statuses/Closable.php | 2 +- .../Statuses/DefaultStatusForAction.php | 2 +- api/BusinessLogic/Statuses/Status.php | 2 +- .../Statuses/StatusRetriever.php | 2 +- api/BusinessLogic/Tickets/Attachment.php | 2 +- api/BusinessLogic/Tickets/Autoassigner.php | 2 +- .../Tickets/CreateTicketByCustomerModel.php | 2 +- .../Tickets/CreatedTicketModel.php | 2 +- .../CustomFields/CustomFieldValidator.php | 2 +- api/BusinessLogic/Tickets/EditTicketModel.php | 2 +- .../UnableToGenerateTrackingIdException.php | 4 +- .../Tickets/NewTicketValidator.php | 2 +- api/BusinessLogic/Tickets/Reply.php | 2 +- api/BusinessLogic/Tickets/Ticket.php | 2 +- api/BusinessLogic/Tickets/TicketCreator.php | 2 +- api/BusinessLogic/Tickets/TicketDeleter.php | 2 +- api/BusinessLogic/Tickets/TicketEditor.php | 2 +- .../Tickets/TicketGatewayGeneratedFields.php | 2 +- api/BusinessLogic/Tickets/TicketRetriever.php | 2 +- .../Tickets/TicketValidators.php | 2 +- .../Tickets/TrackingIdGenerator.php | 2 +- .../Tickets/VerifiedEmailChecker.php | 2 +- api/BusinessLogic/ValidationModel.php | 2 +- api/BusinessLogic/Validators.php | 2 +- .../PublicAttachmentController.php | 2 +- .../StaffTicketAttachmentsController.php | 2 +- .../Categories/CategoryController.php | 2 +- api/Controllers/InternalApiController.php | 2 +- api/Controllers/JsonRetriever.php | 2 +- .../Settings/SettingsController.php | 2 +- api/Controllers/Statuses/StatusController.php | 2 +- .../System/HeskVersionController.php | 2 +- .../Tickets/CustomerTicketController.php | 2 +- .../Tickets/StaffTicketController.php | 2 +- api/Core/Constants/CustomField.php | 2 +- api/Core/Constants/Priority.php | 2 +- api/Core/Exceptions/SQLException.php | 4 +- api/DataAccess/CommonDao.php | 2 +- api/DataAccess/Files/FileDeleter.php | 4 +- api/DataAccess/Files/FileReader.php | 2 +- api/DataAccess/Files/FileWriter.php | 2 +- api/DataAccess/Logging/Severity.php | 2 +- api/Link.php | 2 +- api/index.php | 46 +++++++++---------- 81 files changed, 115 insertions(+), 107 deletions(-) create mode 100644 api/BaseClass.php create mode 100644 api/BaseException.php diff --git a/api/BaseClass.php b/api/BaseClass.php new file mode 100644 index 00000000..51ca30ae --- /dev/null +++ b/api/BaseClass.php @@ -0,0 +1,7 @@ +subject = $subject; $this->message = $message; diff --git a/api/BusinessLogic/Exceptions/ApiFriendlyException.php b/api/BusinessLogic/Exceptions/ApiFriendlyException.php index f9fac53b..b9db70e8 100644 --- a/api/BusinessLogic/Exceptions/ApiFriendlyException.php +++ b/api/BusinessLogic/Exceptions/ApiFriendlyException.php @@ -5,7 +5,7 @@ namespace BusinessLogic\Exceptions; use Exception; -class ApiFriendlyException extends Exception { +class ApiFriendlyException extends \BaseException { public $title; public $httpResponseCode; diff --git a/api/BusinessLogic/Helpers.php b/api/BusinessLogic/Helpers.php index 61f6af2d..5a36c723 100644 --- a/api/BusinessLogic/Helpers.php +++ b/api/BusinessLogic/Helpers.php @@ -3,7 +3,7 @@ namespace BusinessLogic; -class Helpers { +class Helpers extends \BaseClass { static function getHeader($key) { $headers = getallheaders(); diff --git a/api/BusinessLogic/Navigation/CustomNavElement.php b/api/BusinessLogic/Navigation/CustomNavElement.php index 74b4ca1a..dfaf43f2 100644 --- a/api/BusinessLogic/Navigation/CustomNavElement.php +++ b/api/BusinessLogic/Navigation/CustomNavElement.php @@ -3,7 +3,7 @@ namespace BusinessLogic\Navigation; -class CustomNavElement { +class CustomNavElement extends \BaseClass { /* @var $id int*/ public $id; diff --git a/api/BusinessLogic/Navigation/CustomNavElementHandler.php b/api/BusinessLogic/Navigation/CustomNavElementHandler.php index 8f5ac644..85fba023 100644 --- a/api/BusinessLogic/Navigation/CustomNavElementHandler.php +++ b/api/BusinessLogic/Navigation/CustomNavElementHandler.php @@ -6,7 +6,7 @@ namespace BusinessLogic\Navigation; use BusinessLogic\Exceptions\ApiFriendlyException; use DataAccess\Navigation\CustomNavElementGateway; -class CustomNavElementHandler { +class CustomNavElementHandler extends \BaseClass { /* @var $customNavElementGateway CustomNavElementGateway */ private $customNavElementGateway; diff --git a/api/BusinessLogic/Navigation/CustomNavElementPlace.php b/api/BusinessLogic/Navigation/CustomNavElementPlace.php index 3114fdc7..2a2984b9 100644 --- a/api/BusinessLogic/Navigation/CustomNavElementPlace.php +++ b/api/BusinessLogic/Navigation/CustomNavElementPlace.php @@ -3,7 +3,7 @@ namespace BusinessLogic\Navigation; -class CustomNavElementPlace { +class CustomNavElementPlace extends \BaseClass { const HOMEPAGE_BLOCK = 1; const CUSTOMER_NAVIGATION = 2; const ADMIN_NAVIGATION = 3; diff --git a/api/BusinessLogic/Navigation/Direction.php b/api/BusinessLogic/Navigation/Direction.php index f14a00cf..390b9915 100644 --- a/api/BusinessLogic/Navigation/Direction.php +++ b/api/BusinessLogic/Navigation/Direction.php @@ -3,7 +3,7 @@ namespace BusinessLogic\Navigation; -class Direction { +class Direction extends \BaseClass { const UP = 'up'; const DOWN = 'down'; } \ No newline at end of file diff --git a/api/BusinessLogic/Security/BanRetriever.php b/api/BusinessLogic/Security/BanRetriever.php index 66213cf5..4d1676fe 100644 --- a/api/BusinessLogic/Security/BanRetriever.php +++ b/api/BusinessLogic/Security/BanRetriever.php @@ -5,7 +5,7 @@ namespace BusinessLogic\Security; use DataAccess\Security\BanGateway; -class BanRetriever { +class BanRetriever extends \BaseClass { /** * @var BanGateway */ diff --git a/api/BusinessLogic/Security/BannedEmail.php b/api/BusinessLogic/Security/BannedEmail.php index 691a6604..9cd4a408 100644 --- a/api/BusinessLogic/Security/BannedEmail.php +++ b/api/BusinessLogic/Security/BannedEmail.php @@ -3,7 +3,7 @@ namespace BusinessLogic\Security; -class BannedEmail { +class BannedEmail extends \BaseClass { /** * @var int */ diff --git a/api/BusinessLogic/Security/BannedIp.php b/api/BusinessLogic/Security/BannedIp.php index e34b2516..f2c8572b 100644 --- a/api/BusinessLogic/Security/BannedIp.php +++ b/api/BusinessLogic/Security/BannedIp.php @@ -3,7 +3,7 @@ namespace BusinessLogic\Security; -class BannedIp { +class BannedIp extends \BaseClass { /** * @var int */ diff --git a/api/BusinessLogic/Security/PermissionChecker.php b/api/BusinessLogic/Security/PermissionChecker.php index cf2b1a43..de47465f 100644 --- a/api/BusinessLogic/Security/PermissionChecker.php +++ b/api/BusinessLogic/Security/PermissionChecker.php @@ -3,7 +3,7 @@ namespace BusinessLogic\Security; -class PermissionChecker { +class PermissionChecker extends \BaseClass { /** * @param $userContext UserContext * @param $permission string diff --git a/api/BusinessLogic/Security/UserContext.php b/api/BusinessLogic/Security/UserContext.php index 0beedc07..ee1522a9 100644 --- a/api/BusinessLogic/Security/UserContext.php +++ b/api/BusinessLogic/Security/UserContext.php @@ -3,7 +3,7 @@ namespace BusinessLogic\Security; -class UserContext { +class UserContext extends \BaseClass { /* @var $id int */ public $id; diff --git a/api/BusinessLogic/Security/UserContextBuilder.php b/api/BusinessLogic/Security/UserContextBuilder.php index 7bb975ee..a236f4be 100644 --- a/api/BusinessLogic/Security/UserContextBuilder.php +++ b/api/BusinessLogic/Security/UserContextBuilder.php @@ -8,7 +8,7 @@ use BusinessLogic\Exceptions\MissingAuthenticationTokenException; use BusinessLogic\Helpers; use DataAccess\Security\UserGateway; -class UserContextBuilder { +class UserContextBuilder extends \BaseClass { /** * @var UserGateway */ diff --git a/api/BusinessLogic/Security/UserContextNotifications.php b/api/BusinessLogic/Security/UserContextNotifications.php index 9c32547c..c75742f4 100644 --- a/api/BusinessLogic/Security/UserContextNotifications.php +++ b/api/BusinessLogic/Security/UserContextNotifications.php @@ -3,7 +3,7 @@ namespace BusinessLogic\Security; -class UserContextNotifications { +class UserContextNotifications extends \BaseClass { public $newUnassigned; public $newAssignedToMe; public $replyUnassigned; diff --git a/api/BusinessLogic/Security/UserContextPreferences.php b/api/BusinessLogic/Security/UserContextPreferences.php index f860d3ec..b342070c 100644 --- a/api/BusinessLogic/Security/UserContextPreferences.php +++ b/api/BusinessLogic/Security/UserContextPreferences.php @@ -3,7 +3,7 @@ namespace BusinessLogic\Security; -class UserContextPreferences { +class UserContextPreferences extends \BaseClass { public $afterReply; public $autoStartTimeWorked; public $autoreload; diff --git a/api/BusinessLogic/Security/UserPrivilege.php b/api/BusinessLogic/Security/UserPrivilege.php index 1e90ff70..353e8e43 100644 --- a/api/BusinessLogic/Security/UserPrivilege.php +++ b/api/BusinessLogic/Security/UserPrivilege.php @@ -9,7 +9,7 @@ namespace BusinessLogic\Security; -class UserPrivilege { +class UserPrivilege extends \BaseClass { const CAN_VIEW_TICKETS = 'can_view_tickets'; const CAN_REPLY_TO_TICKETS = 'can_reply_tickets'; const CAN_EDIT_TICKETS = 'can_edit_tickets'; diff --git a/api/BusinessLogic/Security/UserToTicketChecker.php b/api/BusinessLogic/Security/UserToTicketChecker.php index 0f21d785..13d88226 100644 --- a/api/BusinessLogic/Security/UserToTicketChecker.php +++ b/api/BusinessLogic/Security/UserToTicketChecker.php @@ -6,7 +6,7 @@ namespace BusinessLogic\Security; use BusinessLogic\Tickets\Ticket; use DataAccess\Security\UserGateway; -class UserToTicketChecker { +class UserToTicketChecker extends \BaseClass { /* @var $userGateway UserGateway */ private $userGateway; diff --git a/api/BusinessLogic/Settings/ApiChecker.php b/api/BusinessLogic/Settings/ApiChecker.php index 8645dd5c..da1a3d11 100644 --- a/api/BusinessLogic/Settings/ApiChecker.php +++ b/api/BusinessLogic/Settings/ApiChecker.php @@ -5,7 +5,7 @@ namespace BusinessLogic\Settings; use DataAccess\Settings\ModsForHeskSettingsGateway; -class ApiChecker { +class ApiChecker extends \BaseClass { /* @var $modsForHeskSettingsGateway ModsForHeskSettingsGateway */ private $modsForHeskSettingsGateway; diff --git a/api/BusinessLogic/Settings/SettingsRetriever.php b/api/BusinessLogic/Settings/SettingsRetriever.php index 21eeb13a..a18ce15a 100644 --- a/api/BusinessLogic/Settings/SettingsRetriever.php +++ b/api/BusinessLogic/Settings/SettingsRetriever.php @@ -5,7 +5,7 @@ namespace BusinessLogic\Settings; // TODO Test! use DataAccess\Settings\ModsForHeskSettingsGateway; -class SettingsRetriever { +class SettingsRetriever extends \BaseClass { /* @var $modsForHeskSettingsGateway ModsForHeskSettingsGateway */ private $modsForHeskSettingsGateway; diff --git a/api/BusinessLogic/Statuses/Closable.php b/api/BusinessLogic/Statuses/Closable.php index 9d87efca..2dd68c03 100644 --- a/api/BusinessLogic/Statuses/Closable.php +++ b/api/BusinessLogic/Statuses/Closable.php @@ -3,7 +3,7 @@ namespace BusinessLogic\Statuses; -class Closable { +class Closable extends \BaseClass { const YES = "yes"; const STAFF_ONLY = "sonly"; const CUSTOMERS_ONLY = "conly"; diff --git a/api/BusinessLogic/Statuses/DefaultStatusForAction.php b/api/BusinessLogic/Statuses/DefaultStatusForAction.php index bfafff7c..a6ce7ac6 100644 --- a/api/BusinessLogic/Statuses/DefaultStatusForAction.php +++ b/api/BusinessLogic/Statuses/DefaultStatusForAction.php @@ -3,7 +3,7 @@ namespace BusinessLogic\Statuses; -class DefaultStatusForAction { +class DefaultStatusForAction extends \BaseClass { const NEW_TICKET = "IsNewTicketStatus"; const CLOSED_STATUS = "IsClosed"; const CLOSED_BY_CLIENT = "IsClosedByClient"; diff --git a/api/BusinessLogic/Statuses/Status.php b/api/BusinessLogic/Statuses/Status.php index c5ef3242..fc5babd4 100644 --- a/api/BusinessLogic/Statuses/Status.php +++ b/api/BusinessLogic/Statuses/Status.php @@ -3,7 +3,7 @@ namespace BusinessLogic\Statuses; -class Status { +class Status extends \BaseClass { static function fromDatabase($row, $languageRs) { $status = new Status(); $status->id = intval($row['ID']); diff --git a/api/BusinessLogic/Statuses/StatusRetriever.php b/api/BusinessLogic/Statuses/StatusRetriever.php index 181ceae1..a16d0ca7 100644 --- a/api/BusinessLogic/Statuses/StatusRetriever.php +++ b/api/BusinessLogic/Statuses/StatusRetriever.php @@ -6,7 +6,7 @@ namespace BusinessLogic\Statuses; use DataAccess\Statuses\StatusGateway; // TODO Test! -class StatusRetriever { +class StatusRetriever extends \BaseClass { /* @var $statusGateway StatusGateway */ private $statusGateway; diff --git a/api/BusinessLogic/Tickets/Attachment.php b/api/BusinessLogic/Tickets/Attachment.php index 295864bc..e665f69b 100644 --- a/api/BusinessLogic/Tickets/Attachment.php +++ b/api/BusinessLogic/Tickets/Attachment.php @@ -3,7 +3,7 @@ namespace BusinessLogic\Tickets; -class Attachment { +class Attachment extends \BaseClass { /** * @var int */ diff --git a/api/BusinessLogic/Tickets/Autoassigner.php b/api/BusinessLogic/Tickets/Autoassigner.php index e4095815..fd9797b9 100644 --- a/api/BusinessLogic/Tickets/Autoassigner.php +++ b/api/BusinessLogic/Tickets/Autoassigner.php @@ -8,7 +8,7 @@ use BusinessLogic\Security\UserPrivilege; use DataAccess\Categories\CategoryGateway; use DataAccess\Security\UserGateway; -class Autoassigner { +class Autoassigner extends \BaseClass { /* @var $categoryGateway CategoryGateway */ private $categoryGateway; diff --git a/api/BusinessLogic/Tickets/CreateTicketByCustomerModel.php b/api/BusinessLogic/Tickets/CreateTicketByCustomerModel.php index 7163e6b8..d5fa6126 100644 --- a/api/BusinessLogic/Tickets/CreateTicketByCustomerModel.php +++ b/api/BusinessLogic/Tickets/CreateTicketByCustomerModel.php @@ -2,7 +2,7 @@ namespace BusinessLogic\Tickets; -class CreateTicketByCustomerModel { +class CreateTicketByCustomerModel extends \BaseClass { /** * @var string */ diff --git a/api/BusinessLogic/Tickets/CreatedTicketModel.php b/api/BusinessLogic/Tickets/CreatedTicketModel.php index daeee757..a45385e9 100644 --- a/api/BusinessLogic/Tickets/CreatedTicketModel.php +++ b/api/BusinessLogic/Tickets/CreatedTicketModel.php @@ -3,7 +3,7 @@ namespace BusinessLogic\Tickets; -class CreatedTicketModel { +class CreatedTicketModel extends \BaseClass { /* @var $ticket Ticket */ public $ticket; diff --git a/api/BusinessLogic/Tickets/CustomFields/CustomFieldValidator.php b/api/BusinessLogic/Tickets/CustomFields/CustomFieldValidator.php index 12e1ccc7..dee499b9 100644 --- a/api/BusinessLogic/Tickets/CustomFields/CustomFieldValidator.php +++ b/api/BusinessLogic/Tickets/CustomFields/CustomFieldValidator.php @@ -3,7 +3,7 @@ namespace BusinessLogic\Tickets\CustomFields; -class CustomFieldValidator { +class CustomFieldValidator extends \BaseClass { static function isCustomFieldInCategory($customFieldId, $categoryId, $staff, $heskSettings) { $customField = $heskSettings['custom_fields']["custom{$customFieldId}"]; diff --git a/api/BusinessLogic/Tickets/EditTicketModel.php b/api/BusinessLogic/Tickets/EditTicketModel.php index 21e95ef1..b1b0fdd2 100644 --- a/api/BusinessLogic/Tickets/EditTicketModel.php +++ b/api/BusinessLogic/Tickets/EditTicketModel.php @@ -3,7 +3,7 @@ namespace BusinessLogic\Tickets; -class EditTicketModel { +class EditTicketModel extends \BaseClass { /* @var $id int */ public $id; diff --git a/api/BusinessLogic/Tickets/Exceptions/UnableToGenerateTrackingIdException.php b/api/BusinessLogic/Tickets/Exceptions/UnableToGenerateTrackingIdException.php index 0d2718a8..65e041d2 100644 --- a/api/BusinessLogic/Tickets/Exceptions/UnableToGenerateTrackingIdException.php +++ b/api/BusinessLogic/Tickets/Exceptions/UnableToGenerateTrackingIdException.php @@ -3,9 +3,7 @@ namespace BusinessLogic\Tickets\Exceptions; -use Exception; - -class UnableToGenerateTrackingIdException extends Exception { +class UnableToGenerateTrackingIdException extends \BaseException { public function __construct() { parent::__construct("Error generating a unique ticket ID."); } diff --git a/api/BusinessLogic/Tickets/NewTicketValidator.php b/api/BusinessLogic/Tickets/NewTicketValidator.php index 7697f860..8f1c10d6 100644 --- a/api/BusinessLogic/Tickets/NewTicketValidator.php +++ b/api/BusinessLogic/Tickets/NewTicketValidator.php @@ -10,7 +10,7 @@ use BusinessLogic\ValidationModel; use BusinessLogic\Validators; use Core\Constants\CustomField; -class NewTicketValidator { +class NewTicketValidator extends \BaseClass { /** * @var $categoryRetriever CategoryRetriever */ diff --git a/api/BusinessLogic/Tickets/Reply.php b/api/BusinessLogic/Tickets/Reply.php index 77c1d4b9..3c623f2c 100644 --- a/api/BusinessLogic/Tickets/Reply.php +++ b/api/BusinessLogic/Tickets/Reply.php @@ -9,7 +9,7 @@ namespace BusinessLogic\Tickets; -class Reply { +class Reply extends \BaseClass { /** * @var $id int */ diff --git a/api/BusinessLogic/Tickets/Ticket.php b/api/BusinessLogic/Tickets/Ticket.php index 42eda13c..0b7c56cf 100644 --- a/api/BusinessLogic/Tickets/Ticket.php +++ b/api/BusinessLogic/Tickets/Ticket.php @@ -3,7 +3,7 @@ namespace BusinessLogic\Tickets; -class Ticket { +class Ticket extends \BaseClass { static function fromDatabaseRow($row, $linkedTicketsRs, $repliesRs, $heskSettings) { $ticket = new Ticket(); $ticket->id = intval($row['id']); diff --git a/api/BusinessLogic/Tickets/TicketCreator.php b/api/BusinessLogic/Tickets/TicketCreator.php index d9e8c346..7f677c50 100644 --- a/api/BusinessLogic/Tickets/TicketCreator.php +++ b/api/BusinessLogic/Tickets/TicketCreator.php @@ -12,7 +12,7 @@ use DataAccess\Settings\ModsForHeskSettingsGateway; use DataAccess\Statuses\StatusGateway; use DataAccess\Tickets\TicketGateway; -class TicketCreator { +class TicketCreator extends \BaseClass { /** * @var $newTicketValidator NewTicketValidator */ diff --git a/api/BusinessLogic/Tickets/TicketDeleter.php b/api/BusinessLogic/Tickets/TicketDeleter.php index 7d1fa4d9..bbc22c2a 100644 --- a/api/BusinessLogic/Tickets/TicketDeleter.php +++ b/api/BusinessLogic/Tickets/TicketDeleter.php @@ -10,7 +10,7 @@ use BusinessLogic\Security\UserPrivilege; use BusinessLogic\Security\UserToTicketChecker; use DataAccess\Tickets\TicketGateway; -class TicketDeleter { +class TicketDeleter extends \BaseClass { /* @var $ticketGateway TicketGateway */ private $ticketGateway; diff --git a/api/BusinessLogic/Tickets/TicketEditor.php b/api/BusinessLogic/Tickets/TicketEditor.php index ac0bca61..e15b33d9 100644 --- a/api/BusinessLogic/Tickets/TicketEditor.php +++ b/api/BusinessLogic/Tickets/TicketEditor.php @@ -15,7 +15,7 @@ use BusinessLogic\Validators; use Core\Constants\CustomField; use DataAccess\Tickets\TicketGateway; -class TicketEditor { +class TicketEditor extends \BaseClass { /* @var $ticketGateway TicketGateway */ private $ticketGateway; diff --git a/api/BusinessLogic/Tickets/TicketGatewayGeneratedFields.php b/api/BusinessLogic/Tickets/TicketGatewayGeneratedFields.php index 56c2a8b3..602321f8 100644 --- a/api/BusinessLogic/Tickets/TicketGatewayGeneratedFields.php +++ b/api/BusinessLogic/Tickets/TicketGatewayGeneratedFields.php @@ -3,7 +3,7 @@ namespace BusinessLogic\Tickets; -class TicketGatewayGeneratedFields { +class TicketGatewayGeneratedFields extends \BaseClass { public $id; public $dateCreated; public $dateModified; diff --git a/api/BusinessLogic/Tickets/TicketRetriever.php b/api/BusinessLogic/Tickets/TicketRetriever.php index 569210ef..ec71329d 100644 --- a/api/BusinessLogic/Tickets/TicketRetriever.php +++ b/api/BusinessLogic/Tickets/TicketRetriever.php @@ -10,7 +10,7 @@ use BusinessLogic\Security\UserToTicketChecker; use BusinessLogic\ValidationModel; use DataAccess\Tickets\TicketGateway; -class TicketRetriever { +class TicketRetriever extends \BaseClass { /** * @var $ticketGateway TicketGateway */ diff --git a/api/BusinessLogic/Tickets/TicketValidators.php b/api/BusinessLogic/Tickets/TicketValidators.php index ff310757..ce9d9582 100644 --- a/api/BusinessLogic/Tickets/TicketValidators.php +++ b/api/BusinessLogic/Tickets/TicketValidators.php @@ -4,7 +4,7 @@ namespace BusinessLogic\Tickets; use DataAccess\Tickets\TicketGateway; -class TicketValidators { +class TicketValidators extends \BaseClass { /** * @var $ticketGateway TicketGateway */ diff --git a/api/BusinessLogic/Tickets/TrackingIdGenerator.php b/api/BusinessLogic/Tickets/TrackingIdGenerator.php index 892953e5..c397c7c2 100644 --- a/api/BusinessLogic/Tickets/TrackingIdGenerator.php +++ b/api/BusinessLogic/Tickets/TrackingIdGenerator.php @@ -6,7 +6,7 @@ namespace BusinessLogic\Tickets; use BusinessLogic\Tickets\Exceptions\UnableToGenerateTrackingIdException; use DataAccess\Tickets\TicketGateway; -class TrackingIdGenerator { +class TrackingIdGenerator extends \BaseClass { /** * @var $ticketGateway TicketGateway */ diff --git a/api/BusinessLogic/Tickets/VerifiedEmailChecker.php b/api/BusinessLogic/Tickets/VerifiedEmailChecker.php index 3846fbc3..5770b9c1 100644 --- a/api/BusinessLogic/Tickets/VerifiedEmailChecker.php +++ b/api/BusinessLogic/Tickets/VerifiedEmailChecker.php @@ -11,7 +11,7 @@ namespace BusinessLogic\Tickets; use DataAccess\Tickets\VerifiedEmailGateway; -class VerifiedEmailChecker { +class VerifiedEmailChecker extends \BaseClass { /** * @var $verifiedEmailGateway VerifiedEmailGateway */ diff --git a/api/BusinessLogic/ValidationModel.php b/api/BusinessLogic/ValidationModel.php index b3e085cd..0ca28eaf 100644 --- a/api/BusinessLogic/ValidationModel.php +++ b/api/BusinessLogic/ValidationModel.php @@ -2,7 +2,7 @@ namespace BusinessLogic; -class ValidationModel { +class ValidationModel extends \BaseClass { /** * @var array */ diff --git a/api/BusinessLogic/Validators.php b/api/BusinessLogic/Validators.php index a718dfd4..e0303434 100644 --- a/api/BusinessLogic/Validators.php +++ b/api/BusinessLogic/Validators.php @@ -3,7 +3,7 @@ namespace BusinessLogic; -class Validators { +class Validators extends \BaseClass { /** * @param string $address - the email address * @param array $multiple_emails - true if HESK (or custom field) supports multiple emails diff --git a/api/Controllers/Attachments/PublicAttachmentController.php b/api/Controllers/Attachments/PublicAttachmentController.php index c12325a5..da489d42 100644 --- a/api/Controllers/Attachments/PublicAttachmentController.php +++ b/api/Controllers/Attachments/PublicAttachmentController.php @@ -7,7 +7,7 @@ use BusinessLogic\Attachments\Attachment; use BusinessLogic\Attachments\AttachmentRetriever; use BusinessLogic\Exceptions\ApiFriendlyException; -class PublicAttachmentController { +class PublicAttachmentController extends \BaseClass { static function getRaw($trackingId, $attachmentId) { global $hesk_settings, $applicationContext, $userContext; diff --git a/api/Controllers/Attachments/StaffTicketAttachmentsController.php b/api/Controllers/Attachments/StaffTicketAttachmentsController.php index 7f6a09c0..c97b0d1f 100644 --- a/api/Controllers/Attachments/StaffTicketAttachmentsController.php +++ b/api/Controllers/Attachments/StaffTicketAttachmentsController.php @@ -11,7 +11,7 @@ use BusinessLogic\Helpers; use BusinessLogic\Security\UserToTicketChecker; use Controllers\JsonRetriever; -class StaffTicketAttachmentsController { +class StaffTicketAttachmentsController extends \BaseClass { function get($ticketId, $attachmentId) { global $hesk_settings, $applicationContext, $userContext; diff --git a/api/Controllers/Categories/CategoryController.php b/api/Controllers/Categories/CategoryController.php index 0ef2bf75..a9943bcd 100644 --- a/api/Controllers/Categories/CategoryController.php +++ b/api/Controllers/Categories/CategoryController.php @@ -9,7 +9,7 @@ use BusinessLogic\Exceptions\ApiFriendlyException; use BusinessLogic\Helpers; use Controllers\JsonRetriever; -class CategoryController { +class CategoryController extends \BaseClass { function get($id) { $categories = self::getAllCategories(); diff --git a/api/Controllers/InternalApiController.php b/api/Controllers/InternalApiController.php index c629e136..dd7286fe 100644 --- a/api/Controllers/InternalApiController.php +++ b/api/Controllers/InternalApiController.php @@ -6,7 +6,7 @@ namespace Controllers; use BusinessLogic\Exceptions\InternalUseOnlyException; use BusinessLogic\Helpers; -abstract class InternalApiController { +abstract class InternalApiController extends \BaseClass { static function staticCheckForInternalUseOnly() { $tokenHeader = Helpers::getHeader('X-AUTH-TOKEN'); if ($tokenHeader !== null && trim($tokenHeader) !== '') { diff --git a/api/Controllers/JsonRetriever.php b/api/Controllers/JsonRetriever.php index 6b0810d3..fef06694 100644 --- a/api/Controllers/JsonRetriever.php +++ b/api/Controllers/JsonRetriever.php @@ -3,7 +3,7 @@ namespace Controllers; -class JsonRetriever { +class JsonRetriever extends \BaseClass { /** * Support POST, PUT, and PATCH request (and possibly more) * diff --git a/api/Controllers/Settings/SettingsController.php b/api/Controllers/Settings/SettingsController.php index 4e66016a..6737052f 100644 --- a/api/Controllers/Settings/SettingsController.php +++ b/api/Controllers/Settings/SettingsController.php @@ -5,7 +5,7 @@ namespace Controllers\Settings; use BusinessLogic\Settings\SettingsRetriever; -class SettingsController { +class SettingsController extends \BaseClass { function get() { global $applicationContext, $hesk_settings; diff --git a/api/Controllers/Statuses/StatusController.php b/api/Controllers/Statuses/StatusController.php index 536c6b60..16473ae3 100644 --- a/api/Controllers/Statuses/StatusController.php +++ b/api/Controllers/Statuses/StatusController.php @@ -5,7 +5,7 @@ namespace Controllers\Statuses; use BusinessLogic\Statuses\StatusRetriever; -class StatusController { +class StatusController extends \BaseClass { function get() { global $applicationContext, $hesk_settings; diff --git a/api/Controllers/System/HeskVersionController.php b/api/Controllers/System/HeskVersionController.php index c07122ed..0b578595 100644 --- a/api/Controllers/System/HeskVersionController.php +++ b/api/Controllers/System/HeskVersionController.php @@ -3,7 +3,7 @@ namespace Controllers\System; -class HeskVersionController { +class HeskVersionController extends \BaseClass { static function getHeskVersion() { global $hesk_settings; diff --git a/api/Controllers/Tickets/CustomerTicketController.php b/api/Controllers/Tickets/CustomerTicketController.php index 2b1b2614..8b8b65fc 100644 --- a/api/Controllers/Tickets/CustomerTicketController.php +++ b/api/Controllers/Tickets/CustomerTicketController.php @@ -10,7 +10,7 @@ use BusinessLogic\ValidationModel; use Controllers\JsonRetriever; -class CustomerTicketController { +class CustomerTicketController extends \BaseClass { function get() { global $applicationContext, $hesk_settings; diff --git a/api/Controllers/Tickets/StaffTicketController.php b/api/Controllers/Tickets/StaffTicketController.php index a4860f07..658d7e7f 100644 --- a/api/Controllers/Tickets/StaffTicketController.php +++ b/api/Controllers/Tickets/StaffTicketController.php @@ -10,7 +10,7 @@ use BusinessLogic\Tickets\TicketEditor; use BusinessLogic\Tickets\TicketRetriever; use Controllers\JsonRetriever; -class StaffTicketController { +class StaffTicketController extends \BaseClass { function get($id) { global $applicationContext, $userContext, $hesk_settings; diff --git a/api/Core/Constants/CustomField.php b/api/Core/Constants/CustomField.php index 6d92cfe8..3bb6ad95 100644 --- a/api/Core/Constants/CustomField.php +++ b/api/Core/Constants/CustomField.php @@ -3,7 +3,7 @@ namespace Core\Constants; -class CustomField { +class CustomField extends \BaseClass { const RADIO = 'radio'; const SELECT = 'select'; const CHECKBOX = 'checkbox'; diff --git a/api/Core/Constants/Priority.php b/api/Core/Constants/Priority.php index 88f98cc3..39b86313 100644 --- a/api/Core/Constants/Priority.php +++ b/api/Core/Constants/Priority.php @@ -3,7 +3,7 @@ namespace Core\Constants; -class Priority { +class Priority extends \BaseClass { const CRITICAL = 0; const HIGH = 1; const MEDIUM = 2; diff --git a/api/Core/Exceptions/SQLException.php b/api/Core/Exceptions/SQLException.php index e9530a5b..2dbfccbe 100644 --- a/api/Core/Exceptions/SQLException.php +++ b/api/Core/Exceptions/SQLException.php @@ -2,9 +2,7 @@ namespace Core\Exceptions; -use Exception; - -class SQLException extends Exception { +class SQLException extends \BaseException { /** * @var $failingQuery string */ diff --git a/api/DataAccess/CommonDao.php b/api/DataAccess/CommonDao.php index f98056fb..cb3f5b3e 100644 --- a/api/DataAccess/CommonDao.php +++ b/api/DataAccess/CommonDao.php @@ -5,7 +5,7 @@ namespace DataAccess; use Exception; -class CommonDao { +class CommonDao extends \BaseClass { /** * @throws Exception if the database isn't properly configured */ diff --git a/api/DataAccess/Files/FileDeleter.php b/api/DataAccess/Files/FileDeleter.php index a625d764..eca69406 100644 --- a/api/DataAccess/Files/FileDeleter.php +++ b/api/DataAccess/Files/FileDeleter.php @@ -3,9 +3,7 @@ namespace DataAccess\Files; -use BusinessLogic\Exceptions\ApiFriendlyException; - -class FileDeleter { +class FileDeleter extends \BaseClass { function deleteFile($name, $folder) { $path = __DIR__ . "/../../../{$folder}/{$name}"; if (!file_exists($path)) { diff --git a/api/DataAccess/Files/FileReader.php b/api/DataAccess/Files/FileReader.php index c4ef2eb0..dd2a8ce7 100644 --- a/api/DataAccess/Files/FileReader.php +++ b/api/DataAccess/Files/FileReader.php @@ -5,7 +5,7 @@ namespace DataAccess\Files; use BusinessLogic\Exceptions\ApiFriendlyException; -class FileReader { +class FileReader extends \BaseClass { /** * @param $name string - The file name (including extension) * @param $folder - The folder name (relative to the ROOT of the helpdesk) diff --git a/api/DataAccess/Files/FileWriter.php b/api/DataAccess/Files/FileWriter.php index 8ca47891..368a4f3b 100644 --- a/api/DataAccess/Files/FileWriter.php +++ b/api/DataAccess/Files/FileWriter.php @@ -3,7 +3,7 @@ namespace DataAccess\Files; -class FileWriter { +class FileWriter extends \BaseClass { /** * @param $name string - The file name (including extension) * @param $folder - The folder name (relative to the ROOT of the helpdesk) diff --git a/api/DataAccess/Logging/Severity.php b/api/DataAccess/Logging/Severity.php index 46124c35..6cdd94ec 100644 --- a/api/DataAccess/Logging/Severity.php +++ b/api/DataAccess/Logging/Severity.php @@ -3,7 +3,7 @@ namespace DataAccess\Logging; -class Severity { +class Severity extends \BaseClass { const DEBUG = 0; const INFO = 1; const WARNING = 2; diff --git a/api/Link.php b/api/Link.php index 0e745ee3..10e5758d 100644 --- a/api/Link.php +++ b/api/Link.php @@ -42,7 +42,7 @@ class Link self::$routes = $routes; $method = self::getRequestMethod(); - $acceptedMethods = RequestMethod::ALL; + $acceptedMethods = RequestMethod::all(); $path = '/'; $handler = null; $matched = array(); diff --git a/api/index.php b/api/index.php index c8115d2c..8de69fc5 100644 --- a/api/index.php +++ b/api/index.php @@ -50,7 +50,7 @@ function assertApiIsEnabled() { global $applicationContext, $hesk_settings; /* @var $apiChecker \BusinessLogic\Settings\ApiChecker */ - $apiChecker = $applicationContext->get(\BusinessLogic\Settings\ApiChecker::class); + $apiChecker = $applicationContext->get(\BusinessLogic\Settings\ApiChecker::clazz()); if (!$apiChecker->isApiEnabled($hesk_settings)) { print output(array('message' => 'API Disabled'), 404); @@ -77,7 +77,7 @@ function buildUserContext($xAuthToken) { global $applicationContext, $userContext, $hesk_settings; /* @var $userContextBuilder \BusinessLogic\Security\UserContextBuilder */ - $userContextBuilder = $applicationContext->get(\BusinessLogic\Security\UserContextBuilder::class); + $userContextBuilder = $applicationContext->get(\BusinessLogic\Security\UserContextBuilder::clazz()); $userContext = $userContextBuilder->buildUserContext($xAuthToken, $hesk_settings); } @@ -98,12 +98,12 @@ function exceptionHandler($exception) { } // We don't cast API Friendly Exceptions as they're user-generated errors - if (exceptionIsOfType($exception, \BusinessLogic\Exceptions\ApiFriendlyException::class)) { + if (exceptionIsOfType($exception, \BusinessLogic\Exceptions\ApiFriendlyException::clazz())) { /* @var $castedException \BusinessLogic\Exceptions\ApiFriendlyException */ $castedException = $exception; print_error($castedException->title, $castedException->getMessage(), $castedException->httpResponseCode); - } elseif (exceptionIsOfType($exception, \Core\Exceptions\SQLException::class)) { + } elseif (exceptionIsOfType($exception, \Core\Exceptions\SQLException::clazz())) { /* @var $castedException \Core\Exceptions\SQLException */ $castedException = $exception; @@ -138,7 +138,7 @@ function tryToLog($location, $message, $stackTrace, $userContext, $heskSettings) global $applicationContext; /* @var $loggingGateway \DataAccess\Logging\LoggingGateway */ - $loggingGateway = $applicationContext->get(\DataAccess\Logging\LoggingGateway::class); + $loggingGateway = $applicationContext->get(\DataAccess\Logging\LoggingGateway::clazz()); try { return $loggingGateway->logError($location, $message, $stackTrace, $userContext, $heskSettings); @@ -183,41 +183,41 @@ Link::before('globalBefore'); Link::all(array( // Categories - '/v1/categories/all' => action(\Controllers\Categories\CategoryController::class . '::printAllCategories', [RequestMethod::GET], SecurityHandler::INTERNAL_OR_AUTH_TOKEN), - '/v1/categories' => action(\Controllers\Categories\CategoryController::class, [RequestMethod::POST], SecurityHandler::INTERNAL_OR_AUTH_TOKEN), - '/v1/categories/{i}' => action(\Controllers\Categories\CategoryController::class, [RequestMethod::GET, RequestMethod::PUT, RequestMethod::DELETE], SecurityHandler::INTERNAL_OR_AUTH_TOKEN), - '/v1-internal/categories/{i}/sort/{s}' => action(\Controllers\Categories\CategoryController::class . '::sort', [RequestMethod::POST], SecurityHandler::INTERNAL), + '/v1/categories/all' => action(\Controllers\Categories\CategoryController::clazz() . '::printAllCategories', [RequestMethod::GET], SecurityHandler::INTERNAL_OR_AUTH_TOKEN), + '/v1/categories' => action(\Controllers\Categories\CategoryController::clazz(), [RequestMethod::POST], SecurityHandler::INTERNAL_OR_AUTH_TOKEN), + '/v1/categories/{i}' => action(\Controllers\Categories\CategoryController::clazz(), [RequestMethod::GET, RequestMethod::PUT, RequestMethod::DELETE], SecurityHandler::INTERNAL_OR_AUTH_TOKEN), + '/v1-internal/categories/{i}/sort/{s}' => action(\Controllers\Categories\CategoryController::clazz() . '::sort', [RequestMethod::POST], SecurityHandler::INTERNAL), // Tickets - '/v1/tickets' => action(\Controllers\Tickets\CustomerTicketController::class, RequestMethod::all()), + '/v1/tickets' => action(\Controllers\Tickets\CustomerTicketController::clazz(), RequestMethod::all()), // Tickets - Staff - '/v1/staff/tickets/{i}' => action(\Controllers\Tickets\StaffTicketController::class, RequestMethod::all()), + '/v1/staff/tickets/{i}' => action(\Controllers\Tickets\StaffTicketController::clazz(), RequestMethod::all()), // Attachments - '/v1/tickets/{a}/attachments/{i}' => action(\Controllers\Attachments\PublicAttachmentController::class . '::getRaw', RequestMethod::all()), - '/v1/staff/tickets/{i}/attachments' => action(\Controllers\Attachments\StaffTicketAttachmentsController::class, RequestMethod::all()), - '/v1/staff/tickets/{i}/attachments/{i}' => action(\Controllers\Attachments\StaffTicketAttachmentsController::class, RequestMethod::all()), + '/v1/tickets/{a}/attachments/{i}' => action(\Controllers\Attachments\PublicAttachmentController::clazz() . '::getRaw', RequestMethod::all()), + '/v1/staff/tickets/{i}/attachments' => action(\Controllers\Attachments\StaffTicketAttachmentsController::clazz(), RequestMethod::all()), + '/v1/staff/tickets/{i}/attachments/{i}' => action(\Controllers\Attachments\StaffTicketAttachmentsController::clazz(), RequestMethod::all()), // Statuses - '/v1/statuses' => action(\Controllers\Statuses\StatusController::class, RequestMethod::all()), + '/v1/statuses' => action(\Controllers\Statuses\StatusController::clazz(), RequestMethod::all()), // Settings - '/v1/settings' => action(\Controllers\Settings\SettingsController::class, RequestMethod::all()), + '/v1/settings' => action(\Controllers\Settings\SettingsController::clazz(), RequestMethod::all()), /* Internal use only routes */ // Resend email response '/v1-internal/staff/tickets/{i}/resend-email' => - action(\Controllers\Tickets\ResendTicketEmailToCustomerController::class, RequestMethod::all(), SecurityHandler::INTERNAL), + action(\Controllers\Tickets\ResendTicketEmailToCustomerController::clazz(), RequestMethod::all(), SecurityHandler::INTERNAL), // Custom Navigation '/v1-internal/custom-navigation/all' => - action(\Controllers\Navigation\CustomNavElementController::class . '::getAll', RequestMethod::all(), SecurityHandler::INTERNAL), + action(\Controllers\Navigation\CustomNavElementController::clazz() . '::getAll', RequestMethod::all(), SecurityHandler::INTERNAL), '/v1-internal/custom-navigation' => - action(\Controllers\Navigation\CustomNavElementController::class, RequestMethod::all(), SecurityHandler::INTERNAL), + action(\Controllers\Navigation\CustomNavElementController::clazz(), RequestMethod::all(), SecurityHandler::INTERNAL), '/v1-internal/custom-navigation/{i}' => - action(\Controllers\Navigation\CustomNavElementController::class, RequestMethod::all(), SecurityHandler::INTERNAL), + action(\Controllers\Navigation\CustomNavElementController::clazz(), RequestMethod::all(), SecurityHandler::INTERNAL), '/v1-internal/custom-navigation/{i}/sort/{s}' => - action(\Controllers\Navigation\CustomNavElementController::class . '::sort', RequestMethod::all(), SecurityHandler::INTERNAL), + action(\Controllers\Navigation\CustomNavElementController::clazz() . '::sort', RequestMethod::all(), SecurityHandler::INTERNAL), '/v1-public/hesk-version' => - action(\Controllers\System\HeskVersionController::class . '::getHeskVersion', RequestMethod::all(), SecurityHandler::OPEN), + action(\Controllers\System\HeskVersionController::clazz() . '::getHeskVersion', RequestMethod::all(), SecurityHandler::OPEN), '/v1-public/mods-for-hesk-version' => - action(\Controllers\System\HeskVersionController::class . '::getModsForHeskVersion', RequestMethod::all(), SecurityHandler::OPEN), + action(\Controllers\System\HeskVersionController::clazz() . '::getModsForHeskVersion', RequestMethod::all(), SecurityHandler::OPEN), // Any URL that doesn't match goes to the 404 handler '404' => 'handle404'