This commit is contained in:
kaetemi 2014-09-03 04:46:08 +02:00
parent 9f44b039d2
commit d3c3b6ed00
6 changed files with 249 additions and 253 deletions

View file

@ -6,12 +6,12 @@
*/
class Assigned{
private $user; /**< The id of the user being assigned */
private $ticket; /**< The id of the ticket being assigned */
private $user; /**< The id of the user being assigned */
private $ticket; /**< The id of the ticket being assigned */
////////////////////////////////////////////Functions////////////////////////////////////////////////////
/**
* Assigns a ticket to a user or returns an error message.
* It will first check if the ticket isn't already assigned, if not, it will create a new 'assigned' entry.
@ -30,10 +30,10 @@ class Assigned{
}else{
return "ALREADY_ASSIGNED";
}
}
/**
* Unassign a ticket being coupled to a user or return an error message.
* It will first check if the ticket is assigned, if this is indeed the case it will delete the 'assigned' entry.
@ -52,9 +52,9 @@ class Assigned{
}else{
return "NOT_ASSIGNED";
}
}
/**
* Get the (external) id of the user assigned to a ticket
* @param $ticket_id the Id of the ticket that's being queried
@ -65,11 +65,11 @@ class Assigned{
$statement = $dbl->execute("SELECT ticket_user.ExternId FROM `assigned` JOIN `ticket_user` ON assigned.User = ticket_user.TUserId WHERE `Ticket` = :ticket_id", Array('ticket_id' => $ticket_id));
$user_id = $statement->fetch();
return $user_id['ExternId'];
}
/**
* Check if a ticket is already assigned (in case the user_id param is used, it will check if it's assigned to that user)
* @param $ticket_id the Id of the ticket that's being queried
@ -79,26 +79,26 @@ class Assigned{
public static function isAssigned( $ticket_id, $user_id = 0) {
$dbl = new DBLayer("lib");
//check if ticket is already assigned
if($user_id == 0 && $dbl->select("`assigned`", array('ticket_id' => $ticket_id), "`Ticket` = :ticket_id")->rowCount() ){
return true;
}else if( $dbl->select("`assigned`", array('ticket_id' => $ticket_id, 'user_id' => $user_id), "`Ticket` = :ticket_id and `User` = :user_id")->rowCount() ){
return true;
}else{
return false;
}
}
}
////////////////////////////////////////////Methods////////////////////////////////////////////////////
/**
* A constructor.
* Empty constructor
*/
public function __construct() {
}
/**
* sets the object's attributes.
* @param $values should be an array of the form array('User' => user_id, 'Ticket' => ticket_id).
@ -107,25 +107,25 @@ class Assigned{
$this->setUser($values['User']);
$this->setTicket($values['Ticket']);
}
/**
* creates a new 'assigned' entry.
* this method will use the object's attributes for creating a new 'assigned' entry in the database.
*/
public function create() {
$dbl = new DBLayer("lib");
$dbl->insert("`assigned`", Array('User' => $this->getUser(), 'Ticket' => $this->getTicket());
$dbl->insert("`assigned`", Array('User' => $this->getUser(), 'Ticket' => $this->getTicket()));
}
/**
* deletes an existing 'assigned' entry.
* this method will use the object's attributes for deleting an existing 'assigned' entry in the database.
*/
public function delete() {
$dbl = new DBLayer("lib");
$dbl->delete("`assigned`", array('user_id' => $this->getUser() ,'ticket_id' => $this->getTicket(), "`User` = :user_id and `Ticket` = :ticket_id");
$dbl->delete("`assigned`", array('user_id' => $this->getUser() ,'ticket_id' => $this->getTicket(), "`User` = :user_id and `Ticket` = :ticket_id"));
}
/**
@ -139,25 +139,25 @@ class Assigned{
$row = $statement->fetch();
$this->set($row);
}
////////////////////////////////////////////Getters////////////////////////////////////////////////////
/**
* get user attribute of the object.
*/
public function getUser(){
return $this->user;
}
/**
* get ticket attribute of the object.
*/
public function getTicket(){
return $this->ticket;
}
////////////////////////////////////////////Setters////////////////////////////////////////////////////
/**
@ -167,7 +167,7 @@ class Assigned{
public function setUser($u){
$this->user = $u;
}
/**
* set ticket attribute of the object.
* @param $t integer id of the ticket
@ -175,6 +175,6 @@ class Assigned{
public function setTicket($t){
$this->ticket = $t;
}
}

View file

@ -240,30 +240,26 @@ class DBLayer {
* @param array $data array of data to insert in format('fieldname' => $value,....). 'fieldname' must be a field in that table.
* @throws error in inserting.
*/
public function insert( $tb_name, $data ) {
public function insert($tb_name, $data, $datafunc = array()) {
$this->useDb();
$field_values = ':' . implode( ',:', array_keys( $data ) );
$field_options = implode( ',', array_keys( $data ) );
$field_options = implode(',', array_merge(array_keys($data), array_keys($datafunc)));
$field_values = implode(',', array_merge(array(':' . implode(',:', array_keys($data))), array_values($datafunc)));
try {
$sth = $this -> PDO -> prepare( "INSERT INTO $tb_name ($field_options) VALUE ($field_values)" );
foreach ( $data as $key => $value )
{
$sth -> bindValue( ":$key", $value );
}
$this -> PDO -> beginTransaction();
$sth = $this->PDO->prepare("INSERT INTO $tb_name ($field_options) VALUE ($field_values)");
foreach ($data as $key => $value) {
$sth->bindValue(":$key", $value);
}
$this->PDO->beginTransaction();
// execution
$sth -> execute();
$this -> PDO -> commit();
}
catch ( Exception $e )
{
// for rolling back the changes during transaction
$this -> PDO -> rollBack();
throw new Exception( "error in inserting" );
}
$sth->execute();
$this->PDO->commit();
}
catch (Exception $e) {
// for rolling back the changes during transaction
$this->PDO->rollBack();
throw $e; // new Exception("error in inserting");
}
}
/**
* Delete database entery using prepared statement.

View file

@ -3,16 +3,16 @@
* 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..)
* 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.
* @author Daan Janssens, mentored by Matthew Lagoe
*
*
*/
class Forwarded{
private $group; /**< The id of the group to which the ticket is being forwarded */
private $ticket; /**< The id of the ticket being forwarded */
private $group; /**< The id of the group to which the ticket is being forwarded */
private $ticket; /**< The id of the ticket being forwarded */
////////////////////////////////////////////Functions////////////////////////////////////////////////////
/**
* Forward a ticket to a group, also removes the previous group where it was forwarded to.
* It will first check if the ticket is already forwarded, if that's the case, it will delete that entry.
@ -32,10 +32,10 @@ class Forwarded{
$forward->set(array('Group' => $group_id, 'Ticket' => $ticket_id));
$forward->create();
return "SUCCESS_FORWARDED";
}
/**
* get the id of the group a ticket is forwarded to.
* @param $ticket_id the id of the ticket.
@ -46,8 +46,8 @@ class Forwarded{
$forw->load($ticket_id);
return $forw->getGroup();
}
/**
* check if the ticket is forwarded
* @param $ticket_id the id of the ticket.
@ -59,21 +59,21 @@ class Forwarded{
return true;
}else{
return false;
}
}
}
////////////////////////////////////////////Methods////////////////////////////////////////////////////
/**
* A constructor.
* Empty constructor
*/
public function __construct() {
}
/**
* sets the object's attributes.
* @param $values should be an array of the form array('Group' => group_id, 'Ticket' => ticket_id).
@ -82,8 +82,8 @@ class Forwarded{
$this->setGroup($values['Group']);
$this->setTicket($values['Ticket']);
}
/**
* creates a new 'forwarded' entry.
* this method will use the object's attributes for creating a new 'forwarded' entry in the database.
@ -92,15 +92,15 @@ class Forwarded{
$dbl = new DBLayer("lib");
$dbl->insert("`forwarded`", Array('Group' => $this->getGroup(), 'Ticket' => $this->getTicket()));
}
/**
* deletes an existing 'forwarded' entry.
* this method will use the object's attributes for deleting an existing 'forwarded' entry in the database.
*/
public function delete() {
$dbl = new DBLayer("lib");
$dbl->delete("`forwarded`", array('group_id' => $this->getGroup() ,'ticket_id' => $this->getTicket(), "`Group` = :group_id and `Ticket` = :ticket_id");
$dbl->delete("`forwarded`", array('group_id' => $this->getGroup() ,'ticket_id' => $this->getTicket(), "`Group` = :group_id and `Ticket` = :ticket_id"));
}
@ -115,24 +115,24 @@ class Forwarded{
$row = $statement->fetch();
$this->set($row);
}
////////////////////////////////////////////Getters////////////////////////////////////////////////////
/**
* get group attribute of the object.
*/
public function getGroup(){
return $this->group;
}
/**
* get ticket attribute of the object.
*/
public function getTicket(){
return $this->ticket;
}
////////////////////////////////////////////Setters////////////////////////////////////////////////////
/**
@ -142,7 +142,7 @@ class Forwarded{
public function setGroup($g){
$this->group = $g;
}
/**
* set ticket attribute of the object.
* @param $t integer id of the ticket
@ -150,6 +150,6 @@ class Forwarded{
public function setTicket($t){
$this->ticket = $t;
}
}

View file

@ -6,19 +6,19 @@
* @author Daan Janssens, mentored by Matthew Lagoe
*/
class Ticket{
private $tId; /**< The id of ticket */
private $timestamp; /**< Timestamp of the ticket */
private $title; /**< Title of the ticket */
private $status; /**< Status of the ticket (0 = waiting on user reply, 1 = waiting on support, (2= not used atm), 3 = closed */
private $queue; /**< (not in use atm) */
private $ticket_category; /**< the id of the category belonging to the ticket */
private $author; /**< The ticket_users id */
private $priority; /**< The priority of the ticket where 0 = low, 3= supadupahigh */
private $tId; /**< The id of ticket */
private $timestamp; /**< Timestamp of the ticket */
private $title; /**< Title of the ticket */
private $status; /**< Status of the ticket (0 = waiting on user reply, 1 = waiting on support, (2= not used atm), 3 = closed */
private $queue; /**< (not in use atm) */
private $ticket_category; /**< the id of the category belonging to the ticket */
private $author; /**< The ticket_users id */
private $priority; /**< The priority of the ticket where 0 = low, 3= supadupahigh */
////////////////////////////////////////////Functions////////////////////////////////////////////////////
/**
* check if a ticket exists.
* @param $id the id of the ticket to be checked.
@ -31,10 +31,10 @@ class Ticket{
return true;
}else{
return false;
}
}
}
/**
* return an array of the possible statuses
* @return an array containing the string values that represent the different statuses.
@ -51,8 +51,8 @@ class Ticket{
public static function getPriorityArray() {
return Array("Low","Normal","High","Super Dupa High");
}
/**
* return an entire ticket.
* returns the ticket object and an array of all replies to that ticket.
@ -64,10 +64,10 @@ class Ticket{
$ticket = new Ticket();
$ticket->load_With_TId($id);
$reply_array = Ticket_Reply::getRepliesOfTicket($id, $view_as_admin);
return Array('ticket_obj' => $ticket,'reply_array' => $reply_array);
return Array('ticket_obj' => $ticket,'reply_array' => $reply_array);
}
/**
* return all tickets of a specific user.
* an array of all tickets created by a specific user are returned by this function.
@ -90,11 +90,11 @@ class Ticket{
$instance->setAuthor($ticket['Author']);
$result[] = $instance;
}
return $result;
return $result;
}
/**
* 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.
@ -117,13 +117,13 @@ class Ticket{
$ticket->set($values);
$ticket->create();
$ticket_id = $ticket->getTId();
//if ingame then add an extra info
if(Helpers::check_if_game_client() && $extra_info != 0){
$extra_info['Ticket'] = $ticket_id;
Ticket_Info::create_Ticket_Info($extra_info);
}
//write a log entry
if ( $author == $real_author){
Ticket_Log::createLogEntry( $ticket_id, $author, 1);
@ -131,18 +131,18 @@ class Ticket{
Ticket_Log::createLogEntry( $ticket_id, $real_author, 2, $author);
}
Ticket_Reply::createReply($content, $author, $ticket_id, 0, $author);
//forwards the ticket directly after creation to the supposed support group
if($for_support_group){
Ticket::forwardTicket(0, $ticket_id, $for_support_group);
}
//send email that new ticket has been created
Mail_Handler::send_ticketing_mail($ticket->getAuthor(), $ticket, $content, "NEW", $ticket->getForwardedGroupId());
return $ticket_id;
}
/**
* updates the ticket's status.
@ -152,7 +152,7 @@ class Ticket{
* @param $author the user (id) that performed the update status action
*/
public static function updateTicketStatus( $ticket_id, $newStatus, $author) {
$ticket = new Ticket();
$ticket->load_With_TId($ticket_id);
if ($ticket->getStatus() != $newStatus){
@ -160,10 +160,10 @@ class Ticket{
Ticket_Log::createLogEntry( $ticket_id, $author, 5, $newStatus);
}
$ticket->update();
}
/**
* 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.
@ -174,7 +174,7 @@ class Ticket{
* @param $author the user (id) that performed the update
*/
public static function updateTicketStatusAndPriority( $ticket_id, $newStatus, $newPriority, $author) {
$ticket = new Ticket();
$ticket->load_With_TId($ticket_id);
if ($ticket->getStatus() != $newStatus){
@ -186,10 +186,10 @@ class Ticket{
Ticket_Log::createLogEntry( $ticket_id, $author, 6, $newPriority);
}
$ticket->update();
}
/**
* return the latest reply of a ticket
* @param $ticket_id the id of the ticket.
@ -202,8 +202,8 @@ class Ticket{
$reply->set($statement->fetch());
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.
@ -222,13 +222,13 @@ class Ticket{
//if status is not closed
if($ticket->getStatus() != 3){
Ticket_Reply::createReply($content, $author, $ticket_id, $hidden, $ticket->getAuthor());
//notify ticket author that a new reply is added!
if($ticket->getAuthor() != $author){
Mail_Handler::send_ticketing_mail($ticket->getAuthor(), $ticket, $content, "REPLY", $ticket->getForwardedGroupId());
}
}else{
//TODO: Show error message that ticket is closed
}
@ -236,8 +236,8 @@ class Ticket{
//TODO: Show error content is empty
}
}
/**
* 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.
@ -254,8 +254,8 @@ class Ticket{
return "TICKET_NOT_EXISTING";
}
}
/**
* unassign a ticket of a user.
* Checks if the ticket exists, if so then it will try to unassign the user of it, a log entry will be written about this.
@ -272,8 +272,8 @@ class Ticket{
return "TICKET_NOT_EXISTING";
}
}
/**
* forward a ticket to a specific support group.
* Checks if the ticket exists, if so then it will try to forward the ticket to the support group specified, a log entry will be written about this.
@ -288,7 +288,7 @@ class Ticket{
if(isset($group_id) && $group_id != ""){
//forward the ticket
$returnvalue = Forwarded::forwardTicket($group_id, $ticket_id);
if($user_id != 0){
//unassign the ticket incase the ticket is assined to yourself
self::unAssignTicket($user_id, $ticket_id);
@ -303,12 +303,12 @@ class Ticket{
return "TICKET_NOT_EXISTING";
}
}
////////////////////////////////////////////Methods////////////////////////////////////////////////////
/**
* A constructor.
* Empty constructor
@ -335,18 +335,18 @@ class Ticket{
$this->author = $values['Author'];
$this->priority = $values['Priority'];
}
/**
* creates a new 'ticket' entry.
* this method will use the object's attributes for creating a new 'ticket' entry in the database.
*/
public function create(){
$dbl = new DBLayer("lib");
$this->tId = $dbl->executeReturnId("ticket", Array('Timestamp'=>now(), 'Title' => $this->title, 'Status' => $this->status, 'Queue' => $this->queue, 'Ticket_Category' => $this->ticket_category, 'Author' => $this->author, 'Priority' => $this->priority));
$this->tId = $dbl->executeReturnId("ticket", Array('Title' => $this->title, 'Status' => $this->status, 'Queue' => $this->queue, 'Ticket_Category' => $this->ticket_category, 'Author' => $this->author, 'Priority' => $this->priority), array('Timestamp'=>'now()'));
}
/**
* loads the object's attributes.
* loads the object's attributes by giving a TId (ticket id).
@ -365,8 +365,8 @@ class Ticket{
$this->author = $row['Author'];
$this->priority = $row['Priority'];
}
/**
* update the objects attributes to the db.
*/
@ -374,8 +374,8 @@ class Ticket{
$dbl = new DBLayer("lib");
$dbl->update("ticket", Array('Timestamp' => $this->timestamp, 'Title' => $this->title, 'Status' => $this->status, 'Queue' => $this->queue, 'Ticket_Category' => $this->ticket_category, 'Author' => $this->author, 'Priority' => $this->priority), "TId=$this->tId");
}
/**
* check if a ticket has a ticket_info page or not.
* @return true or false
@ -383,38 +383,38 @@ class Ticket{
public function hasInfo(){
return Ticket_Info::TicketHasInfo($this->getTId());
}
////////////////////////////////////////////Getters////////////////////////////////////////////////////
/**
* get tId attribute of the object.
*/
public function getTId(){
return $this->tId;
}
/**
* get timestamp attribute of the object in the format defined in the outputTime function of the Helperclass.
*/
public function getTimestamp(){
return Helpers::outputTime($this->timestamp);
}
/**
* get title attribute of the object.
*/
public function getTitle(){
return $this->title;
}
/**
* get status attribute of the object.
*/
public function getStatus(){
return $this->status;
}
/**
* get status attribute of the object in the form of text (string).
*/
@ -422,43 +422,43 @@ class Ticket{
$statusArray = Ticket::getStatusArray();
return $statusArray[$this->getStatus()];
}
/**
* get category attribute of the object in the form of text (string).
*/
public function getCategoryName(){
$category = Ticket_Category::constr_TCategoryId($this->getTicket_Category());
return $category->getName();
return $category->getName();
}
/**
* get queue attribute of the object.
*/
public function getQueue(){
return $this->queue;
}
/**
* get ticket_category attribute of the object (int).
*/
public function getTicket_Category(){
return $this->ticket_category;
}
/**
* get author attribute of the object (int).
*/
public function getAuthor(){
return $this->author;
}
/**
* get priority attribute of the object (int).
*/
public function getPriority(){
return $this->priority;
}
/**
* get priority attribute of the object in the form of text (string).
*/
@ -466,7 +466,7 @@ class Ticket{
$priorityArray = Ticket::getPriorityArray();
return $priorityArray[$this->getPriority()];
}
/**
* get the user assigned to the ticket.
* or return 0 in case not assigned.
@ -479,7 +479,7 @@ class Ticket{
return $user_id;
}
}
/**
* get the name of the support group to whom the ticket is forwarded
* or return 0 in case not forwarded.
@ -492,7 +492,7 @@ class Ticket{
return Support_Group::getGroup($group_id)->getName();
}
}
/**
* get the id of the support group to whom the ticket is forwarded
* or return 0 in case not forwarded.
@ -506,7 +506,7 @@ class Ticket{
}
}
////////////////////////////////////////////Setters////////////////////////////////////////////////////
/**
* set tId attribute of the object.
* @param $id integer id of the ticket
@ -514,7 +514,7 @@ class Ticket{
public function setTId($id){
$this->tId = $id;
}
/**
* set timestamp attribute of the object.
* @param $ts timestamp of the ticket
@ -522,7 +522,7 @@ class Ticket{
public function setTimestamp($ts){
$this->timestamp = $ts;
}
/**
* set title attribute of the object.
* @param $t title of the ticket
@ -530,7 +530,7 @@ class Ticket{
public function setTitle($t){
$this->title = $t;
}
/**
* set status attribute of the object.
* @param $s status of the ticket(int)
@ -538,7 +538,7 @@ class Ticket{
public function setStatus($s){
$this->status = $s;
}
/**
* set queue attribute of the object.
* @param $q queue of the ticket
@ -546,7 +546,7 @@ class Ticket{
public function setQueue($q){
$this->queue = $q;
}
/**
* set ticket_category attribute of the object.
* @param $tc ticket_category id of the ticket(int)
@ -554,7 +554,7 @@ class Ticket{
public function setTicket_Category($tc){
$this->ticket_category = $tc;
}
/**
* set author attribute of the object.
* @param $a author of the ticket
@ -562,7 +562,7 @@ class Ticket{
public function setAuthor($a){
$this->author = $a;
}
/**
* set priority attribute of the object.
* @param $p priority of the ticket
@ -570,5 +570,5 @@ class Ticket{
public function setPriority($p){
$this->priority = $p;
}
}

View file

@ -2,7 +2,7 @@
/**
* Class that handles the logging. The logging will be used when a ticket is created, a reply is added, if someone views a ticket,
* if someone assigns a ticket to him or if someone forwards a ticket. This class provides functions to get retrieve those logs and also make them.
*
*
*-the Action IDs being used are:
* -# User X Created ticket
* -# Admin X created ticket for arg
@ -18,13 +18,13 @@
*/
class Ticket_Log{
private $tLogId; /**< The id of the log entry */
private $timestamp; /**< The timestamp of the log entry */
private $query; /**< The query (json encoded array containing action id & argument) */
private $author; /**< author of the log */
private $ticket; /**< the id of the ticket related to the log entry */
private $tLogId; /**< The id of the log entry */
private $timestamp; /**< The timestamp of the log entry */
private $query; /**< The query (json encoded array containing action id & argument) */
private $author; /**< author of the log */
private $ticket; /**< the id of the ticket related to the log entry */
/****************************************
*Action ID's:
* 1: User X Created Ticket
@ -38,10 +38,10 @@ class Ticket_Log{
* 9: unassigned to the ticket
*
****************************************/
////////////////////////////////////////////Functions////////////////////////////////////////////////////
/**
* 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.
@ -65,10 +65,10 @@ class Ticket_Log{
$instanceLog->setQuery($log['Query']);
$result[] = $instanceLog;
}
return $result;
return $result;
}
/**
* create a new log entry.
* It will check if the $TICKET_LOGGING global var is true, this var is used to turn logging on and off. In case it's on, the log message will be stored.
@ -82,8 +82,8 @@ class Ticket_Log{
global $TICKET_LOGGING;
if($TICKET_LOGGING){
$dbl = new DBLayer("lib");
$values = Array('Timestamp'=>now(), 'Query' => json_encode(array($action,$arg)), 'Ticket' => $ticket_id, 'Author' => $author_id);
$dbl->insert("ticket_log", $values);
$values = Array('Query' => json_encode(array($action,$arg)), 'Ticket' => $ticket_id, 'Author' => $author_id);
$dbl->insert("ticket_log", $values, array('Timestamp'=>'now()'));
}
}
@ -98,7 +98,7 @@ class Ticket_Log{
$instance->setTLogId($id);
return $instance;
}
/**
* 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.
@ -115,19 +115,19 @@ class Ticket_Log{
$instance->set($log);
$result[] = $instance;
}
return $result;
return $result;
}
////////////////////////////////////////////Methods////////////////////////////////////////////////////
/**
* A constructor.
* Empty constructor
*/
public function __construct() {
}
/**
* sets the object's attributes.
* @param $values should be an array.
@ -138,7 +138,7 @@ class Ticket_Log{
$this->setQuery($values['Query']);
$this->setTicket($values['Ticket']);
$this->setAuthor($values['Author']);
}
}
/**
* loads the object's attributes.
@ -151,56 +151,56 @@ class Ticket_Log{
$row = $statement->fetch();
$this->set($row);
}
/**
* update attributes of the object to the DB.
*/
public function update(){
$dbl = new DBLayer("lib");
$values = Array('timestamp' => $this->getTimestamp(), 'query' => $this->getQuery(), 'author' => $this->getAuthor(), 'ticket' => $this->getTicket() );
$dbl->update("ticket_log", $values, "TLogId = $this->getTLogId()");
}
////////////////////////////////////////////Getters////////////////////////////////////////////////////
/**
* get tLogId attribute of the object.
*/
public function getTLogId(){
return $this->tLogId;
}
/**
* get timestamp attribute of the object.
*/
public function getTimestamp(){
return Helpers::outputTime($this->timestamp);
}
/**
* get query attribute of the object.
*/
public function getQuery(){
return $this->query;
}
/**
* get author attribute of the object.
*/
public function getAuthor(){
return $this->author;
}
/**
* get ticket attribute of the object.
*/
public function getTicket(){
return $this->ticket;
}
/**
* get the action id out of the query by decoding it.
*/
@ -208,7 +208,7 @@ class Ticket_Log{
$decodedQuery = json_decode($this->query);
return $decodedQuery[0];
}
/**
* get the argument out of the query by decoding it.
*/
@ -216,7 +216,7 @@ class Ticket_Log{
$decodedQuery = json_decode($this->query);
return $decodedQuery[1];
}
/**
* get the action text(string) array.
* this is being read from the language .ini files.
@ -229,9 +229,9 @@ class Ticket_Log{
}
return $result;
}
////////////////////////////////////////////Setters////////////////////////////////////////////////////
/**
* set tLogId attribute of the object.
* @param $id integer id of the log entry
@ -239,7 +239,7 @@ class Ticket_Log{
public function setTLogId($id){
$this->tLogId = $id;
}
/**
* set timestamp attribute of the object.
* @param $t timestamp of the log entry
@ -247,7 +247,7 @@ class Ticket_Log{
public function setTimestamp($t){
$this->timestamp = $t;
}
/**
* set query attribute of the object.
* @param $q the encoded query
@ -255,7 +255,7 @@ class Ticket_Log{
public function setQuery($q){
$this->query = $q;
}
/**
* set author attribute of the object.
* @param $a integer id of the user who created the log entry
@ -263,7 +263,7 @@ class Ticket_Log{
public function setAuthor($a){
$this->author = $a;
}
/**
* set ticket attribute of the object.
* @param $t integer id of ticket of which the log entry is related to.
@ -271,6 +271,6 @@ class Ticket_Log{
public function setTicket($t){
$this->ticket = $t;
}
}

View file

@ -4,15 +4,15 @@
* @author Daan Janssens, mentored by Matthew Lagoe
*/
class Ticket_Reply{
private $tReplyId; /**< The id of the reply */
private $ticket; /**< the ticket id related to the reply */
private $content; /**< the content of the reply */
private $author; /**< The id of the user that made the reply */
private $timestamp; /**< The timestamp of the reply */
private $hidden; /**< indicates if reply should be hidden for normal users or not */
private $tReplyId; /**< The id of the reply */
private $ticket; /**< the ticket id related to the reply */
private $content; /**< the content of the reply */
private $author; /**< The id of the user that made the reply */
private $timestamp; /**< The timestamp of the reply */
private $hidden; /**< indicates if reply should be hidden for normal users or not */
////////////////////////////////////////////Functions////////////////////////////////////////////////////
/**
* return constructed element based on TReplyId.
* @param $id the Id the reply we want to load.
@ -23,8 +23,8 @@ class Ticket_Reply{
$instance->setTReplyId($id);
return $instance;
}
/**
* return all replies on a specific ticket.
* @param $ticket_id the id of the ticket of which we want the replies.
@ -43,12 +43,12 @@ class Ticket_Reply{
$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']);
@ -60,9 +60,9 @@ class Ticket_Reply{
$result[] = $instanceReply;
}
}
return $result;
return $result;
}
/**
* 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.
@ -78,19 +78,19 @@ class Ticket_Reply{
$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);
}
////////////////////////////////////////////Methods////////////////////////////////////////////////////
/**
@ -116,14 +116,14 @@ class Ticket_Reply{
$this->setHidden($values['Hidden']);
}
}
/**
* creates a new 'ticket_reply' entry.
* this method will use the object's attributes for creating a new 'ticket_reply' entry in the database (the now() function will create the timestamp).
*/
public function create(){
$dbl = new DBLayer("lib");
$this->tReplyId = $dbl->executeReturnId("ticket_reply", Array('Ticket' => $this->ticket, 'Content' => $this->content, 'Author' => $this->author,'Timestamp'=>now(), 'Hidden' => $this->hidden));
$this->tReplyId = $dbl->executeReturnId("ticket_reply", Array('Ticket' => $this->ticket, 'Content' => $this->content, 'Author' => $this->author, 'Hidden' => $this->hidden), array('Timestamp'=>'now()'));
}
/**
@ -142,7 +142,7 @@ class Ticket_Reply{
$this->timestamp = $row['Timestamp'];
$this->hidden = $row['Hidden'];
}
/**
* updates a ticket_reply entry based on the objects attributes.
*/
@ -150,16 +150,16 @@ class Ticket_Reply{
$dbl = new DBLayer("lib");
$dbl->update("ticket", Array('Ticket' => $this->ticket, 'Content' => $this->content, 'Author' => $this->author, 'Timestamp' => $this->timestamp, 'Hidden' => $this->hidden), "TReplyId=$this->tReplyId, ");
}
////////////////////////////////////////////Getters////////////////////////////////////////////////////
/**
* get ticket attribute of the object.
*/
public function getTicket(){
return $this->ticket;
}
/**
* get content attribute of the object.
*/
@ -173,7 +173,7 @@ class Ticket_Reply{
public function getAuthor(){
return $this->author;
}
/**
* get timestamp attribute of the object.
* The output format is defined by the Helpers class function, outputTime().
@ -181,23 +181,23 @@ class Ticket_Reply{
public function getTimestamp(){
return Helpers::outputTime($this->timestamp);
}
/**
* get tReplyId attribute of the object.
*/
public function getTReplyId(){
return $this->tReplyId;
}
/**
* get hidden attribute of the object.
*/
public function getHidden(){
return $this->hidden;
}
}
////////////////////////////////////////////Setters////////////////////////////////////////////////////
/**
* set ticket attribute of the object.
* @param $t integer id of the ticket
@ -205,7 +205,7 @@ class Ticket_Reply{
public function setTicket($t){
$this->ticket = $t;
}
/**
* set content attribute of the object.
* @param $c integer id of the ticket_content entry
@ -213,7 +213,7 @@ class Ticket_Reply{
public function setContent($c){
$this->content = $c;
}
/**
* set author attribute of the object.
* @param $a integer id of the user
@ -221,7 +221,7 @@ class Ticket_Reply{
public function setAuthor($a){
$this->author = $a;
}
/**
* set timestamp attribute of the object.
* @param $t timestamp of the reply
@ -229,7 +229,7 @@ class Ticket_Reply{
public function setTimestamp($t){
$this->timestamp = $t;
}
/**
* set tReplyId attribute of the object.
* @param $i integer id of the ticket_reply
@ -237,7 +237,7 @@ class Ticket_Reply{
public function setTReplyId($i){
$this->tReplyId = $i;
}
/**
* set hidden attribute of the object.
* @param $h should be 0 or 1