Basic ticket info can now be edited
This commit is contained in:
parent
c26db92799
commit
167d6c76ac
@ -15,6 +15,7 @@ use BusinessLogic\Security\UserToTicketChecker;
|
|||||||
use BusinessLogic\Settings\ApiChecker;
|
use BusinessLogic\Settings\ApiChecker;
|
||||||
use BusinessLogic\Tickets\Autoassigner;
|
use BusinessLogic\Tickets\Autoassigner;
|
||||||
use BusinessLogic\Tickets\TicketDeleter;
|
use BusinessLogic\Tickets\TicketDeleter;
|
||||||
|
use BusinessLogic\Tickets\TicketEditor;
|
||||||
use BusinessLogic\Tickets\TicketRetriever;
|
use BusinessLogic\Tickets\TicketRetriever;
|
||||||
use BusinessLogic\Tickets\TicketCreator;
|
use BusinessLogic\Tickets\TicketCreator;
|
||||||
use BusinessLogic\Tickets\NewTicketValidator;
|
use BusinessLogic\Tickets\NewTicketValidator;
|
||||||
@ -117,5 +118,7 @@ class ApplicationContext {
|
|||||||
new TicketDeleter($this->get[TicketGateway::class],
|
new TicketDeleter($this->get[TicketGateway::class],
|
||||||
$this->get[UserToTicketChecker::class],
|
$this->get[UserToTicketChecker::class],
|
||||||
$this->get[AttachmentHandler::class]);
|
$this->get[AttachmentHandler::class]);
|
||||||
|
$this->get[TicketEditor::class] =
|
||||||
|
new TicketEditor($this->get[TicketGateway::class], $this->get[UserToTicketChecker::class]);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,6 +25,6 @@ class EditTicketModel {
|
|||||||
/* @var $html bool */
|
/* @var $html bool */
|
||||||
public $html;
|
public $html;
|
||||||
|
|
||||||
/* @var $customFields array */
|
/* @var $customFields string[] */
|
||||||
public $customFields;
|
public $customFields;
|
||||||
}
|
}
|
@ -47,6 +47,14 @@ class TicketEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->validate($editTicketModel, $ticket->categoryId, $heskSettings);
|
$this->validate($editTicketModel, $ticket->categoryId, $heskSettings);
|
||||||
|
|
||||||
|
$ticket->name = $editTicketModel->name;
|
||||||
|
$ticket->email = $editTicketModel->email;
|
||||||
|
$ticket->subject = $editTicketModel->subject;
|
||||||
|
$ticket->message = $editTicketModel->message;
|
||||||
|
$ticket->customFields = $editTicketModel->customFields;
|
||||||
|
|
||||||
|
$this->ticketGateway->updateBasicTicketInfo($ticket, $heskSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,7 +3,11 @@
|
|||||||
namespace Controllers\Tickets;
|
namespace Controllers\Tickets;
|
||||||
|
|
||||||
|
|
||||||
|
use BusinessLogic\Helpers;
|
||||||
|
use BusinessLogic\Tickets\EditTicketModel;
|
||||||
use BusinessLogic\Tickets\TicketDeleter;
|
use BusinessLogic\Tickets\TicketDeleter;
|
||||||
|
use BusinessLogic\Tickets\TicketEditor;
|
||||||
|
use Controllers\JsonRetriever;
|
||||||
|
|
||||||
class StaffTicketController {
|
class StaffTicketController {
|
||||||
function delete($id) {
|
function delete($id) {
|
||||||
@ -14,4 +18,39 @@ class StaffTicketController {
|
|||||||
|
|
||||||
$ticketDeleter->deleteTicket($id, $userContext, $hesk_settings);
|
$ticketDeleter->deleteTicket($id, $userContext, $hesk_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function put($id) {
|
||||||
|
global $applicationContext, $userContext, $hesk_settings;
|
||||||
|
|
||||||
|
/* @var $ticketEditor TicketEditor */
|
||||||
|
$ticketEditor = $applicationContext->get[TicketEditor::class];
|
||||||
|
|
||||||
|
$jsonRequest = JsonRetriever::getJsonData();
|
||||||
|
|
||||||
|
$ticketEditor->editTicket($this->getEditTicketModel($id, $jsonRequest), $userContext, $hesk_settings);
|
||||||
|
|
||||||
|
http_response_code(204);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getEditTicketModel($id, $jsonRequest) {
|
||||||
|
$editTicketModel = new EditTicketModel();
|
||||||
|
$editTicketModel->id = $id;
|
||||||
|
$editTicketModel->language = Helpers::safeArrayGet($jsonRequest, 'language');
|
||||||
|
$editTicketModel->name = Helpers::safeArrayGet($jsonRequest, 'name');
|
||||||
|
$editTicketModel->subject = Helpers::safeArrayGet($jsonRequest, 'subject');
|
||||||
|
$editTicketModel->message = Helpers::safeArrayGet($jsonRequest, 'message');
|
||||||
|
$editTicketModel->html = Helpers::safeArrayGet($jsonRequest, 'html');
|
||||||
|
$editTicketModel->email = Helpers::safeArrayGet($jsonRequest, 'email');
|
||||||
|
|
||||||
|
$jsonCustomFields = Helpers::safeArrayGet($jsonRequest, 'customFields');
|
||||||
|
|
||||||
|
if ($jsonCustomFields !== null && !empty($jsonCustomFields)) {
|
||||||
|
foreach ($jsonCustomFields as $key => $value) {
|
||||||
|
$editTicketModel->customFields[intval($key)] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $editTicketModel;
|
||||||
|
}
|
||||||
}
|
}
|
@ -329,12 +329,12 @@ class TicketGateway extends CommonDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hesk_dbQuery("UPDATE `" . hesk_dbEscape($heskSettings['db_pfix']) . "tickets`
|
hesk_dbQuery("UPDATE `" . hesk_dbEscape($heskSettings['db_pfix']) . "tickets`
|
||||||
SET `subject` = {$subject},
|
SET `subject` = '{$subject}',
|
||||||
`message` = {$message},
|
`message` = '{$message}',
|
||||||
`language` = {$language},
|
`language` = '{$language}',
|
||||||
`name` = {$name},
|
`name` = '{$name}',
|
||||||
`email` = {$email},
|
`email` = '{$email}',
|
||||||
`html` = " . ($ticket->usesHtml ? 1 : 0) . "
|
`html` = " . ($ticket->usesHtml ? 1 : 0) . ",
|
||||||
{$customSql}
|
{$customSql}
|
||||||
WHERE `id` = " . intval($ticket->id));
|
WHERE `id` = " . intval($ticket->id));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user