Add endpoint for retrieving helpdesk settings
This commit is contained in:
parent
7494efb8ca
commit
ee4ba00fe9
@ -13,6 +13,7 @@ use BusinessLogic\Security\BanRetriever;
|
|||||||
use BusinessLogic\Security\UserContextBuilder;
|
use BusinessLogic\Security\UserContextBuilder;
|
||||||
use BusinessLogic\Security\UserToTicketChecker;
|
use BusinessLogic\Security\UserToTicketChecker;
|
||||||
use BusinessLogic\Settings\ApiChecker;
|
use BusinessLogic\Settings\ApiChecker;
|
||||||
|
use BusinessLogic\Settings\SettingsRetriever;
|
||||||
use BusinessLogic\Statuses\StatusRetriever;
|
use BusinessLogic\Statuses\StatusRetriever;
|
||||||
use BusinessLogic\Tickets\Autoassigner;
|
use BusinessLogic\Tickets\Autoassigner;
|
||||||
use BusinessLogic\Tickets\TicketDeleter;
|
use BusinessLogic\Tickets\TicketDeleter;
|
||||||
@ -124,5 +125,8 @@ class ApplicationContext {
|
|||||||
|
|
||||||
// Statuses
|
// Statuses
|
||||||
$this->get[StatusRetriever::class] = new StatusRetriever($this->get[StatusGateway::class]);
|
$this->get[StatusRetriever::class] = new StatusRetriever($this->get[StatusGateway::class]);
|
||||||
|
|
||||||
|
// Settings
|
||||||
|
$this->get[SettingsRetriever::class] = new SettingsRetriever($this->get[ModsForHeskSettingsGateway::class]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3,20 +3,84 @@
|
|||||||
namespace BusinessLogic\Settings;
|
namespace BusinessLogic\Settings;
|
||||||
|
|
||||||
// TODO Test!
|
// TODO Test!
|
||||||
|
use DataAccess\Settings\ModsForHeskSettingsGateway;
|
||||||
|
|
||||||
class SettingsRetriever {
|
class SettingsRetriever {
|
||||||
|
/* @var $modsForHeskSettingsGateway ModsForHeskSettingsGateway */
|
||||||
|
private $modsForHeskSettingsGateway;
|
||||||
|
|
||||||
|
function __construct($modsForHeskSettingsGateway) {
|
||||||
|
$this->modsForHeskSettingsGateway = $modsForHeskSettingsGateway;
|
||||||
|
}
|
||||||
|
|
||||||
private static $settingsToNotReturn = array(
|
private static $settingsToNotReturn = array(
|
||||||
'webmaster_email',
|
'webmaster_email',
|
||||||
'noreply_email',
|
'noreply_email',
|
||||||
'noreply_name',
|
'noreply_name',
|
||||||
'db_.*',
|
'db_.*',
|
||||||
|
'admin_dir',
|
||||||
|
'attach_dir',
|
||||||
|
'cache_dir',
|
||||||
|
'autoclose',
|
||||||
|
'autologin',
|
||||||
|
'autoassign',
|
||||||
|
'secimg_.*',
|
||||||
|
'recaptcha_.*',
|
||||||
|
'question_.*',
|
||||||
|
'attempt_.*',
|
||||||
|
'reset_pass',
|
||||||
|
'x_frame_opt',
|
||||||
|
'force_ssl',
|
||||||
|
'imap.*',
|
||||||
|
'smtp.*',
|
||||||
|
'email_piping',
|
||||||
|
'pop3.*',
|
||||||
|
'loop.*',
|
||||||
|
'email_providers',
|
||||||
|
'notify_.*',
|
||||||
|
'alink',
|
||||||
|
'submit_notice',
|
||||||
|
'online',
|
||||||
|
'online_min',
|
||||||
|
'modsForHeskVersion',
|
||||||
|
'use_mailgun',
|
||||||
|
'mailgun.*',
|
||||||
|
'kb_attach_dir',
|
||||||
|
'public_api',
|
||||||
|
'custom_fields',
|
||||||
|
'hesk_version',
|
||||||
|
'hesk_license',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $heskSettings array
|
* @param $heskSettings array
|
||||||
* @param $modsForHeskSettings array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getAllSettings($heskSettings, $modsForHeskSettings) {
|
function getAllSettings($heskSettings) {
|
||||||
|
$modsForHeskSettings = $this->modsForHeskSettingsGateway->getAllSettings($heskSettings);
|
||||||
|
$settingsToReturn = array();
|
||||||
|
|
||||||
|
foreach ($heskSettings as $key => $value) {
|
||||||
|
if ($this->isPermittedKey($key)) {
|
||||||
|
$settingsToReturn[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($modsForHeskSettings as $key => $value) {
|
||||||
|
if ($this->isPermittedKey($key)) {
|
||||||
|
$settingsToReturn[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $settingsToReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function isPermittedKey($key) {
|
||||||
|
foreach (self::$settingsToNotReturn as $setting) {
|
||||||
|
if (preg_match("/{$setting}/", $key)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
17
api/Controllers/Settings/SettingsController.php
Normal file
17
api/Controllers/Settings/SettingsController.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Controllers\Settings;
|
||||||
|
|
||||||
|
|
||||||
|
use BusinessLogic\Settings\SettingsRetriever;
|
||||||
|
|
||||||
|
class SettingsController {
|
||||||
|
function get() {
|
||||||
|
global $applicationContext, $hesk_settings, $modsForHesk_settings;
|
||||||
|
|
||||||
|
/* @var $settingsRetriever SettingsRetriever */
|
||||||
|
$settingsRetriever = $applicationContext->get[SettingsRetriever::class];
|
||||||
|
|
||||||
|
output($settingsRetriever->getAllSettings($hesk_settings, $modsForHesk_settings));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -159,6 +159,8 @@ Link::all(array(
|
|||||||
'/v1/staff/tickets/{i}/attachments/{i}' => \Controllers\Attachments\StaffTicketAttachmentsController::class,
|
'/v1/staff/tickets/{i}/attachments/{i}' => \Controllers\Attachments\StaffTicketAttachmentsController::class,
|
||||||
// Statuses
|
// Statuses
|
||||||
'/v1/statuses' => \Controllers\Statuses\StatusController::class,
|
'/v1/statuses' => \Controllers\Statuses\StatusController::class,
|
||||||
|
// Settings
|
||||||
|
'/v1/settings' => \Controllers\Settings\SettingsController::class,
|
||||||
|
|
||||||
// Any URL that doesn't match goes to the 404 handler
|
// Any URL that doesn't match goes to the 404 handler
|
||||||
'404' => 'handle404'
|
'404' => 'handle404'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user