Update VDM.Data.UsersSubform code

This commit is contained in:
Llewellyn 2024-09-10 22:00:24 +00:00
parent e432b291f4
commit 66cf997003

View File

@ -29,6 +29,14 @@
*/ */
protected array $user; protected array $user;
/**
* The current active user
*
* @var User
* @since 5.0.2
*/
protected User $identity;
/** /**
* The active users * The active users
* *
@ -53,6 +61,8 @@
$this->table = $table; $this->table = $table;
} }
$this->identity = Factory::getApplication()->getIdentity();
// Retrieve the user properties // Retrieve the user properties
$this->initializeUserProperties(); $this->initializeUserProperties();
} }
@ -397,8 +407,12 @@
{ {
$user = $this->loadUser($item, $activeUsers); $user = $this->loadUser($item, $activeUsers);
$details = $this->extractUserDetails($item, $user); $details = $this->extractUserDetails($item, $user);
$this->assignUserGroups($details, $user, $item);
if ($this->identity->id != $user->id)
{
$this->assignUserGroups($details, $user, $item);
}
return $this->saveUserDetails($details, $details['id'] ?? 0); return $this->saveUserDetails($details, $details['id'] ?? 0);
} }
@ -503,7 +517,7 @@
private function saveUserDetails(array $details, int $userId): int private function saveUserDetails(array $details, int $userId): int
{ {
try { try {
return UserHelper::save($details); return UserHelper::save($details, 0, ['useractivation' => 0, 'sendpassword' => 1, 'allowUserRegistration' => 1]);
} catch (NoUserIdFoundException $e) { } catch (NoUserIdFoundException $e) {
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error'); Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
} catch (\Exception $e) { } catch (\Exception $e) {