mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
🤖 Auto commit for release 'develop' on 2025-09-26
This commit is contained in:
@@ -82,8 +82,8 @@ trait CalculateRangeOccurrences
|
||||
*/
|
||||
protected function getNdomInRange(Carbon $start, Carbon $end, int $skipMod, string $moment): array
|
||||
{
|
||||
$return = [];
|
||||
$attempts = 0;
|
||||
$return = [];
|
||||
$attempts = 0;
|
||||
$start->startOfMonth();
|
||||
// this feels a bit like a cop out but why reinvent the wheel?
|
||||
$counters = [1 => 'first', 2 => 'second', 3 => 'third', 4 => 'fourth', 5 => 'fifth'];
|
||||
@@ -108,12 +108,12 @@ trait CalculateRangeOccurrences
|
||||
*/
|
||||
protected function getWeeklyInRange(Carbon $start, Carbon $end, int $skipMod, string $moment): array
|
||||
{
|
||||
$return = [];
|
||||
$attempts = 0;
|
||||
$return = [];
|
||||
$attempts = 0;
|
||||
app('log')->debug('Rep is weekly.');
|
||||
// monday = 1
|
||||
// sunday = 7
|
||||
$dayOfWeek = (int)$moment;
|
||||
$dayOfWeek = (int)$moment;
|
||||
app('log')->debug(sprintf('DoW in repetition is %d, in mutator is %d', $dayOfWeek, $start->dayOfWeekIso));
|
||||
if ($start->dayOfWeekIso > $dayOfWeek) {
|
||||
// day has already passed this week, add one week:
|
||||
@@ -154,8 +154,8 @@ trait CalculateRangeOccurrences
|
||||
}
|
||||
|
||||
// is $date between $start and $end?
|
||||
$obj = clone $date;
|
||||
$count = 0;
|
||||
$obj = clone $date;
|
||||
$count = 0;
|
||||
while ($obj <= $end && $obj >= $start && $count < 10) {
|
||||
if (0 === $attempts % $skipMod) {
|
||||
$return[] = clone $obj;
|
||||
|
@@ -89,10 +89,10 @@ trait CalculateXOccurrences
|
||||
*/
|
||||
protected function getXNDomOccurrences(Carbon $date, int $count, int $skipMod, string $moment): array
|
||||
{
|
||||
$return = [];
|
||||
$total = 0;
|
||||
$attempts = 0;
|
||||
$mutator = clone $date;
|
||||
$return = [];
|
||||
$total = 0;
|
||||
$attempts = 0;
|
||||
$mutator = clone $date;
|
||||
$mutator->addDay(); // always assume today has passed.
|
||||
$mutator->startOfMonth();
|
||||
// this feels a bit like a cop out but why reinvent the wheel?
|
||||
@@ -120,14 +120,14 @@ trait CalculateXOccurrences
|
||||
*/
|
||||
protected function getXWeeklyOccurrences(Carbon $date, int $count, int $skipMod, string $moment): array
|
||||
{
|
||||
$return = [];
|
||||
$total = 0;
|
||||
$attempts = 0;
|
||||
$mutator = clone $date;
|
||||
$return = [];
|
||||
$total = 0;
|
||||
$attempts = 0;
|
||||
$mutator = clone $date;
|
||||
// monday = 1
|
||||
// sunday = 7
|
||||
$mutator->addDay(); // always assume today has passed.
|
||||
$dayOfWeek = (int)$moment;
|
||||
$dayOfWeek = (int)$moment;
|
||||
if ($mutator->dayOfWeekIso > $dayOfWeek) {
|
||||
// day has already passed this week, add one week:
|
||||
$mutator->addWeek();
|
||||
@@ -164,7 +164,7 @@ trait CalculateXOccurrences
|
||||
if ($mutator > $date) {
|
||||
$date->addYear();
|
||||
}
|
||||
$obj = clone $date;
|
||||
$obj = clone $date;
|
||||
while ($total < $count) {
|
||||
if (0 === $attempts % $skipMod) {
|
||||
$return[] = clone $obj;
|
||||
|
@@ -87,7 +87,7 @@ trait CalculateXOccurrencesSince
|
||||
++$total;
|
||||
}
|
||||
++$attempts;
|
||||
$mutator = $mutator->endOfMonth()->addDay();
|
||||
$mutator = $mutator->endOfMonth()->addDay();
|
||||
}
|
||||
Log::debug('Collected enough occurrences.');
|
||||
|
||||
@@ -103,10 +103,10 @@ trait CalculateXOccurrencesSince
|
||||
protected function getXNDomOccurrencesSince(Carbon $date, Carbon $afterDate, int $count, int $skipMod, string $moment): array
|
||||
{
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
$return = [];
|
||||
$total = 0;
|
||||
$attempts = 0;
|
||||
$mutator = clone $date;
|
||||
$return = [];
|
||||
$total = 0;
|
||||
$attempts = 0;
|
||||
$mutator = clone $date;
|
||||
$mutator->addDay(); // always assume today has passed.
|
||||
$mutator->startOfMonth();
|
||||
// this feels a bit like a cop out but why reinvent the wheel?
|
||||
@@ -137,15 +137,15 @@ trait CalculateXOccurrencesSince
|
||||
protected function getXWeeklyOccurrencesSince(Carbon $date, Carbon $afterDate, int $count, int $skipMod, string $moment): array
|
||||
{
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
$return = [];
|
||||
$total = 0;
|
||||
$attempts = 0;
|
||||
$mutator = clone $date;
|
||||
$return = [];
|
||||
$total = 0;
|
||||
$attempts = 0;
|
||||
$mutator = clone $date;
|
||||
// monday = 1
|
||||
// sunday = 7
|
||||
// Removed assumption today has passed, see issue https://github.com/firefly-iii/firefly-iii/issues/4798
|
||||
// $mutator->addDay(); // always assume today has passed.
|
||||
$dayOfWeek = (int)$moment;
|
||||
$dayOfWeek = (int)$moment;
|
||||
if ($mutator->dayOfWeekIso > $dayOfWeek) {
|
||||
// day has already passed this week, add one week:
|
||||
$mutator->addWeek();
|
||||
@@ -189,7 +189,7 @@ trait CalculateXOccurrencesSince
|
||||
$date->addYear();
|
||||
Log::debug(sprintf('Date is now %s', $date->format('Y-m-d')));
|
||||
}
|
||||
$obj = clone $date;
|
||||
$obj = clone $date;
|
||||
while ($total < $count) {
|
||||
Log::debug(sprintf('total (%d) < count (%d) so go.', $total, $count));
|
||||
Log::debug(sprintf('attempts (%d) %% skipmod (%d) === %d', $attempts, $skipMod, $attempts % $skipMod));
|
||||
|
@@ -46,7 +46,7 @@ trait FiltersWeekends
|
||||
|
||||
return $dates;
|
||||
}
|
||||
$return = [];
|
||||
$return = [];
|
||||
|
||||
/** @var Carbon $date */
|
||||
foreach ($dates as $date) {
|
||||
@@ -60,7 +60,7 @@ trait FiltersWeekends
|
||||
|
||||
// is weekend and must set back to Friday?
|
||||
if (RecurrenceRepetitionWeekend::WEEKEND_TO_FRIDAY->value === $repetition->weekend) {
|
||||
$clone = clone $date;
|
||||
$clone = clone $date;
|
||||
$clone->addDays(5 - $date->dayOfWeekIso);
|
||||
Log::debug(
|
||||
sprintf('Date is %s, and this is in the weekend, so corrected to %s (Friday).', $date->format('D d M Y'), $clone->format('D d M Y'))
|
||||
@@ -72,7 +72,7 @@ trait FiltersWeekends
|
||||
|
||||
// postpone to Monday?
|
||||
if (RecurrenceRepetitionWeekend::WEEKEND_TO_MONDAY->value === $repetition->weekend) {
|
||||
$clone = clone $date;
|
||||
$clone = clone $date;
|
||||
$clone->addDays(8 - $date->dayOfWeekIso);
|
||||
Log::debug(
|
||||
sprintf('Date is %s, and this is in the weekend, so corrected to %s (Monday).', $date->format('D d M Y'), $clone->format('D d M Y'))
|
||||
|
@@ -37,7 +37,7 @@ interface UserGroupInterface
|
||||
|
||||
public function getUserGroup(): ?UserGroup;
|
||||
|
||||
public function setUser(Authenticatable | User | null $user): void;
|
||||
public function setUser(Authenticatable|User|null $user): void;
|
||||
|
||||
public function setUserGroup(UserGroup $userGroup): void;
|
||||
|
||||
|
@@ -61,10 +61,10 @@ trait UserGroupTrait
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function setUser(Authenticatable | User | null $user): void
|
||||
public function setUser(Authenticatable|User|null $user): void
|
||||
{
|
||||
if ($user instanceof User) {
|
||||
$this->user = $user;
|
||||
$this->user = $user;
|
||||
if (null === $user->userGroup) {
|
||||
throw new FireflyException(sprintf('User #%d ("%s") has no user group.', $user->id, $user->email));
|
||||
}
|
||||
@@ -99,14 +99,15 @@ trait UserGroupTrait
|
||||
public function setUserGroupById(int $userGroupId): void
|
||||
{
|
||||
$memberships = GroupMembership::where('user_id', $this->user->id)
|
||||
->where('user_group_id', $userGroupId)
|
||||
->count();
|
||||
->where('user_group_id', $userGroupId)
|
||||
->count()
|
||||
;
|
||||
if (0 === $memberships) {
|
||||
throw new FireflyException(sprintf('User #%d has no access to administration #%d', $this->user->id, $userGroupId));
|
||||
}
|
||||
|
||||
/** @var null|UserGroup $userGroup */
|
||||
$userGroup = UserGroup::find($userGroupId);
|
||||
$userGroup = UserGroup::find($userGroupId);
|
||||
if (null === $userGroup) {
|
||||
throw new FireflyException(sprintf('Cannot find administration for user #%d', $this->user->id));
|
||||
}
|
||||
|
Reference in New Issue
Block a user