Start working on attachments API. Fix .gitignore
Parent
f40eaf1a23
révision
8378d35149
@ -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;
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace BusinessLogic\Attachments;
|
||||
|
||||
|
||||
class AttachmentHandler {
|
||||
|
||||
|
||||
function createAttachmentForTicket($createAttachmentModel) {
|
||||
|
||||
}
|
||||
|
||||
private function validate($createAttachmentModel) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace BusinessLogic\Attachments;
|
||||
|
||||
|
||||
class AttachmentType {
|
||||
const MESSAGE = 0;
|
||||
const REPLY = 1;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Controllers\Attachments;
|
||||
|
||||
|
||||
class StaffAttachmentsController {
|
||||
function post() {
|
||||
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
Chargement…
Référencer dans un nouveau ticket