firefly-iii/app/Http/Controllers/Admin/ConfigurationController.php

100 lines
3.1 KiB
PHP
Raw Normal View History

<?php
/**
* ConfigurationController.php
2017-10-21 01:40:00 -05:00
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
2017-10-21 01:40:00 -05:00
* This file is part of Firefly III.
*
2017-10-21 01:40:00 -05: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 07:41:58 -06:00
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Admin;
use FireflyIII\Http\Controllers\Controller;
2017-12-19 12:25:50 -06:00
use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Http\Middleware\IsSandStormUser;
use FireflyIII\Http\Requests\ConfigurationRequest;
use FireflyIII\Support\Facades\FireflyConfig;
use Preferences;
use Redirect;
use Session;
use View;
/**
2017-11-15 05:25:49 -06:00
* Class ConfigurationController.
*/
class ConfigurationController extends Controller
{
/**
* ConfigurationController constructor.
*/
public function __construct()
{
parent::__construct();
2016-10-29 00:44:46 -05:00
$this->middleware(
function ($request, $next) {
2017-12-16 12:46:36 -06:00
app('view')->share('title', strval(trans('firefly.administration')));
app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
2016-10-29 00:44:46 -05:00
return $next($request);
}
);
2017-12-19 12:25:50 -06:00
$this->middleware(IsDemoUser::class)->except(['index']);
$this->middleware(IsSandStormUser::class);
}
/**
* @return View
*/
public function index()
{
$subTitle = strval(trans('firefly.instance_configuration'));
$subTitleIcon = 'fa-wrench';
// all available configuration and their default value in case
// they don't exist yet.
2016-12-30 06:47:23 -06: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-12-14 11:59:12 -06:00
return view(
'admin.configuration.index',
compact('subTitle', 'subTitleIcon', 'singleUserMode', 'isDemoSite', 'siteOwner')
2016-12-14 11:59:12 -06:00
);
}
/**
* @param ConfigurationRequest $request
2016-10-09 00:58:27 -05:00
*
* @return \Illuminate\Http\RedirectResponse
*/
2016-12-07 13:06:06 -06:00
public function postIndex(ConfigurationRequest $request)
{
// get config values:
2016-10-23 05:10:22 -05:00
$data = $request->getConfigurationData();
// store config values
2016-10-23 05:10:22 -05:00
FireflyConfig::set('single_user_mode', $data['single_user_mode']);
2016-11-07 11:49:35 -06:00
FireflyConfig::set('is_demo_site', $data['is_demo_site']);
// flash message
Session::flash('success', strval(trans('firefly.configuration_updated')));
Preferences::mark();
return Redirect::route('admin.configuration.index');
}
}