Merged in Full-ticket-create-logic (pull request #32)

(Guillermo)  full ticket create
This commit is contained in:
Ivan Diaz 2016-08-03 15:08:57 -03:00
commit a98cf9176b
5 changed files with 12 additions and 6 deletions

View File

@ -11,7 +11,7 @@ class CreateController extends Controller {
public function validations() { public function validations() {
return [ return [
'permission' => 'any', 'permission' => 'user',
'requestData' => [ 'requestData' => [
'title' => [ 'title' => [
'validation' => DataValidator::length(3, 30), 'validation' => DataValidator::length(3, 30),
@ -48,13 +48,12 @@ class CreateController extends Controller {
'language' => $this->language, 'language' => $this->language,
'department' => $this->departmentId, 'department' => $this->departmentId,
'file' => '', 'file' => '',
'date' => date('F j, Y, g:i a'), 'date' => Date::getCurrentDate(),
'unread' => false, 'unread' => false,
'closed' => false 'closed' => false
)); ));
//TODO: Add logged user as author $ticket->setAuthor(Controller::getLoggedUser());
$ticket->setAuthor(User::getUser(1));
$ticket->store(); $ticket->store();
} }

View File

@ -15,6 +15,7 @@ include_once 'libs/Controller.php';
include_once 'libs/ControllerGroup.php'; include_once 'libs/ControllerGroup.php';
include_once 'libs/Hashing.php'; include_once 'libs/Hashing.php';
include_once 'libs/MailSender.php'; include_once 'libs/MailSender.php';
include_once 'libs/Date.php';
// LOAD DATA // LOAD DATA
spl_autoload_register(function ($class) { spl_autoload_register(function ($class) {

6
server/libs/Date.php Normal file
View File

@ -0,0 +1,6 @@
<?php
class Date {
public static function getCurrentDate() {
return date('F j, Y, g:i a');
}
}

View File

@ -65,6 +65,6 @@ class Session {
} }
private function generateToken() { private function generateToken() {
return Hashing::generateRandomToken();; return Hashing::generateRandomToken();
} }
} }

View File

@ -52,5 +52,5 @@ describe '/ticket/create' do
(result['status']).should.equal('success') (result['status']).should.equal('success')
ticket = $database.getRow('ticket','Winter is coming','title') ticket = $database.getRow('ticket','Winter is coming','title')
(ticket['content']).should.equal('The north remembers') (ticket['content']).should.equal('The north remembers')
end end
end end