/** * creates a new reply on a ticket. * Creates a ticket_content entry and links it with a new created ticket_reply, a log entry will be written about this. * In case the ticket creator replies on a ticket, he will set the status by default to 'waiting on support'. * @param $content the content of the reply * @param $author the id of the reply creator. * @param $ticket_id the id of the ticket of which we want the replies. * @param $hidden should be 0 or 1 * @param $ticket_creator the ticket's starter his id. */ public static function createReply($content, $author, $ticket_id, $hidden, $ticket_creator) { $ticket_content = new Ticket_Content(); $ticket_content->setContent($content); $ticket_content->create(); $content_id = $ticket_content->getTContentId(); $ticket_reply = new Ticket_Reply(); $ticket_reply->set(array('Ticket' => $ticket_id, 'Content' => $content_id, 'Author' => $author, 'Hidden' => $hidden)); $ticket_reply->create(); $reply_id = $ticket_reply->getTReplyId(); if ($ticket_creator == $author) { Ticket::updateTicketStatus($ticket_id, 1, $author); } Ticket_Log::createLogEntry($ticket_id, $author, 4, $reply_id); }
/** * This function is beign used to load info that's needed for the show_reply page. * check if the person is allowed to see the reply, if not he'll be redirected to an error page. * data regarding to the reply will be returned by this function that will be used by the template. * @author Daan Janssens, mentored by Matthew Lagoe */ function show_reply() { //if logged in if (WebUsers::isLoggedIn() && isset($_GET['id'])) { $result['reply_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT); $reply = new Ticket_Reply(); $reply->load_With_TReplyId($result['reply_id']); $ticket = new Ticket(); $ticket->load_With_TId($reply->getTicket()); //check if the user is allowed to see the reply if ($ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId() && !$reply->getHidden() || Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) { $content = new Ticket_Content(); $content->load_With_TContentId($reply->getContent()); $author = new Ticket_User(); $author->load_With_TUserId($reply->getAuthor()); $result['hidden'] = $reply->getHidden(); $result['ticket_id'] = $reply->getTicket(); $result['reply_timestamp'] = $reply->getTimestamp(); $result['author_permission'] = $author->getPermission(); $result['reply_content'] = $content->getContent(); $result['author'] = $author->getExternId(); $webUser = new WebUsers($author->getExternId()); $result['authorName'] = $webUser->getUsername(); if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) { $result['isMod'] = "TRUE"; } global $INGAME_WEBPATH; $result['ingame_webpath'] = $INGAME_WEBPATH; return $result; } else { //ERROR: No access! $_SESSION['error_code'] = "403"; header("Cache-Control: max-age=1"); header("Location: index.php?page=error"); throw new SystemExit(); } } else { //ERROR: not logged in! header("Cache-Control: max-age=1"); header("Location: index.php"); throw new SystemExit(); } }
/** * create a new reply for a ticket. * A reply will only be added if the content isn't empty and if the ticket isn't closed. * The ticket creator will be notified by email that someone else replied on his ticket. * @param $content the content of the reply * @param $author the author of the reply * @param $ticket_id the id of the ticket to which we want to add the reply. * @param $hidden boolean that specifies if the reply should only be shown to mods/admins or all users. */ public static function createReply($content, $author, $ticket_id, $hidden) { //if not empty if (!(Trim($content) === '')) { $content = filter_var($content, FILTER_SANITIZE_STRING); $ticket = new Ticket(); $ticket->load_With_TId($ticket_id); //if status is not closed if ($ticket->getStatus() != 3) { Ticket_Reply::createReply($content, $author, $ticket_id, $hidden, $ticket->getAuthor()); //notify ticket author that a new reply is added! if ($ticket->getAuthor() != $author) { Mail_Handler::send_ticketing_mail($ticket->getAuthor(), $ticket, $content, "REPLY", $ticket->getForwardedGroupId()); } } else { //TODO: Show error message that ticket is closed } } else { //TODO: Show error content is empty } }