2013-07-10 18:46:26 +00:00
|
|
|
<?php
|
2013-09-13 22:39:03 +00:00
|
|
|
/**
|
|
|
|
* This function is beign used to reply on a ticket.
|
|
|
|
* 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.
|
|
|
|
* 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
|
|
|
|
* it will try to update the status and priority. Afterwards the page is being redirecte to the ticket again.
|
|
|
|
* @author Daan Janssens, mentored by Matthew Lagoe
|
|
|
|
*/
|
2013-07-10 18:46:26 +00:00
|
|
|
function reply_on_ticket(){
|
2013-09-09 01:47:32 +00:00
|
|
|
global $INGAME_WEBPATH;
|
|
|
|
global $WEBPATH;
|
|
|
|
//if logged in
|
2013-07-10 18:46:26 +00:00
|
|
|
if(WebUsers::isLoggedIn() && isset($_POST['ticket_id'])){
|
2014-09-03 05:06:43 +00:00
|
|
|
|
|
|
|
$ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT);
|
2013-07-10 18:46:26 +00:00
|
|
|
$target_ticket = new Ticket();
|
|
|
|
$target_ticket->load_With_TId($ticket_id);
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-09-13 22:39:03 +00:00
|
|
|
//check if the user who executed this function is a mod/admin or the topic creator himself.
|
2013-09-09 01:47:32 +00:00
|
|
|
if(($target_ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId()) || Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) ){
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-07-10 18:46:26 +00:00
|
|
|
try{
|
2013-09-09 01:47:32 +00:00
|
|
|
$author = unserialize($_SESSION['ticket_user'])->getTUserId();
|
|
|
|
if(isset($_POST['Content'])){
|
|
|
|
$content = $_POST['Content'];
|
|
|
|
}else{
|
|
|
|
$content="";
|
|
|
|
}
|
2013-07-19 13:59:39 +00:00
|
|
|
$hidden = 0;
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-09-09 01:47:32 +00:00
|
|
|
if(isset($_POST['hidden']) && Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
|
2013-07-19 13:59:39 +00:00
|
|
|
$hidden = 1;
|
|
|
|
}
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-09-13 22:39:03 +00:00
|
|
|
//create the reply
|
2013-07-19 13:59:39 +00:00
|
|
|
Ticket::createReply($content, $author, $ticket_id, $hidden);
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-09-13 22:39:03 +00:00
|
|
|
//try to update the status & priority in case these are set.
|
2013-09-09 01:47:32 +00:00
|
|
|
if(isset($_POST['ChangeStatus']) && isset($_POST['ChangePriority']) && Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
|
2013-07-11 18:31:34 +00:00
|
|
|
$newStatus = filter_var($_POST['ChangeStatus'], FILTER_SANITIZE_NUMBER_INT);
|
2014-09-03 05:06:43 +00:00
|
|
|
$newPriority = filter_var($_POST['ChangePriority'], FILTER_SANITIZE_NUMBER_INT);
|
2013-07-12 17:43:33 +00:00
|
|
|
Ticket::updateTicketStatusAndPriority($ticket_id,$newStatus, $newPriority, $author);
|
2013-07-11 00:39:52 +00:00
|
|
|
}
|
2014-09-03 05:36:10 +00:00
|
|
|
header("Cache-Control: max-age=1");
|
2013-09-09 01:47:32 +00:00
|
|
|
if (Helpers::check_if_game_client()) {
|
|
|
|
header("Location: ".$INGAME_WEBPATH."?page=show_ticket&id=".$ticket_id);
|
|
|
|
}else{
|
|
|
|
header("Location: ".$WEBPATH."?page=show_ticket&id=".$ticket_id);
|
|
|
|
}
|
2014-09-03 05:23:39 +00:00
|
|
|
throw new SystemExit();
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-07-10 18:46:26 +00:00
|
|
|
}catch (PDOException $e) {
|
|
|
|
//ERROR: LIB DB is not online!
|
2013-08-13 15:16:43 +00:00
|
|
|
print_r($e);
|
|
|
|
//header("Location: index.php");
|
2014-09-03 05:23:39 +00:00
|
|
|
throw new SystemExit();
|
2013-07-10 18:46:26 +00:00
|
|
|
}
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-07-10 18:46:26 +00:00
|
|
|
}else{
|
|
|
|
//ERROR: No access!
|
|
|
|
$_SESSION['error_code'] = "403";
|
2014-09-03 05:36:10 +00:00
|
|
|
header("Cache-Control: max-age=1");
|
2013-07-10 18:46:26 +00:00
|
|
|
header("Location: index.php?page=error");
|
2014-09-03 05:23:39 +00:00
|
|
|
throw new SystemExit();
|
2013-07-10 18:46:26 +00:00
|
|
|
}
|
|
|
|
}else{
|
|
|
|
//ERROR: not logged in!
|
2014-09-03 05:36:10 +00:00
|
|
|
header("Cache-Control: max-age=1");
|
2013-07-10 18:46:26 +00:00
|
|
|
header("Location: index.php");
|
2014-09-03 05:23:39 +00:00
|
|
|
throw new SystemExit();
|
2013-07-10 18:46:26 +00:00
|
|
|
}
|
2014-09-03 05:06:43 +00:00
|
|
|
|
|
|
|
}
|