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
43 changes: 40 additions & 3 deletions lib/Controller/GebruikController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public function getGebruiken(): JSONResponse
{
$user = $this->userSession->getUser();

// Return empty results for non-logged-in users to prevent unnecessary errors.
if ($user === null) {
return new JSONResponse($this->getEmptyResult());
}

$groups = $this->groupManager->getUserGroups(user: $user);
$groupNames = array_map(function (IGroup $group) {
return $group->getGID();
Expand All @@ -85,17 +90,17 @@ public function getGebruiken(): JSONResponse
$applicatieIds = $this->gebruikService->getApplicationIds(options: $applicatieOptions);

if ($applicatieIds === []) {
return new JSONResponse(data: ['error' => 'no access'], statusCode: 403);
return new JSONResponse($this->getEmptyResult());
}

if (isset($options['module']) === true && in_array($options['module'], $applicatieIds) === false) {
return new JSONResponse(data: ['error' => 'no access'], statusCode: 403);
return new JSONResponse($this->getEmptyResult());
} else if (isset($options['module']) === false) {
$options['module'] = $applicatieIds;
}

} else {
return new JSONResponse(data: ['error' => 'no access'], statusCode: 403);
return new JSONResponse($this->getEmptyResult());
}

try {
Expand All @@ -116,6 +121,12 @@ public function getGebruiken(): JSONResponse
public function getGebruikenForDeelnemer(): JSONResponse
{
$user = $this->userSession->getUser();

// Return empty results for non-logged-in users to prevent unnecessary errors.
if ($user === null) {
return new JSONResponse($this->getEmptyResult());
}

$orgUuid = $this->config->getUserValue(userId: $user->getUID(), appName: 'core', key: 'organisation');

$options = $this->request->getParams();
Expand All @@ -128,6 +139,32 @@ public function getGebruikenForDeelnemer(): JSONResponse
}
}

/**
* Returns an empty result set with the standard paginated response structure.
*
* @return array The empty result structure.
*/
private function getEmptyResult(): array
{
return [
'results' => [],
'total' => 0,
'page' => 1,
'pages' => 0,
'limit' => 1000,
'offset' => 0,
'facets' => [],
'@self' => [
'source' => 'database',
'query' => [],
'rbac' => false,
'multi' => false,
'published' => false,
'deleted' => false,
],
];
}



}
11 changes: 11 additions & 0 deletions lib/Service/GebruikService.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ public function getGebruiken(array $options): array
'schema' => $gebruiksConfig['gebruikSchema'],
];

// Normalize _extend parameter to array format.
// Supports both 'extend' and '_extend' parameter names.
$extend = $options['extend'] ?? $options['_extend'] ?? [];
if (is_string($extend) === true) {
$extend = array_map('trim', explode(',', $extend));
} else if (is_array($extend) === false) {
$extend = [$extend];
}
$options['_extend'] = $extend;
unset($options['extend']);

$searchResult = $objectService->searchObjectsPaginated(query: $options, _rbac: false, _multitenancy: false);

$searchResult['results'] = array_map(function($object) {
Expand Down
8 changes: 4 additions & 4 deletions lib/Service/ModuleComplianceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function handleModuleComplianceUpdate(object $moduleObject): void
]);

// Get current standaarden from module
$currentStandaarden = $moduleData['standaarden'] ?? [];
$currentStandaarden = $moduleData['standaardVersies'] ?? [];

// Ensure currentStandaarden is an array
if (!is_array($currentStandaarden)) {
Expand Down Expand Up @@ -360,13 +360,13 @@ private function updateModuleStandaarden(object $moduleObject, array $standaardv
$moduleData = $moduleObject->getObject();

// Update standaarden property
$moduleData['standaarden'] = $standaardversieUuids;
$moduleData['standaardVersies'] = $standaardversieUuids;

// Get register ID from module object
$registerId = $moduleObject->getRegister();

// Save the updated module
$objectService->saveObject(
$savedObject = $objectService->saveObject(
object: $moduleData,
extend: [],
register: $registerId,
Expand Down Expand Up @@ -586,7 +586,7 @@ public function bulkSyncModuleStandards(): array
}

// Get current standaarden from module
$currentStandaarden = $moduleData['standaarden'] ?? [];
$currentStandaarden = $moduleData['standaardVersies'] ?? [];

// Ensure currentStandaarden is an array
if (!is_array($currentStandaarden)) {
Expand Down
17 changes: 17 additions & 0 deletions lib/Settings/Settings/softwarecatalogus_register.json
Original file line number Diff line number Diff line change
Expand Up @@ -5418,6 +5418,23 @@
"type": "string"
}
},
"standaardVersies": {
"description": "De standaardversies die deze applicatie implementeert",
"type": "array",
"visible": true,
"order": 26,
"facetable": true,
"title": "Standaard Versies",
"hideOnForm": true,
"items": {
"type": "object",
"objectConfiguration": {
"handling": "related-object",
"queryParams": "gemmaType=standaardversie"
},
"$ref": "#/components/schemas/element"
}
},
"moduleVersies": {
"description": "De versies van deze applicatie",
"type": "array",
Expand Down
17 changes: 17 additions & 0 deletions lib/Settings/softwarecatalogus_register.json
Original file line number Diff line number Diff line change
Expand Up @@ -5724,6 +5724,23 @@
"type": "string"
}
},
"standaardVersies": {
"description": "De standaardversies die deze applicatie implementeert",
"type": "array",
"visible": true,
"order": 26,
"facetable": true,
"title": "Standaard Versies",
"hideOnForm": true,
"items": {
"type": "object",
"objectConfiguration": {
"handling": "related-object",
"queryParams": "gemmaType=standaardversie"
},
"$ref": "#/components/schemas/element"
}
},
"moduleVersies": {
"description": "De versies van deze applicatie",
"type": "array",
Expand Down