opensupports/server/controllers/system/get-settings.php

86 lines
4.3 KiB
PHP
Raw Normal View History

<?php
2017-04-18 02:09:16 +02:00
/**
* @api {post} /system/get-settings Get settings
2019-10-08 01:21:43 +02:00
* @apiVersion 4.5.0
2017-04-18 02:09:16 +02:00
*
* @apiName Get settings
*
* @apiGroup System
2017-04-18 02:09:16 +02:00
*
* @apiDescription This path retrieves all the settings.
2017-04-18 02:09:16 +02:00
*
* @apiPermission any
*
* @apiParam {Boolean} allSettings Indicates if you want the regular settings list or a complete settings list. Complete list only available for staff level3.
2017-04-18 02:09:16 +02:00
*
2017-04-22 03:33:17 +02:00
* @apiSuccess {Object} data Contains the information about the settings
2017-04-18 02:09:16 +02:00
*
*/
class GetSettingsController extends Controller {
const PATH = '/get-settings';
const METHOD = 'POST';
public function validations() {
return [
'permission' => 'any',
'requestData' => []
];
}
public function handler() {
$settingsList = [];
if(InstallationDoneController::isInstallationDone()) {
if(Controller::request('allSettings') && Controller::isStaffLogged(3)) {
$settingsList = [
'language' => Setting::getSetting('language')->getValue(),
'reCaptchaKey' => Setting::getSetting('recaptcha-public')->getValue(),
'reCaptchaPrivate' => Setting::getSetting('recaptcha-private')->getValue(),
'time-zone' => Setting::getSetting('time-zone')->getValue(),
2018-07-06 21:06:51 +02:00
'maintenance-mode' => intval(Setting::getSetting('maintenance-mode')->getValue()),
'layout' => Setting::getSetting('layout')->getValue(),
2018-07-06 21:06:51 +02:00
'allow-attachments' => intval(Setting::getSetting('allow-attachments')->getValue()),
'max-size' => Setting::getSetting('max-size')->getValue(),
'url' => Setting::getSetting('url')->getValue(),
'title' => Setting::getSetting('title')->getValue(),
2019-01-12 04:38:33 +01:00
'server-email' => Setting::getSetting('server-email')->getValue(),
'smtp-host' => Setting::getSetting('smtp-host')->getValue(),
'smtp-user' => Setting::getSetting('smtp-user')->getValue(),
2019-01-12 04:38:33 +01:00
'imap-host' => Setting::getSetting('imap-host')->getValue(),
'imap-user' => Setting::getSetting('imap-user')->getValue(),
2019-01-19 00:58:30 +01:00
'imap-token' => Setting::getSetting('imap-token')->getValue(),
'registration' => Setting::getSetting('registration')->getValue(),
2018-11-16 00:51:44 +01:00
'departments' => Department::getAllDepartmentNames(),
'supportedLanguages' => Language::getSupportedLanguages(),
2017-06-14 05:37:40 +02:00
'allowedLanguages' => Language::getAllowedLanguages(),
'session-prefix' => Setting::getSetting('session-prefix')->getValue(),
2019-02-22 18:08:49 +01:00
'mail-template-header-image' => Setting::getSetting('mail-template-header-image')->getValue(),
'tags' => Tag::getAll()->toArray()
];
} else {
$settingsList = [
'language' => Setting::getSetting('language')->getValue(),
'reCaptchaKey' => Setting::getSetting('recaptcha-public')->getValue(),
'time-zone' => Setting::getSetting('time-zone')->getValue(),
2018-07-06 21:06:51 +02:00
'maintenance-mode' => intval(Setting::getSetting('maintenance-mode')->getValue()),
'layout' => Setting::getSetting('layout')->getValue(),
2018-07-06 21:06:51 +02:00
'allow-attachments' => intval(Setting::getSetting('allow-attachments')->getValue()),
'max-size' => Setting::getSetting('max-size')->getValue(),
'title' => Setting::getSetting('title')->getValue(),
'registration' => Setting::getSetting('registration')->getValue(),
2018-11-16 00:51:44 +01:00
'departments' => Controller::isStaffLogged() ? Department::getAllDepartmentNames() : Department::getPublicDepartmentNames(),
'supportedLanguages' => Language::getSupportedLanguages(),
'allowedLanguages' => Language::getAllowedLanguages(),
2018-07-06 21:06:51 +02:00
'user-system-enabled' => intval(Setting::getSetting('user-system-enabled')->getValue()),
2019-02-22 18:08:49 +01:00
'session-prefix' => Setting::getSetting('session-prefix')->getValue(),
'tags' => Tag::getAll()->toArray()
];
}
}
Response::respondSuccess($settingsList);
}
2018-07-06 21:06:51 +02:00
}