diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_log.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_log.php index bffbec7b9..1f7c03158 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_log.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_log.php @@ -22,6 +22,28 @@ class Ticket_Log{ ////////////////////////////////////////////Functions//////////////////////////////////////////////////// + //return all logs that are related to a ticket + public static function getLogsOfTicket( $ticket_id) { + $dbl = new DBLayer("lib"); + $statement = $dbl->execute("SELECT * FROM ticket_log INNER JOIN ticket_user ON ticket_log.Author = ticket_user.TUserId and ticket_log.Ticket=:id ORDER BY ticket_log.TLogId DESC", array('id' => $ticket_id)); + $row = $statement->fetchAll(); + $result = Array(); + foreach($row as $log){ + $instanceAuthor = Ticket_User::constr_TUserId($log['Author']); + $instanceAuthor->setExternId($log['ExternId']); + $instanceAuthor->setPermission($log['Permission']); + + $instanceLog = new self(); + $instanceLog->setTLogId($log['TLogId']); + $instanceLog->setTimestamp($log['Timestamp']); + $instanceLog->setAuthor($instanceAuthor); + $instanceLog->setTicket($ticket_id); + $instanceLog->setQuery($log['Query']); + + $result[] = $instanceLog; + } + return $result; + } //Creates a log entry public static function createLogEntry( $ticket_id, $author_id, $action, $arg = -1) { @@ -110,13 +132,13 @@ class Ticket_Log{ return $this->ticket; } - public function getAcion(){ - $decodedQuery = json_decode($this->ticket); + public function getAction(){ + $decodedQuery = json_decode($this->query); return $decodedQuery[0]; } public function getArgument(){ - $decodedQuery = json_decode($this->ticket); + $decodedQuery = json_decode($this->query); return $decodedQuery[1]; } diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_ticket_log.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_ticket_log.php index 470543802..48cd3eff7 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_ticket_log.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_ticket_log.php @@ -1,6 +1,38 @@ load_With_TId($result['ticket_id']); + + if(($target_ticket->getAuthor() == $_SESSION['ticket_user']->getTUserId()) || WebUsers::isAdmin() ){ + + $result['ticket_title'] = $target_ticket->getTitle(); + $ticket_logs = Ticket_Log::getLogsOfTicket( $result['ticket_id']); + $result['ticket_logs'] = Gui_Elements::make_table($ticket_logs, Array("getTLogId","getTimestamp","getAuthor()->getExternId","getAction","getArgument()"), Array("tLogId","timestamp","authorExtern","action","argument")); + $i = 0; + foreach( $result['ticket_logs'] as $log){ + $result['ticket_logs'][$i]['author'] = WebUsers::getUsername($log['authorExtern']); + $i++; + } + if(WebUsers::isAdmin()){ + $result['isAdmin'] = "TRUE"; + } + return $result; + + }else{ + //ERROR: No access! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + } + }else{ + //ERROR: not logged in! + header("Location: index.php"); + exit; + } } \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_ticket_log.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_ticket_log.tpl index 75f1f148b..a075faf50 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_ticket_log.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_ticket_log.tpl @@ -2,7 +2,7 @@
-

Tickets of {$target_name}

+

Log of Ticket #{$ticket_id}

@@ -10,26 +10,26 @@
- Tickets + Title: {$ticket_title} - - - + + + - {foreach from=$ticketlist item=ticket} + {foreach from=$ticket_logs item=log} - - - - + + + + + - {/foreach}
IDTitle TimestampCategoryStatusUserActionArgument
{$ticket.tId}{$ticket.title}{$ticket.timestamp}{$ticket.category}{$log.tLogId}{$log.timestamp}{$log.author}{$log.action}{$log.argument}{if $ticket.status eq 0} {/if} {$ticket.statusText}