/** * @param \Hackzilla\Bundle\TicketBundle\Model\UserInterface|string $user * @param Ticket $ticket */ private function checkUserPermission($user, Ticket $ticket) { if (!\is_object($user) || !$this->get('hackzilla_ticket.user_manager')->hasRole($user, TicketRole::Admin) && $ticket->getUserCreated() != $user->getId()) { throw new \Symfony\Component\HttpKernel\Exception\HttpException(403); } }
/** * Set ticket * * @param \Hackzilla\Bundle\TicketBundle\Entity\Ticket $ticket * * @return $this */ public function setTicket(Ticket $ticket = null) { $this->ticket = $ticket; if (\is_null($this->getUserObject())) { $user = $this->getUser(); } else { $user = $this->getUserObject(); } // if null, then new ticket if (\is_null($ticket->getUserCreated())) { $ticket->setUserCreated($user); } $ticket->setLastUser($user); $ticket->setLastMessage($this->getCreatedAt()); $ticket->setPriority($this->getPriority()); // if ticket not closed, then it'll be set to null if (\is_null($this->getStatus())) { $this->setStatus($ticket->getStatus()); } else { $ticket->setStatus($this->getStatus()); } return $this; }
/** * @param \FOS\UserBundle\Model\UserInterface|string $user * @param Ticket $ticket */ private function checkUserPermission($user, Ticket $ticket) { if (!\is_object($user) || !$this->get('hackzilla_ticket.user')->isGranted($user, 'ROLE_TICKET_ADMIN') && $ticket->getUserCreated() != $user->getId()) { throw new \Symfony\Component\HttpKernel\Exception\HttpException(403); } }