Merged in OS131-Path-system-edit-settings (pull request #100)
Os131 path system edit settings
This commit is contained in:
commit
6d9d3e8248
|
@ -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);
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
use Respect\Validation\Validator as DataValidator;
|
||||
|
||||
class EditSettingsController extends Controller {
|
||||
const PATH = '/edit-settings';
|
||||
|
||||
public function validations() {
|
||||
return [
|
||||
'permission' => 'staff_3',
|
||||
'requestData' => []
|
||||
];
|
||||
}
|
||||
|
||||
public function handler() {
|
||||
$settings = [
|
||||
'language',
|
||||
'recaptcha-public',
|
||||
'recaptcha-private',
|
||||
'no-reply-email',
|
||||
'smtp-host',
|
||||
'smtp-port',
|
||||
'smtp-user',
|
||||
'smtp-pass',
|
||||
'time-zone',
|
||||
'maintenance-mode',
|
||||
'layout',
|
||||
'allow-attachments',
|
||||
'max-size',
|
||||
'system-title'
|
||||
];
|
||||
|
||||
foreach($settings as $setting) {
|
||||
if(Controller::request($setting)) {
|
||||
$settingInstance = Setting::getSetting($setting);
|
||||
$settingInstance->value = Controller::request($setting);
|
||||
$settingInstance->store();
|
||||
}
|
||||
}
|
||||
Response::respondSuccess();
|
||||
}
|
||||
}
|
|
@ -38,7 +38,7 @@ class InitSettingsController extends Controller {
|
|||
'layout' => 'boxed',
|
||||
'allow-attachments' => 0,
|
||||
'max-size' => 0,
|
||||
|
||||
'system-title' => 'Support Center'
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ require './scripts.rb'
|
|||
# TESTS
|
||||
require './system/init-settings.rb'
|
||||
require './system/get-settings.rb'
|
||||
require './system/edit-settings.rb'
|
||||
require './user/signup.rb'
|
||||
require './user/login.rb'
|
||||
require './user/send-recover-password.rb'
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
describe'system/edit-settings' do
|
||||
request('/user/logout')
|
||||
Scripts.login($staff[:email], $staff[:password], true)
|
||||
|
||||
it 'should edit settings' do
|
||||
result= request('/system/edit-settings', {
|
||||
"csrf_userid" => $csrf_userid,
|
||||
"csrf_token" => $csrf_token,
|
||||
"maintenance-mode" => 1,
|
||||
"time-zone" => -3,
|
||||
"layout" => 'full-width',
|
||||
"allow-attachments" => 1,
|
||||
"max-size" => 2,
|
||||
"language" => 'es',
|
||||
"no-reply-email" => 'testemail@hotmail.com',
|
||||
"smtp-host" => 'www.opensupports.com',
|
||||
"smtp-port" => 18,
|
||||
"smtp-user" => 'admin',
|
||||
"smtp-pass" => 'pass1234',
|
||||
})
|
||||
puts result['message']
|
||||
|
||||
(result['status']).should.equal('success')
|
||||
|
||||
row = $database.getRow('setting', 'maintenance-mode', 'name')
|
||||
(row['value']).should.equal('1')
|
||||
|
||||
row = $database.getRow('setting', 'time-zone', 'name')
|
||||
(row['value']).should.equal('-3')
|
||||
|
||||
row = $database.getRow('setting', 'layout', 'name')
|
||||
(row['value']).should.equal('full-width')
|
||||
|
||||
row = $database.getRow('setting', 'max-size', 'name')
|
||||
(row['value']).should.equal('2')
|
||||
|
||||
row = $database.getRow('setting', 'language', 'name')
|
||||
(row['value']).should.equal('es')
|
||||
|
||||
row = $database.getRow('setting', 'no-reply-email', 'name')
|
||||
(row['value']).should.equal('testemail@hotmail.com')
|
||||
|
||||
row = $database.getRow('setting', 'smtp-host', 'name')
|
||||
(row['value']).should.equal('www.opensupports.com')
|
||||
|
||||
row = $database.getRow('setting', 'smtp-port', 'name')
|
||||
(row['value']).should.equal('18')
|
||||
|
||||
row = $database.getRow('setting', 'smtp-user', 'name')
|
||||
(row['value']).should.equal('admin')
|
||||
|
||||
row = $database.getRow('setting', 'smtp-pass', 'name')
|
||||
(row['value']).should.equal('pass1234')
|
||||
|
||||
request('/user/logout')
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue