From dad5d0bd86adc3a00901a1ca19da9ad52f0cc371 Mon Sep 17 00:00:00 2001 From: Ivan Diaz Date: Wed, 4 Jan 2017 19:29:23 -0300 Subject: [PATCH] Ivan - Update settings values [skip ci] --- server/controllers/system/edit-settings.php | 3 +- server/controllers/system/get-setting.php | 30 ------------- server/controllers/system/get-settings.php | 50 ++++++++++++++++----- server/controllers/system/init-settings.php | 3 +- server/controllers/system/set-setting.php | 35 --------------- 5 files changed, 42 insertions(+), 79 deletions(-) delete mode 100644 server/controllers/system/get-setting.php delete mode 100644 server/controllers/system/set-setting.php diff --git a/server/controllers/system/edit-settings.php b/server/controllers/system/edit-settings.php index 7432e040..c78f1f97 100644 --- a/server/controllers/system/edit-settings.php +++ b/server/controllers/system/edit-settings.php @@ -26,7 +26,8 @@ class EditSettingsController extends Controller { 'layout', 'allow-attachments', 'max-size', - 'system-title' + 'title', + 'url' ]; foreach($settings as $setting) { diff --git a/server/controllers/system/get-setting.php b/server/controllers/system/get-setting.php deleted file mode 100644 index daa46300..00000000 --- a/server/controllers/system/get-setting.php +++ /dev/null @@ -1,30 +0,0 @@ - '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); - } - } -} \ No newline at end of file diff --git a/server/controllers/system/get-settings.php b/server/controllers/system/get-settings.php index 7a5b07cf..566110f3 100644 --- a/server/controllers/system/get-settings.php +++ b/server/controllers/system/get-settings.php @@ -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); } } \ No newline at end of file diff --git a/server/controllers/system/init-settings.php b/server/controllers/system/init-settings.php index 7bc58d88..98fce211 100644 --- a/server/controllers/system/init-settings.php +++ b/server/controllers/system/init-settings.php @@ -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' ]); } diff --git a/server/controllers/system/set-setting.php b/server/controllers/system/set-setting.php deleted file mode 100644 index d142d578..00000000 --- a/server/controllers/system/set-setting.php +++ /dev/null @@ -1,35 +0,0 @@ - '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); - } - } -} \ No newline at end of file