Linux multi-monitor fullscreen support
[ryzomcore.git] / web / public_php / ams / func / reply_on_ticket.php
blob41845f03ad806435151f8ef9cb5a36216feb5d7b
1 <?php
2 /**
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
8 */
9 function reply_on_ticket(){
10 global $INGAME_WEBPATH;
11 global $WEBPATH;
12 //if logged in
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'])) ){
22 try{
23 $author = unserialize($_SESSION['ticket_user'])->getTUserId();
24 if(isset($_POST['Content'])){
25 $content = $_POST['Content'];
26 }else{
27 $content="";
29 $hidden = 0;
31 if(isset($_POST['hidden']) && Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
32 $hidden = 1;
35 //create the reply
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);
47 }else{
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!
54 print_r($e);
55 //header("Location: index.php");
56 throw new SystemExit();
59 }else{
60 //ERROR: No access!
61 $_SESSION['error_code'] = "403";
62 header("Cache-Control: max-age=1");
63 header("Location: index.php?page=error");
64 throw new SystemExit();
66 }else{
67 //ERROR: not logged in!
68 header("Cache-Control: max-age=1");
69 header("Location: index.php");
70 throw new SystemExit();