mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-18 15:39:50 +00:00
Code cleanup
This commit is contained in:
@@ -57,16 +57,16 @@ class HomeController extends Controller
|
||||
public function index()
|
||||
{
|
||||
Log::channel('audit')->info('User visits admin index.');
|
||||
$title = (string) trans('firefly.administration');
|
||||
$title = (string)trans('firefly.administration');
|
||||
$mainTitleIcon = 'fa-hand-spock-o';
|
||||
$email = auth()->user()->email;
|
||||
$pref = app('preferences')->get('remote_guard_alt_email', null);
|
||||
if(null !== $pref && is_string($pref->data)) {
|
||||
$email = auth()->user()->email;
|
||||
$pref = app('preferences')->get('remote_guard_alt_email', null);
|
||||
if (null !== $pref && is_string($pref->data)) {
|
||||
$email = $pref->data;
|
||||
}
|
||||
Log::debug('Email is ', [$email]);
|
||||
|
||||
return prefixView('admin.index', compact('title', 'mainTitleIcon','email'));
|
||||
return prefixView('admin.index', compact('title', 'mainTitleIcon', 'email'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +84,7 @@ class HomeController extends Controller
|
||||
$ipAddress = $request->ip();
|
||||
Log::debug(sprintf('Now in testMessage() controller. IP is %s', $ipAddress));
|
||||
event(new AdminRequestedTestMessage($user, $ipAddress));
|
||||
session()->flash('info', (string) trans('firefly.send_test_triggered'));
|
||||
session()->flash('info', (string)trans('firefly.send_test_triggered'));
|
||||
|
||||
return redirect(route('admin.index'));
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\View\View;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -53,7 +54,7 @@ class LinkController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.administration'));
|
||||
app('view')->share('title', (string)trans('firefly.administration'));
|
||||
app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
|
||||
$this->repository = app(LinkTypeRepositoryInterface::class);
|
||||
|
||||
@@ -66,13 +67,13 @@ class LinkController extends Controller
|
||||
/**
|
||||
* Make a new link form.
|
||||
*
|
||||
* @return Factory|\Illuminate\View\View
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
Log::channel('audit')->info('User visits link index.');
|
||||
|
||||
$subTitle = (string) trans('firefly.create_new_link_type');
|
||||
$subTitle = (string)trans('firefly.create_new_link_type');
|
||||
$subTitleIcon = 'fa-link';
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
@@ -89,22 +90,22 @@ class LinkController extends Controller
|
||||
* @param Request $request
|
||||
* @param LinkType $linkType
|
||||
*
|
||||
* @return Factory|RedirectResponse|Redirector|\Illuminate\View\View
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
*/
|
||||
public function delete(Request $request, LinkType $linkType)
|
||||
{
|
||||
if (!$linkType->editable) {
|
||||
$request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));
|
||||
$request->session()->flash('error', (string)trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));
|
||||
|
||||
return redirect(route('admin.links.index'));
|
||||
}
|
||||
|
||||
Log::channel('audit')->info(sprintf('User wants to delete link type #%d', $linkType->id));
|
||||
$subTitle = (string) trans('firefly.delete_link_type', ['name' => $linkType->name]);
|
||||
$subTitle = (string)trans('firefly.delete_link_type', ['name' => $linkType->name]);
|
||||
$otherTypes = $this->repository->get();
|
||||
$count = $this->repository->countJournals($linkType);
|
||||
$moveTo = [];
|
||||
$moveTo[0] = (string) trans('firefly.do_not_save_connection');
|
||||
$moveTo[0] = (string)trans('firefly.do_not_save_connection');
|
||||
|
||||
/** @var LinkType $otherType */
|
||||
foreach ($otherTypes as $otherType) {
|
||||
@@ -131,10 +132,10 @@ class LinkController extends Controller
|
||||
{
|
||||
Log::channel('audit')->info(sprintf('User destroyed link type #%d', $linkType->id));
|
||||
$name = $linkType->name;
|
||||
$moveTo = $this->repository->findNull((int) $request->get('move_link_type_before_delete'));
|
||||
$moveTo = $this->repository->findNull((int)$request->get('move_link_type_before_delete'));
|
||||
$this->repository->destroy($linkType, $moveTo);
|
||||
|
||||
$request->session()->flash('success', (string) trans('firefly.deleted_link_type', ['name' => $name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.deleted_link_type', ['name' => $name]));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect($this->getPreviousUri('link-types.delete.uri'));
|
||||
@@ -146,16 +147,16 @@ class LinkController extends Controller
|
||||
* @param Request $request
|
||||
* @param LinkType $linkType
|
||||
*
|
||||
* @return Factory|RedirectResponse|Redirector|\Illuminate\View\View
|
||||
* @return Factory|RedirectResponse|Redirector|View
|
||||
*/
|
||||
public function edit(Request $request, LinkType $linkType)
|
||||
{
|
||||
if (!$linkType->editable) {
|
||||
$request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));
|
||||
$request->session()->flash('error', (string)trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));
|
||||
|
||||
return redirect(route('admin.links.index'));
|
||||
}
|
||||
$subTitle = (string) trans('firefly.edit_link_type', ['name' => $linkType->name]);
|
||||
$subTitle = (string)trans('firefly.edit_link_type', ['name' => $linkType->name]);
|
||||
$subTitleIcon = 'fa-link';
|
||||
|
||||
Log::channel('audit')->info(sprintf('User wants to edit link type #%d', $linkType->id));
|
||||
@@ -172,11 +173,11 @@ class LinkController extends Controller
|
||||
/**
|
||||
* Show index of all links.
|
||||
*
|
||||
* @return Factory|\Illuminate\View\View
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$subTitle = (string) trans('firefly.journal_link_configuration');
|
||||
$subTitle = (string)trans('firefly.journal_link_configuration');
|
||||
$subTitleIcon = 'fa-link';
|
||||
$linkTypes = $this->repository->get();
|
||||
|
||||
@@ -195,11 +196,11 @@ class LinkController extends Controller
|
||||
*
|
||||
* @param LinkType $linkType
|
||||
*
|
||||
* @return Factory|\Illuminate\View\View
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function show(LinkType $linkType)
|
||||
{
|
||||
$subTitle = (string) trans('firefly.overview_for_link', ['name' => $linkType->name]);
|
||||
$subTitle = (string)trans('firefly.overview_for_link', ['name' => $linkType->name]);
|
||||
$subTitleIcon = 'fa-link';
|
||||
$links = $this->repository->getJournalLinks($linkType);
|
||||
|
||||
@@ -226,9 +227,9 @@ class LinkController extends Controller
|
||||
|
||||
Log::channel('audit')->info('User stored new link type.', $linkType->toArray());
|
||||
|
||||
$request->session()->flash('success', (string) trans('firefly.stored_new_link_type', ['name' => $linkType->name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.stored_new_link_type', ['name' => $linkType->name]));
|
||||
$redirect = redirect($this->getPreviousUri('link-types.create.uri'));
|
||||
if (1 === (int) $request->get('create_another')) {
|
||||
if (1 === (int)$request->get('create_another')) {
|
||||
// set value so create routine will not overwrite URL:
|
||||
$request->session()->put('link-types.create.fromStore', true);
|
||||
|
||||
@@ -250,7 +251,7 @@ class LinkController extends Controller
|
||||
public function update(LinkTypeFormRequest $request, LinkType $linkType)
|
||||
{
|
||||
if (!$linkType->editable) {
|
||||
$request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));
|
||||
$request->session()->flash('error', (string)trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));
|
||||
|
||||
return redirect(route('admin.links.index'));
|
||||
}
|
||||
@@ -264,10 +265,10 @@ class LinkController extends Controller
|
||||
|
||||
Log::channel('audit')->info(sprintf('User update link type #%d.', $linkType->id), $data);
|
||||
|
||||
$request->session()->flash('success', (string) trans('firefly.updated_link_type', ['name' => $linkType->name]));
|
||||
$request->session()->flash('success', (string)trans('firefly.updated_link_type', ['name' => $linkType->name]));
|
||||
app('preferences')->mark();
|
||||
$redirect = redirect($this->getPreviousUri('link-types.edit.uri'));
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
if (1 === (int)$request->get('return_to_edit')) {
|
||||
// set value so edit routine will not overwrite URL:
|
||||
$request->session()->put('link-types.edit.fromUpdate', true);
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class UserController extends Controller
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string) trans('firefly.administration'));
|
||||
app('view')->share('title', (string)trans('firefly.administration'));
|
||||
app('view')->share('mainTitleIcon', 'fa-hand-spock-o');
|
||||
$this->repository = app(UserRepositoryInterface::class);
|
||||
|
||||
@@ -63,6 +63,7 @@ class UserController extends Controller
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|RedirectResponse|Redirector|\Illuminate\View\View
|
||||
*/
|
||||
public function delete(User $user)
|
||||
@@ -73,7 +74,7 @@ class UserController extends Controller
|
||||
return redirect(route('admin.users'));
|
||||
}
|
||||
|
||||
$subTitle = (string) trans('firefly.delete_user', ['email' => $user->email]);
|
||||
$subTitle = (string)trans('firefly.delete_user', ['email' => $user->email]);
|
||||
|
||||
return prefixView('admin.users.delete', compact('user', 'subTitle'));
|
||||
}
|
||||
@@ -93,7 +94,7 @@ class UserController extends Controller
|
||||
return redirect(route('admin.users'));
|
||||
}
|
||||
$this->repository->destroy($user);
|
||||
session()->flash('success', (string) trans('firefly.user_deleted'));
|
||||
session()->flash('success', (string)trans('firefly.user_deleted'));
|
||||
|
||||
return redirect(route('admin.users'));
|
||||
}
|
||||
@@ -117,15 +118,15 @@ class UserController extends Controller
|
||||
}
|
||||
session()->forget('users.edit.fromUpdate');
|
||||
|
||||
$subTitle = (string) trans('firefly.edit_user', ['email' => $user->email]);
|
||||
$subTitle = (string)trans('firefly.edit_user', ['email' => $user->email]);
|
||||
$subTitleIcon = 'fa-user-o';
|
||||
$currentUser = auth()->user();
|
||||
$isAdmin = $this->repository->hasRole($user, 'owner');
|
||||
$codes = [
|
||||
'' => (string) trans('firefly.no_block_code'),
|
||||
'bounced' => (string) trans('firefly.block_code_bounced'),
|
||||
'expired' => (string) trans('firefly.block_code_expired'),
|
||||
'email_changed' => (string) trans('firefly.block_code_email_changed'),
|
||||
'' => (string)trans('firefly.no_block_code'),
|
||||
'bounced' => (string)trans('firefly.block_code_bounced'),
|
||||
'expired' => (string)trans('firefly.block_code_expired'),
|
||||
'email_changed' => (string)trans('firefly.block_code_email_changed'),
|
||||
];
|
||||
|
||||
return prefixView('admin.users.edit', compact('user', 'canEditDetails', 'subTitle', 'subTitleIcon', 'codes', 'currentUser', 'isAdmin'));
|
||||
@@ -138,7 +139,7 @@ class UserController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$subTitle = (string) trans('firefly.user_administration');
|
||||
$subTitle = (string)trans('firefly.user_administration');
|
||||
$subTitleIcon = 'fa-users';
|
||||
$users = $this->repository->all();
|
||||
|
||||
@@ -162,9 +163,9 @@ class UserController extends Controller
|
||||
*/
|
||||
public function show(User $user)
|
||||
{
|
||||
$title = (string) trans('firefly.administration');
|
||||
$title = (string)trans('firefly.administration');
|
||||
$mainTitleIcon = 'fa-hand-spock-o';
|
||||
$subTitle = (string) trans('firefly.single_user_administration', ['email' => $user->email]);
|
||||
$subTitle = (string)trans('firefly.single_user_administration', ['email' => $user->email]);
|
||||
$subTitleIcon = 'fa-user';
|
||||
$information = $this->repository->getUserData($user);
|
||||
|
||||
@@ -211,10 +212,10 @@ class UserController extends Controller
|
||||
$this->repository->changeStatus($user, $data['blocked'], $data['blocked_code']);
|
||||
$this->repository->updateEmail($user, $data['email']);
|
||||
|
||||
session()->flash('success', (string) trans('firefly.updated_user', ['email' => $user->email]));
|
||||
session()->flash('success', (string)trans('firefly.updated_user', ['email' => $user->email]));
|
||||
app('preferences')->mark();
|
||||
$redirect = redirect($this->getPreviousUri('users.edit.uri'));
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
if (1 === (int)$request->get('return_to_edit')) {
|
||||
// @codeCoverageIgnoreStart
|
||||
session()->put('users.edit.fromUpdate', true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user