diff --git a/lib/Controller/AanbodController.php b/lib/Controller/AanbodController.php index b684abac..eb6dceab 100644 --- a/lib/Controller/AanbodController.php +++ b/lib/Controller/AanbodController.php @@ -20,6 +20,7 @@ namespace OCA\SoftwareCatalog\Controller; use OCP\AppFramework\Controller; +use OCP\AppFramework\Http; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; use OCP\IUserSession; @@ -162,6 +163,10 @@ public function getAanbod(): JSONResponse */ public function acceptAanbod(string $uuid): JSONResponse { + if ($this->userSession->getUser() === null) { + return new JSONResponse(['message' => 'Not authenticated'], Http::STATUS_UNAUTHORIZED); + } + $this->logger->info( 'API: Accepting aanbod object', [ @@ -262,6 +267,10 @@ function ($key) { */ public function denyAanbod(string $uuid): JSONResponse { + if ($this->userSession->getUser() === null) { + return new JSONResponse(['message' => 'Not authenticated'], Http::STATUS_UNAUTHORIZED); + } + $this->logger->info( 'API: Denying aanbod object', [ diff --git a/lib/Controller/AangebodenGebruikController.php b/lib/Controller/AangebodenGebruikController.php index aadaac54..ae434c9f 100644 --- a/lib/Controller/AangebodenGebruikController.php +++ b/lib/Controller/AangebodenGebruikController.php @@ -21,6 +21,7 @@ namespace OCA\SoftwareCatalog\Controller; use OCP\AppFramework\Controller; +use OCP\AppFramework\Http; use OCP\AppFramework\Http\JSONResponse; use OCP\IGroupManager; use OCP\IRequest; @@ -604,10 +605,14 @@ public function getGebruiksWhereDeelnemers(): JSONResponse * * @NoAdminRequired * @NoCSRFRequired - * @spec openspec/changes/retrofit-2026-05-26-aangeboden-gebruik-api/tasks.md#task-2 + * @spec openspec/changes/retrofit-2026-05-26-aangeboden-gebruik-api/tasks.md#task-2 */ public function setGebruikSelfToActiveOrg(string $gebruikId): JSONResponse { + if ($this->userSession->getUser() === null) { + return new JSONResponse(['message' => 'Not authenticated'], Http::STATUS_UNAUTHORIZED); + } + $this->logger->info( 'API: Setting gebruik @self property to active org', [ @@ -710,10 +715,14 @@ function ($key) { * * @NoAdminRequired * @NoCSRFRequired - * @spec openspec/changes/retrofit-2026-05-26-aangeboden-gebruik-api/tasks.md#task-2 + * @spec openspec/changes/retrofit-2026-05-26-aangeboden-gebruik-api/tasks.md#task-2 */ public function deleteGebruikAsAfnemer(string $gebruikId): JSONResponse { + if ($this->userSession->getUser() === null) { + return new JSONResponse(['message' => 'Not authenticated'], Http::STATUS_UNAUTHORIZED); + } + $this->logger->info( 'API: Deleting gebruik object as afnemer', [ diff --git a/lib/Controller/ContactpersonenController.php b/lib/Controller/ContactpersonenController.php index d4d2bd7d..57b64912 100644 --- a/lib/Controller/ContactpersonenController.php +++ b/lib/Controller/ContactpersonenController.php @@ -525,7 +525,8 @@ public function changePassword(string $username, string $newPassword, string $cu $isSelfReset = $currentUser->getUID() === $username; // Non-admins may only change their own password. - if ($isAdmin === false && $isSelfReset === false) { + $hasPasswordChangePermission = ($isAdmin === true || $isSelfReset === true); + if ($hasPasswordChangePermission === false) { return new JSONResponse(['message' => 'Insufficient permissions'], Http::STATUS_FORBIDDEN); } diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 304824fd..d549096c 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -815,7 +815,13 @@ public function performSync(int $minutesBack=0): JSONResponse // For incremental sync, use the original method. $result = $this->orgSyncSvc->performManualSync($minutesBack); - return new JSONResponse($result, $result['success'] === true ? 200 : 500); + if ($result['success'] === true) { + $statusCode = 200; + } else { + $statusCode = 500; + } + + return new JSONResponse($result, $statusCode); } catch (\Exception $e) { $this->logger->error( 'Manual sync failed', @@ -958,7 +964,13 @@ public function resetAutoConfig(): JSONResponse $result = $this->settingsService->resetAutoConfiguration($resetConfiguration); - return new JSONResponse($result, $result['success'] === true ? 200 : 400); + if ($result['success'] === true) { + $statusCode = 200; + } else { + $statusCode = 400; + } + + return new JSONResponse($result, $statusCode); } catch (\Exception $e) { return new JSONResponse( [ @@ -1046,7 +1058,13 @@ public function manualImport(): JSONResponse // Add timestamp for cache busting. $result['timestamp'] = time(); - return new JSONResponse($result, $result['success'] === true ? 200 : 400); + if ($result['success'] === true) { + $importStatusCode = 200; + } else { + $importStatusCode = 400; + } + + return new JSONResponse($result, $importStatusCode); } catch (\Exception $e) { $this->logger->error( 'SettingsController: Manual import failed', @@ -1697,20 +1715,19 @@ public function exportOrgArchiMate(string $organizationUuid): Response } // Require admin or organisation-admin group membership. - $isAdmin = $this->groupManager->isAdmin($currentUser->getUID()); - if ($isAdmin === false) { - $orgAdminGroups = $this->settingsService->getOrganizationAdminGroups(); - $isOrgAdmin = false; - foreach ($orgAdminGroups as $groupName) { - if ($this->groupManager->isInGroup($currentUser->getUID(), $groupName) === true) { - $isOrgAdmin = true; - break; - } + $isAdmin = $this->groupManager->isAdmin($currentUser->getUID()); + $orgAdminGroups = $this->settingsService->getOrganizationAdminGroups(); + $isOrgAdmin = false; + foreach ($orgAdminGroups as $groupName) { + if ($this->groupManager->isInGroup($currentUser->getUID(), $groupName) === true) { + $isOrgAdmin = true; + break; } + } - if ($isOrgAdmin === false) { - return new JSONResponse(['message' => 'Admin or organisation-admin privileges required'], Http::STATUS_FORBIDDEN); - } + $hasExportPermission = ($isAdmin === true || $isOrgAdmin === true); + if ($hasExportPermission === false) { + return new JSONResponse(['message' => 'Admin or organisation-admin privileges required'], Http::STATUS_FORBIDDEN); } try { @@ -2211,7 +2228,11 @@ public function updateEmailTemplate(string $templateName): JSONResponse templateContent: $templateContent ); - $updateMsg = ($success === true) ? "Template {$templateName} updated successfully" : "Failed to update template {$templateName}"; + if ($success === true) { + $updateMsg = "Template {$templateName} updated successfully"; + } else { + $updateMsg = "Failed to update template {$templateName}"; + } return new JSONResponse( [ @@ -2788,8 +2809,12 @@ public function cancelArchiMateImport(): JSONResponse } try { - $result = $this->settingsService->cancelArchiMateImport(); - $message = ($result['cancelled'] === true) ? 'ArchiMate import cancellation succeeded' : 'ArchiMate import cancellation failed'; + $result = $this->settingsService->cancelArchiMateImport(); + if ($result['cancelled'] === true) { + $message = 'ArchiMate import cancellation succeeded'; + } else { + $message = 'ArchiMate import cancellation failed'; + } return new JSONResponse( [ @@ -3515,7 +3540,11 @@ public function syncOrganisations(): JSONResponse // Call the settings service method. $result = $this->settingsService->syncOrganisationsToVoorzieningenOptimized($options); - $statusCode = ($result['success'] === true) ? 200 : 500; + if ($result['success'] === true) { + $statusCode = 200; + } else { + $statusCode = 500; + } $this->logger->info( 'SettingsController: Organisation sync completed', @@ -3667,7 +3696,11 @@ public function updateCronjobConfig(): JSONResponse $data = $this->request->getParams(); $result = $this->settingsService->updateCronjobConfig($data); - $statusCode = ($result['success'] === true) ? 200 : 400; + if ($result['success'] === true) { + $statusCode = 200; + } else { + $statusCode = 400; + } return new JSONResponse($result, $statusCode); } catch (\Exception $e) { @@ -3701,6 +3734,10 @@ public function updateCronjobConfig(): JSONResponse */ public function getCronjobUsers(): JSONResponse { + if ($this->userSession->getUser() === null) { + return new JSONResponse(['message' => 'Not authenticated'], Http::STATUS_UNAUTHORIZED); + } + return new JSONResponse( [ 'success' => false, @@ -3723,6 +3760,10 @@ public function getCronjobUsers(): JSONResponse */ public function getCronjobOrganisations(): JSONResponse { + if ($this->userSession->getUser() === null) { + return new JSONResponse(['message' => 'Not authenticated'], Http::STATUS_UNAUTHORIZED); + } + return new JSONResponse( [ 'success' => false, diff --git a/lib/Controller/ViewController.php b/lib/Controller/ViewController.php index 3f487c5c..03cb8c68 100644 --- a/lib/Controller/ViewController.php +++ b/lib/Controller/ViewController.php @@ -20,8 +20,10 @@ namespace OCA\SoftwareCatalog\Controller; use OCP\AppFramework\Controller; +use OCP\AppFramework\Http; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; +use OCP\IUserSession; use OCA\SoftwareCatalog\Service\ViewService; use Psr\Log\LoggerInterface; @@ -48,12 +50,14 @@ class ViewController extends Controller * @param IRequest $request The request object * @param ViewService $viewService The view service for business logic * @param LoggerInterface $logger The logger service + * @param IUserSession $userSession The user session service */ public function __construct( string $appName, IRequest $request, private readonly ViewService $viewService, - private readonly LoggerInterface $logger + private readonly LoggerInterface $logger, + private readonly IUserSession $userSession ) { parent::__construct(appName: $appName, request: $request); }//end __construct() @@ -78,6 +82,10 @@ public function __construct( */ public function getAllViews(): JSONResponse { + if ($this->userSession->getUser() === null) { + return new JSONResponse(['message' => 'Not authenticated'], Http::STATUS_UNAUTHORIZED); + } + $this->logger->info( 'API: Getting all views', [ @@ -153,6 +161,10 @@ public function getAllViews(): JSONResponse */ public function getView(string $viewId): JSONResponse { + if ($this->userSession->getUser() === null) { + return new JSONResponse(['message' => 'Not authenticated'], Http::STATUS_UNAUTHORIZED); + } + $this->logger->info( 'API: Getting specific view', [ @@ -313,6 +325,10 @@ private function parseBooleanParam($value): bool */ public function getApiDocumentation(): JSONResponse { + if ($this->userSession->getUser() === null) { + return new JSONResponse(['message' => 'Not authenticated'], Http::STATUS_UNAUTHORIZED); + } + $documentation = [ 'api_version' => '1.0.0', 'description' => 'SoftwareCatalog View API - Query and enrich ArchiMate views', diff --git a/lib/Service/ArchiMateExportService.php b/lib/Service/ArchiMateExportService.php index d594ca89..1d0697e0 100644 --- a/lib/Service/ArchiMateExportService.php +++ b/lib/Service/ArchiMateExportService.php @@ -347,7 +347,11 @@ private function getNamespaceUri(\SimpleXMLElement $xml, string $prefix): string } $docNamespaces = $xml->getDocNamespaces(true); - $namespaces = ($docNamespaces !== false) ? $docNamespaces : []; + if ($docNamespaces !== false) { + $namespaces = $docNamespaces; + } else { + $namespaces = []; + } return $namespaces[$prefix] ?? ''; }//end getNamespaceUri() diff --git a/lib/Service/ArchiMateImportService.php b/lib/Service/ArchiMateImportService.php index 9280bc12..ffae0e63 100644 --- a/lib/Service/ArchiMateImportService.php +++ b/lib/Service/ArchiMateImportService.php @@ -211,9 +211,11 @@ public function xmlToArray(\SimpleXMLElement $xml): array $name = (string) $attrName; $value = (string) $attrValue; // OPTIMIZATION: Only apply str_replace for namespaced names (e.g. xsi:type -> _xsi_type). - $underscoredKey = (strpos($name, ':') !== false) - ? '_'.str_replace(':', '_', $name) - : '_'.$name; + if (strpos($name, ':') !== false) { + $underscoredKey = '_'.str_replace(':', '_', $name); + } else { + $underscoredKey = '_'.$name; + } $result[$underscoredKey] = $value; $attrBag[$name] = $value; @@ -512,10 +514,14 @@ public function importArchiMateFileFromPath(array $options=[]): array $statistics = $this->calculateObjectStatistics(normalizedData: $normalizedData, savedObjects: $savedObjects); // Calculate performance metrics. - $created = $statistics['summary']['total_objects_created']; - $updated = $statistics['summary']['total_objects_updated']; - $totalObjects = $created + $updated; - $itemsPerSecond = ($totalObjects > 0) ? round($totalObjects / max($totalTime, 0.001), 2) : 0; + $created = $statistics['summary']['total_objects_created']; + $updated = $statistics['summary']['total_objects_updated']; + $totalObjects = $created + $updated; + if ($totalObjects > 0) { + $itemsPerSecond = round($totalObjects / max($totalTime, 0.001), 2); + } else { + $itemsPerSecond = 0; + } // Extract detailed error information from statistics. $detailedErrors = $this->extractDetailedErrors(statistics: $statistics); @@ -1277,7 +1283,7 @@ private function saveObjectsToDatabase(array $objects): array // DEBUG: Log basic object info before sending to ObjectService. // Find first element with gemmaType for debugging. - $gemmaElements = array_filter( + $gemmaElements = array_filter( $objects, fn($o) => ($o['section'] ?? '') === 'element' && empty($o['gemmaType']) === false ); @@ -1344,7 +1350,11 @@ private function saveObjectsToDatabase(array $objects): array try { // Save this schema group with the specific schema ID. // PERFORMANCE: Disabled validation and events for bulk import (like CSV import pattern). - $schemaValue = ($schemaId !== 'unknown') ? $schemaId : null; + if ($schemaId !== 'unknown') { + $schemaValue = $schemaId; + } else { + $schemaValue = null; + } $saveResult = $objectService->saveObjects( objects: $schemaObjects, @@ -1415,11 +1425,15 @@ private function saveObjectsToDatabase(array $objects): array // Database save completed. // Store timing breakdown for performance metrics. // FIX: Use aggregatedStats counts instead of $result which may be empty from bulk operations. - $savedCount = count($aggregatedStats['saved'] ?? []); - $updatedCount = count($aggregatedStats['updated'] ?? []); - $unchangedCount = count($aggregatedStats['unchanged'] ?? []); - $totalSavedCount = $savedCount + $updatedCount + $unchangedCount; - $objectsSavedValue = ($totalSavedCount > 0) ? $totalSavedCount : count($objects); + $savedCount = count($aggregatedStats['saved'] ?? []); + $updatedCount = count($aggregatedStats['updated'] ?? []); + $unchangedCount = count($aggregatedStats['unchanged'] ?? []); + $totalSavedCount = $savedCount + $updatedCount + $unchangedCount; + if ($totalSavedCount > 0) { + $objectsSavedValue = $totalSavedCount; + } else { + $objectsSavedValue = count($objects); + } $this->lastSaveTiming = [ 'total_save_seconds' => round($totalSaveTime, 3), @@ -1556,7 +1570,11 @@ private function saveObjectsDirectToService(array $objects, ObjectService $objec $allInvalid = []; foreach ($schemaGroups as $schemaId => $schemaObjects) { - $schemaValue = ($schemaId !== 'unknown') ? $schemaId : null; + if ($schemaId !== 'unknown') { + $schemaValue = $schemaId; + } else { + $schemaValue = null; + } $saveResult = $objectService->saveObjects( objects: $schemaObjects, @@ -1661,7 +1679,11 @@ private function saveObjectsInParallelBatches(array $objects, ObjectService $obj try { // Disable RBAC for bulk import when the performance optimisation flag is set. - $_rbacValue = (self::PERFORMANCE_OPTIMIZATIONS['disable_rbac'] === true) ? false : true; + if (self::PERFORMANCE_OPTIMIZATIONS['disable_rbac'] === true) { + $_rbacValue = false; + } else { + $_rbacValue = true; + } $saveResult = $objectService->saveObjects( objects: $chunk, @@ -1750,7 +1772,11 @@ private function saveObjectsInSingleBatch(array $objects, ObjectService $objectS { // Using single batch processing. // Disable RBAC for bulk import when the performance optimisation flag is set. - $_rbacValue = (self::PERFORMANCE_OPTIMIZATIONS['disable_rbac'] === true) ? false : true; + if (self::PERFORMANCE_OPTIMIZATIONS['disable_rbac'] === true) { + $_rbacValue = false; + } else { + $_rbacValue = true; + } $saveResult = $objectService->saveObjects( objects: $objects, @@ -3078,10 +3104,25 @@ private function extractNodesRecursively($nodeData, array $elementsLookup=[]): a foreach ($nodeData as $node) { if (isset($node['_attributes']) === true) { - $xValue = isset($node['_attributes']['x']) === true ? (int) $node['_attributes']['x'] : null; - $yValue = isset($node['_attributes']['y']) === true ? (int) $node['_attributes']['y'] : null; - $wValue = isset($node['_attributes']['w']) === true ? (int) $node['_attributes']['w'] : null; - $hValue = isset($node['_attributes']['h']) === true ? (int) $node['_attributes']['h'] : null; + $xValue = null; + $yValue = null; + $wValue = null; + $hValue = null; + if (isset($node['_attributes']['x']) === true) { + $xValue = (int) $node['_attributes']['x']; + } + + if (isset($node['_attributes']['y']) === true) { + $yValue = (int) $node['_attributes']['y']; + } + + if (isset($node['_attributes']['w']) === true) { + $wValue = (int) $node['_attributes']['w']; + } + + if (isset($node['_attributes']['h']) === true) { + $hValue = (int) $node['_attributes']['h']; + } $processedNode = [ 'identifier' => $node['_attributes']['identifier'] ?? null, @@ -3309,10 +3350,10 @@ private function applyNodeStyle(array &$viewNode, array $style): void } if (isset($style['font']['color']['_attributes']) === true) { - $fontColor = $style['font']['color']['_attributes']; - $r = (int) ($fontColor['r'] ?? 0); - $g = (int) ($fontColor['g'] ?? 0); - $b = (int) ($fontColor['b'] ?? 0); + $fontColor = $style['font']['color']['_attributes']; + $r = (int) ($fontColor['r'] ?? 0); + $g = (int) ($fontColor['g'] ?? 0); + $b = (int) ($fontColor['b'] ?? 0); $font['color'] = "rgb($r, $g, $b)"; }//end if @@ -3377,7 +3418,11 @@ private function extractViewRelationshipsRecursively($connectionData): array // Extract bend points if present. if (isset($connection['bendpoint']) === true) { // Normalise to indexed array: single bendpoint is a plain assoc array. - $bendpoints = (isset($connection['bendpoint'][0]) === true) ? $connection['bendpoint'] : [$connection['bendpoint']]; + if (isset($connection['bendpoint'][0]) === true) { + $bendpoints = $connection['bendpoint']; + } else { + $bendpoints = [$connection['bendpoint']]; + } foreach ($bendpoints as $bendpoint) { if (isset($bendpoint['_attributes']) === true) { @@ -3485,7 +3530,7 @@ private function extractNodeType(array $node): ?string if (str_contains($xsiType, ':') === true) { // Handle namespaced types like "archimate:BusinessService". - return strtolower(substr($xsiType, (int)strpos($xsiType, ':') + 1)); + return strtolower(substr($xsiType, (int) strpos($xsiType, ':') + 1)); } return strtolower($xsiType); @@ -3526,16 +3571,16 @@ private function extractConnectionType(array $connection): string // Remove namespace. $type = preg_replace('/relationship$/i', '', $type); // Remove "Relationship" suffix. - return strtolower((string)$type); + return strtolower((string) $type); } if (str_contains($xsiType, ':') === true) { // Handle other namespaced types. - return strtolower(substr($xsiType, (int)strpos($xsiType, ':') + 1)); + return strtolower(substr($xsiType, (int) strpos($xsiType, ':') + 1)); } return strtolower($xsiType); - } + }//end if // Priority 2: Check if this has a relationshipRef (use that to determine type if possible). if (isset($connection['_attributes']['relationshipRef']) === true) { diff --git a/lib/Service/ArchiMateService.php b/lib/Service/ArchiMateService.php index 24a4a120..c54822a2 100644 --- a/lib/Service/ArchiMateService.php +++ b/lib/Service/ArchiMateService.php @@ -321,17 +321,26 @@ public function exportOrgArchiMate(string $organizationUuid, array $options=[]): } // Look up the organization from Voorzieningen register. - $voorzConfig = $this->settingsService->getVoorzieningenConfig(); - $orgRegisterId = (empty($voorzConfig['register']) === false) ? $voorzConfig['register'] : null; - $orgSchemaId = (empty($voorzConfig['organisatie_schema']) === false) ? $voorzConfig['organisatie_schema'] : null; + $voorzConfig = $this->settingsService->getVoorzieningenConfig(); + if (empty($voorzConfig['register']) === false) { + $orgRegisterId = $voorzConfig['register']; + } else { + $orgRegisterId = null; + } + + if (empty($voorzConfig['organisatie_schema']) === false) { + $orgSchemaId = $voorzConfig['organisatie_schema']; + } else { + $orgSchemaId = null; + } - if ($orgRegisterId === null || $orgSchemaId === false) { + if (empty($orgRegisterId) === true || empty($orgSchemaId) === true) { // Fallback to generic lookup. $orgRegisterId = $this->settingsService->getVoorzieningenRegisterId(); $orgSchemaId = $this->settingsService->getSchemaIdForObjectType('organisatie'); } - if ($orgRegisterId === null || $orgSchemaId === false) { + if ($orgRegisterId === null || $orgSchemaId === null) { throw new \RuntimeException('Organization register/schema not configured'); } @@ -367,7 +376,11 @@ public function exportOrgArchiMate(string $organizationUuid, array $options=[]): $schemaIdMap = $this->createSchemaIdMap(); // Query organization's gebruik and modules from Voorzieningen register. - $gebruikSchemaId = (empty($voorzConfig['gebruik_schema']) === false) ? $voorzConfig['gebruik_schema'] : null; + if (empty($voorzConfig['gebruik_schema']) === false) { + $gebruikSchemaId = $voorzConfig['gebruik_schema']; + } else { + $gebruikSchemaId = null; + } $gebruikData = []; if (empty($gebruikSchemaId) === false) { @@ -382,7 +395,11 @@ public function exportOrgArchiMate(string $organizationUuid, array $options=[]): $gebruikData = $objectService->searchObjects(query: $gebruikQuery, _rbac: false, _multitenancy: false); } - $moduleSchemaId = (empty($voorzConfig['module_schema']) === false) ? $voorzConfig['module_schema'] : null; + if (empty($voorzConfig['module_schema']) === false) { + $moduleSchemaId = $voorzConfig['module_schema']; + } else { + $moduleSchemaId = null; + } $modulesData = []; if (empty($moduleSchemaId) === false) { @@ -440,7 +457,11 @@ public function exportOrgArchiMate(string $organizationUuid, array $options=[]): // Merge into modulesData, deduplicating by ID. $existingIds = []; foreach ($modulesData as $m) { - $mid = is_array($m) === true ? ($m['id'] ?? $m['@self']['id'] ?? null) : null; + if (is_array($m) === true) { + $mid = $m['id'] ?? $m['@self']['id'] ?? null; + } else { + $mid = null; + } if (empty($mid) === false) { $existingIds[$mid] = true; @@ -448,9 +469,11 @@ public function exportOrgArchiMate(string $organizationUuid, array $options=[]): } foreach ($allModules as $mod) { - $modArr = (is_object($mod) === true && method_exists($mod, 'jsonSerialize') === true) - ? $mod->jsonSerialize() - : $mod; + if (is_object($mod) === true && method_exists($mod, 'jsonSerialize') === true) { + $modArr = $mod->jsonSerialize(); + } else { + $modArr = $mod; + } $modId = $modArr['id'] ?? $modArr['@self']['id'] ?? null; if ($modId !== false && isset($existingIds[$modId]) === false) { @@ -1096,7 +1119,11 @@ private function saveObjectsInParallelBatches(array $objects, ObjectService $obj foreach ($chunks as $chunkIndex => $chunk) { // OPTIMIZATION: Removed debug logging from chunk processing loop. try { - $rbacValue = (self::PERFORMANCE_OPTIMIZATIONS['disable_rbac'] === true) ? false : true; + if (self::PERFORMANCE_OPTIMIZATIONS['disable_rbac'] === true) { + $rbacValue = false; + } else { + $rbacValue = true; + } $saveResult = $objectService->saveObjects( objects: $chunk, @@ -1186,7 +1213,11 @@ private function saveObjectsInSingleBatch(array $objects, ObjectService $objectS ] ); - $rbacValue = (self::PERFORMANCE_OPTIMIZATIONS['disable_rbac'] === true) ? false : true; + if (self::PERFORMANCE_OPTIMIZATIONS['disable_rbac'] === true) { + $rbacValue = false; + } else { + $rbacValue = true; + } $saveResult = $objectService->saveObjects( objects: $objects, @@ -1903,12 +1934,12 @@ private function getObjectsWithPagination(string $schemaType, array $query=[]): // Use AMEF register ID for AMEF types, otherwise use per-type register ID. $registerId = $this->settingsService->getRegisterIdForObjectType($schemaType); if ($isAmefType === true) { - $registerId = $this->settingsService->getAmefRegisterId(); + $registerId = $this->getAmefRegisterId(); } $schemaId = $this->settingsService->getSchemaIdForObjectType($schemaType); - if ($registerId === null || $schemaId === false) { + if ($registerId === null || $schemaId === null) { $errorMessage = "ArchiMateService: Register or {$schemaType} schema not configured"; if ($isAmefType === true) { $errorMessage = "ArchiMateService: AMEF register or {$schemaType} schema not configured"; diff --git a/lib/Service/OrganizationSyncService.php b/lib/Service/OrganizationSyncService.php index e56280bb..cb8cd4f6 100644 --- a/lib/Service/OrganizationSyncService.php +++ b/lib/Service/OrganizationSyncService.php @@ -250,10 +250,13 @@ public function performOrganizationsSync(int $batchSize=50, int $maxExecutionSec $registerIdOrg = (int) $register; $schemaIdOrg = (int) $organizationSchema; if ($registerIdOrg <= 0 || $schemaIdOrg <= 0) { - $this->logger->warning('OrganizationSync: register or organisatie_schema is not a valid positive integer', [ - 'register' => $register, - 'organizationSchema' => $organizationSchema, - ]); + $this->logger->warning( + 'OrganizationSync: register or organisatie_schema is not a valid positive integer', + [ + 'register' => $register, + 'organizationSchema' => $organizationSchema, + ] + ); return $stats; } @@ -397,10 +400,13 @@ public function performContactSync(int $batchSize=100, int $maxExecutionSeconds= $registerIdContact = (int) $register; $schemaIdContact = (int) $contactSchema; if ($registerIdContact <= 0 || $schemaIdContact <= 0) { - $this->logger->warning('ContactSync: register or contactpersoon_schema is not a valid positive integer', [ - 'register' => $register, - 'contactSchema' => $contactSchema, - ]); + $this->logger->warning( + 'ContactSync: register or contactpersoon_schema is not a valid positive integer', + [ + 'register' => $register, + 'contactSchema' => $contactSchema, + ] + ); return $stats; } @@ -512,10 +518,13 @@ public function performUserSync(): array $registerId = (int) $register; $schemaId = (int) $contactSchema; if ($registerId <= 0 || $schemaId <= 0) { - $this->logger->warning('UserSync: register or contactpersoon_schema is not a valid positive integer', [ - 'register' => $register, - 'contactSchema' => $contactSchema, - ]); + $this->logger->warning( + 'UserSync: register or contactpersoon_schema is not a valid positive integer', + [ + 'register' => $register, + 'contactSchema' => $contactSchema, + ] + ); return []; } @@ -1242,7 +1251,11 @@ private function processContactPerson(object $contactPerson, array &$stats): ?st // Check if user already exists. $userManager = $this->container->get('OCP\IUserManager'); // Use the stored username when available, otherwise fall back to email as username. - $username = (empty($existingUsername) === false) ? $existingUsername : $email; + if (empty($existingUsername) === false) { + $username = $existingUsername; + } else { + $username = $email; + } $user = $userManager->get($username); diff --git a/lib/Service/SettingsService.php b/lib/Service/SettingsService.php index ba4b8d7b..2288ca62 100644 --- a/lib/Service/SettingsService.php +++ b/lib/Service/SettingsService.php @@ -2102,13 +2102,17 @@ public function updateEmailSettings(array $emailSettings): array // Convert boolean values to strings. if (is_bool($value) === true) { - $value = ($value === true) ? 'true' : 'false'; + if ($value === true) { + $value = 'true'; + } else { + $value = 'false'; + } } $this->config->setValueString($this->appName, $configKey, (string) $value); $updatedSettings[$settingKey] = $this->config->getValueString($this->appName, $configKey); } - } + }//end foreach $this->logger->info( 'Email settings updated successfully', @@ -2638,7 +2642,11 @@ private function getConnectionDetails(array $emailSettings): array switch ($transportType) { case 'smtp': - $usernameValue = (empty($emailSettings['smtpUsername']) === false) ? 'configured' : 'none'; + if (empty($emailSettings['smtpUsername']) === false) { + $usernameValue = 'configured'; + } else { + $usernameValue = 'none'; + } return [ 'type' => 'SMTP', 'host' => $emailSettings['smtpHost'] ?? '', @@ -2823,7 +2831,11 @@ private function createSmtpTransport(array $settings): \Symfony\Component\Mailer $dsn .= '?encryption='.$encryption; } - $encSuffix = (empty($encryption) === false && $encryption !== 'none') ? '?encryption='.$encryption : ''; + if (empty($encryption) === false && $encryption !== 'none') { + $encSuffix = '?encryption='.$encryption; + } else { + $encSuffix = ''; + } $dsnPattern = sprintf('smtp://***:***@%s:%d%s', $host, $port, $encSuffix); @@ -2974,7 +2986,11 @@ public function getVersionInfo(): array $openRegisterInstalled = $this->isOpenRegisterInstalled(); $openRegisterEnabled = $openRegisterInstalled && $this->isOpenRegisterEnabled(); - $versionComparisonValue = ($storedConfigVersion !== null) ? version_compare($currentAppVersion, $storedConfigVersion) : null; + if ($storedConfigVersion !== null) { + $versionComparisonValue = version_compare($currentAppVersion, $storedConfigVersion); + } else { + $versionComparisonValue = null; + } $versionInfo = [ 'appName' => 'SoftwareCatalog', @@ -3056,7 +3072,11 @@ public function forceUpdate(): array ); // Return concise response to avoid serialization issues with large nested structures. - $messageValue = ($success === true) ? 'Force update completed successfully' : 'Force update completed but configuration needs attention'; + if ($success === true) { + $messageValue = 'Force update completed successfully'; + } else { + $messageValue = 'Force update completed but configuration needs attention'; + } return [ 'success' => $success, @@ -3206,7 +3226,11 @@ public function manualImport(bool $forceImport=false): array // If force import is requested or auto-config not completed, reset auto-configuration flag. if ($forceImport === true || $versionInfo['autoConfigCompleted'] === false) { $this->config->setValueString($this->appName, 'auto_config_completed', 'false'); - $reasonValue = ($forceImport === true) ? 'force_import_requested' : 'auto_config_not_completed'; + if ($forceImport === true) { + $reasonValue = 'force_import_requested'; + } else { + $reasonValue = 'auto_config_not_completed'; + } $this->logger->info( 'SettingsService: Reset auto-configuration flag', diff --git a/lib/Service/SoftwareCatalogue/ContactPersonHandler.php b/lib/Service/SoftwareCatalogue/ContactPersonHandler.php index 7a9362e8..034c6022 100644 --- a/lib/Service/SoftwareCatalogue/ContactPersonHandler.php +++ b/lib/Service/SoftwareCatalogue/ContactPersonHandler.php @@ -465,9 +465,9 @@ public function createUserAccount(object $contactpersoonObject, bool $isFirstCon // Build a password that satisfies NC default policy (≥10 chars, upper+lower+digit+special). $randomPw = $this->_secureRandom->generate(length: 4, characters: ISecureRandom::CHAR_UPPER) - . $this->_secureRandom->generate(length: 4, characters: ISecureRandom::CHAR_LOWER) - . $this->_secureRandom->generate(length: 2, characters: ISecureRandom::CHAR_DIGITS) - . $this->_secureRandom->generate(length: 2, characters: '!@#$%^&*()-_=+[]'); + .$this->_secureRandom->generate(length: 4, characters: ISecureRandom::CHAR_LOWER) + .$this->_secureRandom->generate(length: 2, characters: ISecureRandom::CHAR_DIGITS) + .$this->_secureRandom->generate(length: 2, characters: '!@#$%^&*()-_=+[]'); $user = $this->_userManager->createUser(uid: $username, password: $randomPw); if (empty($user) === false) { @@ -487,7 +487,6 @@ public function createUserAccount(object $contactpersoonObject, bool $isFirstCon // and created a fork-bomb risk when user creation is triggered from an // unauthenticated path. NC performs setupFS/copySkeleton automatically on // first login without any pre-warming. - // Set user details. $this->_logger->info( '[USER] Step 4: Setting user details', diff --git a/lib/Service/SoftwareCatalogueService.php b/lib/Service/SoftwareCatalogueService.php index 41f219c4..7a087a0d 100644 --- a/lib/Service/SoftwareCatalogueService.php +++ b/lib/Service/SoftwareCatalogueService.php @@ -3325,10 +3325,11 @@ public function syncContactPersonUsernamesWithOrganization(string $organizationU * Ensures a contact person's username is in their organization's users array. * NOTE: Dead method — retained only as implementation reference until the sync * pipeline invocation point is wired; not called from any live code path. - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) * * @param object $contactPersonObject The contact person object * + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + * * @return void */ private function ensureContactPersonInOrganization(object $contactPersonObject): void diff --git a/src/manifest.json b/src/manifest.json index 7e8be220..fc6a30e0 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -94,10 +94,21 @@ "title": "Dashboard", "config": { "widgets": [ - { "id": "dashboardHome", "title": "Dashboard", "type": "custom" } + { + "id": "dashboardHome", + "title": "Dashboard", + "type": "custom" + } ], "layout": [ - { "id": 1, "widgetId": "dashboardHome", "gridX": 0, "gridY": 0, "gridWidth": 12, "gridHeight": 12 } + { + "id": "1", + "widgetId": "dashboardHome", + "gridX": 0, + "gridY": 0, + "gridWidth": 12, + "gridHeight": 12 + } ] }, "slots": { diff --git a/tests/validate-manifest.js b/tests/validate-manifest.js index a8ecf897..ab1b09cf 100644 --- a/tests/validate-manifest.js +++ b/tests/validate-manifest.js @@ -83,7 +83,7 @@ function structuralLint(manifest) { } if (!Array.isArray(manifest.menu)) errors.push('top-level: menu (array) is required') if (!Array.isArray(manifest.pages)) errors.push('top-level: pages (array) is required') - const allowedTypes = new Set(['index', 'detail', 'dashboard', 'logs', 'settings', 'chat', 'files', 'custom']) + const allowedTypes = new Set(['index', 'detail', 'dashboard', 'logs', 'settings', 'chat', 'files', 'form', 'map', 'roadmap', 'search', 'custom']) const seenIds = new Set() for (let i = 0; i < (manifest.pages || []).length; i++) { const page = manifest.pages[i]