3 * Handles the forwarding of a ticket to a support_group. This is being used to transfer tickets to different groups (eg Developers, Website-Team, SupportGroup etc..)
4 * The idea is that someone can easily forward a ticket to a group and by doing that, the moderators that are in that group will receive the ticket in their todo queue.
5 * @author Daan Janssens, mentored by Matthew Lagoe
10 private $group; /**< The id of the group to which the ticket is being forwarded */
11 private $ticket; /**< The id of the ticket being forwarded */
13 ////////////////////////////////////////////Functions////////////////////////////////////////////////////
17 * Forward a ticket to a group, also removes the previous group where it was forwarded to.
18 * It will first check if the ticket is already forwarded, if that's the case, it will delete that entry.
19 * Afterwards it creates the new forward entry
20 * @param $group_id the id of the support group we want to forward the ticket to.
21 * @param $ticket_id the id of the ticket.
22 * @return A string, if assigning succeedded "SUCCESS_FORWARDED" will be returned.
24 public static function forwardTicket( $group_id, $ticket_id) {
25 $dbl = new DBLayer("lib");
26 if (forwarded
::isForwarded($ticket_id)){
27 $forw = new Forwarded();
28 $forw->load($ticket_id);
31 $forward = new Forwarded();
32 $forward->set(array('Group' => $group_id, 'Ticket' => $ticket_id));
34 return "SUCCESS_FORWARDED";
40 * get the id of the group a ticket is forwarded to.
41 * @param $ticket_id the id of the ticket.
42 * @return the id of the group
44 public static function getSGroupOfTicket($ticket_id) {
46 $forw->load($ticket_id);
47 return $forw->getGroup();
52 * check if the ticket is forwarded
53 * @param $ticket_id the id of the ticket.
54 * @return returns true if the ticket is forwarded, else return false;
56 public static function isForwarded( $ticket_id) {
57 $dbl = new DBLayer("lib");
58 if( $dbl->select("`forwarded`", array('ticket_id' => $ticket_id), "`Ticket` = :ticket_id")->rowCount() ){
66 ////////////////////////////////////////////Methods////////////////////////////////////////////////////
73 public function __construct() {
78 * sets the object's attributes.
79 * @param $values should be an array of the form array('Group' => group_id, 'Ticket' => ticket_id).
81 public function set($values) {
82 $this->setGroup($values['Group']);
83 $this->setTicket($values['Ticket']);
88 * creates a new 'forwarded' entry.
89 * this method will use the object's attributes for creating a new 'forwarded' entry in the database.
91 public function create() {
92 $dbl = new DBLayer("lib");
93 $dbl->insert("`forwarded`", Array('Group' => $this->getGroup(), 'Ticket' => $this->getTicket()));
98 * deletes an existing 'forwarded' entry.
99 * this method will use the object's attributes for deleting an existing 'forwarded' entry in the database.
101 public function delete() {
102 $dbl = new DBLayer("lib");
103 $dbl->delete("`forwarded`", array('group_id' => $this->getGroup() ,'ticket_id' => $this->getTicket(), "`Group` = :group_id and `Ticket` = :ticket_id"));
108 * loads the object's attributes.
109 * loads the object's attributes by giving a ticket_id, it will put the matching group_id and the ticket_id into the attributes.
110 * @param $ticket_id the id of the ticket that should be loaded
112 public function load( $ticket_id) {
113 $dbl = new DBLayer("lib");
114 $statement = $dbl->select("`forwarded`", Array('ticket_id' => $ticket_id), "`Ticket` = :ticket_id");
115 $row = $statement->fetch();
120 ////////////////////////////////////////////Getters////////////////////////////////////////////////////
123 * get group attribute of the object.
125 public function getGroup(){
130 * get ticket attribute of the object.
132 public function getTicket(){
133 return $this->ticket
;
136 ////////////////////////////////////////////Setters////////////////////////////////////////////////////
139 * set group attribute of the object.
140 * @param $g integer id of the group
142 public function setGroup($g){
147 * set ticket attribute of the object.
148 * @param $t integer id of the ticket
150 public function setTicket($t){