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
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ updates:
timezone: "America/Los_Angeles"
commit-message:
prefix: "chore(deps)"
versioning-strategy: increase

- package-ecosystem: "pip" # Python uses pip
directory: "/"
Expand Down
2 changes: 1 addition & 1 deletion Domain/Access/ScheduleRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public function Update(Schedule $schedule)
$schedule->GetAdminGroupId(),
$schedule->GetAvailabilityBegin(),
$schedule->GetAvailabilityEnd(),
$schedule->GetDefaultStyle(),
$schedule->GetDefaultStyleInt(),
$schedule->GetTotalConcurrentReservations(),
$schedule->GetMaxResourcesPerReservation()
));
Expand Down
39 changes: 20 additions & 19 deletions Domain/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ public function GetAvailability();
*/
public function HasAvailability();

/**
* @return int
*/
public function GetDefaultStyle();
public function GetDefaultStyle(): ScheduleStyle;
}

class Schedule implements ISchedule
Expand All @@ -64,7 +61,7 @@ class Schedule implements ISchedule
protected $_adminGroupId;
protected $_availabilityBegin;
protected $_availabilityEnd;
protected $_defaultStyle;
protected ScheduleStyle $_defaultStyle;
protected $_layoutType;
protected $_totalConcurrentReservations = 0;
protected $_maxResourcesPerReservation = 0;
Expand Down Expand Up @@ -272,20 +269,24 @@ public function HasAvailability()
return $this->GetAvailabilityBegin()->ToString() != '' && $this->GetAvailabilityEnd()->ToString() != '';
}

/**
* @return int|ScheduleStyle
*/
public function GetDefaultStyle()
public function GetDefaultStyle(): ScheduleStyle
{
return $this->_defaultStyle;
}

/**
* @param $defaultDisplay int|ScheduleStyle
*/
public function SetDefaultStyle($defaultDisplay)
public function GetDefaultStyleInt(): int
{
return $this->_defaultStyle->value;
}

public function SetDefaultStyle(int|ScheduleStyle $defaultDisplay): void
{
$this->_defaultStyle = $defaultDisplay;
if ($defaultDisplay instanceof ScheduleStyle) {
$this->_defaultStyle = $defaultDisplay;
return;
}

$this->_defaultStyle = ScheduleStyle::tryFrom($defaultDisplay) ?? ScheduleStyle::Standard;
}

/**
Expand Down Expand Up @@ -434,10 +435,10 @@ public function __construct()
}


class ScheduleStyle
enum ScheduleStyle: int
{
public const Standard = 0;
public const Wide = 1;
public const Tall = 2;
public const CondensedWeek = 3;
case Standard = 0;
case Wide = 1;
case Tall = 2;
case CondensedWeek = 3;
}
8 changes: 4 additions & 4 deletions Pages/Admin/ManageSchedulesPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@ public function ProcessPageLoad()
$this->Set('Months', Resources::GetInstance()->GetMonths('full'));
$this->Set('DayList', range(1, 31));
$this->Set('StyleNames', [
ScheduleStyle::Standard => $resources->GetString('Standard'),
ScheduleStyle::Wide => $resources->GetString('Wide'),
ScheduleStyle::Tall => $resources->GetString('Tall'),
ScheduleStyle::CondensedWeek => $resources->GetString('Week'),
ScheduleStyle::Standard->value => $resources->GetString('Standard'),
ScheduleStyle::Wide->value => $resources->GetString('Wide'),
ScheduleStyle::Tall->value => $resources->GetString('Tall'),
ScheduleStyle::CondensedWeek->value => $resources->GetString('Week'),
]);
$this->Display('Admin/Schedules/manage_schedules.tpl');
}
Expand Down
32 changes: 16 additions & 16 deletions Pages/SchedulePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ public function GetLayoutDate();

/**
* @param int $scheduleId
* @return string|ScheduleStyle
* @return ScheduleStyle|null
*/
public function GetScheduleStyle($scheduleId);
public function GetScheduleStyle(int $scheduleId): ?ScheduleStyle;

