GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 53c71b...87c8b3 )
by James
15:15 queued 05:54
created

Http/Controllers/Admin/ConfigurationController.php (2 issues)

1
<?php
2
/**
3
 * ConfigurationController.php
4
 * Copyright (c) 2017 [email protected]
5
 *
6
 * This file is part of Firefly III.
7
 *
8
 * Firefly III is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * Firefly III is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
20
 */
21
/** @noinspection PhpUndefinedClassInspection */
22
declare(strict_types=1);
23
24
namespace FireflyIII\Http\Controllers\Admin;
25
26
use FireflyIII\Http\Controllers\Controller;
27
use FireflyIII\Http\Middleware\IsDemoUser;
28
use FireflyIII\Http\Middleware\IsSandStormUser;
29
use FireflyIII\Http\Requests\ConfigurationRequest;
30
use FireflyIII\Support\Facades\FireflyConfig;
31
use Illuminate\Http\RedirectResponse;
32
use Log;
33
34
/**
35
 * Class ConfigurationController.
36
 */
37
class ConfigurationController extends Controller
38
{
39
    /**
40
     * ConfigurationController constructor.
41
     */
42
    public function __construct()
43
    {
44
        parent::__construct();
45
46
        $this->middleware(
47
            function ($request, $next) {
48
                app('view')->share('title', (string)trans('firefly.administration'));
49
                app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
50
51
                return $next($request);
52
            }
53
        );
54
        $this->middleware(IsDemoUser::class)->except(['index']);
55
        $this->middleware(IsSandStormUser::class);
56
    }
57
58
    /**
59
     * Show configuration index.
60
     *
61
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
62
     */
63
    public function index()
64
    {
65
        $subTitle     = (string)trans('firefly.instance_configuration');
66
        $subTitleIcon = 'fa-wrench';
67
68
        Log::channel('audit')->info('User visits admin config index.');
69
70
        // all available configuration and their default value in case
71
        // they don't exist yet.
72
        $singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
0 ignored issues
show
Bug Best Practice introduced by
The method FireflyIII\Support\Facades\FireflyConfig::get() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

72
        $singleUserMode = FireflyConfig::/** @scrutinizer ignore-call */ get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
Loading history...
73
        $isDemoSite     = FireflyConfig::get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
74
        $siteOwner      = config('firefly.site_owner');
75
76
        return view(
77
            'admin.configuration.index',
78
            compact('subTitle', 'subTitleIcon', 'singleUserMode', 'isDemoSite', 'siteOwner')
79
        );
80
    }
81
82
    /**
83
     * Store new configuration values.
84
     *
85
     * @param ConfigurationRequest $request
86
     *
87
     * @return RedirectResponse
88
     */
89
    public function postIndex(ConfigurationRequest $request): RedirectResponse
90
    {
91
        // get config values:
92
        $data = $request->getConfigurationData();
93
94
        Log::channel('audit')->info('User updates global configuration.', $data);
95
96
        // store config values
97
        FireflyConfig::set('single_user_mode', $data['single_user_mode']);
0 ignored issues
show
Bug Best Practice introduced by
The method FireflyIII\Support\Facades\FireflyConfig::set() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

97
        FireflyConfig::/** @scrutinizer ignore-call */ 
98
                       set('single_user_mode', $data['single_user_mode']);
Loading history...
98
        FireflyConfig::set('is_demo_site', $data['is_demo_site']);
99
100
        // flash message
101
        session()->flash('success', (string)trans('firefly.configuration_updated'));
102
        app('preferences')->mark();
103
104
        return redirect()->route('admin.configuration.index');
105
    }
106
}
107