From 2d863042e58b08c2de8a80576f02ea818e900a9f Mon Sep 17 00:00:00 2001 From: Quitta Date: Tue, 6 Aug 2013 01:00:17 +0200 Subject: [PATCH] I think I'm done refactoring the queues --- .../ryzom_ams/ams_lib/autoload/ticket.php | 3 +- .../ams_lib/autoload/ticket_queue.php | 6 +-- .../ams_lib/autoload/ticket_queue_handler.php | 37 +++++++++------ .../ryzom_ams/www/html/func/create_ticket.php | 4 +- .../ryzom_ams/www/html/inc/show_queue.php | 46 +++++++++++++++---- .../ryzom_ams/www/html/inc/show_ticket.php | 1 + .../www/html/templates/show_queue.tpl | 38 +++++++++------ .../www/html/templates/show_ticket.tpl | 2 +- 8 files changed, 92 insertions(+), 45 deletions(-) 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 26c131e33..e6961b9b8 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 @@ -86,7 +86,8 @@ class Ticket{ public static function create_Ticket( $title, $content, $category, $author, $real_author) { $ticket = new Ticket(); - $ticket->set($title,1,0,$category,$author,0); + $values = array("Title" => $title, "Status"=> 1, "Queue"=> 0, "Ticket_Category" => $category, "Author" => $author, "Priority" => 0); + $ticket->set($values); $ticket->create(); $ticket_id = $ticket->getTId(); 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 9f8fb2ce6..8751efbaa 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 @@ -40,7 +40,6 @@ class Ticket_Queue{ } public function createQueue($userid, $groupid, $what, $how, $who){ - $dbl = new DBLayer("lib"); if($who == "user"){ $selectfrom = "SELECT * FROM `ticket` t LEFT JOIN `assigned` a ON t.TId = a.Ticket LEFT JOIN `ticket_user` tu ON tu.TUserId = a.User"; @@ -76,9 +75,8 @@ class Ticket_Queue{ }else if ($who == "support_group"){ $params = array('id' => $groupid); } - $statement = $dbl->execute($query, $params); - $rows = $statement->fetchAll(); - $this->setQueue($rows); + $this->query = $query; + $this->params = $params; } public function getQuery(){ 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 index 24257c087..15b3b6acd 100644 --- 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 @@ -3,31 +3,37 @@ class Ticket_Queue_Handler{ private $pagination; + private $queue; + + function __construct() { + $this->queue = new Ticket_Queue(); + } public function getTickets($input, $user_id){ - $queue = new Ticket_Queue(); - switch ($input){ case "all": - $queue->loadAllTickets(); + $this->queue->loadAllTickets(); break; case "all_open": - $queue->loadAllOpenTickets(); + $this->queue->loadAllOpenTickets(); break; case "archive": - $queue->loadAllClosedTickets(); + $this->queue->loadAllClosedTickets(); break; case "not_assigned": - $queue->loadAllNotAssignedTickets(); + $this->queue->loadAllNotAssignedTickets(); break; case "todo": - $queue->loadToDoTickets($user_id); + $this->queue->loadToDoTickets($user_id); + break; + case "create": + //set these with the createQueue function proceding the getTickets function break; default: return "ERROR"; } - $this->pagination = new Pagination($queue->getQuery(),"lib",10,"Ticket",$queue->getParams()); + $this->pagination = new Pagination($this->queue->getQuery(),"lib",2,"Ticket",$this->queue->getParams()); foreach( $this->pagination->getElements() as $element ){ $catInstance = new Ticket_Category(); $catInstance->load_With_TCategoryId($element->getTicket_Category()); @@ -37,15 +43,16 @@ class Ticket_Queue_Handler{ $userInstance->load_With_TUserId($element->getAuthor()); $element->setAuthor($userInstance); } - return $this->pagination->getElements(); - - + return $this->pagination->getElements(); } - public static function CreateQueue($userid, $groupid, $what, $how, $who){ - $queue = new Ticket_Queue(); - $queue->createQueue($userid, $groupid, $what, $how, $who); - return $queue->getTickets(); + public function getPagination(){ + return $this->pagination; } + + public function createQueue($userid, $groupid, $what, $how, $who){ + $this->queue->createQueue($userid, $groupid, $what, $how, $who); + } + } \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/func/create_ticket.php b/code/ryzom/tools/server/ryzom_ams/www/html/func/create_ticket.php index db7621493..af51c6969 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/func/create_ticket.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/func/create_ticket.php @@ -24,6 +24,8 @@ function create_ticket(){ }catch (PDOException $e) { //ERROR: LIB DB is not online! + print_r($e); + exit; header("Location: index.php"); exit; } @@ -37,7 +39,7 @@ function create_ticket(){ }else{ //ERROR: The form was not filled in correclty - header("Location: index.php?page=settings"); + header("Location: index.php?page=create_ticket"); exit; } }else{ 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 136b1941b..0d057e7e4 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 @@ -12,7 +12,25 @@ function show_queue(){ $user_id = $_SESSION['ticket_user']->getTUserId(); $queueArray = array(); $queue_handler = new Ticket_Queue_handler(); - + + //Pagination Base Links + $result['pagination_base_link'] = "index.php?page=show_queue&get=".$result['queue_view'] ; + + if(isset($_GET['get']) && ($_GET['get'] == "create") && isset($_GET['userid']) && isset($_GET['groupid']) && isset($_GET['what']) && isset($_GET['how']) && isset($_GET['who'])){ + $userid = filter_var($_GET['userid'], FILTER_SANITIZE_NUMBER_INT); + $groupid = filter_var($_GET['groupid'], FILTER_SANITIZE_NUMBER_INT); + $what = filter_var($_GET['what'], FILTER_SANITIZE_STRING); + $how = filter_var($_GET['how'], FILTER_SANITIZE_STRING); + $who = filter_var($_GET['who'], FILTER_SANITIZE_STRING); + $queue_handler->CreateQueue($userid, $groupid, $what, $how, $who); + $result['pagination_base_link'] = "index.php?page=show_queue&get=create&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who; + $result['prev_created_userid'] = $userid; + $result['prev_created_groupid'] = $groupid; + $result['prev_created_what'] = $what; + $result['prev_created_how'] = $how; + $result['prev_created_who'] = $who; + } + //if an action is set if(isset($_POST['action'])){ switch($_POST['action']){ @@ -32,19 +50,29 @@ function show_queue(){ $what = filter_var($_POST['what'], FILTER_SANITIZE_STRING); $how = filter_var($_POST['how'], FILTER_SANITIZE_STRING); $who = filter_var($_POST['who'], FILTER_SANITIZE_STRING); - $result['ACTION_RESULT'] = $queue_handler->CreateQueue($userid, $groupid, $what, $how, $who); - if ($result['ACTION_RESULT'] != "ERROR"){ - $queueArray = $result['ACTION_RESULT']; - } + $queue_handler->CreateQueue($userid, $groupid, $what, $how, $who); + $result['pagination_base_link'] = "index.php?page=show_queue&get=create&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who; + $result['prev_created_userid'] = $userid; + $result['prev_created_groupid'] = $groupid; + $result['prev_created_what'] = $what; + $result['prev_created_how'] = $how; + $result['prev_created_who'] = $who; + + + + break; } } + + $queueArray = $queue_handler->getTickets($result['queue_view'], $user_id); + + //pagination + $result['links'] = $queue_handler->getPagination()->getLinks(5); + $result['lastPage'] = $queue_handler->getPagination()->getLast(); + $result['currentPage'] = $queue_handler->getPagination()->getCurrent(); - //if we didn't make a queue ourselves, then use the one specified by the get param - if( ! (isset($_POST['action']) && $_POST['action'] == "create_queue") ){ - $queueArray = $queue_handler->getTickets($result['queue_view'], $user_id); - } //if queue_view is a valid parameter value if ($queueArray != "ERROR"){ 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 6cc3f1676..3179a0e25 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 @@ -44,6 +44,7 @@ function show_ticket(){ $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_author'] = $entire_ticket['ticket_obj']->getAuthor(); $result['ticket_prioritytext'] = $entire_ticket['ticket_obj']->getPriorityText(); $result['ticket_priorities'] = Ticket::getPriorityArray(); $result['ticket_priority'] = $entire_ticket['ticket_obj']->getPriority(); diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl index 650be9c92..179767589 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl @@ -13,35 +13,35 @@ Tickets
-
+ Show tickets to - + -
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 1867ec86a..aae1bf9f9 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 @@ -223,7 +223,7 @@