/**
* @param string|ScheduleStyle $direction
* @param ScheduleStyle $direction
*/
public function SetScheduleStyle($direction);
public function SetScheduleStyle(ScheduleStyle $direction): void;

/**
* @return int
Expand Down Expand Up @@ -237,9 +237,9 @@ class SchedulePage extends ActionPage implements ISchedulePage
protected $_presenter;

private $_styles = [
ScheduleStyle::Wide => 'Schedule/schedule-days-horizontal.tpl',
ScheduleStyle::Tall => 'Schedule/schedule-flipped.tpl',
ScheduleStyle::CondensedWeek => 'Schedule/schedule-week-condensed.tpl',
ScheduleStyle::Wide->value => 'Schedule/schedule-days-horizontal.tpl',
ScheduleStyle::Tall->value => 'Schedule/schedule-flipped.tpl',
ScheduleStyle::CondensedWeek->value => 'Schedule/schedule-week-condensed.tpl',
];

/**
Expand All @@ -259,7 +259,6 @@ public function __construct()
$this->Set('CanViewUsers', !Configuration::Instance()->GetKey(ConfigKeys::PRIVACY_HIDE_USER_DETAILS, new BooleanConverter()));
$this->Set('AllowParticipation', !Configuration::Instance()->GetKey(ConfigKeys::RESERVATION_PREVENT_PARTICIPATION, new BooleanConverter()));
$this->Set('AllowCreatePastReservationsButton', ServiceLocator::GetServer()->GetUserSession()->IsAdmin);

$permissionServiceFactory = new PermissionServiceFactory();
$scheduleRepository = new ScheduleRepository();
$userRepository = new UserRepository();
Expand Down Expand Up @@ -319,8 +318,9 @@ public function ProcessPageLoad()
$this->Display('Schedule/schedule-mobile.tpl');
}
} else {
if (array_key_exists($this->ScheduleStyle, $this->_styles)) {
$this->Display($this->_styles[$this->ScheduleStyle]);
$styleValue = $this->ScheduleStyle->value;
if (array_key_exists($styleValue, $this->_styles)) {
$this->Display($this->_styles[$styleValue]);
} else {
$this->Display('Schedule/schedule.tpl');
}
Expand Down Expand Up @@ -457,21 +457,21 @@ public function GetLayoutDate()
return $this->GetQuerystring(QueryStringKeys::LAYOUT_DATE);
}

public function GetScheduleStyle($scheduleId)
public function GetScheduleStyle(int $scheduleId): ?ScheduleStyle
{
$cookie = $this->server->GetCookie("schedule-style-$scheduleId");
if ($cookie != null) {
return $cookie;
if ($cookie == null || $cookie === '') {
return null;
}

return null;
return ScheduleStyle::tryFrom(intval($cookie));
}

public function SetScheduleStyle($style)
public function SetScheduleStyle(ScheduleStyle $style): void
{
$this->ScheduleStyle = $style;
$this->Set('CookieName', 'schedule-style-' . $this->GetVar('ScheduleId'));
$this->Set('ScheduleStyle', $style);
$this->Set('ScheduleStyle', $style->value);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions Pages/ScheduleViewerViewSchedulesPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public function PageLoad()
$this->Set('Today', Resources::GetInstance()->GetString('Today'));
$this->Set('Months', Resources::GetInstance()->GetMonths('full'));
$this->Set('StyleNames', [
ScheduleStyle::Standard => $resources->GetString('Standard'),
ScheduleStyle::Wide => $resources->GetString('Wide'),
ScheduleStyle::Tall => $resources->GetString('Tall'),
ScheduleStyle::CondensedWeek => $resources->GetString('Week'),
ScheduleStyle::Standard->value => $resources->GetString('Standard'),
ScheduleStyle::Wide->value => $resources->GetString('Wide'),
ScheduleStyle::Tall->value => $resources->GetString('Tall'),
ScheduleStyle::CondensedWeek->value => $resources->GetString('Week'),
]);

$this->Display(ROOT_DIR.'tpl/Admin/Schedules/view_schedules.tpl');
Expand Down
11 changes: 6 additions & 5 deletions Pages/ViewSchedulePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class ViewSchedulePage extends SchedulePage
private $userRepository;

private $_styles = [
ScheduleStyle::Wide => 'Schedule/schedule-days-horizontal.tpl',
ScheduleStyle::Tall => 'Schedule/schedule-flipped.tpl',
ScheduleStyle::CondensedWeek => 'Schedule/schedule-week-condensed.tpl',
ScheduleStyle::Wide->value => 'Schedule/schedule-days-horizontal.tpl',
ScheduleStyle::Tall->value => 'Schedule/schedule-flipped.tpl',
ScheduleStyle::CondensedWeek->value => 'Schedule/schedule-week-condensed.tpl',
];

public function __construct()
Expand Down Expand Up @@ -66,8 +66,9 @@ public function ProcessPageLoad()
$this->Display('Schedule/schedule-mobile.tpl');
}
} else {
if (array_key_exists($this->ScheduleStyle, $this->_styles)) {
$this->Display($this->_styles[$this->ScheduleStyle]);
$styleValue = $this->ScheduleStyle->value;
if (array_key_exists($styleValue, $this->_styles)) {
$this->Display($this->_styles[$styleValue]);
} else {
$this->Display('Schedule/schedule.tpl');
}
Expand Down
2 changes: 1 addition & 1 deletion Presenters/Schedule/SchedulePageBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function BindSchedules(ISchedulePage $page, $schedules, $currentSchedule)
$page->SetScheduleName($currentSchedule->GetName());
$page->SetFirstWeekday($currentSchedule->GetWeekdayStart());
$style = $page->GetScheduleStyle($scheduleId);
$page->SetScheduleStyle($style == '' ? $currentSchedule->GetDefaultStyle() : $style);
$page->SetScheduleStyle($style ?? $currentSchedule->GetDefaultStyle());
if ($currentSchedule->GetIsCalendarSubscriptionAllowed()) {
$page->SetSubscriptionUrl(new CalendarSubscriptionUrl(null, $currentSchedule->GetPublicId(), null));
}
Expand Down
4 changes: 2 additions & 2 deletions WebServices/SchedulesWebService.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,12 @@ public function GetLayoutDate()
return '';
}

public function GetScheduleStyle($scheduleId)
public function GetScheduleStyle(int $scheduleId): ?ScheduleStyle
{
return ScheduleStyle::Standard;
}

public function SetScheduleStyle($direction)
public function SetScheduleStyle(ScheduleStyle $direction): void
{
// no op
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"require": {
"php": ">=8.2",
"smarty/smarty": "^5.5",
"smarty/smarty": "^5.8",
"stripe/stripe-php": "^19.3",
"monolog/monolog": "^3.10",
"google/recaptcha": "1.3.*",
Expand Down
16 changes: 8 additions & 8 deletions composer.lock

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

6 changes: 4 additions & 2 deletions tests/Domain/Reservation/ExistingReservationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ public function testWhenApplyingRecurrenceUpdatesToFullSeries()

public function testWhenExtendingEndDateOfRepeatOptionsOnFullSeries()
{
$currentSeriesDate = new DateRange(Date::Now()->AddDays(1), Date::Now()->AddDays(1));
$start = TestBase::GetTestDate();
$currentSeriesDate = new DateRange($start, $start);
$currentInstance = new TestReservation('current', $currentSeriesDate);
$futureInstance = new TestReservation('future', $currentSeriesDate->AddDays(11));
$repeatDaily = new RepeatDaily(1, $currentSeriesDate->AddDays(10)->GetBegin());
Expand All @@ -259,7 +260,8 @@ public function testWhenExtendingEndDateOfRepeatOptionsOnFullSeries()

public function testWhenReducingEndDateOfRepeatOptionsOnFullSeries()
{
$currentSeriesDate = new DateRange(Date::Now()->AddDays(1), Date::Now()->AddDays(1));
$start = TestBase::GetTestDate();
$currentSeriesDate = new DateRange($start, $start);
$currentInstance = new TestReservation('current', $currentSeriesDate);
$futureInstance = new TestReservation('future', $currentSeriesDate->AddDays(20));
$repeatDaily = new RepeatDaily(1, $currentSeriesDate->AddDays(10)->GetBegin());
Expand Down
2 changes: 1 addition & 1 deletion tests/Domain/Schedule/ScheduleRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public function testCanUpdateSchedule()
$begin = Date::Now();
$end = Date::Now()->AddDays(1);
$allowConcurrent = true;
$style = ScheduleStyle::CondensedWeek;
$style = ScheduleStyle::CondensedWeek->value;
$maxConcurrent = 10;
$maxResources = 50;

Expand Down
10 changes: 5 additions & 5 deletions tests/Presenters/SchedulePresenterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1061,17 +1061,17 @@ public function GetLayoutDate()

/**
* @param int $scheduleId
* @return string|ScheduleStyle
* @return ScheduleStyle|null
*/
public function GetScheduleStyle($scheduleId)
public function GetScheduleStyle(int $scheduleId): ?ScheduleStyle
{
return '';
return null;
}

