From 3e5222ff1b11fed732e17855be4c12a18088c920 Mon Sep 17 00:00:00 2001 From: Quitta Date: Thu, 11 Jul 2013 20:31:34 +0200 Subject: [PATCH] fixed upper info bar when showing ticket: which contains the initial time, the time passed since latest update, the status, the category and the priority. DB got updated, ticket has an extra priority field now, to make it easier for admins to make a distinction between tickets! Also made it possible for admins to change the status/priority when replying. --- .../ams_lib/autoload/gui_elements.php | 33 ++++ .../ryzom_ams/ams_lib/autoload/ticket.php | 75 ++++++-- .../ams_lib/autoload/ticket_reply.php | 14 +- .../www/html/func/reply_on_ticket.php | 6 +- .../ryzom_ams/www/html/inc/show_ticket.php | 8 + .../server/ryzom_ams/www/html/sql/install.php | 1 + .../www/html/templates/show_ticket.tpl | 163 +++++++++++++++++- 7 files changed, 271 insertions(+), 29 deletions(-) diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/gui_elements.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/gui_elements.php index 1a7dfc27c..e542c732f 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/gui_elements.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/gui_elements.php @@ -43,4 +43,37 @@ class Gui_Elements{ } return $result; } + + public static function time_elapsed_string($ptime){ + + $ttime = new DateTime($ptime); + $ptime = $ttime->getTimestamp(); + + $etime = time() - $ptime; + + if ($etime < 1) + { + return '0 seconds'; + } + + $a = array( 12 * 30 * 24 * 60 * 60 => 'year', + 30 * 24 * 60 * 60 => 'month', + 24 * 60 * 60 => 'day', + 60 * 60 => 'hour', + 60 => 'minute', + 1 => 'second' + ); + + foreach ($a as $secs => $str) + { + $d = $etime / $secs; + if ($d >= 1) + { + $r = round($d); + return $r . ' ' . $str . ($r > 1 ? 's' : '') . ' ago'; + } + } + } + + } \ No newline at end of file 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 5ac6499e5..ad5c0e4b0 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 @@ -8,21 +8,31 @@ class Ticket{ private $queue; private $ticket_category; private $author; + private $priority; - ////////////////////////////////////////////Functions//////////////////////////////////////////////////// + ////////////////////////////////////////////Functions//////////////////////////////////////////////////// - /*FUNCTION: getStatusArray - * returns all possible statusses - * - */ + /*FUNCTION: getStatusArray + * returns all possible statusses + * + */ public static function getStatusArray() { return Array("Waiting on user reply","Waiting on support","Waiting on Dev reply","Closed"); } - /*FUNCTION: getEntireTicket - * return all ticket of the given author's id. - * - */ + /*FUNCTION: getPriorityArray + * returns all possible statusses + * + */ + public static function getPriorityArray() { + return Array("Low","Normal","High","Super Dupa High"); + } + + + /*FUNCTION: getEntireTicket + * return all ticket of the given author's id. + * + */ public static function getEntireTicket($id) { $ticket = new Ticket(); $ticket->load_With_TId($id); @@ -62,14 +72,25 @@ class Ticket{ public static function create_Ticket( $title, $content, $category, $author) { $ticket = new Ticket(); - $ticket->set($title,1,0,$category,$author); + $ticket->set($title,1,0,$category,$author,0); $ticket->create(); $ticket_id = $ticket->getTId(); + Ticket_Reply::createReply($content, $author, $ticket_id); return $ticket_id; } + //return constructed element based on TCategoryId + public static function getLatestReply( $ticket_id) { + $dbl = new DBLayer("lib"); + $statement = $dbl->execute("SELECT * FROM ticket_reply WHERE Ticket =:id ORDER BY TReplyId DESC LIMIT 1 ", array('id' => $ticket_id)); + $reply = new Ticket_Reply(); + $reply->set($statement->fetch()); + return $reply; + } + + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// public function __construct() { @@ -77,19 +98,20 @@ class Ticket{ //Set ticket object - public function set($t,$s,$q,$t_c,$a){ + public function set($t,$s,$q,$t_c,$a,$p){ $this->title = $t; $this->status = $s; $this->queue = $q; $this->ticket_category = $t_c; $this->author = $a; + $this->priority = $p; } //create ticket by writing private data to DB. public function create(){ $dbl = new DBLayer("lib"); - $query = "INSERT INTO ticket (Timestamp, Title, Status, Queue, Ticket_Category, Author) VALUES (now(), :title, :status, :queue, :tcat, :author)"; - $values = Array('title' => $this->title, 'status' => $this->status, 'queue' => $this->queue, 'tcat' => $this->ticket_category, 'author' => $this->author); + $query = "INSERT INTO ticket (Timestamp, Title, Status, Queue, Ticket_Category, Author, Priority) VALUES (now(), :title, :status, :queue, :tcat, :author, :priority)"; + $values = Array('title' => $this->title, 'status' => $this->status, 'queue' => $this->queue, 'tcat' => $this->ticket_category, 'author' => $this->author, 'priority' => $this->priority); $this->tId = $dbl->executeReturnId($query, $values); ; } @@ -105,18 +127,24 @@ class Ticket{ $this->queue = $row['Queue']; $this->ticket_category = $row['Ticket_Category']; $this->author = $row['Author']; + $this->priority = $row['Priority']; } - //update private data to DB. public function update(){ $dbl = new DBLayer("lib"); - $query = "UPDATE ticket SET Timestamp = :timestamp, Title = :title, Status = :status, Queue = :queue, Ticket_Category = :tcat, Author = :author WHERE TId=:id"; - $values = Array('id' => $this->tId, 'timestamp' => $this->timestamp, 'title' => $this->title, 'status' => $this->status, 'queue' => $this->queue, 'tcat' => $this->ticket_category, 'author' => $this->author); + $query = "UPDATE ticket SET Timestamp = :timestamp, Title = :title, Status = :status, Queue = :queue, Ticket_Category = :tcat, Author = :author, Priority = :priority WHERE TId=:id"; + $values = Array('id' => $this->tId, 'timestamp' => $this->timestamp, 'title' => $this->title, 'status' => $this->status, 'queue' => $this->queue, 'tcat' => $this->ticket_category, 'author' => $this->author, 'priority' => $this->priority); $statement = $dbl->execute($query, $values); } - + /*FUNCTION: postreply + * returns all possible statusses + * + * + public function postReply() { + return Array("Waiting on user reply","Waiting on support","Waiting on Dev reply","Closed"); + }*/ ////////////////////////////////////////////Getters//////////////////////////////////////////////////// public function getTId(){ @@ -157,6 +185,15 @@ class Ticket{ return $this->author; } + public function getPriority(){ + return $this->priority; + } + + public function getPriorityText(){ + $priorityArray = Ticket::getPriorityArray(); + return $priorityArray[$this->getPriority()]; + } + ////////////////////////////////////////////Setters//////////////////////////////////////////////////// public function setTId($id){ @@ -187,4 +224,8 @@ class Ticket{ $this->author = $a; } + public function setPriority($p){ + $this->priority = $p; + } + } \ No newline at end of file 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 d21cdd2a7..b77d20a43 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 @@ -16,6 +16,7 @@ class Ticket_Reply{ return $instance; } + //return constructed element based on TCategoryId public static function getRepliesOfTicket( $ticket_id) { $dbl = new DBLayer("lib"); @@ -50,7 +51,7 @@ class Ticket_Reply{ $content_id = $ticket_content->getTContentId(); $ticket_reply = new Ticket_Reply(); - $ticket_reply->set($ticket_id, $content_id, $author); + $ticket_reply->set(Array('Ticket' => $ticket_id,'Content' => $content_id,'Author' => $author)); $ticket_reply->create(); } @@ -61,10 +62,13 @@ class Ticket_Reply{ //Set ticket_reply object - public function set($t,$c,$a){ - $this->setTicket($t); - $this->setContent($c); - $this->setAuthor($a); + public function set($values){ + $this->setTicket($values['Ticket']); + $this->setContent($values['Content']); + $this->setAuthor($values['Author']); + if(isset($values['Timestamp'])){ + $this->setTimestamp($values['Timestamp']); + } } //create ticket by writing private data to DB. diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/reply_on_ticket.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/reply_on_ticket.php index b6017670a..2e8178262 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/func/reply_on_ticket.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/reply_on_ticket.php @@ -17,11 +17,13 @@ function reply_on_ticket(){ $author = $_SESSION['ticket_user']->getTUserId(); Ticket_Reply::createReply($content, $author, $ticket_id); - if(isset($_POST['ChangeStatus']) && WebUsers::isAdmin()){ - $newStatus = filter_var($_POST['ChangeStatus'], FILTER_SANITIZE_NUMBER_INT); + if(isset($_POST['ChangeStatus']) && isset($_POST['ChangePriority']) && WebUsers::isAdmin()){ + $newStatus = filter_var($_POST['ChangeStatus'], FILTER_SANITIZE_NUMBER_INT); + $newPriority = filter_var($_POST['ChangePriority'], FILTER_SANITIZE_NUMBER_INT); $ticket = new Ticket(); $ticket->load_With_TId($ticket_id); $ticket->setStatus($newStatus); + $ticket->setPriority($newPriority); $ticket->update(); } header("Location: index.php?page=show_ticket&id=".$ticket_id); 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 f409e2cb0..a6ac5557e 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,6 +13,14 @@ 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_timestamp'] = $entire_ticket['ticket_obj']->getTimestamp(); + $result['ticket_status'] = $entire_ticket['ticket_obj']->getStatus(); + $result['ticket_prioritytext'] = $entire_ticket['ticket_obj']->getPriorityText(); + $result['ticket_priorities'] = Ticket::getPriorityArray(); + $result['ticket_priority'] = $entire_ticket['ticket_obj']->getPriority(); + $result['ticket_statustext'] = $entire_ticket['ticket_obj']->getStatusText(); + $result['ticket_lastupdate'] = Gui_Elements::time_elapsed_string(Ticket::getLatestReply($result['ticket_id'])->getTimestamp()); + $result['ticket_category'] = $entire_ticket['ticket_obj']->getCategoryName(); $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){ diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php b/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php index 09eca3684..d85328983 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/sql/install.php @@ -83,6 +83,7 @@ `Title` VARCHAR(120) NOT NULL , `Status` INT NULL DEFAULT 0 , `Queue` INT NULL DEFAULT 0 , + `Priority` INT NULL DEFAULT 0 , `Ticket_Category` INT NOT NULL , `Author` INT NOT NULL , PRIMARY KEY (`TId`) , 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 37444058e..3d3bf93b5 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} #{$ticket_tId}

@@ -11,12 +11,29 @@
{$title}: {$ticket_title} - + + + +
+ + + + + + + + + + +
Original Submitted: {$ticket_timestamp}Last Updated: {$ticket_lastupdate}Status: {if $ticket_status neq 3}Open{/if} {$ticket_statustext}
Category: {$ticket_category}Priority: {$ticket_prioritytext}Associated: Ticket#33
+ + + {foreach from=$ticket_replies item=reply}
-

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

{$reply.timestamp} {if $reply.permission eq '1'} {else if $reply.permission eq '2'} @@ -41,8 +58,8 @@ {if isset($isAdmin) and $isAdmin eq "TRUE"} -

- +
+
+
+ +
+ +
+
{/if} @@ -68,6 +95,132 @@
+ + + +
+
+

Tags

+
+ + +
+
+
+
+ + Tags + +
+ +
+
+
Hacked +
Botanic +
evilwebsite.comz +
keylogger +
+
+
+
+ +
+
+ +
+
+
+
+ +
+ +
+
+ +
+
+
+ + +
+
+

Groups

+
+ + +
+
+
+
+
+ Groups + +
+ +
+
+
Hacked accounts +
+
+
+
+ +
+
+ +
+
+
+
+ +
+ +
+
+
+
+
+
+ +
+
+

Associations

+
+ + +
+
+
+
+
+ Associations + +
+ +
+
+
Ticket #33 +
+
+
+
+ +
+
+ +
+
+
+
+ +
+ +
+
+
+
+
+
{/block}