dev #8

Merged
Llewellyn merged 3 commits from dev into master 2024-09-10 22:04:17 +00:00
3 changed files with 34 additions and 18 deletions

View File

@ -15,6 +15,7 @@ class UsersSubform << (F,LightGreen) >> #RoyalBlue {
# Items $items # Items $items
# string $table # string $table
# array $user # array $user
# User $identity
# array $activeUsers # array $activeUsers
+ __construct(Items $items, ?string $table = null) + __construct(Items $items, ?string $table = null)
+ table(string $table) : self + table(string $table) : self

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) {

View File

@ -1,17 +1,11 @@
{ {
"add_head": "1", "add_head": "1",
"add_licensing_template": "2", "description": "CRUD the user data of any sub-form to another view (table)\r\n\r\n@since 5.0.2",
"extends": "", "extends": "",
"extendsinterfaces": null,
"extendsinterfaces_custom": "",
"guid": "46b98346-ec98-42b3-a393-96c7d1282b1c", "guid": "46b98346-ec98-42b3-a393-96c7d1282b1c",
"implements": [ "head": "use Joomla\\CMS\\Factory;\r\nuse Joomla\\CMS\\User\\User;",
"576685fd-263c-46bb-9fdc-1f5eb234cbb6",
"34959721-415b-4b5e-8002-3d1fc84b3b2b"
],
"load_selection": null,
"name": "UsersSubform",
"power_version": "1.0.0",
"system_name": "VDM.Data.UsersSubform",
"type": "final class",
"use_selection": { "use_selection": {
"use_selection0": { "use_selection0": {
"use": "7212e4db-371f-4cfd-8122-32e9bb100d83", "use": "7212e4db-371f-4cfd-8122-32e9bb100d83",
@ -34,10 +28,17 @@
"as": "Component" "as": "Component"
} }
}, },
"extendsinterfaces": null, "implements": [
"576685fd-263c-46bb-9fdc-1f5eb234cbb6",
"34959721-415b-4b5e-8002-3d1fc84b3b2b"
],
"load_selection": null,
"name": "UsersSubform",
"power_version": "1.0.0",
"system_name": "VDM.Data.UsersSubform",
"type": "final class",
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Data.UsersSubform", "namespace": "[[[NamespacePrefix]]]\\Joomla\\Data.UsersSubform",
"description": "CRUD the user data of any sub-form to another view (table)\r\n\r\n@since 5.0.2", "composer": "",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 3rd September, 2020\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", "add_licensing_template": "2",
"head": "use Joomla\\CMS\\Factory;\r\nuse Joomla\\CMS\\User\\User;", "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 3rd September, 2020\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n"
"composer": ""
} }