if( $dbl->execute(" SELECT * FROM `ticket` WHERE `TId` = :ticket_id", array('ticket_id' => $id) )->rowCount() ){
return true;
}else{
@ -26,26 +34,31 @@ class Ticket{
}
}
/*FUNCTION: getStatusArray
* returns all possible statusses
*
/**
* return an array of the possible statuses
* @return an array containing the string values that represent the different statuses.
*/
public static function getStatusArray() {
return Array("Waiting on user reply","Waiting on support","Waiting on Dev reply","Closed");
}
/*FUNCTION: getPriorityArray
* returns all possible statusses
*
/**
* return an array of the possible priorities
* @return an array containing the string values that represent the different priorities.
*/
public static function getPriorityArray() {
return Array("Low","Normal","High","Super Dupa High");
}
/*FUNCTION: getEntireTicket
* return all ticket of the given author's id.
*
/**
* return an entire ticket.
* returns the ticket object and an array of all replies to that ticket.
* @param $id the id of the ticket.
* @param $view_as_admin true if the viewer of the ticket is a mod, else false (depending on this it will also show the hidden comments)
* @return an array containing the 'ticket_obj' and a 'reply_array', which is an array containing all replies to that ticket.
*/
public static function getEntireTicket($id,$view_as_admin) {
$ticket = new Ticket();
@ -55,9 +68,11 @@ class Ticket{
}
/*FUNCTION: getTicketTitlesOf
* return all ticket of the given author's id.
*
/**
* return all tickets of a specific user.
* an array of all tickets created by a specific user are returned by this function.
* @param $author the id of the user of whom we want all tickets from.
* @return an array containing all ticket objects related to a user.
*/
public static function getTicketsOf($author) {
$dbl = new DBLayer("lib");
@ -79,9 +94,20 @@ class Ticket{
}
/*FUNCTION: create_Ticket()
* creates a ticket + first initial reply and fills in the content of it!
* for_support_group defines to which support group the ticket has to be forwarded
/**
* function that creates a new ticket.
* A new ticket will be created, in case the extra_info != 0 and the http request came from ingame, then a ticket_info page will be created.
* A log entry will be written, depending on the $real_authors value. In case the for_support_group parameter is set, the ticket will be forwarded immediately.
* Also the mail handler will create a new email that will be sent to the author to notify him that his ticket is freshly created.
* @param $title the title we want to give to the ticket.
* @param $content the content we want to give to the starting post of the ticket.
* @param $category the id of the category that should be related to the ticket.
* @param $author the person who's id will be stored in the database as creator of the ticket.
* @param $real_author should be the same id, or a moderator/admin who creates a ticket for another user (this is used for logging purposes).
* @param $for_support_group in case you directly want to forward the ticket after creating it. (default value = 0 = don't forward)
* @param $extra_info used for creating an ticket_info page related to the ticket, this only happens when the ticket is made ingame.
* @return the created tickets id.
*/
public static function create_Ticket( $title, $content, $category, $author, $real_author, $for_support_group = 0, $extra_info = 0) {
@ -117,9 +143,13 @@ class Ticket{
}
/*FUNCTION: updateTicketStatus()
*
*
/**
* updates the ticket's status.
* A log entry about this will be created only if the newStatus is different from the current status.
* @param $ticket_id the id of the ticket of which we want to change the status.
* @param $newStatus the new status value (integer)
* @param $author the user (id) that performed the update status action
*/
public static function updateTicketStatus( $ticket_id, $newStatus, $author) {
@ -134,9 +164,14 @@ class Ticket{
}
/*FUNCTION: updateTicketStatusAndPriority()
* creates a ticket + first initial reply and fills in the content of it!
*
/**
* updates the ticket's status & priority.
* A log entry about this will be created only if the newStatus is different from the current status and also when the newPriority is different from the current priority.
* @todo break this function up into a updateStatus (already exists) and updatePriority function and perhaps write a wrapper function for the combo.
* @param $ticket_id the id of the ticket of which we want to change the status & priority
* @param $newStatus the new status value (integer)
* @param $newPriority the new priority value (integer)
* @param $author the user (id) that performed the update
*/
public static function updateTicketStatusAndPriority( $ticket_id, $newStatus, $newPriority, $author) {
@ -154,7 +189,12 @@ class Ticket{
}
//return the latest reply.
/**
* return the latest reply of a ticket
* @param $ticket_id the id of the ticket.
* @return a ticket_reply object.
*/
public static function getLatestReply( $ticket_id) {
$dbl = new DBLayer("lib");
$statement = $dbl->execute("SELECT * FROM ticket_reply WHERE Ticket =:id ORDER BY TReplyId DESC LIMIT 1 ", array('id' => $ticket_id));
@ -163,6 +203,16 @@ class Ticket{
return $reply;
}
/**
* create a new reply for a ticket.
* A reply will only be added if the content isn't empty and if the ticket isn't closed.
* The ticket creator will be notified by email that someone else replied on his ticket.
* @param $content the content of the reply
* @param $author the author of the reply
* @param $ticket_id the id of the ticket to which we want to add the reply.
* @param $hidden boolean that specifies if the reply should only be shown to mods/admins or all users.
*/
public static function createReply($content, $author, $ticket_id, $hidden){
//if not empty
if(! ( Trim ( $content ) === '' )){
@ -187,7 +237,14 @@ class Ticket{
}
}
//returns SUCCESS_ASSIGNED, TICKET_NOT_EXISTING or ALREADY_ASSIGNED
/**
* assign a ticket to a user.
* Checks if the ticket exists, if so then it will try to assign the user to it, a log entry will be written about this.
* @param $user_id the id of user trying to be assigned to the ticket.
* @param $ticket_id the id of the ticket that we try to assign to the user.
* @return SUCCESS_ASSIGNED, TICKET_NOT_EXISTING or ALREADY_ASSIGNED
*/
public static function assignTicket($user_id, $ticket_id){
* The Ticket_Content has a one-to-one relation with a ticket_reply, it contains the content of a reply, this way the content doesn't always have to be loaded when
* we query the database when we only need information regarding to the replies basic information.
* @author Daan Janssens, mentored by Matthew Lagoe