2016-08-27 04:00:48 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* ConfigurationController.php
|
|
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
|
|
|
*
|
2016-10-05 06:52:15 +02: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-27 04:00:48 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
declare(strict_types = 1);
|
|
|
|
|
|
|
|
namespace FireflyIII\Http\Controllers\Admin;
|
|
|
|
|
|
|
|
|
|
|
|
use FireflyIII\Http\Controllers\Controller;
|
2016-09-01 18:31:39 +02:00
|
|
|
use FireflyIII\Http\Requests\ConfigurationRequest;
|
|
|
|
use FireflyIII\Support\Facades\FireflyConfig;
|
|
|
|
use Preferences;
|
|
|
|
use Redirect;
|
|
|
|
use Session;
|
2016-08-27 04:00:48 +02:00
|
|
|
use View;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ConfigurationController
|
|
|
|
*
|
|
|
|
* @package FireflyIII\Http\Controllers\Admin
|
|
|
|
*/
|
|
|
|
class ConfigurationController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* ConfigurationController constructor.
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
2016-10-29 07:44:46 +02:00
|
|
|
|
|
|
|
$this->middleware(
|
|
|
|
function ($request, $next) {
|
|
|
|
View::share('title', strval(trans('firefly.administration')));
|
|
|
|
View::share('mainTitleIcon', 'fa-hand-spock-o');
|
|
|
|
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
);
|
2016-08-27 04:00:48 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return View
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$subTitle = strval(trans('firefly.instance_configuration'));
|
|
|
|
$subTitleIcon = 'fa-wrench';
|
|
|
|
|
2016-09-01 18:31:39 +02:00
|
|
|
// all available configuration and their default value in case
|
|
|
|
// they don't exist yet.
|
2016-11-07 18:49:35 +01:00
|
|
|
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
|
|
|
|
$mustConfirmAccount = FireflyConfig::get('must_confirm_account', config('firefly.configuration.must_confirm_account'))->data;
|
|
|
|
$isDemoSite = FireflyConfig::get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
|
2016-08-27 04:00:48 +02:00
|
|
|
|
2016-11-07 18:49:35 +01:00
|
|
|
return view('admin.configuration.index', compact('subTitle', 'subTitleIcon', 'singleUserMode', 'mustConfirmAccount', 'isDemoSite'));
|
2016-09-01 18:31:39 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param ConfigurationRequest $request
|
2016-10-09 07:58:27 +02:00
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
2016-09-01 18:31:39 +02:00
|
|
|
*/
|
2016-12-07 20:06:06 +01:00
|
|
|
public function postIndex(ConfigurationRequest $request)
|
2016-09-01 18:31:39 +02:00
|
|
|
{
|
|
|
|
// get config values:
|
2016-10-23 12:10:22 +02:00
|
|
|
$data = $request->getConfigurationData();
|
2016-09-01 18:31:39 +02:00
|
|
|
|
|
|
|
// store config values
|
2016-10-23 12:10:22 +02:00
|
|
|
FireflyConfig::set('single_user_mode', $data['single_user_mode']);
|
2016-11-07 18:49:35 +01:00
|
|
|
FireflyConfig::set('must_confirm_account', $data['must_confirm_account']);
|
|
|
|
FireflyConfig::set('is_demo_site', $data['is_demo_site']);
|
2016-09-01 18:31:39 +02:00
|
|
|
|
|
|
|
// flash message
|
|
|
|
Session::flash('success', strval(trans('firefly.configuration_updated')));
|
|
|
|
Preferences::mark();
|
|
|
|
|
|
|
|
return Redirect::route('admin.configuration.index');
|
2016-08-27 04:00:48 +02:00
|
|
|
}
|
|
|
|
|
2016-08-27 04:34:59 +02:00
|
|
|
}
|