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

82 lines
4.0 KiB
PHP
Raw Normal View History

<?php
2017-04-18 02:09:16 +02:00
/**
* @api {post} /system/get-settings Get settings
2018-09-20 22:19:47 +02:00
* @apiVersion 4.3.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(),
'no-reply-email' => Setting::getSetting('no-reply-email')->getValue(),
'smtp-port' => Setting::getSetting('smtp-port')->getValue(),
'smtp-host' => Setting::getSetting('smtp-host')->getValue(),
'smtp-user' => Setting::getSetting('smtp-user')->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(),
'mail-template-header-image' => Setting::getSetting('mail-template-header-image')->getValue()
];
} 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()),
'session-prefix' => Setting::getSetting('session-prefix')->getValue()
];
}
}
Response::respondSuccess($settingsList);
}
2018-07-06 21:06:51 +02:00
}