diff --git a/api/ApplicationContext.php b/api/ApplicationContext.php index 09e4cdd4..aa09011c 100644 --- a/api/ApplicationContext.php +++ b/api/ApplicationContext.php @@ -1,17 +1,16 @@ id = $row['id']; + $ticket->id = intval($row['id']); $ticket->trackingId = $row['trackid']; $ticket->name = $row['name']; $ticket->email = $row['email']; - $ticket->categoryId = $row['category']; - $ticket->priorityId = $row['priority']; + $ticket->categoryId = intval($row['category']); + $ticket->priorityId = intval($row['priority']); $ticket->subject = $row['subject']; $ticket->message = $row['message']; $ticket->dateCreated = $row['dt']; $ticket->lastChanged = $row['lastchange']; $ticket->firstReplyDate = $row['firstreply']; $ticket->closedDate = $row['closedat']; - $ticket->suggestedArticles = explode(',', $row['articles']); + + if (trim($row['articles']) !== '') { + $ticket->suggestedArticles = explode(',', $row['articles']); + } + $ticket->ipAddress = $row['ip']; $ticket->language = $row['language']; - $ticket->statusId = $row['status']; - $ticket->openedBy = $row['openedby']; - $ticket->firstReplyByUserId = $row['firstreplyby']; - $ticket->closedByUserId = $row['closedby']; - $ticket->numberOfReplies = $row['replies']; - $ticket->numberOfStaffReplies = $row['staffreplies']; - $ticket->ownerId = $row['owner']; + $ticket->statusId = intval($row['status']); + $ticket->openedBy = intval($row['openedby']); + $ticket->firstReplyByUserId = $row['firstreplyby'] === null ? null : intval($row['firstreplyby']); + $ticket->closedByUserId = $row['closedby'] === null ? null : intval($row['closedby']); + $ticket->numberOfReplies = intval($row['replies']); + $ticket->numberOfStaffReplies = intval($row['staffreplies']); + $ticket->ownerId = intval($row['owner']); $ticket->timeWorked = $row['time_worked']; - $ticket->lastReplyBy = $row['lastreplier']; - $ticket->lastReplier = $row['replierid']; + $ticket->lastReplyBy = intval($row['lastreplier']); + $ticket->lastReplier = $row['replierid'] === null ? null : intval($row['replierid']); $ticket->archived = intval($row['archive']) === 1; $ticket->locked = intval($row['locked']) === 1; @@ -68,15 +72,23 @@ class Ticket { $ticket->linkedTicketIds[] = $linkedTicketsRow['id']; } - $ticket->location = array(); - $ticket->location[0] = $row['latitude']; - $ticket->location[1] = $row['longitude']; + if ($row['latitude'] !== '' && $row['longitude'] !== '') { + $ticket->location = array(); + $ticket->location[0] = $row['latitude']; + $ticket->location[1] = $row['longitude']; + } $ticket->usesHtml = intval($row['html']) === 1; - $ticket->userAgent = $row['user_agent']; - $ticket->screenResolution = array(); - $ticket->screenResolution[0] = $row['screen_resolution_width']; - $ticket->screenResolution[1] = $row['screen_resolution_height']; + + if ($row['user_agent'] !== null && trim($row['user_agent']) !== '') { + $ticket->userAgent = $row['user_agent']; + } + + if ($row['screen_resolution_height'] !== null && $row['screen_resolution_width'] !== null){ + $ticket->screenResolution = array(); + $ticket->screenResolution[0] = $row['screen_resolution_width']; + $ticket->screenResolution[1] = $row['screen_resolution_height']; + } $ticket->dueDate = $row['due_date']; $ticket->dueDateOverdueEmailSent = $row['overdue_email_sent'] !== null && intval($row['overdue_email_sent']) === 1; diff --git a/api/businesslogic/ticket/TicketCreator.php b/api/BusinessLogic/Tickets/TicketCreator.php similarity index 98% rename from api/businesslogic/ticket/TicketCreator.php rename to api/BusinessLogic/Tickets/TicketCreator.php index f34ae95f..74d7786d 100644 --- a/api/businesslogic/ticket/TicketCreator.php +++ b/api/BusinessLogic/Tickets/TicketCreator.php @@ -22,7 +22,7 @@ class TicketCreator { throw new ValidationException($validationModel); } - // Create the ticket + // Create the Tickets } /** @@ -30,7 +30,7 @@ class TicketCreator { * @param $staff bool * @param $heskSettings array HESK settings * @param $modsForHeskSettings array Mods for HESK settings - * @return ValidationModel If errorKeys is empty, validation successful. Otherwise invalid ticket + * @return ValidationModel If errorKeys is empty, validation successful. Otherwise invalid Tickets */ function validate($ticketRequest, $staff, $heskSettings, $modsForHeskSettings) { $TICKET_PRIORITY_CRITICAL = 0; diff --git a/api/businesslogic/ticket/TicketRetriever.php b/api/BusinessLogic/Tickets/TicketRetriever.php similarity index 100% rename from api/businesslogic/ticket/TicketRetriever.php rename to api/BusinessLogic/Tickets/TicketRetriever.php diff --git a/api/businesslogic/ticket/TicketValidators.php b/api/BusinessLogic/Tickets/TicketValidators.php similarity index 100% rename from api/businesslogic/ticket/TicketValidators.php rename to api/BusinessLogic/Tickets/TicketValidators.php diff --git a/api/controllers/CategoryController.php b/api/Controllers/Categories/CategoryController.php similarity index 100% rename from api/controllers/CategoryController.php rename to api/Controllers/Categories/CategoryController.php diff --git a/api/controllers/TicketController.php b/api/Controllers/Tickets/TicketController.php similarity index 100% rename from api/controllers/TicketController.php rename to api/Controllers/Tickets/TicketController.php diff --git a/api/core/SQLException.php b/api/Core/Exceptions/SQLException.php similarity index 72% rename from api/core/SQLException.php rename to api/Core/Exceptions/SQLException.php index e9530a5b..db3f412b 100644 --- a/api/core/SQLException.php +++ b/api/Core/Exceptions/SQLException.php @@ -13,6 +13,6 @@ class SQLException extends Exception { function __construct($failingQuery) { $this->failingQuery = $failingQuery; - parent::__construct('A SQL exception occurred. Check the logs for more information.'); + parent::__construct('A SQL Exceptions occurred. Check the logs for more information.'); } } \ No newline at end of file diff --git a/api/dao/category/CategoryGateway.php b/api/DataAccess/Categories/CategoryGateway.php similarity index 94% rename from api/dao/category/CategoryGateway.php rename to api/DataAccess/Categories/CategoryGateway.php index a2e02174..d12a7e92 100644 --- a/api/dao/category/CategoryGateway.php +++ b/api/DataAccess/Categories/CategoryGateway.php @@ -1,8 +1,9 @@ " . intval($user['id']) . "))"; @@ -34,7 +34,7 @@ function build_results($response) { $results = array(); while ($row = hesk_dbFetchAssoc($response)) { $row['id'] = intval($row['id']); - $row['category'] = intval($row['category']); + $row['Categories'] = intval($row['Categories']); $row['priority'] = intval($row['priority']); $row['status'] = intval($row['status']); $row['replierid'] = intval($row['replierid']); diff --git a/api/dao/ticket_template_dao.php b/api/DataAccess/ticket_template_dao.php similarity index 100% rename from api/dao/ticket_template_dao.php rename to api/DataAccess/ticket_template_dao.php diff --git a/api/dao/user_dao.php b/api/DataAccess/user_dao.php similarity index 100% rename from api/dao/user_dao.php rename to api/DataAccess/user_dao.php diff --git a/api/autoload.php b/api/autoload.php index d468c912..c00cea7b 100644 --- a/api/autoload.php +++ b/api/autoload.php @@ -1,55 +1,15 @@ failingQuery, $exception->getTraceAsString())); + print_error("Fought an uncaught Exceptions", sprintf("%s\n\n%s", $castedException->failingQuery, $exception->getTraceAsString())); } else { - print_error("Fought an uncaught exception", sprintf("%s\n\n%s", $exception->getMessage(), $exception->getTraceAsString())); + print_error("Fought an uncaught Exceptions", sprintf("%s\n\n%s", $exception->getMessage(), $exception->getTraceAsString())); } } @@ -61,8 +63,8 @@ function exceptionHandler($exception) { } /** - * @param $exception Exception thrown exception - * @param $class string The name of the expected exception type + * @param $exception Exception thrown Exceptions + * @param $class string The name of the expected Exceptions type * @return bool */ function exceptionIsOfType($exception, $class) {