From 26e410cc2d5b1137e82008de7947098ff374befd Mon Sep 17 00:00:00 2001 From: aB0t Date: Tue, 3 Sep 2024 02:06:09 +0200 Subject: [PATCH] Update 2024-09-03 02:06:33 --- .../code.php | 19 +++++++++++++++---- .../code.power | 19 +++++++++++++++---- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.php b/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.php index c1e0958..8bdd4f1 100644 --- a/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.php +++ b/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.php @@ -374,25 +374,36 @@ final class UsersSubform implements GuidInterface, SubformInterface */ private function setUserDetails(array &$item): int { - $user = []; + $details = []; + $user = null; // now load the user ID if (isset($item['user_id']) && is_numeric($item['user_id']) && $item['user_id'] > 0) { - $user['id'] = (int) $item['user_id']; + // Retrieve the user by ID + $user = UserHelper::getUserById((int)$item['user_id']); + if ($user->id == $item['user_id']) + { + $details['id'] = (int) $item['user_id']; + } } foreach ($this->user as $property) { if (isset($item[$property])) { - $user[$property] = $item[$property]; + $details[$property] = $item[$property]; unset($item[$property]); } } + if ($user !== null) + { + $details['group'] = $user->getAuthorisedGroups(); + } + try { - return UserHelper::save($user); + return UserHelper::save($details); } catch(NoUserIdFoundException $e) { Factory::getApplication()->enqueueMessage($e->getMessage(), 'error'); } catch(\Exception $e) { diff --git a/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.power b/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.power index 1b0d755..4c3d6e8 100644 --- a/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.power +++ b/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.power @@ -344,25 +344,36 @@ */ private function setUserDetails(array &$item): int { - $user = []; + $details = []; + $user = null; // now load the user ID if (isset($item['user_id']) && is_numeric($item['user_id']) && $item['user_id'] > 0) { - $user['id'] = (int) $item['user_id']; + // Retrieve the user by ID + $user = UserHelper::getUserById((int)$item['user_id']); + if ($user->id == $item['user_id']) + { + $details['id'] = (int) $item['user_id']; + } } foreach ($this->user as $property) { if (isset($item[$property])) { - $user[$property] = $item[$property]; + $details[$property] = $item[$property]; unset($item[$property]); } } + if ($user !== null) + { + $details['group'] = $user->getAuthorisedGroups(); + } + try { - return UserHelper::save($user); + return UserHelper::save($details); } catch(NoUserIdFoundException $e) { Factory::getApplication()->enqueueMessage($e->getMessage(), 'error'); } catch(\Exception $e) {