Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Domain/Access/ScheduleRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ public function GetLayout($scheduleId, ILayoutFactory $layoutFactory)
{
$reader = ServiceLocator::GetDatabase()->Query(new GetLayoutCommand($scheduleId));

/** @var ScheduleLayout $layout */
$layout = null;

while ($row = $reader->GetRow()) {
Expand All @@ -309,6 +308,10 @@ public function GetLayout($scheduleId, ILayoutFactory $layoutFactory)
}
$reader->Free();

if ($layout == null) {
$layout = $layoutFactory->CreateLayout();
}

$reader = ServiceLocator::GetDatabase()->Query(new GetPeakTimesCommand($scheduleId));
if ($row = $reader->GetRow()) {
$layout->ChangePeakTimes(PeakTimes::FromRow($row));
Expand Down
4 changes: 3 additions & 1 deletion Domain/PaymentGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,12 @@ public function Charge(CreditCartSession $cart, $email, $token, IPaymentTransact
Log::Debug('Stripe charge response %s', json_encode($charge));
}

$chargeData = $charge->toArray();

$logger->LogPayment(
$cart->UserId,
$charge->status,
$charge->invoice,
$chargeData['invoice'] ?? null,
$charge->id,
$currency->FromStripe($charge->amount),
$currency->FromStripe($charge->balance_transaction->fee),
Expand Down
4 changes: 4 additions & 0 deletions Domain/RepeatOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ public function ConfigurationString()

public function HasSameConfigurationAs(IRepeatOptions $repeatOptions)
{
if (!$repeatOptions instanceof self) {
return false;
}

return parent::HasSameConfigurationAs($repeatOptions) && $this->_daysOfWeek == $repeatOptions->_daysOfWeek;
}
}
Expand Down
4 changes: 3 additions & 1 deletion Domain/ReservationItemView.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ public function GetLabel();
* @return int
*/
public function GetScheduleId();

public function IsUserParticipating(int $userId): bool;
}

class ReservationItemView implements IReservedItemView
Expand Down Expand Up @@ -785,7 +787,7 @@ public function IsUserOwner($userId)
* @param $userId int
* @return bool
*/
public function IsUserParticipating($userId)
public function IsUserParticipating(int $userId): bool
{
return in_array($userId, $this->ParticipantIds);
}
Expand Down
4 changes: 2 additions & 2 deletions Domain/ScheduleLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -979,9 +979,9 @@ class LayoutPeriod
public $End;

/**
* @var PeriodTypes
* @var int
*/
public $PeriodType;
public int $PeriodType;

/**
* @var string
Expand Down
12 changes: 12 additions & 0 deletions Pages/SchedulePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ public function GetOwnerText();
*/
public function GetParticipantId();

public function GetGroupId(): int|null;

/**
* @return string
*/
Expand Down Expand Up @@ -666,6 +668,16 @@ public function GetParticipantId()
return intval($id);
}

public function GetGroupId(): int|null
{
$id = $this->GetQuerystring(QueryStringKeys::GROUP_ID);
if (empty($id)) {
return null;
}

return intval($id);
}

public function GetOwnerText()
{
return $this->GetQuerystring(FormKeys::OWNER_TEXT);
Expand Down
2 changes: 1 addition & 1 deletion Presenters/Admin/Import/ICalImportPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function Import()
die('Invalid import file: ' . $e->getMessage());
}

$events = $vcalendar->VEVENT;
$events = $vcalendar->select('VEVENT');
Log::Debug('Found %s events in ics file', count($events));

