Allows all staff members in charge of the department of a ticket to manage it (change its department, priority, comment on it, etc.)

This commit is contained in:
Maxi Redigonda 2019-07-11 19:42:09 -03:00
parent 5073188d71
commit c70e9a444d
3 changed files with 19 additions and 29 deletions

View File

@ -50,26 +50,20 @@ class ChangePriorityController extends Controller {
$ticket = Ticket::getByTicketNumber($ticketNumber);
$user = Controller::getLoggedUser();
if (!$user->canManageTicket($ticket)) throw new RequestException(ERRORS::NO_PERMISSION);
if(!$user->canManageTicket($ticket)) throw new RequestException(ERRORS::NO_PERMISSION);
$ticket->priority = $priority;
$ticket->unread = !$ticket->isAuthor($user);
$event = Ticketevent::getEvent(Ticketevent::PRIORITY_CHANGED);
$event->setProperties(array(
'authorStaff' => Controller::getLoggedUser(),
'content' => $ticket->priority,
'date' => Date::getCurrentDate()
));
$ticket->addEvent($event);
$ticket->store();
if($ticket->owner && $user->id === $ticket->owner->id) {
$ticket->priority = $priority;
$ticket->unread = !$ticket->isAuthor($user);
$event = Ticketevent::getEvent(Ticketevent::PRIORITY_CHANGED);
$event->setProperties(array(
'authorStaff' => Controller::getLoggedUser(),
'content' => $ticket->priority,
'date' => Date::getCurrentDate()
));
$ticket->addEvent($event);
$ticket->store();
Log::createLog('PRIORITY_CHANGED', $ticket->ticketNumber);
Response::respondSuccess();
} else {
throw new RequestException(ERRORS::NO_PERMISSION);
}
Log::createLog('PRIORITY_CHANGED', $ticket->ticketNumber);
Response::respondSuccess();
}
}

View File

@ -61,19 +61,15 @@ class CloseController extends Controller {
public function handler() {
$this->ticket = Ticket::getByTicketNumber(Controller::request('ticketNumber'));
$user = Controller::getLoggedUser();
if(
(Controller::isUserSystemEnabled() || Controller::isStaffLogged()) &&
!$this->ticket->isOwner(Controller::getLoggedUser()) &&
!$this->ticket->isAuthor(Controller::getLoggedUser())
) {
if(!Controller::isStaffLogged() && Controller::isUserSystemEnabled() &&
!$this->ticket->isAuthor($user)){
throw new RequestException(ERRORS::NO_PERMISSION);
}
if(Controller::isStaffLogged()){
$user = Controller::getLoggedUser();
if (!$user->canManageTicket($this->ticket)) throw new RequestException(ERRORS::NO_PERMISSION);
if(Controller::isStaffLogged() && (!$user->canManageTicket($this->ticket))){
throw new RequestException(ERRORS::NO_PERMISSION);
}
$this->markAsUnread();

View File

@ -83,7 +83,7 @@ class CommentController extends Controller {
$isOwner = $this->ticket->isOwner(Controller::getLoggedUser());
$user = Controller::getLoggedUser();
if((Controller::isUserSystemEnabled() || Controller::isStaffLogged()) && !$isOwner && !$isAuthor) {
if(!Controller::isStaffLogged() && Controller::isUserSystemEnabled() && !$isAuthor){
throw new RequestException(ERRORS::NO_PERMISSION);
}