Browse Source

Start working on attachments API. Fix .gitignore

tags/3.1.0
Mike Koch 2 years ago
parent
commit
8378d35149

+ 1
- 1
.gitignore View File

@@ -270,7 +270,7 @@ readme.html
robots.txt
.idea/
attachments/__latest.txt
attachments
/attachments
img/ban.png
img/banned.png
img/ico_tools.png

+ 21
- 0
api/BusinessLogic/Attachments/Attachment.php View File

@@ -0,0 +1,21 @@
<?php

namespace BusinessLogic\Attachments;


class Attachment {
/* @var $id int */
public $id;

/* @var $savedName string */
public $savedName;

/* @var $displayName string */
public $displayName;

/* @var $id int */
public $fileSize;

/* @var $downloadCount int */
public $downloadCount;
}

+ 16
- 0
api/BusinessLogic/Attachments/AttachmentHandler.php View File

@@ -0,0 +1,16 @@
<?php

namespace BusinessLogic\Attachments;


class AttachmentHandler {


function createAttachmentForTicket($createAttachmentModel) {

}

private function validate($createAttachmentModel) {

}
}

+ 9
- 0
api/BusinessLogic/Attachments/AttachmentType.php View File

@@ -0,0 +1,9 @@
<?php

namespace BusinessLogic\Attachments;


class AttachmentType {
const MESSAGE = 0;
const REPLY = 1;
}

+ 12
- 0
api/BusinessLogic/Attachments/CreateAttachmentForTicketModel.php View File

@@ -0,0 +1,12 @@
<?php

namespace BusinessLogic\Attachments;


class CreateAttachmentForTicketModel extends CreateAttachmentModel {
/* @var $ticketId int */
public $ticketId;

/* @var $type int [use <code>AttachmentType</code] */
public $type;
}

+ 18
- 0
api/BusinessLogic/Attachments/CreateAttachmentModel.php View File

@@ -0,0 +1,18 @@
<?php

namespace BusinessLogic\Attachments;


class CreateAttachmentModel {
/* @var $savedName string */
public $savedName;

/* @var $displayName string */
public $displayName;

/* @var $id int */
public $fileSize;

/* @var $attachmentContents string [base64-encoded] */
public $attachmentContents;
}

+ 12
- 0
api/BusinessLogic/Attachments/TicketAttachment.php View File

@@ -0,0 +1,12 @@
<?php

namespace BusinessLogic\Attachments;


class TicketAttachment extends Attachment {
/* @var $ticketTrackingId string */
public $ticketTrackingId;

/* @var $type int [use <code>AttachmentType</code>] */
public $type;
}

+ 10
- 0
api/Controllers/Attachments/StaffAttachmentsController.php View File

@@ -0,0 +1,10 @@
<?php

namespace Controllers\Attachments;


class StaffAttachmentsController {
function post() {

}
}

+ 30
- 0
api/DataAccess/Attachments/AttachmentGateway.php View File

@@ -0,0 +1,30 @@
<?php

namespace DataAccess\Attachments;


use BusinessLogic\Attachments\TicketAttachment;
use DataAccess\CommonDao;

class AttachmentGateway extends CommonDao {

/**
* @param $attachment TicketAttachment
* @param $heskSettings array
* @return int The inserted attachment ID
*/
function createAttachmentForTicket($attachment, $heskSettings) {
$this->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;
}
}

+ 17
- 0
api/Tests/BusinessLogic/Attachments/AttachmentHandlerTest.php View File

@@ -0,0 +1,17 @@
<?php


namespace BusinessLogic\Attachments;


use PHPUnit\Framework\TestCase;

class AttachmentHandlerTest extends TestCase {

/* @var $attachmentHandler AttachmentHandler */
private $attachmentHandler;

protected function setUp() {
$this->attachmentHandler = new AttachmentHandler();
}
}

Loading…
Cancel
Save