foreach ($events as $event) {
Expand Down
4 changes: 3 additions & 1 deletion Presenters/ParticipationPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ private function HandleInvitationAction($invitationAction)

$series = $this->reservationRepository->LoadByReferenceNumber($referenceNumber);

/** @var IReservationValidationRule[] $rules */
$rules = [];

if ($invitationAction == InvitationAction::Join || $invitationAction == InvitationAction::CancelInstance) {
$rules = [new ReservationStartTimeRule(new ScheduleRepository()), new ResourceMinimumNoticeCurrentInstanceRuleUpdate($user), new ResourceMaximumNoticeCurrentInstanceRule($user)];
} else {
$rules = [new ReservationStartTimeRule(new ScheduleRepository()), new ResourceMinimumNoticeRuleAdd($user), new ResourceMaximumNoticeRule($user)];
}

/** @var IReservationValidationRule $rule */
foreach ($rules as $rule) {
$ruleResult = $rule->Validate($series, null);

Expand Down
2 changes: 1 addition & 1 deletion Presenters/ResourceDisplayPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function DisplayResource($resourcePublicId, $startDate)

$reservationList = $reservations->OnDateForResource($reservationDate, $resource->GetId());

/** @var ReservationListItem $next */
/** @var ReservationListItem|null $next */
$next = null;

/** @var ReservationListItem[] $upcoming */
Expand Down
5 changes: 1 addition & 4 deletions Presenters/ViewSchedulesPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

class ViewSchedulesPresenter
{
/**
* @var ResourceViewerViewResourcesPage
*/
private $page;
private ScheduleViewerViewSchedulesPage $page;

/**
* @var IResourceRepository
Expand Down
2 changes: 1 addition & 1 deletion WebServices/SchedulesWebService.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public function SetScheduleStyle($direction)
// no op
}

public function GetGroupId()
public function GetGroupId(): int|null
{
return null;
}
Expand Down
3 changes: 2 additions & 1 deletion WebServices/Validators/AccountRequestValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ public function ValidateUpdate($request, WebServiceUserSession $session)

public function ValidatePasswordUpdate($request, WebServiceUserSession $session)
{
/** @var IValidator[] $validators */
$validators = [];
$validators[] = new PasswordComplexityValidator($request->newPassword);
$validators[] = new PasswordValidator($request->currentPassword, $this->userRepository->LoadById($session->UserId));

$errors = [];
/** @var IValidator $validator */
foreach ($validators as $validator) {
$validator->Validate();
if (!$validator->IsValid()) {
Expand Down
3 changes: 2 additions & 1 deletion WebServices/Validators/ResourceRequestValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ private function ValidateCommon($request)
}
$errors = [];

/** @var IValidator[] $validators */
$validators = [];
$validators[] = new RequestRequiredValueValidator($request->name, 'name');
$validators[] = new RequestRequiredValueValidator($request->scheduleId, 'scheduleId');
$validators[] = new TimeIntervalValidator($request->minLength, 'minLength');
Expand All @@ -70,7 +72,6 @@ private function ValidateCommon($request)
$validators[] = new AttributeValidator($this->attributeService, CustomAttributeCategory::RESOURCE, $attributes);


/** @var IValidator $validator */
foreach ($validators as $validator) {
$validator->Validate();
if (!$validator->IsValid()) {
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
"squizlabs/php_codesniffer": "^3.7.1",
"phpcompatibility/php-compatibility": "^9.3.5",
"phpunit/phpunit": "^11.3",
"phpstan/phpstan": "^2.1"
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-phpunit": "^2.0"
},
"require": {
"php": ">=8.2",
"smarty/smarty": "^5.5",
"stripe/stripe-php": "^10.2",
"stripe/stripe-php": "^19.3",
"monolog/monolog": "^3.10",
"google/recaptcha": "1.3.*",
"gregwar/captcha": "^1.3",
Expand Down
78 changes: 66 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/Application/Reservation/ReservationComponentBinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function Bind(IReservationComponentInitializer $initializer)
$resources = $groups->GetAllResources();
if (empty($requestedResourceId) && count($resources) > 0) {
$first = reset($resources);
$requestedResourceId = $first->Id;
$requestedResourceId = $first->GetId();
}

$bindableResourceData = $this->GetBindableResourceData($resources, $requestedResourceId);
Expand Down
4 changes: 4 additions & 0 deletions lib/Application/Reservation/ResourceTypeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public function __construct($resourcetypename)
*/
public function ShouldInclude($assignment)
{
if (!$assignment instanceof IBookableResource) {
return false;
}

return in_array($assignment->GetResourceTypeId(), $this->resourcetypeids);
}
}
Loading