Update 2024-09-03 02:06:33

This commit is contained in:
Robot 2024-09-03 02:06:09 +02:00
parent e5a248a773
commit 26e410cc2d
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
2 changed files with 30 additions and 8 deletions

View File

@ -374,25 +374,36 @@ final class UsersSubform implements GuidInterface, SubformInterface
*/ */
private function setUserDetails(array &$item): int private function setUserDetails(array &$item): int
{ {
$user = []; $details = [];
$user = null;
// now load the user ID // now load the user ID
if (isset($item['user_id']) && is_numeric($item['user_id']) && $item['user_id'] > 0) 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) foreach ($this->user as $property)
{ {
if (isset($item[$property])) if (isset($item[$property]))
{ {
$user[$property] = $item[$property]; $details[$property] = $item[$property];
unset($item[$property]); unset($item[$property]);
} }
} }
if ($user !== null)
{
$details['group'] = $user->getAuthorisedGroups();
}
try { try {
return UserHelper::save($user); return UserHelper::save($details);
} catch(NoUserIdFoundException $e) { } catch(NoUserIdFoundException $e) {
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error'); Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
} catch(\Exception $e) { } catch(\Exception $e) {

View File

@ -344,25 +344,36 @@
*/ */
private function setUserDetails(array &$item): int private function setUserDetails(array &$item): int
{ {
$user = []; $details = [];
$user = null;
// now load the user ID // now load the user ID
if (isset($item['user_id']) && is_numeric($item['user_id']) && $item['user_id'] > 0) 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) foreach ($this->user as $property)
{ {
if (isset($item[$property])) if (isset($item[$property]))
{ {
$user[$property] = $item[$property]; $details[$property] = $item[$property];
unset($item[$property]); unset($item[$property]);
} }
} }
if ($user !== null)
{
$details['group'] = $user->getAuthorisedGroups();
}
try { try {
return UserHelper::save($user); return UserHelper::save($details);
} catch(NoUserIdFoundException $e) { } catch(NoUserIdFoundException $e) {
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error'); Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
} catch(\Exception $e) { } catch(\Exception $e) {