From 86fc4ab0b65ae5be8f31eb987a9297081d05c271 Mon Sep 17 00:00:00 2001 From: Ivan Diaz Date: Fri, 17 Jun 2016 17:16:10 -0300 Subject: [PATCH] [AntonyAntonio] - Add initial 'ticket/create' controller [skip ci] --- server/controllers/ticket/create.php | 40 +++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/server/controllers/ticket/create.php b/server/controllers/ticket/create.php index 527c3fcd..51e85dca 100644 --- a/server/controllers/ticket/create.php +++ b/server/controllers/ticket/create.php @@ -4,6 +4,44 @@ class CreateController extends Controller { const PATH = '/create'; public function handler(){ - Response::respondError('TEST'); + $title = Controller::request('title'); + $content = Controller::request('content'); + $departmentId = Controller::request('departmentId'); + $language = Controller::request('language'); + if (strlen($title)<3 ){ + Response::respondError('title is so short'); + return; + } + if (strlen($title)>30){ + Response::respondError('title is so long'); + return; + } + if (strlen($content)<5){ + Response::respondError('content is so short'); + return; + } + if (strlen($content)>100){ + Response::respondError('content is so long'); + return; + } + $ticket = new Ticket(); + $ticket->setProperties(array( + 'ticketId' => '', + 'title' => $title, + 'content' => $content, + 'language' => $language, + 'department' => $departmentId, + 'file' => '', + 'date' => date("F j, Y, g:i a"), + 'unread' => false, + 'closed' => false, + 'author' => '', + 'owner'=> '', + 'ownComments' => [] + )); + + $ticket->store(); + Response::respondSuccess(); + } } \ No newline at end of file