[AntonyAntonio] - Add initial 'ticket/create' controller [skip ci]
This commit is contained in:
parent
c4341002ef
commit
86fc4ab0b6
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue