From ab323a9c6bcfab033dfa4f470a9ef961f26c38f5 Mon Sep 17 00:00:00 2001 From: Quitta Date: Tue, 9 Jul 2013 01:03:49 +0200 Subject: [PATCH] Show the user his tickets in the user profile screen --- .../ryzom_ams/ams_lib/autoload/ticket.php | 23 +++++++++++ .../ryzom_ams/www/html/inc/show_user.php | 30 +++++++++++++- .../ryzom_ams/www/html/templates/layout.tpl | 1 + .../www/html/templates/layout_admin.tpl | 1 + .../www/html/templates/layout_user.tpl | 1 + .../www/html/templates/show_user.tpl | 39 +++++++++++++++++++ 6 files changed, 94 insertions(+), 1 deletion(-) diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket.php index ec34ceaa3..f8f9f10e3 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket.php @@ -12,6 +12,29 @@ class Ticket{ ////////////////////////////////////////////Functions//////////////////////////////////////////////////// + /*FUNCTION: getTicketTitlesOf() + * return all ticket of the given author's id. + * + */ + public static function getTicketsOf($author, $db_data) { + $dbl = new DBLayer($db_data); + $statement = $dbl->execute("SELECT * FROM ticket INNER JOIN ticket_user ON ticket.Author = ticket_user.TUserId and ticket_user.ExternId=:id", array('id' => $author)); + $row = $statement->fetchAll(); + $result = Array(); + foreach($row as $ticket){ + $instance = new self($db_data); + $instance->setTimestamp($ticket['Timestamp']); + $instance->setTitle($ticket['Title']); + $instance->setStatus($ticket['Status']); + $instance->setQueue($ticket['Queue']); + $instance->setTicket_Category($ticket['Ticket_Category']); + $instance->setAuthor($ticket['Author']); + $result[] = $instance; + } + return $result; + } + + /*FUNCTION: create_Ticket() * creates a ticket + first initial reply and fills in the content of it! * diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_user.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_user.php index 7e802cee8..a0d9c9132 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_user.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_user.php @@ -4,7 +4,7 @@ function show_user(){ //if logged in if(WebUsers::isLoggedIn()){ - if(WebUsers::isAdmin()){ + if( !isset($_GET['id']) || WebUsers::isAdmin() || $_GET['id'] == $_SESSION['id'] ){ if(isset($_GET['id'])){ $result['target_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT); @@ -19,6 +19,34 @@ function show_user(){ $result['country'] = $info['Country']; $result['gender'] = $info['Gender']; + global $cfg; + $ticket_user = Ticket_User::constr_ExternId($result['target_id'],$cfg['db']['lib']); + $ticketlist = Ticket::getTicketsOf($ticket_user->getTUserId(),$cfg['db']['lib']); + $i = 0; + $result['ticketlist'] = Array(); + foreach($ticketlist as $ticket){ + $result['ticketlist'][$i]['tId'] = $ticket->getTId(); + $result['ticketlist'][$i]['timestamp'] = $ticket->getTimestamp(); + $result['ticketlist'][$i]['title'] = $ticket->getTitle(); + + //get the status + $statusId = $ticket->getStatus(); + if ($statusId == 0){ + $status = "Waiting on support.."; + }else if($statusId == 1){ + $status = "Being handled.."; + }else if($statusId == 2){ + $status = "Closed"; + } + + $result['ticketlist'][$i]['statusText'] = $status; + $result['ticketlist'][$i]['status'] = $statusId; + //get the category + $category = Ticket_Category::constr_TCategoryId($ticket->getTicket_Category(), $cfg['db']['lib']); + $result['ticketlist'][$i]['category'] = $category->getName(); + $i++; + } + return $result; }else{ diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl index 1316aca7d..32088c7b8 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout.tpl @@ -96,6 +96,7 @@ diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_admin.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_admin.tpl index aaa625a7d..cd7bc60ad 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_admin.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_admin.tpl @@ -2,6 +2,7 @@ {block name=menu}
  • Dashboard
  • +
  • Profile
  • Settings
  • Liblist
  • diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_user.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_user.tpl index 8195658d0..8da6ca313 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_user.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/layout_user.tpl @@ -2,6 +2,7 @@ {block name=menu}
  • Dashboard
  • +
  • Profile
  • Settings
  • Create New Ticket
  • diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_user.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_user.tpl index 2e07ec91d..0b2a57c2b 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_user.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_user.tpl @@ -74,5 +74,44 @@ + +
    +
    +
    +

    Tickets of {$target_name}

    +
    + + +
    +
    +
    +
    + Tickets + + + + + + + + + + + {foreach from=$ticketlist item=ticket} + + + + + + + + {/foreach} + + +
    TitleTimestampCategoryStatus
    {$ticket.title}{$ticket.timestamp}{$ticket.category}{$ticket.statusText}
    +
    +
    +
    +
    {/block}