2016-08-26 21:00:48 -05:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* ConfigurationController.php
|
|
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
|
|
|
*
|
2016-10-04 23:52:15 -05:00
|
|
|
* This software may be modified and distributed under the terms of the
|
|
|
|
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
|
|
|
*
|
|
|
|
* See the LICENSE file for details.
|
2016-08-26 21:00:48 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
declare(strict_types = 1);
|
|
|
|
|
|
|
|
namespace FireflyIII\Http\Controllers\Admin;
|
|
|
|
|
|
|
|
|
2016-09-01 11:31:39 -05:00
|
|
|
use Config;
|
2016-08-26 21:00:48 -05:00
|
|
|
use FireflyIII\Http\Controllers\Controller;
|
2016-09-01 11:31:39 -05:00
|
|
|
use FireflyIII\Http\Requests\ConfigurationRequest;
|
|
|
|
use FireflyIII\Support\Facades\FireflyConfig;
|
|
|
|
use Preferences;
|
|
|
|
use Redirect;
|
|
|
|
use Session;
|
2016-08-26 21:00:48 -05:00
|
|
|
use View;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ConfigurationController
|
|
|
|
*
|
|
|
|
* @package FireflyIII\Http\Controllers\Admin
|
|
|
|
*/
|
|
|
|
class ConfigurationController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* ConfigurationController constructor.
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
View::share('title', strval(trans('firefly.administration')));
|
|
|
|
View::share('mainTitleIcon', 'fa-hand-spock-o');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return View
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$subTitle = strval(trans('firefly.instance_configuration'));
|
|
|
|
$subTitleIcon = 'fa-wrench';
|
|
|
|
|
2016-09-01 11:31:39 -05:00
|
|
|
// all available configuration and their default value in case
|
|
|
|
// they don't exist yet.
|
|
|
|
$singleUserMode = FireflyConfig::get('single_user_mode', Config::get('firefly.configuration.single_user_mode'))->data;
|
2016-08-26 21:00:48 -05:00
|
|
|
|
2016-09-01 11:31:39 -05:00
|
|
|
return view('admin.configuration.index', compact('subTitle', 'subTitleIcon', 'singleUserMode'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param ConfigurationRequest $request
|
2016-10-09 00:58:27 -05:00
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
2016-09-01 11:31:39 -05:00
|
|
|
*/
|
|
|
|
public function store(ConfigurationRequest $request)
|
|
|
|
{
|
|
|
|
// get config values:
|
2016-10-23 05:10:22 -05:00
|
|
|
$data = $request->getConfigurationData();
|
2016-09-01 11:31:39 -05:00
|
|
|
|
|
|
|
// store config values
|
2016-10-23 05:10:22 -05:00
|
|
|
FireflyConfig::set('single_user_mode', $data['single_user_mode']);
|
2016-09-01 11:31:39 -05:00
|
|
|
|
|
|
|
// flash message
|
|
|
|
Session::flash('success', strval(trans('firefly.configuration_updated')));
|
|
|
|
Preferences::mark();
|
|
|
|
|
|
|
|
return Redirect::route('admin.configuration.index');
|
2016-08-26 21:00:48 -05:00
|
|
|
}
|
|
|
|
|
2016-08-26 21:34:59 -05:00
|
|
|
}
|