3 * This function is beign used to reply on a ticket.
4 * It will first check if the user who executed this function is a mod/admin or the topic creator himself. If this is not the case the page will be redirected to an error page.
5 * in case the isset($_POST['hidden'] is set and the user is a mod, the message will be hidden for the topic starter. The reply will be created. If $_POST['ChangeStatus']) & $_POST['ChangePriority'] is set
6 * it will try to update the status and priority. Afterwards the page is being redirecte to the ticket again.
7 * @author Daan Janssens, mentored by Matthew Lagoe
9 function reply_on_ticket(){
10 global $INGAME_WEBPATH;
13 if(WebUsers
::isLoggedIn() && isset($_POST['ticket_id'])){
15 $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT
);
16 $target_ticket = new Ticket();
17 $target_ticket->load_With_TId($ticket_id);
19 //check if the user who executed this function is a mod/admin or the topic creator himself.
20 if(($target_ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId()) || Ticket_User
::isMod(unserialize($_SESSION['ticket_user'])) ){
23 $author = unserialize($_SESSION['ticket_user'])->getTUserId();
24 if(isset($_POST['Content'])){
25 $content = $_POST['Content'];
31 if(isset($_POST['hidden']) && Ticket_User
::isMod(unserialize($_SESSION['ticket_user']))){
36 Ticket
::createReply($content, $author, $ticket_id, $hidden);
38 //try to update the status & priority in case these are set.
39 if(isset($_POST['ChangeStatus']) && isset($_POST['ChangePriority']) && Ticket_User
::isMod(unserialize($_SESSION['ticket_user']))){
40 $newStatus = filter_var($_POST['ChangeStatus'], FILTER_SANITIZE_NUMBER_INT
);
41 $newPriority = filter_var($_POST['ChangePriority'], FILTER_SANITIZE_NUMBER_INT
);
42 Ticket
::updateTicketStatusAndPriority($ticket_id,$newStatus, $newPriority, $author);
44 header("Cache-Control: max-age=1");
45 if (Helpers
::check_if_game_client()) {
46 header("Location: ".$INGAME_WEBPATH."?page=show_ticket&id=".$ticket_id);
48 header("Location: ".$WEBPATH."?page=show_ticket&id=".$ticket_id);
50 throw new SystemExit();
52 }catch (PDOException
$e) {
53 //ERROR: LIB DB is not online!
55 //header("Location: index.php");
56 throw new SystemExit();
61 $_SESSION['error_code'] = "403";
62 header("Cache-Control: max-age=1");
63 header("Location: index.php?page=error");
64 throw new SystemExit();
67 //ERROR: not logged in!
68 header("Cache-Control: max-age=1");
69 header("Location: index.php");
70 throw new SystemExit();