Skip to content

Commit caf5cb6

Browse files
authored
Merge pull request #196 from ConductionNL/fix/migrate-cnindexpage
refactor: Replace GenericObjectTable with CnIndexPage
2 parents 46525ef + 016410a commit caf5cb6

53 files changed

Lines changed: 959 additions & 3519 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/code-quality.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Code Quality
22

33
on:
4-
push:
5-
branches: [main, development, feature/**, bugfix/**, hotfix/**]
64
pull_request:
75
branches: [main, beta, development]
86

.license-overrides.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"@fortawesome/free-solid-svg-icons": "License is (CC-BY-4.0 AND MIT) — both are approved open-source licenses, compound AND expression not parsed by checker"
3+
}

lib/Controller/AangebodenGebruikController.php

Lines changed: 11 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ public function __construct(
8585
* @NoCSRFRequired
8686
* @PublicPage
8787
* @PublicPage
88-
*
89-
* @SuppressWarnings(PHPMD.ElseExpression)
9088
*/
9189
public function getGebruiksWhereAfnemer(): JSONResponse
9290
{
@@ -108,10 +106,8 @@ public function getGebruiksWhereAfnemer(): JSONResponse
108106
$result = $this->gebruikSvc->getGebruiksWhereAfnemer($options);
109107

110108
// Determine HTTP status code based on whether there's an error.
111-
if (isset($result['error']) === true) {
112-
$statusCode = 500;
113-
} else {
114109
$statusCode = 200;
110+
if (isset($result['error']) === true) {
115111
}
116112

117113
$this->logger->info(
@@ -164,8 +160,6 @@ public function getGebruiksWhereAfnemer(): JSONResponse
164160
* @NoAdminRequired
165161
* @NoCSRFRequired
166162
* @PublicPage
167-
*
168-
* @SuppressWarnings(PHPMD.ElseExpression)
169163
*/
170164
public function getKoppelingenGebruikByUuid(string $uuid): JSONResponse
171165
{
@@ -202,10 +196,8 @@ public function getKoppelingenGebruikByUuid(string $uuid): JSONResponse
202196
);
203197

204198
// Determine HTTP status code based on whether there's an error.
205-
if (isset($result['error']) === true) {
206-
$statusCode = 500;
207-
} else {
208199
$statusCode = 200;
200+
if (isset($result['error']) === true) {
209201
}
210202

211203
$this->logger->info(
@@ -258,8 +250,6 @@ public function getKoppelingenGebruikByUuid(string $uuid): JSONResponse
258250
* @NoAdminRequired
259251
* @NoCSRFRequired
260252
* @PublicPage
261-
*
262-
* @SuppressWarnings(PHPMD.ElseExpression)
263253
*/
264254
public function getAllGebruiksForAmbtenaar(): JSONResponse
265255
{
@@ -278,11 +268,9 @@ public function getAllGebruiksForAmbtenaar(): JSONResponse
278268
$isAmbtenaar = $this->isUserInGroup(groupName: 'ambtenaar');
279269
if ($isAdmin === false && $isAmbtenaar === false) {
280270
// Get user ID for logging (may be null if not authenticated).
281-
$user = $this->userSession->getUser();
282-
if ($user !== null) {
283-
$userId = $user->getUID();
284-
} else {
271+
$user = $this->userSession->getUser();
285272
$userId = 'null';
273+
if ($user !== null) {
286274
}
287275

288276
$this->logger->info(
@@ -315,10 +303,8 @@ public function getAllGebruiksForAmbtenaar(): JSONResponse
315303
$result = $this->gebruikSvc->getAllGebruiksForAmbtenaar($options);
316304

317305
// Determine HTTP status code based on whether there's an error.
318-
if (isset($result['error']) === true) {
319-
$statusCode = 500;
320-
} else {
321306
$statusCode = 200;
307+
if (isset($result['error']) === true) {
322308
}
323309

324310
$this->logger->info(
@@ -370,7 +356,6 @@ public function getAllGebruiksForAmbtenaar(): JSONResponse
370356
* @PublicPage
371357
* @PublicPage
372358
*
373-
* @SuppressWarnings(PHPMD.ElseExpression)
374359
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
375360
*/
376361
public function getSingleGebruikForAmbtenaar(string $gebruikId): JSONResponse
@@ -391,11 +376,9 @@ public function getSingleGebruikForAmbtenaar(string $gebruikId): JSONResponse
391376
$isAmbtenaar = $this->isUserInGroup(groupName: 'ambtenaar');
392377
if ($isAdmin === false && $isAmbtenaar === false) {
393378
// Get user ID for logging (may be null if not authenticated).
394-
$user = $this->userSession->getUser();
395-
if ($user !== null) {
396-
$userId = $user->getUID();
397-
} else {
379+
$user = $this->userSession->getUser();
398380
$userId = 'null';
381+
if ($user !== null) {
399382
}
400383

401384
$this->logger->info(
@@ -432,10 +415,8 @@ public function getSingleGebruikForAmbtenaar(string $gebruikId): JSONResponse
432415
);
433416

434417
// Determine HTTP status code based on whether there's an error.
435-
if (isset($result['error']) === true) {
436-
$statusCode = 500;
437-
} else {
438418
$statusCode = 200;
419+
if (isset($result['error']) === true) {
439420
}
440421

441422
$this->logger->info(
@@ -548,8 +529,6 @@ private function isUserInGroup(string $groupName): bool
548529
* @NoCSRFRequired
549530
* @PublicPage
550531
* @PublicPage
551-
*
552-
* @SuppressWarnings(PHPMD.ElseExpression)
553532
*/
554533
public function getGebruiksWhereDeelnemers(): JSONResponse
555534
{
@@ -571,10 +550,8 @@ public function getGebruiksWhereDeelnemers(): JSONResponse
571550
$result = $this->gebruikSvc->getGebruiksWhereDeelnemers($options);
572551

573552
// Determine appropriate HTTP status code.
574-
if ($result['success'] === true) {
575-
$statusCode = 200;
576-
} else {
577553
$statusCode = 500;
554+
if ($result['success'] === true) {
578555
}
579556

580557
$this->logger->info(
@@ -625,8 +602,6 @@ public function getGebruiksWhereDeelnemers(): JSONResponse
625602
* @NoCSRFRequired
626603
* @PublicPage
627604
* @PublicPage
628-
*
629-
* @SuppressWarnings(PHPMD.ElseExpression)
630605
*/
631606
public function setGebruikSelfToActiveOrg(string $gebruikId): JSONResponse
632607
{
@@ -673,14 +648,13 @@ function ($key) {
673648
);
674649

675650
// Determine appropriate HTTP status code.
651+
$statusCode = 500;
676652
if ($result['success'] === true) {
677653
$statusCode = 200;
678654
} else if ($result['error'] === 'Gebruik object not found') {
679655
$statusCode = 404;
680656
} else if (strpos(haystack: ($result['error'] ?? ''), needle: 'Operation not allowed') !== false) {
681657
$statusCode = 403;
682-
} else {
683-
$statusCode = 500;
684658
}
685659

686660
$this->logger->info(
@@ -735,8 +709,6 @@ function ($key) {
735709
* @NoCSRFRequired
736710
* @PublicPage
737711
* @PublicPage
738-
*
739-
* @SuppressWarnings(PHPMD.ElseExpression)
740712
*/
741713
public function deleteGebruikAsAfnemer(string $gebruikId): JSONResponse
742714
{
@@ -783,14 +755,13 @@ function ($key) {
783755
);
784756

785757
// Determine appropriate HTTP status code.
758+
$statusCode = 500;
786759
if ($result['success'] === true) {
787760
$statusCode = 200;
788761
} else if ($result['error'] === 'Gebruik object not found') {
789762
$statusCode = 404;
790763
} else if (strpos(haystack: ($result['error'] ?? ''), needle: 'Operation not allowed') !== false) {
791764
$statusCode = 403;
792-
} else {
793-
$statusCode = 500;
794765
}
795766

796767
$this->logger->info(

lib/Controller/ContactpersonenController.php

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ function ($group) {
264264
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
265265
* @SuppressWarnings(PHPMD.NPathComplexity)
266266
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
267-
* @SuppressWarnings(PHPMD.ElseExpression)
268267
*/
269268
public function convertToUser(string $contactpersoonId): JSONResponse
270269
{
@@ -402,11 +401,9 @@ public function convertToUser(string $contactpersoonId): JSONResponse
402401
$contactpersoonObject->setObject($contactData);
403402

404403
// Debug logging to understand data types before save.
405-
$achternaamValue = $contactData['achternaam'] ?? 'not set';
406-
if (isset($contactData['achternaam']) === true) {
407-
$achternaamType = gettype($contactData['achternaam']);
408-
} else {
404+
$achternaamValue = $contactData['achternaam'] ?? 'not set';
409405
$achternaamType = 'not set';
406+
if (isset($contactData['achternaam']) === true) {
410407
}
411408

412409
$this->logger->info(
@@ -580,7 +577,6 @@ public function changePassword(string $username, string $newPassword): JSONRespo
580577
*
581578
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
582579
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
583-
* @SuppressWarnings(PHPMD.ElseExpression)
584580
*/
585581
public function updateUserGroups(string $username, array $groups=[]): JSONResponse
586582
{
@@ -633,25 +629,26 @@ public function updateUserGroups(string $username, array $groups=[]): JSONRespon
633629
$groupsToAdd = array_diff($validGroups, $curCatalogGroups);
634630
foreach ($groupsToAdd as $groupName) {
635631
$group = $this->groupManager->get($groupName);
636-
if ($group !== null) {
637-
if ($group->inGroup($user) === false) {
638-
$group->addUser($user);
639-
$this->logger->info(
640-
'Added user to group',
641-
[
642-
'username' => $username,
643-
'group' => $groupName,
644-
]
645-
);
646-
}
647-
} else {
632+
if ($group === null) {
648633
$this->logger->warning(
649634
'Group does not exist, skipping',
650635
[
651636
'username' => $username,
652637
'group' => $groupName,
653638
]
654639
);
640+
continue;
641+
}
642+
643+
if ($group->inGroup($user) === false) {
644+
$group->addUser($user);
645+
$this->logger->info(
646+
'Added user to group',
647+
[
648+
'username' => $username,
649+
'group' => $groupName,
650+
]
651+
);
655652
}
656653
}//end foreach
657654

@@ -1076,28 +1073,20 @@ public function enableUser(string $contactpersoonId): JSONResponse
10761073
*
10771074
* @NoAdminRequired
10781075
* @NoCSRFRequired
1079-
*
1080-
* @SuppressWarnings(PHPMD.ElseExpression)
10811076
*/
10821077
public function testBulkUserInfo(): JSONResponse
10831078
{
10841079
try {
1085-
if ($this->contactSvc !== null) {
1086-
$objectServiceAvail = 'available';
1087-
} else {
10881080
$objectServiceAvail = 'null';
1081+
if ($this->contactSvc !== null) {
10891082
}
10901083

1091-
if ($this->userManager !== null) {
1092-
$userManagerAvail = 'available';
1093-
} else {
10941084
$userManagerAvail = 'null';
1085+
if ($this->userManager !== null) {
10951086
}
10961087

1097-
if ($this->groupManager !== null) {
1098-
$groupManagerAvail = 'available';
1099-
} else {
11001088
$groupManagerAvail = 'null';
1089+
if ($this->groupManager !== null) {
11011090
}
11021091

11031092
$this->logger->info(

0 commit comments

Comments
 (0)