diff --git a/api/ApplicationContext.php b/api/ApplicationContext.php index dae5a238..55cb52b7 100644 --- a/api/ApplicationContext.php +++ b/api/ApplicationContext.php @@ -3,6 +3,7 @@ // Responsible for loading in all necessary classes. AKA a poor man's DI solution. use BusinessLogic\Attachments\AttachmentHandler; use BusinessLogic\Attachments\AttachmentRetriever; +use BusinessLogic\Categories\CategoryHandler; use BusinessLogic\Categories\CategoryRetriever; use BusinessLogic\Emails\BasicEmailSender; use BusinessLogic\Emails\EmailSenderHelper; @@ -73,6 +74,7 @@ class ApplicationContext { // Categories $this->get[CategoryGateway::class] = new CategoryGateway(); $this->get[CategoryRetriever::class] = new CategoryRetriever($this->get[CategoryGateway::class]); + $this->get[CategoryHandler::class] = new CategoryHandler($this->get[CategoryGateway::class]); // Bans $this->get[BanGateway::class] = new BanGateway(); diff --git a/api/DataAccess/Categories/CategoryGateway.php b/api/DataAccess/Categories/CategoryGateway.php index bf48f5b4..00d24edb 100644 --- a/api/DataAccess/Categories/CategoryGateway.php +++ b/api/DataAccess/Categories/CategoryGateway.php @@ -4,6 +4,7 @@ namespace DataAccess\Categories; use BusinessLogic\Categories\Category; use DataAccess\CommonDao; +use DataAccess\Logging\LoggingGateway; use Exception; class CategoryGateway extends CommonDao { @@ -57,10 +58,10 @@ class CategoryGateway extends CommonDao { (`name`, `cat_order`, `autoassign`, `type`, `priority`, `manager`, `background_color`, `usage`, `foreground_color`, `display_border_outline`, `mfh_description`) VALUES ('" . hesk_dbEscape($category->name) . "', " . intval($newOrder['cat_order']) . ", - '" . $category->autoAssign ? 1 : 0 . "', '" . intval($category->type) . "', - '" . intval($category->priority) . "', " . $category->manager === null ? 'NULL' : intval($category->manager) . ", + '" . ($category->autoAssign ? 1 : 0) . "', '" . intval($category->type) . "', + '" . intval($category->priority) . "', " . ($category->manager === null ? 0 : intval($category->manager)) . ", '" . hesk_dbEscape($category->backgroundColor) . "', " . intval($category->usage) . ", - '" . hesk_dbEscape($category->foregroundColor) . "', '" . $category->displayBorder ? 1 : 0 . "', + '" . hesk_dbEscape($category->foregroundColor) . "', '" . ($category->displayBorder ? 1 : 0) . "', '" . hesk_dbEscape($category->description) . "')"; hesk_dbQuery($sql); diff --git a/api/Link.php b/api/Link.php index f2dbba22..38b8c6e3 100644 --- a/api/Link.php +++ b/api/Link.php @@ -1,5 +1,7 @@ action(\Controllers\Categories\CategoryController::class . '::printAllCategories', [RequestMethod::GET]), + '/v1/categories/all' => action(\Controllers\Categories\CategoryController::class . '::printAllCategories', [RequestMethod::GET]), + '/v1/categories' => action(\Controllers\Categories\CategoryController::class, [RequestMethod::POST]), '/v1/categories/{i}' => action(\Controllers\Categories\CategoryController::class), // Tickets '/v1/tickets' => action(\Controllers\Tickets\CustomerTicketController::class),