Loading patches/036-user-config-change-event.patch +18 −19 Original line number Diff line number Diff line --- ./lib/private/AllConfig.php 2024-03-28 01:02:39 +++ ./lib/private/AllConfig-new.php 2024-04-15 16:36:23 @@ -12,6 +12,8 @@ @@ -14,7 +14,10 @@ use OCP\IConfig; use OCP\IDBConnection; use OCP\PreConditionNotMetException; +use OCP\EventDispatcher\IEventDispatcher; +use OCP\User\Events\UserConfigChangedEvent; + /** * Class to combine all the configuration options ownCloud offers @@ -257,6 +259,8 @@ $qb->executeStatement(); $this->userCache[$userId][$appName][$key] = (string) $value; + $this->triggerUserValueChange($userId, $appName, $key, $value, $prevValue); + return; */ @@ -252,9 +255,18 @@ } catch (TypeConflictException) { } } @@ -282,6 +286,14 @@ $this->userCache[$userId][$appName] = []; } $this->userCache[$userId][$appName][$key] = (string) $value; + } - + $prevValue = $this->getUserValue($userId, $appName, $key, null); $userPreferences->setValueMixed($userId, $appName, $key, (string)$value); + $this->triggerUserValueChange($userId, $appName, $key, $value, $prevValue); + } } + + private function triggerUserValueChange($userId, $appId, $key, $value, $oldValue = null) { + if (\OC::$server instanceof \OCP\IServerContainer) { + $dispatcher = \OC::$server->get(IEventDispatcher::class); + $dispatcher->dispatchTyped(new UserConfigChangedEvent($userId, $appId, $key, $value, $oldValue)); } } + } + } + /** * Getting a user defined value --- ./lib/composer/composer/autoload_static.php 2024-03-28 01:02:39 +++ ./lib/composer/composer/autoload_static-new.php 2024-04-15 16:34:18 @@ -903,6 +903,7 @@ @@ -982,6 +982,7 @@ 'OCP\\User\\Events\\PasswordUpdatedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/PasswordUpdatedEvent.php', 'OCP\\User\\Events\\PostLoginEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/PostLoginEvent.php', 'OCP\\User\\Events\\UserChangedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserChangedEvent.php', Loading @@ -46,7 +45,7 @@ --- ./lib/composer/composer/autoload_classmap.php 2024-03-28 01:02:39 +++ ./lib/composer/composer/autoload_classmap-new.php 2024-04-15 16:33:19 @@ -877,6 +877,7 @@ @@ -942,6 +942,7 @@ 'OCP\\User\\Events\\UserLoggedInEvent' => $baseDir . '/lib/public/User/Events/UserLoggedInEvent.php', 'OCP\\User\\Events\\UserLoggedInWithCookieEvent' => $baseDir . '/lib/public/User/Events/UserLoggedInWithCookieEvent.php', 'OCP\\User\\Events\\UserLoggedOutEvent' => $baseDir . '/lib/public/User/Events/UserLoggedOutEvent.php', Loading Loading
patches/036-user-config-change-event.patch +18 −19 Original line number Diff line number Diff line --- ./lib/private/AllConfig.php 2024-03-28 01:02:39 +++ ./lib/private/AllConfig-new.php 2024-04-15 16:36:23 @@ -12,6 +12,8 @@ @@ -14,7 +14,10 @@ use OCP\IConfig; use OCP\IDBConnection; use OCP\PreConditionNotMetException; +use OCP\EventDispatcher\IEventDispatcher; +use OCP\User\Events\UserConfigChangedEvent; + /** * Class to combine all the configuration options ownCloud offers @@ -257,6 +259,8 @@ $qb->executeStatement(); $this->userCache[$userId][$appName][$key] = (string) $value; + $this->triggerUserValueChange($userId, $appName, $key, $value, $prevValue); + return; */ @@ -252,9 +255,18 @@ } catch (TypeConflictException) { } } @@ -282,6 +286,14 @@ $this->userCache[$userId][$appName] = []; } $this->userCache[$userId][$appName][$key] = (string) $value; + } - + $prevValue = $this->getUserValue($userId, $appName, $key, null); $userPreferences->setValueMixed($userId, $appName, $key, (string)$value); + $this->triggerUserValueChange($userId, $appName, $key, $value, $prevValue); + } } + + private function triggerUserValueChange($userId, $appId, $key, $value, $oldValue = null) { + if (\OC::$server instanceof \OCP\IServerContainer) { + $dispatcher = \OC::$server->get(IEventDispatcher::class); + $dispatcher->dispatchTyped(new UserConfigChangedEvent($userId, $appId, $key, $value, $oldValue)); } } + } + } + /** * Getting a user defined value --- ./lib/composer/composer/autoload_static.php 2024-03-28 01:02:39 +++ ./lib/composer/composer/autoload_static-new.php 2024-04-15 16:34:18 @@ -903,6 +903,7 @@ @@ -982,6 +982,7 @@ 'OCP\\User\\Events\\PasswordUpdatedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/PasswordUpdatedEvent.php', 'OCP\\User\\Events\\PostLoginEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/PostLoginEvent.php', 'OCP\\User\\Events\\UserChangedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserChangedEvent.php', Loading @@ -46,7 +45,7 @@ --- ./lib/composer/composer/autoload_classmap.php 2024-03-28 01:02:39 +++ ./lib/composer/composer/autoload_classmap-new.php 2024-04-15 16:33:19 @@ -877,6 +877,7 @@ @@ -942,6 +942,7 @@ 'OCP\\User\\Events\\UserLoggedInEvent' => $baseDir . '/lib/public/User/Events/UserLoggedInEvent.php', 'OCP\\User\\Events\\UserLoggedInWithCookieEvent' => $baseDir . '/lib/public/User/Events/UserLoggedInWithCookieEvent.php', 'OCP\\User\\Events\\UserLoggedOutEvent' => $baseDir . '/lib/public/User/Events/UserLoggedOutEvent.php', Loading