2016-08-27 04:00:48 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* ConfigurationController.php
|
2017-10-21 08:40:00 +02:00
|
|
|
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
2016-08-27 04:00:48 +02:00
|
|
|
*
|
2017-10-21 08:40:00 +02:00
|
|
|
* This file is part of Firefly III.
|
2016-10-05 06:52:15 +02:00
|
|
|
*
|
2017-10-21 08:40:00 +02:00
|
|
|
* Firefly III is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Firefly III is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2017-12-17 14:41:58 +01:00
|
|
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
2016-08-27 04:00:48 +02:00
|
|
|
*/
|
2017-04-09 07:44:22 +02:00
|
|
|
declare(strict_types=1);
|
2016-08-27 04:00:48 +02:00
|
|
|
|
|
|
|
namespace FireflyIII\Http\Controllers\Admin;
|
|
|
|
|
|
|
|
use FireflyIII\Http\Controllers\Controller;
|
2017-12-19 19:25:50 +01:00
|
|
|
use FireflyIII\Http\Middleware\IsDemoUser;
|
|
|
|
use FireflyIII\Http\Middleware\IsSandStormUser;
|
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;
|
|
|
|
|
|
|
|
/**
|
2017-11-15 12:25:49 +01:00
|
|
|
* Class ConfigurationController.
|
2016-08-27 04:00:48 +02:00
|
|
|
*/
|
|
|
|
class ConfigurationController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* ConfigurationController constructor.
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
2016-10-29 07:44:46 +02:00
|
|
|
$this->middleware(
|
|
|
|
function ($request, $next) {
|
2018-04-02 15:10:40 +02:00
|
|
|
app('view')->share('title', (string)trans('firefly.administration'));
|
2017-12-16 19:46:36 +01:00
|
|
|
app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
|
2016-10-29 07:44:46 +02:00
|
|
|
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
);
|
2017-12-19 19:25:50 +01:00
|
|
|
$this->middleware(IsDemoUser::class)->except(['index']);
|
|
|
|
$this->middleware(IsSandStormUser::class);
|
2016-08-27 04:00:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return View
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
2018-04-02 15:10:40 +02:00
|
|
|
$subTitle = (string)trans('firefly.instance_configuration');
|
2016-08-27 04:00:48 +02:00
|
|
|
$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-12-30 13:47:23 +01:00
|
|
|
$singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
|
|
|
|
$isDemoSite = FireflyConfig::get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
|
|
|
|
$siteOwner = env('SITE_OWNER');
|
2016-08-27 04:00:48 +02:00
|
|
|
|
2016-12-14 18:59:12 +01:00
|
|
|
return view(
|
|
|
|
'admin.configuration.index',
|
2016-12-28 16:55:53 +01:00
|
|
|
compact('subTitle', 'subTitleIcon', 'singleUserMode', 'isDemoSite', 'siteOwner')
|
2016-12-14 18:59:12 +01:00
|
|
|
);
|
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('is_demo_site', $data['is_demo_site']);
|
2016-09-01 18:31:39 +02:00
|
|
|
|
|
|
|
// flash message
|
2018-04-22 17:10:11 +02:00
|
|
|
session()->flash('success', (string)trans('firefly.configuration_updated'));
|
2016-09-01 18:31:39 +02:00
|
|
|
Preferences::mark();
|
|
|
|
|
|
|
|
return Redirect::route('admin.configuration.index');
|
2016-08-27 04:00:48 +02:00
|
|
|
}
|
2016-08-27 04:34:59 +02:00
|
|
|
}
|