Ivan - Update settings values [skip ci]
This commit is contained in:
parent
f9194b1b03
commit
dad5d0bd86
|
@ -26,7 +26,8 @@ class EditSettingsController extends Controller {
|
|||
'layout',
|
||||
'allow-attachments',
|
||||
'max-size',
|
||||
'system-title'
|
||||
'title',
|
||||
'url'
|
||||
];
|
||||
|
||||
foreach($settings as $setting) {
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
use Respect\Validation\Validator as DataValidator;
|
||||
|
||||
class GetSettingController extends Controller {
|
||||
const PATH = '/get-setting';
|
||||
|
||||
public function validations() {
|
||||
return [
|
||||
'permission' => 'any',
|
||||
'requestData' => [
|
||||
'name' => [
|
||||
'validation' => DataValidator::length(4),
|
||||
'error' => ERRORS::INVALID_SETTING
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function handler() {
|
||||
$setting = Setting::getSetting(Controller::request('name'));
|
||||
|
||||
if (!$setting->isNull()) {
|
||||
Response::respondSuccess([
|
||||
'setting' => $setting->value
|
||||
]);
|
||||
} else {
|
||||
Response::respondError(ERRORS::INVALID_SETTING);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,17 +11,43 @@ class GetSettingsController extends Controller {
|
|||
}
|
||||
|
||||
public function handler() {
|
||||
Response::respondSuccess([
|
||||
'language' => Setting::getSetting('language')->getValue(),
|
||||
'reCaptchaKey' => Setting::getSetting('recaptcha-public')->getValue(),
|
||||
'time-zone' => Setting::getSetting('time-zone')->getValue(),
|
||||
'maintenance-mode' => Setting::getSetting('maintenance-mode')->getValue(),
|
||||
'layout' => Setting::getSetting('layout')->getValue(),
|
||||
'allow-attachments' => Setting::getSetting('allow-attachments')->getValue(),
|
||||
'max-size' => Setting::getSetting('max-size')->getValue(),
|
||||
'departments' => Department::getDepartmentNames(),
|
||||
'supportedLanguages' => Language::getSupportedLanguages(),
|
||||
'allowedLanguages' => Language::getAllowedLanguages()
|
||||
]);
|
||||
|
||||
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(),
|
||||
'maintenance-mode' => Setting::getSetting('maintenance-mode')->getValue(),
|
||||
'layout' => Setting::getSetting('layout')->getValue(),
|
||||
'allow-attachments' => 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-port')->getValue(),
|
||||
'smtp-user' => Setting::getSetting('smtp-port')->getValue(),
|
||||
'departments' => Department::getDepartmentNames(),
|
||||
'supportedLanguages' => Language::getSupportedLanguages(),
|
||||
'allowedLanguages' => Language::getAllowedLanguages()
|
||||
];
|
||||
} else {
|
||||
$settingsList = [
|
||||
'language' => Setting::getSetting('language')->getValue(),
|
||||
'reCaptchaKey' => Setting::getSetting('recaptcha-public')->getValue(),
|
||||
'time-zone' => Setting::getSetting('time-zone')->getValue(),
|
||||
'maintenance-mode' => Setting::getSetting('maintenance-mode')->getValue(),
|
||||
'layout' => Setting::getSetting('layout')->getValue(),
|
||||
'allow-attachments' => Setting::getSetting('allow-attachments')->getValue(),
|
||||
'max-size' => Setting::getSetting('max-size')->getValue(),
|
||||
'title' => Setting::getSetting('title')->getValue(),
|
||||
'departments' => Department::getDepartmentNames(),
|
||||
'supportedLanguages' => Language::getSupportedLanguages(),
|
||||
'allowedLanguages' => Language::getAllowedLanguages()
|
||||
];
|
||||
}
|
||||
|
||||
Response::respondSuccess($settingsList);
|
||||
}
|
||||
}
|
|
@ -39,7 +39,8 @@ class InitSettingsController extends Controller {
|
|||
'layout' => 'boxed',
|
||||
'allow-attachments' => 0,
|
||||
'max-size' => 0,
|
||||
'system-title' => 'Support Center'
|
||||
'title' => 'Support Center',
|
||||
'url' => 'http://www.opensupports.com/support'
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
use Respect\Validation\Validator as DataValidator;
|
||||
|
||||
class GetSettingController extends Controller {
|
||||
const PATH = '/get-setting';
|
||||
|
||||
public function validations() {
|
||||
return [
|
||||
'permission' => 'any',
|
||||
'requestData' => [
|
||||
'name' => [
|
||||
'validation' => DataValidator::length(4),
|
||||
'error' => ERRORS::INVALID_SETTING
|
||||
],
|
||||
'value' => [
|
||||
'validation' => DataValidator::length(4),
|
||||
'error' => ERRORS::INVALID_SETTING
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function handler() {
|
||||
$setting = Setting::getSetting(Controller::request('name'));
|
||||
|
||||
if (!$setting->isNull()) {
|
||||
$setting->value = Controller::request('value');
|
||||
$setting->store();
|
||||
|
||||
Response::respondSuccess();
|
||||
} else {
|
||||
Response::respondError(ERRORS::INVALID_SETTING);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue