2013-07-12 18:10:17 +00:00
|
|
|
<?php
|
2013-09-13 22:39:03 +00:00
|
|
|
/**
|
|
|
|
* This function is beign used to load info that's needed for the show_ticket_log page.
|
|
|
|
* This page shows the logs related to a ticket: who created the ticket, who replied on it, who viewed it, assigned or forwarded it.
|
|
|
|
* Only mods/admins are able to browse the log though. The found information is returned so it can be used by the template.
|
|
|
|
* @author Daan Janssens, mentored by Matthew Lagoe
|
|
|
|
*/
|
2013-07-12 18:10:17 +00:00
|
|
|
function show_ticket_log(){
|
2013-09-09 01:47:32 +00:00
|
|
|
global $INGAME_WEBPATH;
|
|
|
|
global $WEBPATH;
|
2013-07-13 01:46:15 +00:00
|
|
|
//if logged in
|
|
|
|
if(WebUsers::isLoggedIn() && isset($_GET['id'])){
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-07-14 14:38:36 +00:00
|
|
|
//only allow admins to browse the log!
|
2013-09-09 01:47:32 +00:00
|
|
|
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) ){
|
2014-09-03 05:06:43 +00:00
|
|
|
|
|
|
|
$result['ticket_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
|
2013-07-14 14:38:36 +00:00
|
|
|
$target_ticket = new Ticket();
|
|
|
|
$target_ticket->load_With_TId($result['ticket_id']);
|
2013-07-13 01:46:15 +00:00
|
|
|
$result['ticket_title'] = $target_ticket->getTitle();
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-09-13 22:39:03 +00:00
|
|
|
//return all logs related to a ticket.
|
2013-07-13 01:46:15 +00:00
|
|
|
$ticket_logs = Ticket_Log::getLogsOfTicket( $result['ticket_id']);
|
2013-07-13 14:41:52 +00:00
|
|
|
$log_action_array = Ticket_Log::getActionTextArray();
|
2013-09-13 22:39:03 +00:00
|
|
|
//fetch information about each returned ticket in a format that is usable for the template
|
2013-07-13 01:46:15 +00:00
|
|
|
$result['ticket_logs'] = Gui_Elements::make_table($ticket_logs, Array("getTLogId","getTimestamp","getAuthor()->getExternId","getAction","getArgument()"), Array("tLogId","timestamp","authorExtern","action","argument"));
|
|
|
|
$i = 0;
|
2013-09-13 22:39:03 +00:00
|
|
|
//for each ticket add action specific informaton to the to-be-shown text: uses the query_backpart
|
2013-07-13 01:46:15 +00:00
|
|
|
foreach( $result['ticket_logs'] as $log){
|
2013-08-05 15:31:36 +00:00
|
|
|
$webUser = new WebUsers($log['authorExtern']);
|
|
|
|
$author = $webUser->getUsername();
|
2013-07-13 14:41:52 +00:00
|
|
|
$result['ticket_logs'][$i]['author'] = $author;
|
|
|
|
$query_backpart = "";
|
|
|
|
if($log['action'] == 2){
|
2013-08-05 15:31:36 +00:00
|
|
|
$webUser2 = new WebUsers($log['argument']);
|
|
|
|
$query_backpart = $webUser2->getUsername();
|
2013-07-13 14:41:52 +00:00
|
|
|
}else if($log['action'] == 4){
|
2013-09-09 01:47:32 +00:00
|
|
|
if (Helpers::check_if_game_client()) {
|
|
|
|
$query_backpart = "<a href='".$INGAME_WEBPATH."?page=show_reply&id=" . $log['argument'] . "'>ID#" . $log['argument'] . "</a>";
|
|
|
|
}else{
|
|
|
|
$query_backpart = "<a href='".$WEBPATH."?page=show_reply&id=" . $log['argument'] . "'>ID#" . $log['argument'] . "</a>";
|
|
|
|
}
|
2013-07-13 14:41:52 +00:00
|
|
|
}else if($log['action'] == 5){
|
|
|
|
$statusArray = Ticket::getStatusArray();
|
|
|
|
$query_backpart = $statusArray[$log['argument'] ];
|
|
|
|
}else if($log['action'] == 6){
|
|
|
|
$priorityArray = Ticket::getPriorityArray();
|
|
|
|
$query_backpart = $priorityArray[$log['argument'] ];
|
2013-07-22 18:33:34 +00:00
|
|
|
}else if($log['action'] == 8){
|
2013-09-09 01:47:32 +00:00
|
|
|
if (Helpers::check_if_game_client()) {
|
|
|
|
$query_backpart = "<a href='".$INGAME_WEBPATH."?page=show_sgroupy&id=" . $log['argument'] . "'>" . Support_Group::getGroup($log['argument'])->getName() . "</a>";
|
|
|
|
}else{
|
|
|
|
$query_backpart = "<a href='".$WEBPATH."?page=show_sgroupy&id=" . $log['argument'] . "'>" . Support_Group::getGroup($log['argument'])->getName() . "</a>";
|
|
|
|
}
|
2013-07-13 14:41:52 +00:00
|
|
|
}
|
|
|
|
$result['ticket_logs'][$i]['query'] = $author . " " . $log_action_array[$log['action']] . " " . $query_backpart;
|
2013-07-13 16:04:40 +00:00
|
|
|
$result['ticket_logs'][$i]['timestamp_elapsed'] = Gui_Elements::time_elapsed_string($log['timestamp']);
|
2013-07-13 01:46:15 +00:00
|
|
|
$i++;
|
2014-09-03 05:06:43 +00:00
|
|
|
}
|
2013-09-09 01:47:32 +00:00
|
|
|
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
|
2013-07-18 19:12:03 +00:00
|
|
|
$result['isMod'] = "TRUE";
|
2013-07-13 01:46:15 +00:00
|
|
|
}
|
2013-09-09 01:47:32 +00:00
|
|
|
global $INGAME_WEBPATH;
|
|
|
|
$result['ingame_webpath'] = $INGAME_WEBPATH;
|
2013-07-13 01:46:15 +00:00
|
|
|
return $result;
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-07-13 01:46:15 +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-13 01:46:15 +00:00
|
|
|
header("Location: index.php?page=error");
|
2014-09-03 05:23:39 +00:00
|
|
|
throw new SystemExit();
|
2013-07-13 01:46:15 +00:00
|
|
|
}
|
|
|
|
}else{
|
|
|
|
//ERROR: not logged in!
|
2014-09-03 05:36:10 +00:00
|
|
|
header("Cache-Control: max-age=1");
|
2013-07-13 01:46:15 +00:00
|
|
|
header("Location: index.php");
|
2014-09-03 05:23:39 +00:00
|
|
|
throw new SystemExit();
|
2014-09-03 05:06:43 +00:00
|
|
|
}
|
|
|
|
}
|