/** * creates a new reply on a ticket. * Creates a ticket_content entry and links it with a new created ticket_reply, a log entry will be written about this. * In case the ticket creator replies on a ticket, he will set the status by default to 'waiting on support'. * @param $content the content of the reply * @param $author the id of the reply creator. * @param $ticket_id the id of the ticket of which we want the replies. * @param $hidden should be 0 or 1 * @param $ticket_creator the ticket's starter his id. */ public static function createReply($content, $author, $ticket_id, $hidden, $ticket_creator) { $ticket_content = new Ticket_Content(); $ticket_content->setContent($content); $ticket_content->create(); $content_id = $ticket_content->getTContentId(); $ticket_reply = new Ticket_Reply(); $ticket_reply->set(array('Ticket' => $ticket_id, 'Content' => $content_id, 'Author' => $author, 'Hidden' => $hidden)); $ticket_reply->create(); $reply_id = $ticket_reply->getTReplyId(); if ($ticket_creator == $author) { Ticket::updateTicketStatus($ticket_id, 1, $author); } Ticket_Log::createLogEntry($ticket_id, $author, 4, $reply_id); }
/** * 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)); $reply = new Ticket_Reply(); $reply->set($statement->fetch()); return $reply; }