Guillermo - path edit-settings[skip ci]

This commit is contained in:
AntonyAntonio 2016-12-13 02:03:35 -03:00
parent 8b69934d36
commit 0000fe5159
2 changed files with 80 additions and 0 deletions

View File

@ -1,6 +1,7 @@
<?php
require_once 'system/init-settings.php';
require_once 'system/get-settings.php';
require_once 'system/edit-settings.php';
require_once 'system/add-department.php';
require_once 'system/edit-department.php';
require_once 'system/delete-department.php';
@ -10,6 +11,7 @@ $systemControllerGroup->setGroupPath('/system');
$systemControllerGroup->addController(new InitSettingsController);
$systemControllerGroup->addController(new GetSettingsController);
$systemControllerGroup->addController(new EditSettingsController);
$systemControllerGroup->addController(new AddDepartmentController);
$systemControllerGroup->addController(new EditDepartmentController);
$systemControllerGroup->addController(new DeleteDepartmentController);

View File

@ -0,0 +1,78 @@
<?php
use Respect\Validation\Validator as DataValidator;
class EditSettingsController extends Controller {
const PATH = '/edit-settings';
private $setting;
public function validations() {
return[
'permission' => 'staff_3',
'requestData' => [
'name' => [
'validation' => DataValidator::length(4),
'error' => ERRORS::INVALID_SETTING
],
]
];
}
public function handler() {
$this->setting = Setting::getSetting(Controller::request('name'));
$this->editInformation();
Response::respondSuccess();
}
public function editInformation() {
if(Controller::request('manteniance-mode')) {
$this->setting->manteniance_mode = Controller::request('manteniance-mode');
}
if(Controller::request('system-title')) {
$this->setting->system_title = Controller::request('system-title');
}
if(Controller::request('timezone')) {
$this->setting->timezone = Controller::request('timezone');
}
if(Controller::request('layout')) {
$this->setting->layout = Controller::request('layout');
}
if(Controller::request('smtp-server')) {
$this->setting->smtp_server = Controller::request('smtp-server');
}
if(Controller::request('smtp-email')) {
$this->setting->smtp_email = Controller::request('smtp-email');
}
if(Controller::request('smtp-password')) {
$this->setting->smtp_password = Controller::request('smtp-password');
}
if(Controller::request('smtp-port')) {
$this->setting->smtp_port = Controller::request('smtp-port');
}
if(Controller::request('default-language')) {
$this->setting->default_language = Controller::request('default-language');
}
if(Controller::request('recaptcha-public')) {
$this->setting->recaptcha_public = Controller::request('recaptcha-public');
}
if(Controller::request('recaptcha-private')) {
$this->setting->sharedDepartmentList = Controller::request('recaptcha-private');
}
if(Controller::request('allow-attachments')) {
$this->setting->allow_attachments = Controller::request('allow-attachments');
}
if(Controller::request('max-size')) {
$this->setting->max_size = Controller::request('max-size');
}
$this->setting->store();
}
}