From 95806fa9f4d36e0fa7f078af3fa38e0752e37049 Mon Sep 17 00:00:00 2001 From: Quitta Date: Mon, 22 Jul 2013 14:51:42 +0200 Subject: [PATCH] Forward works, though needs refinement! also is shown in ticket info bar --- .../ryzom_ams/ams_lib/autoload/forwarded.php | 13 +++- .../ams_lib/autoload/support_group.php | 14 ++++ .../ryzom_ams/ams_lib/autoload/ticket.php | 34 +++++++++ .../ryzom_ams/ams_lib/translations/en.ini | 4 + .../ryzom_ams/ams_lib/translations/fr.ini | 4 + .../ryzom_ams/www/html/inc/show_ticket.php | 16 ++++ .../www/html/templates/show_sgroup.tpl | 2 +- .../www/html/templates/show_ticket.tpl | 76 ++++++++----------- 8 files changed, 114 insertions(+), 49 deletions(-) diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/forwarded.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/forwarded.php index 2a4b9e8e6..003811fe9 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/forwarded.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/forwarded.php @@ -1,6 +1,6 @@ load($ticket_id); + return $forw->getGroup(); + } + public static function isForwarded( $ticket_id) { $dbl = new DBLayer("lib"); @@ -48,7 +53,7 @@ class Assigned{ public function create() { $dbl = new DBLayer("lib"); $query = "INSERT INTO `forwarded` (`Group`,`Ticket`) VALUES (:group, :ticket)"; - $values = Array('user' => $this->getGroup(), 'ticket' => $this->getTicket()); + $values = Array('group' => $this->getGroup(), 'ticket' => $this->getTicket()); $dbl->execute($query, $values); } @@ -63,7 +68,7 @@ class Assigned{ //Load with sGroupId public function load( $ticket_id) { $dbl = new DBLayer("lib"); - $statement = $dbl->execute("SELECT * FROM `forwarded` WHERE `Ticket` = :ticket_id", Array('ticket_id' => $ticket_id); + $statement = $dbl->execute("SELECT * FROM `forwarded` WHERE `Ticket` = :ticket_id", Array('ticket_id' => $ticket_id)); $row = $statement->fetch(); $this->set($row); } diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/support_group.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/support_group.php index ab0f29c75..4ee3e79fe 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/support_group.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/support_group.php @@ -175,6 +175,20 @@ class Support_Group{ } } + + //returns list of all category objects + public static function getAllSupportGroups() { + $dbl = new DBLayer("lib"); + $statement = $dbl->executeWithoutParams("SELECT * FROM `support_group`"); + $row = $statement->fetchAll(); + $result = Array(); + foreach($row as $group){ + $instance = new self(); + $instance->set($group); + $result[] = $instance; + } + return $result; + } ////////////////////////////////////////////Methods//////////////////////////////////////////////////// public function __construct() { 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 24732f3f4..8a1251de4 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 @@ -161,6 +161,22 @@ class Ticket{ return "TICKET_NOT_EXISTING"; } } + + public static function forwardTicket($user_id, $ticket_id, $group_id){ + if(self::ticketExists($ticket_id)){ + if(isset($group_id) && $group_id != ""){ + return Forwarded::forwardTicket($group_id, $ticket_id); + }else{ + return "INVALID_SGROUP"; + } + }else{ + return "TICKET_NOT_EXISTING"; + } + } + + + + ////////////////////////////////////////////Methods//////////////////////////////////////////////////// public function __construct() { @@ -272,6 +288,24 @@ class Ticket{ return $user_id; } } + + public function getForwardedGroupName(){ + $group_id = Forwarded::getSGroupOfTicket($this->getTId()); + if ($group_id == ""){ + return 0; + }else{ + return Support_Group::getGroup($group_id)->getName(); + } + } + + public function getForwardedGroupId(){ + $group_id = Forwarded::getSGroupOfTicket($this->getTId()); + if ($group_id == ""){ + return 0; + }else{ + return $group_id; + } + } ////////////////////////////////////////////Setters//////////////////////////////////////////////////// public function setTId($id){ 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 df46cd938..57cce4170 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 @@ -26,6 +26,10 @@ title = "Title" t_reply = "Reply on ticket" t_fill = "Fill in your reply" t_send = "Send reply" +invalid_sgroup = "Invalid support group!" +ticket_not_existing = "That's an invalid ticket" +success_forwarded = "The ticket was forwarded successfully!" +public_sgroup = "Public" [show_user] 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 f3f208a0f..8cd3b01a3 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 @@ -26,6 +26,10 @@ title = "Titre" t_reply = "Repondre a billet" t_fill = "Remplissez votre reponse" t_send = "Envoyer la reponse" +invalid_sgroup = "Invalide support group!" +ticket_not_existing = "c'est un billet invalide" +success_forwarded = "ce billet est renvoyee bien!" +public_sgroup = "Publique" [show_user] 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 699311781..03a7036e7 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 @@ -7,6 +7,19 @@ function show_ticket(){ $result['ticket_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT); $target_ticket = new Ticket(); $target_ticket->load_With_TId($result['ticket_id']); + + if(Ticket_User::isMod($_SESSION['ticket_user'] )){ + if(isset($_POST['action'])){ + switch($_POST['action']){ + case "forward": + $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); + $group_id = filter_var($_POST['group'], FILTER_SANITIZE_NUMBER_INT); + $result['ACTION_RESULT'] = Ticket::forwardTicket($_SESSION['ticket_user']->getTUserId(), $ticket_id, $group_id); + break; + } + } + } + if(($target_ticket->getAuthor() == $_SESSION['ticket_user']->getTUserId()) || Ticket_User::isMod($_SESSION['ticket_user'] )){ @@ -17,6 +30,8 @@ function show_ticket(){ $entire_ticket = Ticket::getEntireTicket( $result['ticket_id'],$show_as_admin); Ticket_Log::createLogEntry($result['ticket_id'],$_SESSION['ticket_user']->getTUserId(), 3); $result['ticket_tId'] = $entire_ticket['ticket_obj']->getTId(); + $result['ticket_forwardedGroupName'] = $entire_ticket['ticket_obj']->getForwardedGroupName(); + $result['ticket_forwardedGroupId'] = $entire_ticket['ticket_obj']->getForwardedGroupId(); $result['ticket_title'] = $entire_ticket['ticket_obj']->getTitle(); $result['ticket_timestamp'] = $entire_ticket['ticket_obj']->getTimestamp(); $result['ticket_status'] = $entire_ticket['ticket_obj']->getStatus(); @@ -35,6 +50,7 @@ function show_ticket(){ if(Ticket_User::isMod($_SESSION['ticket_user'])){ $result['isMod'] = "TRUE"; $result['statusList'] = Ticket::getStatusArray(); + $result['sGroups'] = Gui_Elements::make_table_with_key_is_id(Support_Group::getAllSupportGroups(), Array("getName"), "getSGroupId" ); } return $result; diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_sgroup.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_sgroup.tpl index 9201ca535..15c1d7b80 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_sgroup.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_sgroup.tpl @@ -10,7 +10,7 @@
- All support groups + All members of the {$groupsname} Support Group 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 d91aeeb15..b1cdc78ad 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 @@ -23,7 +23,15 @@ - +
Category: {$ticket_category} Priority: {$ticket_prioritytext}Associated: Ticket#33Support Group: + + {if $ticket_forwardedGroupName eq "0"} + {$public_sgroup} + {else} + {$ticket_forwardedGroupName} + {/if} + +
@@ -130,62 +138,42 @@
-
- Tags + {if isset($isMod) and $isMod eq "TRUE"} + + Forward to Group
-
-
-
Hacked -
Botanic -
evilwebsite.comz -
keylogger -
+
+ +
-
-
- -
-
-
-
- -
- +
- -
- Associations - -
- -
-
-
Ticket #33 -
-
+ {if isset($ACTION_RESULT) and $ACTION_RESULT eq "INVALID_SGROUP"} +
+ {$invalid_sgroup}
-
- -
-
- -
-
+ {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "TICKET_NOT_EXISTING"} +
+ {$ticket_not_existing}
-
- -
- -
+ {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_FORWARDED"} +
+ {$success_forwarded}
- + {/if} + {/if} Actions