From 8378d35149f097cd25237e7d7bf9288ecd3626ea Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Wed, 15 Mar 2017 22:07:17 -0400 Subject: [PATCH] Start working on attachments API. Fix .gitignore --- .gitignore | 2 +- api/BusinessLogic/Attachments/Attachment.php | 21 +++++++++++++ .../Attachments/AttachmentHandler.php | 16 ++++++++++ .../Attachments/AttachmentType.php | 9 ++++++ .../CreateAttachmentForTicketModel.php | 12 ++++++++ .../Attachments/CreateAttachmentModel.php | 18 +++++++++++ .../Attachments/TicketAttachment.php | 12 ++++++++ .../StaffAttachmentsController.php | 10 +++++++ .../Attachments/AttachmentGateway.php | 30 +++++++++++++++++++ .../Attachments/AttachmentHandlerTest.php | 17 +++++++++++ 10 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 api/BusinessLogic/Attachments/Attachment.php create mode 100644 api/BusinessLogic/Attachments/AttachmentHandler.php create mode 100644 api/BusinessLogic/Attachments/AttachmentType.php create mode 100644 api/BusinessLogic/Attachments/CreateAttachmentForTicketModel.php create mode 100644 api/BusinessLogic/Attachments/CreateAttachmentModel.php create mode 100644 api/BusinessLogic/Attachments/TicketAttachment.php create mode 100644 api/Controllers/Attachments/StaffAttachmentsController.php create mode 100644 api/DataAccess/Attachments/AttachmentGateway.php create mode 100644 api/Tests/BusinessLogic/Attachments/AttachmentHandlerTest.php diff --git a/.gitignore b/.gitignore index 2e3f55a2..70d3d8c3 100644 --- a/.gitignore +++ b/.gitignore @@ -270,7 +270,7 @@ readme.html robots.txt .idea/ attachments/__latest.txt -attachments +/attachments img/ban.png img/banned.png img/ico_tools.png diff --git a/api/BusinessLogic/Attachments/Attachment.php b/api/BusinessLogic/Attachments/Attachment.php new file mode 100644 index 00000000..380d00b3 --- /dev/null +++ b/api/BusinessLogic/Attachments/Attachment.php @@ -0,0 +1,21 @@ +AttachmentTypeAttachmentType] */ + public $type; +} \ No newline at end of file diff --git a/api/Controllers/Attachments/StaffAttachmentsController.php b/api/Controllers/Attachments/StaffAttachmentsController.php new file mode 100644 index 00000000..6bfbbd81 --- /dev/null +++ b/api/Controllers/Attachments/StaffAttachmentsController.php @@ -0,0 +1,10 @@ +init(); + + hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($heskSettings['db_pfix']) . "attachments` + (`ticket_id`, `note_id`, `saved_name`, `real_name`, `size`, `type`, `download_count`) + VALUES ('" . hesk_dbEscape($attachment->ticketTrackingId) . "', NULL, '" . hesk_dbEscape($attachment->savedName) . "', + '" . hesk_dbEscape($attachment->displayName) . "', " . intval($attachment->fileSize) . ", '" . intval($attachment->type) . "', 0)"); + + $attachmentId = hesk_dbInsertID(); + + $this->close(); + + return $attachmentId; + } +} \ No newline at end of file diff --git a/api/Tests/BusinessLogic/Attachments/AttachmentHandlerTest.php b/api/Tests/BusinessLogic/Attachments/AttachmentHandlerTest.php new file mode 100644 index 00000000..335b3b88 --- /dev/null +++ b/api/Tests/BusinessLogic/Attachments/AttachmentHandlerTest.php @@ -0,0 +1,17 @@ +attachmentHandler = new AttachmentHandler(); + } +}