From e1a7e13c4e874c6d6451f11c16190fb3293cff0f Mon Sep 17 00:00:00 2001 From: Quitta Date: Wed, 10 Jul 2013 22:40:01 +0200 Subject: [PATCH] ticket reply show correct username, this was harder then expected --- .../ryzom_ams/ams_lib/autoload/ticket_reply.php | 14 +++++++++----- .../ryzom_ams/ams_lib/autoload/ticket_user.php | 11 +++++------ .../server/ryzom_ams/www/html/inc/show_ticket.php | 7 ++++++- .../ryzom_ams/www/html/templates/show_ticket.tpl | 10 ++++++++-- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_reply.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_reply.php index e58484a06..d21cdd2a7 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_reply.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_reply.php @@ -19,19 +19,23 @@ class Ticket_Reply{ //return constructed element based on TCategoryId public static function getRepliesOfTicket( $ticket_id) { $dbl = new DBLayer("lib"); - $statement = $dbl->execute("SELECT * FROM ticket_reply INNER JOIN ticket_content ON ticket_reply.Content = ticket_content.TContentId and ticket_reply.Ticket=:id", array('id' => $ticket_id)); + $statement = $dbl->execute("SELECT * FROM ticket_reply INNER JOIN ticket_content INNER JOIN ticket_user ON ticket_reply.Content = ticket_content.TContentId and ticket_reply.Ticket=:id and ticket_user.TUserId = ticket_reply.Author ORDER BY ticket_reply.TReplyId ASC", array('id' => $ticket_id)); $row = $statement->fetchAll(); $result = Array(); foreach($row as $tReply){ - $instanceReply = new self(); - $instanceReply->setTReplyId($tReply['TReplyId']); - $instanceReply->setTimestamp($tReply['Timestamp']); - $instanceReply->set($tReply['Ticket'],$tReply['Content'],$tReply['Author']); + $instanceAuthor = Ticket_User::constr_TUserId($tReply['Author']); + $instanceAuthor->setExternId($tReply['ExternId']); + $instanceAuthor->setPermission($tReply['Permission']); $instanceContent = new Ticket_Content(); $instanceContent->setTContentId($tReply['TContentId']); $instanceContent->setContent($tReply['Content']); + $instanceReply = new self(); + $instanceReply->setTReplyId($tReply['TReplyId']); + $instanceReply->setTimestamp($tReply['Timestamp']); + $instanceReply->setAuthor($instanceAuthor); + $instanceReply->setTicket($ticket_id); $instanceReply->setContent($instanceContent); $result[] = $instanceReply; diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_user.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_user.php index 32ad604f5..506cc4193 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_user.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_user.php @@ -65,17 +65,11 @@ class Ticket_User{ ////////////////////////////////////////////Getters//////////////////////////////////////////////////// public function getPermission(){ - if ($this->permission == ""){ - $this->load_With_TUserId($this->tUserId); - } return $this->permission; } public function getExternId(){ - if ($this->ExternId == ""){ - $this->load_With_TUserId($this->tUserId); - } return $this->externId; } @@ -96,4 +90,9 @@ class Ticket_User{ $this->externId = $id; } + public function setTUserId($id){ + $this->tUserId= $id; + } + + } \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_ticket.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_ticket.php index 919d38ca8..93654d126 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_ticket.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_ticket.php @@ -13,7 +13,12 @@ function show_ticket(){ $entire_ticket = Ticket::getEntireTicket( $result['ticket_id']); $result['ticket_tId'] = $entire_ticket['ticket_obj']->getTId(); $result['ticket_title'] = $entire_ticket['ticket_obj']->getTitle(); - $result['ticket_replies'] = Gui_Elements::make_table($entire_ticket['reply_array'], Array("getTReplyId","getContent()->getContent","getTimestamp"), Array("tReplyId","replyContent","timestamp")); + $result['ticket_replies'] = Gui_Elements::make_table($entire_ticket['reply_array'], Array("getTReplyId","getContent()->getContent","getTimestamp","getAuthor()->getExternId","getAuthor()->getPermission"), Array("tReplyId","replyContent","timestamp","authorExtern","permission")); + $i = 0; + foreach( $result['ticket_replies'] as $reply){ + $result['ticket_replies'][$i]['author'] = WebUsers::getUsername($reply['authorExtern']); + $i++; + } return $result; }else{ diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_ticket.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_ticket.tpl index 09967552b..22d8f8c46 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_ticket.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_ticket.tpl @@ -2,7 +2,7 @@
-

{$t_title}[ID#{$ticket_tId}]

+

{$t_title}[ID#{$ticket_tId}]

@@ -16,7 +16,13 @@ {foreach from=$ticket_replies item=reply} -

[ID#{$reply.tReplyId}] {$reply.timestamp} {$username}

+

[ID#{$reply.tReplyId}] {$reply.timestamp} + {if $reply.permission eq '1'} + + {else if $reply.permission eq '2'} + [CSR] + {/if} + {$reply.author}

{$reply.replyContent}