From ea80798bd09b5084760357bd99af78ee12dc808f Mon Sep 17 00:00:00 2001 From: Quitta Date: Sun, 14 Jul 2013 16:38:36 +0200 Subject: [PATCH] ticket queue base added --- .../ams_lib/autoload/ticket_queue.php | 57 ++++++++++++++++ .../ryzom_ams/ams_lib/translations/en.ini | 2 + .../ryzom_ams/ams_lib/translations/fr.ini | 2 + .../ryzom_ams/www/html/inc/show_queue.php | 46 +++++++++++++ .../ryzom_ams/www/html/inc/show_ticket.php | 2 +- .../www/html/inc/show_ticket_log.php | 12 ++-- .../www/html/templates/layout_admin.tpl | 6 +- .../www/html/templates/show_queue.tpl | 66 +++++++++++++++++++ .../www/html/templates/show_ticket.tpl | 2 +- 9 files changed, 183 insertions(+), 12 deletions(-) create mode 100644 code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue.php create mode 100644 code/ryzom/tools/server/ryzom_ams/www/html/inc/show_queue.php create mode 100644 code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl 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 new file mode 100644 index 000000000..0907a7014 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue.php @@ -0,0 +1,57 @@ +executeWithoutParams("SELECT * FROM ticket INNER JOIN ticket_user ON ticket.Author = ticket_user.TUserId and ticket.Status!=3"); + $rows = $statement->fetchAll(); + $this->setQueue($rows); + } + + public function loadAllClosedTickets(){ + $dbl = new DBLayer("lib"); + $statement = $dbl->executeWithoutParams("SELECT * FROM ticket INNER JOIN ticket_user ON ticket.Author = ticket_user.TUserId and ticket.Status=3"); + $rows = $statement->fetchAll(); + $this->setQueue($rows); + } + + public function getTickets(){ + return $this->queueElements; + } + + protected function setQueue($rows){ + + $result = Array(); + foreach($rows as $ticket){ + $instance = new Ticket(); + $instance->setTId($ticket['TId']); + $instance->setTimestamp($ticket['Timestamp']); + $instance->setTitle($ticket['Title']); + $instance->setStatus($ticket['Status']); + $instance->setQueue($ticket['Queue']); + + $catInstance = new Ticket_Category(); + $catInstance->load_With_TCategoryId($ticket['Ticket_Category']); + $instance->setTicket_Category($catInstance); + + $userInstance = new Ticket_User(); + $userInstance->load_With_TUserId($ticket['Author']); + $instance->setAuthor($userInstance); + + $result[] = $instance; + } + $this->queueElements = $result; + + } + + + + + + + + + +} \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini index c82896fa2..a5bb624cd 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini @@ -29,6 +29,8 @@ t_send = "Send reply" [show_user] +[show_queue] + [createticket] [show_ticket_log] diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini index d726bdcfa..e54f4371a 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini @@ -29,6 +29,8 @@ t_send = "Envoyer la reponse" [show_user] +[show_queue] + [createticket] [show_reply] 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 new file mode 100644 index 000000000..59e95879f --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_queue.php @@ -0,0 +1,46 @@ +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"; + } + return $result; + + }else{ + //ERROR: No access! + $_SESSION['error_code'] = "403"; + header("Location: index.php?page=error"); + exit; + } + }else{ + //ERROR: not logged in! + header("Location: index.php"); + exit; + } + +} \ 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 b380acb9c..c5e370849 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 @@ -30,7 +30,7 @@ function show_ticket(){ } if(WebUsers::isAdmin()){ $result['isAdmin'] = "TRUE"; - $result['statusList'] = Ticket::getStatusArray(); + //$result['statusList'] = Ticket::getStatusArray(); } return $result; diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_ticket_log.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_ticket_log.php index 3d988b26d..06172482a 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_ticket_log.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_ticket_log.php @@ -4,13 +4,11 @@ function show_ticket_log(){ //if logged in if(WebUsers::isLoggedIn() && isset($_GET['id'])){ - - $result['ticket_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT); - $target_ticket = new Ticket(); - $target_ticket->load_With_TId($result['ticket_id']); - - if(($target_ticket->getAuthor() == $_SESSION['ticket_user']->getTUserId()) || WebUsers::isAdmin() ){ - + //only allow admins to browse the log! + if(WebUsers::isAdmin() ){ + $result['ticket_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT); + $target_ticket = new Ticket(); + $target_ticket->load_With_TId($result['ticket_id']); $result['ticket_title'] = $target_ticket->getTitle(); $ticket_logs = Ticket_Log::getLogsOfTicket( $result['ticket_id']); $log_action_array = Ticket_Log::getActionTextArray(); 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 cd7bc60ad..1e4e8ddf2 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 @@ -5,10 +5,10 @@
  • Profile
  • Settings
  • -
  • Liblist
  • -
  • UserList
  • +
  • Users
  • +
  • Queues
  • +
  • Syncing
  • Logout
  • - {/block} 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 new file mode 100644 index 000000000..ea07383fc --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl @@ -0,0 +1,66 @@ +{block name=content} +
    +
    +
    +

    Ticket Queue {$queue_action}

    +
    + + +
    +
    +
    +
    + Tickets + + + + + + + + + + + + {foreach from=$tickets item=ticket} + + + + + + + + + {/foreach} + + +
    IDTitleTimestampCategoryStatus
    {$ticket.tId}{$ticket.title}{$ticket.timestamp}{$ticket.category}{if $ticket.status eq 0} {/if} {$ticket.statusText}
    +
    +
    +
    + +
    +
    +

    Actions

    +
    + + +
    +
    +
    +
    +
    + + +
    +
    +
    +
    +
    +{/block} + 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 15d898f5e..2a230453c 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 @@ -181,7 +181,7 @@