3 * This function is beign used to load info that's needed for the show_ticket_log page.
4 * This page shows the logs related to a ticket: who created the ticket, who replied on it, who viewed it, assigned or forwarded it.
5 * Only mods/admins are able to browse the log though. The found information is returned so it can be used by the template.
6 * @author Daan Janssens, mentored by Matthew Lagoe
8 function show_ticket_log(){
9 global $INGAME_WEBPATH;
12 if(WebUsers
::isLoggedIn() && isset($_GET['id'])){
14 //only allow admins to browse the log!
15 if(Ticket_User
::isMod(unserialize($_SESSION['ticket_user'])) ){
17 $result['ticket_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT
);
18 $target_ticket = new Ticket();
19 $target_ticket->load_With_TId($result['ticket_id']);
20 $result['ticket_title'] = $target_ticket->getTitle();
22 //return all logs related to a ticket.
23 $ticket_logs = Ticket_Log
::getLogsOfTicket( $result['ticket_id']);
24 $log_action_array = Ticket_Log
::getActionTextArray();
25 //fetch information about each returned ticket in a format that is usable for the template
26 $result['ticket_logs'] = Gui_Elements
::make_table($ticket_logs, Array("getTLogId","getTimestamp","getAuthor()->getExternId","getAction","getArgument()"), Array("tLogId","timestamp","authorExtern","action","argument"));
28 //for each ticket add action specific informaton to the to-be-shown text: uses the query_backpart
29 foreach( $result['ticket_logs'] as $log){
30 $webUser = new WebUsers($log['authorExtern']);
31 $author = $webUser->getUsername();
32 $result['ticket_logs'][$i]['author'] = $author;
34 if($log['action'] == 2){
35 $webUser2 = new WebUsers($log['argument']);
36 $query_backpart = $webUser2->getUsername();
37 }else if($log['action'] == 4){
38 if (Helpers
::check_if_game_client()) {
39 $query_backpart = "<a href='".$INGAME_WEBPATH."?page=show_reply&id=" . $log['argument'] . "'>ID#" . $log['argument'] . "</a>";
41 $query_backpart = "<a href='".$WEBPATH."?page=show_reply&id=" . $log['argument'] . "'>ID#" . $log['argument'] . "</a>";
43 }else if($log['action'] == 5){
44 $statusArray = Ticket
::getStatusArray();
45 $query_backpart = $statusArray[$log['argument'] ];
46 }else if($log['action'] == 6){
47 $priorityArray = Ticket
::getPriorityArray();
48 $query_backpart = $priorityArray[$log['argument'] ];
49 }else if($log['action'] == 8){
50 if (Helpers
::check_if_game_client()) {
51 $query_backpart = "<a href='".$INGAME_WEBPATH."?page=show_sgroupy&id=" . $log['argument'] . "'>" . Support_Group
::getGroup($log['argument'])->getName() . "</a>";
53 $query_backpart = "<a href='".$WEBPATH."?page=show_sgroupy&id=" . $log['argument'] . "'>" . Support_Group
::getGroup($log['argument'])->getName() . "</a>";
56 $result['ticket_logs'][$i]['query'] = $author . " " . $log_action_array[$log['action']] . " " . $query_backpart;
57 $result['ticket_logs'][$i]['timestamp_elapsed'] = Gui_Elements
::time_elapsed_string($log['timestamp']);
60 if(Ticket_User
::isMod(unserialize($_SESSION['ticket_user']))){
61 $result['isMod'] = "TRUE";
63 global $INGAME_WEBPATH;
64 $result['ingame_webpath'] = $INGAME_WEBPATH;
69 $_SESSION['error_code'] = "403";
70 header("Cache-Control: max-age=1");
71 header("Location: index.php?page=error");
72 throw new SystemExit();
75 //ERROR: not logged in!
76 header("Cache-Control: max-age=1");
77 header("Location: index.php");
78 throw new SystemExit();