From e432b291f4cb988e0f5c2b6b91713a00f76cd760 Mon Sep 17 00:00:00 2001 From: Llewellyn Date: Tue, 10 Sep 2024 22:00:23 +0000 Subject: [PATCH 1/3] Update VDM.Data.UsersSubform settings --- .../settings.json | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/46b98346-ec98-42b3-a393-96c7d1282b1c/settings.json b/src/46b98346-ec98-42b3-a393-96c7d1282b1c/settings.json index f17c492..305c70d 100644 --- a/src/46b98346-ec98-42b3-a393-96c7d1282b1c/settings.json +++ b/src/46b98346-ec98-42b3-a393-96c7d1282b1c/settings.json @@ -1,17 +1,11 @@ { "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": "", + "extendsinterfaces": null, + "extendsinterfaces_custom": "", "guid": "46b98346-ec98-42b3-a393-96c7d1282b1c", - "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", + "head": "use Joomla\\CMS\\Factory;\r\nuse Joomla\\CMS\\User\\User;", "use_selection": { "use_selection0": { "use": "7212e4db-371f-4cfd-8122-32e9bb100d83", @@ -34,10 +28,17 @@ "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", - "description": "CRUD the user data of any sub-form to another view (table)\r\n\r\n@since 5.0.2", - "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 3rd September, 2020\r\n * @author Llewellyn van der Merwe \r\n * @git 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", - "head": "use Joomla\\CMS\\Factory;\r\nuse Joomla\\CMS\\User\\User;", - "composer": "" + "composer": "", + "add_licensing_template": "2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 3rd September, 2020\r\n * @author Llewellyn van der Merwe \r\n * @git 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" } \ No newline at end of file -- 2.45.2 From 66cf9970030cae2905ee459387e30596cf2b635d Mon Sep 17 00:00:00 2001 From: Llewellyn Date: Tue, 10 Sep 2024 22:00:24 +0000 Subject: [PATCH 2/3] Update VDM.Data.UsersSubform code --- .../code.power | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.power b/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.power index 07a1144..7524d48 100644 --- a/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.power +++ b/src/46b98346-ec98-42b3-a393-96c7d1282b1c/code.power @@ -29,6 +29,14 @@ */ protected array $user; + /** + * The current active user + * + * @var User + * @since 5.0.2 + */ + protected User $identity; + /** * The active users * @@ -53,6 +61,8 @@ $this->table = $table; } + $this->identity = Factory::getApplication()->getIdentity(); + // Retrieve the user properties $this->initializeUserProperties(); } @@ -397,8 +407,12 @@ { $user = $this->loadUser($item, $activeUsers); $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); } @@ -503,7 +517,7 @@ private function saveUserDetails(array $details, int $userId): int { try { - return UserHelper::save($details); + return UserHelper::save($details, 0, ['useractivation' => 0, 'sendpassword' => 1, 'allowUserRegistration' => 1]); } catch (NoUserIdFoundException $e) { Factory::getApplication()->enqueueMessage($e->getMessage(), 'error'); } catch (\Exception $e) { -- 2.45.2 From af3e8081ca4b57cfe35650054072f0df40c931b6 Mon Sep 17 00:00:00 2001 From: Llewellyn Date: Tue, 10 Sep 2024 22:00:26 +0000 Subject: [PATCH 3/3] Update VDM.Data.UsersSubform readme file --- src/46b98346-ec98-42b3-a393-96c7d1282b1c/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/46b98346-ec98-42b3-a393-96c7d1282b1c/README.md b/src/46b98346-ec98-42b3-a393-96c7d1282b1c/README.md index 0fa3b87..2ad6e91 100644 --- a/src/46b98346-ec98-42b3-a393-96c7d1282b1c/README.md +++ b/src/46b98346-ec98-42b3-a393-96c7d1282b1c/README.md @@ -15,6 +15,7 @@ class UsersSubform << (F,LightGreen) >> #RoyalBlue { # Items $items # string $table # array $user + # User $identity # array $activeUsers + __construct(Items $items, ?string $table = null) + table(string $table) : self -- 2.45.2