/**
* @param string|ScheduleStyle $direction
* @param ScheduleStyle $direction
*/
public function SetScheduleStyle($direction)
public function SetScheduleStyle(ScheduleStyle $direction): void
{
}

Expand Down
2 changes: 1 addition & 1 deletion tests/fakes/FakeSchedules.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public static function GetRow(
ColumnNames::SCHEDULE_ADMIN_GROUP_ID => $adminId,
ColumnNames::SCHEDULE_AVAILABLE_START_DATE => $availableStart,
ColumnNames::SCHEDULE_AVAILABLE_END_DATE => $availableEnd,
ColumnNames::SCHEDULE_DEFAULT_STYLE => ScheduleStyle::Standard,
ColumnNames::SCHEDULE_DEFAULT_STYLE => ScheduleStyle::Standard->value,
ColumnNames::LAYOUT_TYPE => ScheduleLayout::Standard,
ColumnNames::TOTAL_CONCURRENT_RESERVATIONS => $totalConcurrentReservations,
ColumnNames::MAX_RESOURCES_PER_RESERVATION => $maxResourcesPerReservation,
Expand Down
2 changes: 1 addition & 1 deletion tpl/Admin/Schedules/manage_schedules.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
class="propertyValue defaultScheduleStyle inlineUpdate fw-bold text-decoration-underline"
data-type="select" data-pk="{$id}"
data-name="{FormKeys::SCHEDULE_DEFAULT_STYLE}"
data-value="{$schedule->GetDefaultStyle()}">{$StyleNames[$schedule->GetDefaultStyle()]}</span>
data-value="{$schedule->GetDefaultStyle()->value}">{$StyleNames[$schedule->GetDefaultStyle()->value]}</span>
</div>

{if $CreditsEnabled}
Expand Down
4 changes: 2 additions & 2 deletions tpl/Admin/Schedules/view_schedules.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<div>
{translate key=DefaultStyle}
<span
class="fw-bold">{$StyleNames[$schedule->GetDefaultStyle()]}</span>
class="fw-bold">{$StyleNames[$schedule->GetDefaultStyle()->value]}</span>
</div>

{if $CreditsEnabled}
Expand Down Expand Up @@ -190,4 +190,4 @@
{datatablefilter tableId=$tableIdFilter}
</div>

{include file='globalfooter.tpl'}
{include file='globalfooter.tpl'}
Loading