Example #1
0
 /**
  * return all replies on a specific ticket.
  * @param $ticket_id the id of the ticket of which we want the replies.
  * @param $view_as_admin if the browsing user is an admin/mod it should be 1, this will also show the hidden replies.
  * @return an array with ticket_reply objects (beware the author and content are objects on their own, not integers!)
  */
 public static function getRepliesOfTicket($ticket_id, $view_as_admin)
 {
     $dbl = new DBLayer("lib");
     $statement = $dbl->execute("SELECT * FROM ticket_reply INNER JOIN ticket_content INNER JOIN ticket_user ON ticket_reply.Content = ticket_content.TContentId and ticket_reply.Ticket=:id and ticket_user.TUserId = ticket_reply.Author ORDER BY ticket_reply.TReplyId ASC", array('id' => $ticket_id));
     $row = $statement->fetchAll();
     $result = array();
     foreach ($row as $tReply) {
         //only add hidden replies if the user is a mod/admin
         if (!$tReply['Hidden'] || $view_as_admin) {
             //load author
             $instanceAuthor = Ticket_User::constr_TUserId($tReply['Author']);
             $instanceAuthor->setExternId($tReply['ExternId']);
             $instanceAuthor->setPermission($tReply['Permission']);
             //load content
             $instanceContent = new Ticket_Content();
             $instanceContent->setTContentId($tReply['TContentId']);
             $instanceContent->setContent($tReply['Content']);
             //load reply and add the author and content object in it.
             $instanceReply = new self();
             $instanceReply->setTReplyId($tReply['TReplyId']);
             $instanceReply->setTimestamp($tReply['Timestamp']);
             $instanceReply->setAuthor($instanceAuthor);
             $instanceReply->setTicket($ticket_id);
             $instanceReply->setContent($instanceContent);
             $instanceReply->setHidden($tReply['Hidden']);
             $result[] = $instanceReply;
         }
     }
     return $result;
 }
Example #2
0
 /**
  * return all log entries related to a ticket.
  * @param $ticket_id the id of the ticket of which we want all related log entries returned.
  * @return an array of ticket_log objects, be aware that the author in the ticket_log object is a ticket_user object on its own (so not a simple integer).
  */
 public static function getLogsOfTicket($ticket_id)
 {
     $dbl = new DBLayer("lib");
     $statement = $dbl->execute("SELECT * FROM ticket_log INNER JOIN ticket_user ON ticket_log.Author = ticket_user.TUserId and ticket_log.Ticket=:id ORDER BY ticket_log.TLogId ASC", array('id' => $ticket_id));
     $row = $statement->fetchAll();
     $result = array();
     foreach ($row as $log) {
         $instanceAuthor = Ticket_User::constr_TUserId($log['Author']);
         $instanceAuthor->setExternId($log['ExternId']);
         $instanceAuthor->setPermission($log['Permission']);
         $instanceLog = new self();
         $instanceLog->setTLogId($log['TLogId']);
         $instanceLog->setTimestamp($log['Timestamp']);
         $instanceLog->setAuthor($instanceAuthor);
         $instanceLog->setTicket($ticket_id);
         $instanceLog->setQuery($log['Query']);
         $result[] = $instanceLog;
     }
     return $result;
 }