From 5a8f45f88c2667642221463affa2036ed788cd13 Mon Sep 17 00:00:00 2001 From: Quitta Date: Sun, 14 Jul 2013 22:33:09 +0200 Subject: [PATCH] # ticket queues, though moving away from this approach --HG-- branch : quitta-gsoc-2013 --- .../ams_lib/autoload/ticket_queue.php | 2 +- .../ams_lib/autoload/ticket_queue_csr.php | 11 +++++ .../ams_lib/autoload/ticket_queue_handler.php | 29 ++++++++++++++ .../ryzom_ams/www/html/inc/show_queue.php | 40 +++++++++---------- 4 files changed, 59 insertions(+), 23 deletions(-) create mode 100644 code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue_csr.php create mode 100644 code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue_handler.php diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue.php index 0907a7014..619833e2d 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue.php @@ -1,7 +1,7 @@ executeWithoutParams("SELECT ticket . * FROM ticket LEFT JOIN assigned ON ticket.TId = assigned.Ticket WHERE assigned.Ticket IS NULL"); + $rows = $statement->fetchAll(); + $this->setQueue($rows); + } + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue_handler.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue_handler.php new file mode 100644 index 000000000..0b704d1e2 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue_handler.php @@ -0,0 +1,29 @@ +loadAllOpenTickets(); + break; + case "archive": + $queue->loadAllClosedTickets(); + break; + default: + return "ERROR"; + } + + return $queue->getTickets(); + } +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_queue.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_queue.php index 59e95879f..a60619c04 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_queue.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_queue.php @@ -6,30 +6,26 @@ function show_queue(){ if(WebUsers::isLoggedIn() && isset($_GET['get'])){ if( WebUsers::isAdmin()){ $result['queue_action'] = filter_var($_GET['get'], FILTER_SANITIZE_STRING); - - $queue = new Ticket_Queue(); - - switch ($result['queue_action']){ - case "all_open": - $queue->loadAllOpenTickets(); - break; - case "archive": - $queue->loadAllClosedTickets(); - break; - } - $queueArray = $queue->getTickets(); - $result['tickets'] = Gui_Elements::make_table($queueArray, Array("getTId","getTitle","getTimestamp","getAuthor()->getExternId","getTicket_Category()->getName","getStatus","getStatusText"), Array("tId","title","timestamp","authorExtern","category","status","statusText")); - - $i = 0; - foreach( $result['tickets'] as $ticket){ - $result['tickets'][$i]['author'] = WebUsers::getUsername($ticket['authorExtern']); - $i++; - } - if(WebUsers::isAdmin()){ - $result['isAdmin'] = "TRUE"; + $queueArray = Ticket_Queue_Handler::getTickets($result['queue_action'],2); + if ($queueArray != "ERROR"){ + $result['tickets'] = Gui_Elements::make_table($queueArray, Array("getTId","getTitle","getTimestamp","getAuthor()->getExternId","getTicket_Category()->getName","getStatus","getStatusText"), Array("tId","title","timestamp","authorExtern","category","status","statusText")); + + $i = 0; + foreach( $result['tickets'] as $ticket){ + $result['tickets'][$i]['author'] = WebUsers::getUsername($ticket['authorExtern']); + $i++; + } + if(WebUsers::isAdmin()){ + $result['isAdmin'] = "TRUE"; + } + return $result; + }else{ + //ERROR: Doesn't exist! + $_SESSION['error_code'] = "404"; + header("Location: index.php?page=error"); + exit; } - return $result; }else{ //ERROR: No access!