Ivan - Update ownCommentList logic for tickets [skip ci]
This commit is contained in:
parent
ea65ea35d1
commit
f4450e81de
|
@ -8,38 +8,25 @@ class CommentController extends Controller {
|
||||||
private $content;
|
private $content;
|
||||||
|
|
||||||
public function handler() {
|
public function handler() {
|
||||||
/*
|
$this->requestData();
|
||||||
//$this->storeComment();
|
$this->storeComment();
|
||||||
$ticket = RedBean::load('tickets', Controller::request('ticketId'));
|
|
||||||
$comment = RedBean::dispense('comments');
|
|
||||||
$comment->content = Controller::request('content');
|
|
||||||
|
|
||||||
$ticket->ownCommentsList[] = $comment;
|
Response::respondSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
RedBean::store($ticket);
|
private function requestData() {
|
||||||
$ticket = RedBean::load('tickets', Controller::request('ticketId'));
|
$this->ticketId = Controller::request('ticketId');
|
||||||
|
$this->content = Controller::request('content');
|
||||||
$string = "";
|
|
||||||
$string += count($ticket->ownCommentsList);
|
|
||||||
|
|
||||||
foreach( $ticket->ownCommentsList as $comment2 ) {
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function storeComment() {
|
private function storeComment() {
|
||||||
$this->ticketId = Controller::request('ticketId');
|
|
||||||
$this->content = Controller::request('content');
|
|
||||||
$ticket = Ticket::getTicket($this->ticketId);
|
|
||||||
|
|
||||||
$comment = new Comment();
|
$comment = new Comment();
|
||||||
$comment->setProperties(array(
|
$comment->setProperties(array(
|
||||||
'content' => $this->content
|
'content' => $this->content
|
||||||
//'ticket' => $ticket->getBeanInstance()
|
|
||||||
));
|
));
|
||||||
|
|
||||||
$ticket->getBeanInstance()->ownCommentsList = [$comment->getBeanInstance()];
|
|
||||||
$ticket->store();
|
|
||||||
$ticket = Ticket::getTicket($this->ticketId);
|
$ticket = Ticket::getTicket($this->ticketId);
|
||||||
Response::respondError(count($ticket->ownCommentsList));
|
$ticket->addComment($comment);
|
||||||
|
$ticket->store();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -59,10 +59,11 @@ class CreateController extends Controller {
|
||||||
'date' => date("F j, Y, g:i a"),
|
'date' => date("F j, Y, g:i a"),
|
||||||
'unread' => false,
|
'unread' => false,
|
||||||
'closed' => false,
|
'closed' => false,
|
||||||
'author' => '',
|
'author' => null,
|
||||||
'owner'=> '',
|
'owner'=> null
|
||||||
'ownComments' => []
|
|
||||||
));
|
));
|
||||||
|
$ticket->getBeanInstance()->ownCommentList[] = RedBean::dispense('comment');
|
||||||
|
|
||||||
$ticket->store();
|
$ticket->store();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Comment extends DataStore {
|
class Comment extends DataStore {
|
||||||
const TABLE = 'comments';
|
const TABLE = 'comment';
|
||||||
|
|
||||||
public static function getProps() {
|
public static function getProps() {
|
||||||
return array(
|
return array(
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
use RedBeanPHP\Facade as RedBean;
|
||||||
|
|
||||||
class Ticket extends DataStore {
|
class Ticket extends DataStore {
|
||||||
const TABLE = 'tickets';
|
const TABLE = 'ticket';
|
||||||
|
|
||||||
public static function getProps() {
|
public static function getProps() {
|
||||||
return array(
|
return array(
|
||||||
'ticketId',
|
'ticketNumber',
|
||||||
'title',
|
'title',
|
||||||
'content',
|
'content',
|
||||||
'language',
|
'language',
|
||||||
|
@ -16,15 +17,19 @@ class Ticket extends DataStore {
|
||||||
'closed',
|
'closed',
|
||||||
'author',
|
'author',
|
||||||
'owner',
|
'owner',
|
||||||
'ownComments'
|
'ownCommentList'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getTicket($value, $property = 'id') {
|
public static function getTicket($value, $property = 'id') {
|
||||||
return parent::getDataStore($value, $property);
|
return parent::getDataStore($value, $property);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getDefaultProps() {
|
public function getDefaultProps() {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addComment(Comment $comment) {
|
||||||
|
$this->getBeanInstance()->ownCommentList[] = $comment->getBeanInstance();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
use RedBeanPHP\Facade as RedBean;
|
||||||
|
|
||||||
class User extends DataStore {
|
class User extends DataStore {
|
||||||
const TABLE = 'users';
|
const TABLE = 'user';
|
||||||
|
|
||||||
public static function authenticate($userEmail, $userPassword) {
|
public static function authenticate($userEmail, $userPassword) {
|
||||||
$user = User::getUser($userEmail, 'email');
|
$user = User::getUser($userEmail, 'email');
|
||||||
|
@ -15,18 +16,16 @@ class User extends DataStore {
|
||||||
'password',
|
'password',
|
||||||
'name',
|
'name',
|
||||||
'verificationToken',
|
'verificationToken',
|
||||||
'ownTickets'
|
'ownTicketList'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDefaultProps() {
|
public function getDefaultProps() {
|
||||||
return array(
|
return array();
|
||||||
'ownTickets' => []
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addTicket($ticket) {
|
public function addTicket($ticket) {
|
||||||
$this->ownTickets[] = $ticket;
|
$this->ownTicketList[] = $ticket;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUser($value, $property = 'id') {
|
public static function getUser($value, $property = 'id') {
|
||||||
|
|
|
@ -50,7 +50,7 @@ describe '/user/login' do
|
||||||
})
|
})
|
||||||
|
|
||||||
(result['status']).should.equal('success')
|
(result['status']).should.equal('success')
|
||||||
ticket = $database.getRow('tickets','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
|
|
@ -5,7 +5,7 @@ describe '/user/signup' do
|
||||||
'password' => 'custom'
|
'password' => 'custom'
|
||||||
})
|
})
|
||||||
|
|
||||||
userRow = $database.getRow('users', response['data']['userId'])
|
userRow = $database.getRow('user', response['data']['userId'])
|
||||||
|
|
||||||
(userRow['email']).should.equal('steve@jobs.com')
|
(userRow['email']).should.equal('steve@jobs.com')
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue