From 221288402e72f74ac4fdb0fcaf91a91aca5821e7 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 21 Oct 2016 16:12:17 -0300 Subject: [PATCH] Guillermo - Ticket-seen [skip ci] --- server/controllers/staff/assign-ticket.php | 1 + server/controllers/staff/un-assign-ticket.php | 1 + server/controllers/ticket/change-department.php | 1 + server/controllers/ticket/change-priority.php | 1 + server/controllers/ticket/close.php | 7 ++++++- server/controllers/ticket/comment.php | 6 +++--- server/controllers/ticket/create.php | 1 + server/controllers/ticket/re-open.php | 6 +++++- server/controllers/ticket/seen.php | 4 ++-- 9 files changed, 21 insertions(+), 7 deletions(-) diff --git a/server/controllers/staff/assign-ticket.php b/server/controllers/staff/assign-ticket.php index e32e44cd..30e3f37d 100644 --- a/server/controllers/staff/assign-ticket.php +++ b/server/controllers/staff/assign-ticket.php @@ -34,6 +34,7 @@ class AssignStaffController extends Controller { } else { $this->user->sharedTicketList->add($this->ticket); $this->ticket->owner = $this->user; + $this->ticket->unread = true; $this->ticket->store(); $this->user->store(); diff --git a/server/controllers/staff/un-assign-ticket.php b/server/controllers/staff/un-assign-ticket.php index c46f3fe8..c275507a 100644 --- a/server/controllers/staff/un-assign-ticket.php +++ b/server/controllers/staff/un-assign-ticket.php @@ -26,6 +26,7 @@ class UnAssignStaffController extends Controller { $user->sharedTicketList->remove($ticket); $user->store(); $ticket->owner = null; + $ticket->uread = true; $ticket->store(); Response::respondSuccess(); } else { diff --git a/server/controllers/ticket/change-department.php b/server/controllers/ticket/change-department.php index b291e8a7..bb916826 100644 --- a/server/controllers/ticket/change-department.php +++ b/server/controllers/ticket/change-department.php @@ -34,6 +34,7 @@ class ChangeDepartmentController extends Controller { } $ticket->department = $department; + $ticket->unread = true; $ticket->store(); Response::respondSuccess(); } diff --git a/server/controllers/ticket/change-priority.php b/server/controllers/ticket/change-priority.php index f00e7812..49d4e3a5 100644 --- a/server/controllers/ticket/change-priority.php +++ b/server/controllers/ticket/change-priority.php @@ -28,6 +28,7 @@ class ChangePriorityController extends Controller { if($ticket->owner && $user->id === $ticket->owner->id) { $ticket->priority = $priority; + $ticket->unread = true; $ticket->store(); Response::respondSuccess(); } else { diff --git a/server/controllers/ticket/close.php b/server/controllers/ticket/close.php index 5e0b04f5..8e993477 100644 --- a/server/controllers/ticket/close.php +++ b/server/controllers/ticket/close.php @@ -31,7 +31,12 @@ class CloseController extends Controller { Response::respondError(ERRORS::NO_PERMISSION); return; } - + + if(Controller::isStaffLogged()) { + $ticket->unread = true; + } else { + $ticket->unreadStaff = true; + } $ticket->closed = true; $ticket->store(); Response::respondSuccess(); diff --git a/server/controllers/ticket/comment.php b/server/controllers/ticket/comment.php index 83fb5513..2c4b0714 100644 --- a/server/controllers/ticket/comment.php +++ b/server/controllers/ticket/comment.php @@ -51,11 +51,11 @@ class CommentController extends Controller { )); if(Controller::isStaffLogged()) { - $comment->authorUser = Controller::getLoggedUser(); + $this->ticket->unread = true; } else { - $comment->authorUser = Controller::getLoggedUser(); + $this->ticket->unreadStaff = true; } - + $comment->authorUser = Controller::getLoggedUser(); $this->ticket->addEvent($comment); $this->ticket->store(); } diff --git a/server/controllers/ticket/create.php b/server/controllers/ticket/create.php index 64dab1e7..4de927f9 100644 --- a/server/controllers/ticket/create.php +++ b/server/controllers/ticket/create.php @@ -58,6 +58,7 @@ class CreateController extends Controller { 'file' => '', 'date' => Date::getCurrentDate(), 'unread' => false, + 'unreadStaff' => true, 'closed' => false, )); diff --git a/server/controllers/ticket/re-open.php b/server/controllers/ticket/re-open.php index 0ee2caae..d1332f52 100644 --- a/server/controllers/ticket/re-open.php +++ b/server/controllers/ticket/re-open.php @@ -30,7 +30,11 @@ class ReOpenController extends Controller { Response::respondError(ERRORS::NO_PERMISSION); return; } - + if(Controller::isStaffLogged()) { + $ticket->unread = true; + } else { + $ticket->unreadStaff = true; + } $ticket->closed = false; $ticket->store(); Response::respondSuccess(); diff --git a/server/controllers/ticket/seen.php b/server/controllers/ticket/seen.php index 7f41c1e7..fa07e0c4 100644 --- a/server/controllers/ticket/seen.php +++ b/server/controllers/ticket/seen.php @@ -21,13 +21,13 @@ class SeenController extends Controller { $user = Controller::getLoggedUser(); $ticket = Ticket::getByTicketNumber($ticketnumber); - if (Controller::isStaffLogged() && $ticket->owner_id === $user->id) { + if (Controller::isStaffLogged() && $ticket->owner && $ticket->owner->id === $user->id) { $ticket->unreadStaff = false; $ticket->store(); Response::respondSuccess(); return; } - if (!Controller::isStaffLogged() && $user->id === $ticket->author_id) { + if (!Controller::isStaffLogged() && $ticket->author && $user->id === $ticket->author->id) { $ticket->unread = false; $ticket->store(); Response::respondSuccess();