mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop
This commit is contained in:
@@ -234,7 +234,7 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
|
||||
private function collectMetaData(): void
|
||||
{
|
||||
$set = AccountMeta::whereIn('name', ['is_multi_currency', 'include_net_worth','currency_id', 'account_role', 'account_number', 'liability_direction', 'interest', 'interest_period', 'current_debt'])
|
||||
$set = AccountMeta::whereIn('name', ['is_multi_currency', 'include_net_worth', 'currency_id', 'account_role', 'account_number', 'liability_direction', 'interest', 'interest_period', 'current_debt'])
|
||||
->whereIn('account_id', $this->accountIds)
|
||||
->get(['account_meta.id', 'account_meta.account_id', 'account_meta.name', 'account_meta.data'])->toArray()
|
||||
;
|
||||
|
@@ -47,15 +47,16 @@ class Preferences
|
||||
}
|
||||
|
||||
return Preference::where('user_id', $user->id)
|
||||
->where('name', '!=', 'currencyPreference')
|
||||
->where(function (Builder $q) use ($user): void {
|
||||
$q->whereNull('user_group_id');
|
||||
$q->orWhere('user_group_id', $user->user_group_id);
|
||||
})
|
||||
->get();
|
||||
->where('name', '!=', 'currencyPreference')
|
||||
->where(function (Builder $q) use ($user): void {
|
||||
$q->whereNull('user_group_id');
|
||||
$q->orWhere('user_group_id', $user->user_group_id);
|
||||
})
|
||||
->get()
|
||||
;
|
||||
}
|
||||
|
||||
public function get(string $name, null | array | bool | int | string $default = null): ?Preference
|
||||
public function get(string $name, null|array|bool|int|string $default = null): ?Preference
|
||||
{
|
||||
/** @var null|User $user */
|
||||
$user = auth()->user();
|
||||
@@ -69,7 +70,7 @@ class Preferences
|
||||
return $this->getForUser($user, $name, $default);
|
||||
}
|
||||
|
||||
public function getForUser(User $user, string $name, null | array | bool | int | string $default = null): ?Preference
|
||||
public function getForUser(User $user, string $name, null|array|bool|int|string $default = null): ?Preference
|
||||
{
|
||||
Log::debug(sprintf('getForUser(#%d, "%s")', $user->id, $name));
|
||||
// don't care about user group ID, except for some specific preferences.
|
||||
@@ -80,7 +81,7 @@ class Preferences
|
||||
$query->where('user_group_id', $userGroupId);
|
||||
}
|
||||
|
||||
$preference = $query->first(['id', 'user_id', 'user_group_id', 'name', 'data', 'updated_at', 'created_at']);
|
||||
$preference = $query->first(['id', 'user_id', 'user_group_id', 'name', 'data', 'updated_at', 'created_at']);
|
||||
|
||||
if (null !== $preference && null === $preference->data) {
|
||||
$preference->delete();
|
||||
@@ -90,11 +91,13 @@ class Preferences
|
||||
|
||||
if (null !== $preference) {
|
||||
Log::debug(sprintf('Found preference #%d for user #%d: %s', $preference->id, $user->id, $name));
|
||||
|
||||
return $preference;
|
||||
}
|
||||
// no preference found and default is null:
|
||||
if (null === $default) {
|
||||
Log::debug('Return NULL, create no preference.');
|
||||
|
||||
// return NULL
|
||||
return null;
|
||||
}
|
||||
@@ -131,21 +134,21 @@ class Preferences
|
||||
Cache::put($key, '', 5);
|
||||
}
|
||||
|
||||
public function setForUser(User $user, string $name, null | array | bool | int | string $value): Preference
|
||||
public function setForUser(User $user, string $name, null|array|bool|int|string $value): Preference
|
||||
{
|
||||
$fullName = sprintf('preference%s%s', $user->id, $name);
|
||||
$userGroupId = $this->getUserGroupId($user, $name);
|
||||
$userGroupId = 0 === (int) $userGroupId ? null : (int) $userGroupId;
|
||||
$fullName = sprintf('preference%s%s', $user->id, $name);
|
||||
$userGroupId = $this->getUserGroupId($user, $name);
|
||||
$userGroupId = 0 === (int) $userGroupId ? null : (int) $userGroupId;
|
||||
|
||||
Cache::forget($fullName);
|
||||
|
||||
$query = Preference::where('user_id', $user->id)->where('name', $name);
|
||||
$query = Preference::where('user_id', $user->id)->where('name', $name);
|
||||
if (null !== $userGroupId) {
|
||||
Log::debug('Include user group ID in query');
|
||||
$query->where('user_group_id', $userGroupId);
|
||||
}
|
||||
|
||||
$preference = $query->first(['id', 'user_id', 'user_group_id', 'name', 'data', 'updated_at', 'created_at']);
|
||||
$preference = $query->first(['id', 'user_id', 'user_group_id', 'name', 'data', 'updated_at', 'created_at']);
|
||||
|
||||
if (null !== $preference && null === $value) {
|
||||
$preference->delete();
|
||||
@@ -188,12 +191,13 @@ class Preferences
|
||||
{
|
||||
$result = [];
|
||||
$preferences = Preference::where('user_id', $user->id)
|
||||
->where(function (Builder $q) use ($user): void {
|
||||
$q->whereNull('user_group_id');
|
||||
$q->orWhere('user_group_id', $user->user_group_id);
|
||||
})
|
||||
->whereIn('name', $list)
|
||||
->get(['id', 'name', 'data']);
|
||||
->where(function (Builder $q) use ($user): void {
|
||||
$q->whereNull('user_group_id');
|
||||
$q->orWhere('user_group_id', $user->user_group_id);
|
||||
})
|
||||
->whereIn('name', $list)
|
||||
->get(['id', 'name', 'data'])
|
||||
;
|
||||
|
||||
/** @var Preference $preference */
|
||||
foreach ($preferences as $preference) {
|
||||
@@ -235,7 +239,7 @@ class Preferences
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getEncryptedForUser(User $user, string $name, null | array | bool | int | string $default = null): ?Preference
|
||||
public function getEncryptedForUser(User $user, string $name, null|array|bool|int|string $default = null): ?Preference
|
||||
{
|
||||
$result = $this->getForUser($user, $name, $default);
|
||||
if ('' === $result->data) {
|
||||
@@ -260,7 +264,7 @@ class Preferences
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getFresh(string $name, null | array | bool | int | string $default = null): ?Preference
|
||||
public function getFresh(string $name, null|array|bool|int|string $default = null): ?Preference
|
||||
{
|
||||
/** @var null|User $user */
|
||||
$user = auth()->user();
|
||||
@@ -298,7 +302,7 @@ class Preferences
|
||||
Session::forget('first');
|
||||
}
|
||||
|
||||
public function set(string $name, null | array | bool | int | string $value): Preference
|
||||
public function set(string $name, null|array|bool|int|string $value): Preference
|
||||
{
|
||||
/** @var null|User $user */
|
||||
$user = auth()->user();
|
||||
|
Reference in New Issue
Block a user