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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
26 changes: 12 additions & 14 deletions .github/workflows/lint-and-analyse-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,21 @@ jobs:
- name: Validate composer.json and composer.lock
run: composer validate --strict

# TODO: Enable this after resolving issues
# - name: Cache coding-standard
# # Allow the previous check to fail but not abort
# if: always()
# uses: actions/cache@v4
# with:
# path: .phpcs-cache
# key: phpcs-cache

- name: Lint PHP files
run: ./ci/ci-phplint

# TODO: Enable this after resolving issues
# - name: Check coding-standard
# # Allow the previous check to fail but not abort
# if: always()
# run: composer phpcsfixer:lint
- name: Cache php-cs-fixer
if: matrix.php-version == '8.2'
uses: actions/cache@v4
with:
path: var/cache/.php-cs-fixer.cache
key: php-cs-fixer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.lock', '.php-cs-fixer.dist.php') }}
restore-keys: |
php-cs-fixer-${{ runner.os }}-${{ matrix.php-version }}-
- name: Check coding-standard (php-cs-fixer)
if: matrix.php-version == '8.2'
run: composer phpcsfixer:lint

analyse-php:
runs-on: ubuntu-latest
Expand Down
14 changes: 7 additions & 7 deletions Controls/Dashboard/PastReservations.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function BindThisWeek($reservations)
$this->Set('ThisWeeksReservations', $reservations);
}

public function BindPreviousWeek($reservations)
public function BindPreviousWeek($reservations)
{
$this->Set('PreviousWeekReservations', $reservations);
}
Expand All @@ -81,7 +81,7 @@ public function SetUserId($userId);
public function SetAllowCheckin($allowCheckin);
public function SetAllowCheckout($allowCheckout);

public function BindToday($reservations);
public function BindToday($reservations);
public function BindYesterday($reservations);
public function BindThisWeek($reservations);
public function BindPreviousWeek($reservations);
Expand All @@ -105,9 +105,9 @@ public function PageLoad()

class MissingCheckInOutReservations extends PastReservations implements IRemainingPastReservationsControl
{
/**
* @var MissingCheckInOutReservationsPresenter
*/
/**
* @var MissingCheckInOutReservationsPresenter
*/
protected $presenter;

public function __construct(SmartyPage $smarty)
Expand All @@ -124,8 +124,8 @@ public function PageLoad()
$this->Display('missing_check_in_out_reservations.tpl');
}

public function BindRemaining($reservations)
public function BindRemaining($reservations)
{
$this->Set('RemainingReservations', $reservations);
}
}
}
2 changes: 1 addition & 1 deletion Controls/Dashboard/UpcomingReservations.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,4 @@ public function BindRemaining($reservations)
{
$this->Set('RemainingReservations', $reservations);
}
}
}
2 changes: 1 addition & 1 deletion Controls/DatePickerSetupControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function PageLoad()
{
$this->SetDefault('NumberOfMonths', 1);
$this->SetDefault('ShowButtonPanel', 'false');
$controlId = $this->Get("ControlId");
$controlId = $this->Get('ControlId');
$controlId = str_replace(']', '\\\\]', str_replace('[', '\\\\[', $controlId));
$altId = $this->Get('AltId');

Expand Down
30 changes: 15 additions & 15 deletions Controls/RecurrenceControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ public function PageLoad()
$this->Set(
'RepeatOptions',
[
'none' => ['key' => 'DoesNotRepeat', 'everyKey' => ''],
'daily' => ['key' => 'Daily', 'everyKey' => 'days'],
'weekly' => ['key' => 'Weekly', 'everyKey' => 'weeks'],
'monthly' => ['key' => 'Monthly', 'everyKey' => 'months'],
'yearly' => ['key' => 'Yearly', 'everyKey' => 'years'],
'custom' => ['key' => 'Custom', 'everyKey' => 'custom'],
]
'none' => ['key' => 'DoesNotRepeat', 'everyKey' => ''],
'daily' => ['key' => 'Daily', 'everyKey' => 'days'],
'weekly' => ['key' => 'Weekly', 'everyKey' => 'weeks'],
'monthly' => ['key' => 'Monthly', 'everyKey' => 'months'],
'yearly' => ['key' => 'Yearly', 'everyKey' => 'years'],
'custom' => ['key' => 'Custom', 'everyKey' => 'custom'],
]
);
$this->Set(
'DayNames',
[
0 => 'DaySundayAbbr',
1 => 'DayMondayAbbr',
2 => 'DayTuesdayAbbr',
3 => 'DayWednesdayAbbr',
4 => 'DayThursdayAbbr',
5 => 'DayFridayAbbr',
6 => 'DaySaturdayAbbr',
]
0 => 'DaySundayAbbr',
1 => 'DayMondayAbbr',
2 => 'DayTuesdayAbbr',
3 => 'DayWednesdayAbbr',
4 => 'DayThursdayAbbr',
5 => 'DayFridayAbbr',
6 => 'DaySaturdayAbbr',
]
);

