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
160 changes: 0 additions & 160 deletions lib/Service/AangebodenGebruikService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1223,166 +1223,6 @@ private function resolveVoorzieningenSchemaConfig(string $schemaKey, string $lab
throw new Exception(ucfirst($labelForLogs) . ' configuration not found. Please configure the schemas in the admin panel.');
}//end resolveVoorzieningenSchemaConfig()

/**
* Get all applications/modules owned by an organization
*
* @param ObjectServiceInterface $objectService The OpenRegister object service
* @param string $organisationUuid The organization UUID
*
* @return array Array of application/module UUIDs
*
* @throws Exception When query fails
*/
private function getApplicationsOwnedByOrganisation(
ObjectServiceInterface $objectService,
string $organisationUuid,
): array {
try {
$voorzieningenConfig = $this->settingsService->getVoorzieningenConfig();
$registerId = $voorzieningenConfig['register'] ?? null;

if ($registerId === null) {
return [];
}

$appUuids = [];

// Check suite schema (applications).
if (isset($voorzieningenConfig['suite_schema']) === true) {
$suiteQuery = [
'@self' => [
'register' => $registerId,
'schema' => $voorzieningenConfig['suite_schema'],
'organisation' => $organisationUuid,
],
'_source' => 'database',
'_limit' => 500,
];

$suites = $objectService->searchObjects(
query: $suiteQuery,
_rbac: false,
_multitenancy: false
);

foreach ($suites as $suite) {
$suiteData = $suite;
if (is_array(value: $suite) === false) {
$suiteData = $suite->getObject();
}

$appUuids[] = $suiteData['uuid'] ?? $suiteData['id'] ?? null;
}
}//end if

// Check module schema.
if (isset($voorzieningenConfig['module_schema']) === true) {
$moduleQuery = [
'@self' => [
'register' => $registerId,
'schema' => $voorzieningenConfig['module_schema'],
'organisation' => $organisationUuid,
],
'_source' => 'database',
'_limit' => 500,
];

$modules = $objectService->searchObjects(
query: $moduleQuery,
_rbac: false,
_multitenancy: false
);

foreach ($modules as $module) {
$moduleData = $module;
if (is_array(value: $module) === false) {
$moduleData = $module->getObject();
}

$appUuids[] = $moduleData['uuid'] ?? $moduleData['id'] ?? null;
}
}//end if

// Filter out nulls.
$appUuids = array_filter($appUuids);

$this->logger->debug(
'Found applications owned by organization',
[
'organisation' => $organisationUuid,
'count' => count($appUuids),
]
);

return $appUuids;
} catch (Exception $e) {
$this->logger->error(
'Failed to get applications owned by organization',
[
'organisation' => $organisationUuid,
'error' => $e->getMessage(),
]
);
return [];
}//end try
}//end getApplicationsOwnedByOrganisation()

/**
* Check if an organization owns a specific application/module
*
* @param ObjectServiceInterface $objectService The OpenRegister object service
* @param string $appUuid The application/module UUID
* @param string $organisationUuid The organization UUID
*
* @return bool True if organization owns the application/module
*/
private function checkOrganisationOwnership(
ObjectServiceInterface $objectService,
string $appUuid,
string $organisationUuid,
): bool {
try {
// Get the application/module object.
$appObject = $objectService->find(
id: $appUuid,
_rbac: false,
_multitenancy: false
);

if ($appObject === null) {
return false;
}

// Check if the organization owns it.
$appData = $appObject->getObject();
$ownerOrg = $appData['@self']['organisation'] ?? null;

$isOwner = ($ownerOrg === $organisationUuid);

$this->logger->debug(
'Checked organization ownership',
[
'app_uuid' => $appUuid,
'organisation' => $organisationUuid,
'owner_org' => $ownerOrg,
'is_owner' => $isOwner,
]
);

return $isOwner;
} catch (Exception $e) {
$this->logger->error(
'Failed to check organization ownership',
[
'app_uuid' => $appUuid,
'organisation' => $organisationUuid,
'error' => $e->getMessage(),
]
);
return false;
}//end try
}//end checkOrganisationOwnership()

/**
* Mapping from organisatie.type to registeredBy value
*/
Expand Down
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,6 @@ parameters:
count: 1
path: lib/Service/AangebodenGebruikService.php

-
message: "#^Method OCA\\\\Stackiq\\\\Service\\\\AangebodenGebruikService\\:\\:checkOrganisationOwnership\\(\\) is unused\\.$#"
count: 1
path: lib/Service/AangebodenGebruikService.php

-
message: "#^Method OCA\\\\Stackiq\\\\Service\\\\AangebodenGebruikService\\:\\:getApplicationsOwnedByOrganisation\\(\\) is unused\\.$#"
count: 1
path: lib/Service/AangebodenGebruikService.php

-
message: "#^Property OCA\\\\Stackiq\\\\Service\\\\AangebodenGebruikService\\:\\:\\$config is never read, only written\\.$#"
count: 1
Expand Down
Loading