$this->Display('Controls/RecurrenceDiv.tpl');
Expand Down
2 changes: 1 addition & 1 deletion Domain/Access/AttributeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static function Create($entityTableAndColumn, $attributes)
}
}

$f->AppendSql("WHERE [attribute_list_token] )");
$f->AppendSql('WHERE [attribute_list_token] )');
$f->Substitute('attribute_list_token', $attributeFragment);

if ($filteringAttributes) {
Expand Down
6 changes: 3 additions & 3 deletions Domain/Access/IResourceRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function GetList($pageNumber, $pageSize, $sortField = null, $sortDirectio
* @param ISqlFilter $filter
* @return PageableData|BookableResource[]
*/
public function GetUserList($resourceIds,$pageNumber, $pageSize, $sortField = null, $sortDirection = null, $filter = null);
public function GetUserList($resourceIds, $pageNumber, $pageSize, $sortField = null, $sortDirection = null, $filter = null);

/**
* @param null|string $sortField
Expand Down Expand Up @@ -115,13 +115,13 @@ public function GetUserGroupResourcePermissions($userId, $resourceIds = []);
* @param int $userId
* @param array $resourceIds
*/
public function GetResourceAdminResourceIds($userId, $resourceIds = []);
public function GetResourceAdminResourceIds($userId, $resourceIds = []);

/**
* @param int $userId
* @param array $resourceIds
*/
public function GetScheduleAdminResourceIds($userId, $resourceIds = []);
public function GetScheduleAdminResourceIds($userId, $resourceIds = []);


/**
Expand Down
4 changes: 2 additions & 2 deletions Domain/Access/PageableDataStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public function __construct($totalResults, $pageNumber, $pageSize)
$this->Total = $totalResults;
$this->CurrentPage = $pageNumber;
$this->PageSize = $pageSize;
$this->TotalPages = ceil($totalResults/max($pageSize, 1));
$this->ResultsStart = ($pageNumber-1) * $pageSize + 1;
$this->TotalPages = ceil($totalResults / max($pageSize, 1));
$this->ResultsStart = ($pageNumber - 1) * $pageSize + 1;
$this->ResultsEnd = min(($pageNumber * $pageSize), $totalResults);
}

Expand Down
2 changes: 1 addition & 1 deletion Domain/Access/PaymentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function GetCreditCosts()
{
$reader = ServiceLocator::GetDatabase()->Query(new GetPaymentConfigurationCommand());
$res = [];
for ($i=0;$i<$reader->NumRows();$i++) {
for ($i = 0;$i < $reader->NumRows();$i++) {
$row = $reader->GetRow();
$res[] = new CreditCost($row[ColumnNames::CREDIT_COUNT], $row[ColumnNames::CREDIT_COST], $row[ColumnNames::CREDIT_CURRENCY]);
}
Expand Down
16 changes: 8 additions & 8 deletions Domain/Access/ReservationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public function Delete(ExistingReservationSeries $existingReservationSeries)
{
$database = ServiceLocator::GetDatabase();

// $creditAdjustment = 0 - $existingReservationSeries->GetCreditsConsumed();
// $creditAdjustment = 0 - $existingReservationSeries->GetCreditsConsumed();
// $creditAdjustment = $existingReservationSeries->GetCreditsRequired() - $existingReservationSeries->GetOriginalCreditsConsumed();
$creditAdjustment = 0 - $existingReservationSeries->GetUnusedCreditBalance();
if ($creditAdjustment != 0) {
Expand Down Expand Up @@ -758,13 +758,13 @@ public function Execute(Database $database)
);

$reservationId = $database->ExecuteInsert($insertReservation);
//
// if ($reservationId <= 0)
// {
// $database->Execute(new DeleteSeriesPermanantCommand($this->series->SeriesId()));
// Log::Error("Could not insert reservation because there were conflicts. Command: %s", $insertReservation);
// throw new Exception("Could not insert reservation - conflicting times");
// }
//
// if ($reservationId <= 0)
// {
// $database->Execute(new DeleteSeriesPermanantCommand($this->series->SeriesId()));
// Log::Error("Could not insert reservation because there were conflicts. Command: %s", $insertReservation);
// throw new Exception("Could not insert reservation - conflicting times");
// }
$insertReservationUser = new AddReservationUserCommand($reservationId, $this->series->UserId(), ReservationUserLevel::OWNER);

$database->Execute($insertReservationUser);
Expand Down
36 changes: 21 additions & 15 deletions Domain/Access/ResourceRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public function GetResourceList()
/**
* Gets the resource IDs for all the resources
*/
public function GetResourceIdList(): array {
public function GetResourceIdList(): array
{
$resourceIds = [];
$reader = ServiceLocator::GetDatabase()->Query(new GetAllResourcesCommand());
while ($row = $reader->GetRow()) {
Expand All @@ -93,14 +94,14 @@ public function GetUserResourceList()
if (is_null($userSession)) {
return [];
}
if ($userSession->IsAdmin){
if ($userSession->IsAdmin) {
return $this->GetResourceList();
}
$resourceIds = $this->GetUserResourceIdList();
$resources = [];
foreach($resourceIds as $resourceId){
foreach ($resourceIds as $resourceId) {
$resource = $this->LoadById($resourceId);
if($resource->GetStatusId() != ResourceStatus::HIDDEN){
if ($resource->GetStatusId() != ResourceStatus::HIDDEN) {
$resources[$resourceId] = $resource;
}
}
Expand All @@ -111,23 +112,24 @@ public function GetUserResourceList()
* Gets the resource IDs that the logged in user has permissions (full access and view only permissions)
* This is used to block a user from seeing a resource if they don't have permissions to it.
*/
public function GetUserResourceIdList() {
public function GetUserResourceIdList()
{
$userSession = ServiceLocator::GetUserSession();
if (is_null($userSession)) {
return [];
}
if ($userSession->IsAdmin){
if ($userSession->IsAdmin) {
return $this->GetResourceIdList();
}
$resourceIds = $this->GetUserResourcePermissions(userId: $userSession->UserId);
$resourceIds = $this->GetUserGroupResourcePermissions(userId: $userSession->UserId, resourceIds: $resourceIds);


if ($userSession->IsResourceAdmin){
if ($userSession->IsResourceAdmin) {
$resourceIds = $this->GetResourceAdminResourceIds(userId: $userSession->UserId, resourceIds: $resourceIds);
}

if ($userSession->IsScheduleAdmin){
if ($userSession->IsScheduleAdmin) {
$resourceIds = $this->GetScheduleAdminResourceIds(userId: $userSession->UserId, resourceIds: $resourceIds);
}
return $resourceIds;
Expand Down Expand Up @@ -340,7 +342,7 @@ public function Update(BookableResource $resource)

public function Delete(BookableResource $resource)
{
Log::Debug("Deleting resource %s (%s)", $resource->GetResourceId(), $resource->GetName());
Log::Debug('Deleting resource %s (%s)', $resource->GetResourceId(), $resource->GetName());

$resourceId = $resource->GetResourceId();

Expand Down Expand Up @@ -449,7 +451,8 @@ public function GetResourceGroups($scheduleId = ResourceRepository::ALL_SCHEDULE
/**
* Gets the resource ids that the user has permissions to
*/
public function GetUserResourcePermissions($userId, $resourceIds = []){
public function GetUserResourcePermissions($userId, $resourceIds = [])
{
$command = new GetUserPermissionsCommand($userId);
$reader = ServiceLocator::GetDatabase()->Query($command);

Expand All @@ -469,7 +472,8 @@ public function GetUserResourcePermissions($userId, $resourceIds = []){
/**
* Gets the resource ids that the user groups have permissions to
*/
public function GetUserGroupResourcePermissions($userId, $resourceIds = []){
public function GetUserGroupResourcePermissions($userId, $resourceIds = [])
{
$command = new SelectUserGroupPermissions($userId);
$reader = ServiceLocator::GetDatabase()->Query($command);

Expand All @@ -488,12 +492,13 @@ public function GetUserGroupResourcePermissions($userId, $resourceIds = []){
/**
* Gets the resource ids that are under the responsability of the given resource user groups
*/
public function GetResourceAdminResourceIds($userId, $resourceIds = []){
public function GetResourceAdminResourceIds($userId, $resourceIds = [])
{
$userSession = ServiceLocator::GetUserSession();
if (is_null($userSession)) {
return $resourceIds;
}
if ($userSession->IsResourceAdmin){
if ($userSession->IsResourceAdmin) {
$command = new GetResourceAdminResourcesCommand($userId);
$reader = ServiceLocator::GetDatabase()->Query($command);

Expand All @@ -512,12 +517,13 @@ public function GetResourceAdminResourceIds($userId, $resourceIds = []){
/**
* Gets the resource ids that are under the responsability of the given schedule user groups
*/
public function GetScheduleAdminResourceIds($userId, $resourceIds = []){
public function GetScheduleAdminResourceIds($userId, $resourceIds = [])
{
$userSession = ServiceLocator::GetUserSession();
if (is_null($userSession)) {
return $resourceIds;
}
if ($userSession->IsScheduleAdmin){
if ($userSession->IsScheduleAdmin) {
$command = new GetScheduleAdminResourcesCommand($userId);
$reader = ServiceLocator::GetDatabase()->Query($command);

Expand Down
Loading