From d590373ae7549a8c0e372d7362baf64b08a36f27 Mon Sep 17 00:00:00 2001 From: greta Date: Wed, 30 Aug 2023 15:14:00 +0200 Subject: [PATCH] feat(admin_audit): Audit the tag creation Co-authored-by: greta Co-authored-by: Ferdinand Thiessen Signed-off-by: greta --- .../composer/composer/autoload_classmap.php | 1 + .../composer/composer/autoload_static.php | 1 + .../admin_audit/lib/Actions/TagManagement.php | 27 +++++++++++++++++++ apps/admin_audit/lib/AppInfo/Application.php | 9 +++++++ 4 files changed, 38 insertions(+) create mode 100644 apps/admin_audit/lib/Actions/TagManagement.php diff --git a/apps/admin_audit/composer/composer/autoload_classmap.php b/apps/admin_audit/composer/composer/autoload_classmap.php index fc4be52ebbb..8bfa01ccfdc 100644 --- a/apps/admin_audit/composer/composer/autoload_classmap.php +++ b/apps/admin_audit/composer/composer/autoload_classmap.php @@ -15,6 +15,7 @@ return array( 'OCA\\AdminAudit\\Actions\\GroupManagement' => $baseDir . '/../lib/Actions/GroupManagement.php', 'OCA\\AdminAudit\\Actions\\Security' => $baseDir . '/../lib/Actions/Security.php', 'OCA\\AdminAudit\\Actions\\Sharing' => $baseDir . '/../lib/Actions/Sharing.php', + 'OCA\\AdminAudit\\Actions\\TagManagement' => $baseDir . '/../lib/Actions/TagManagement.php', 'OCA\\AdminAudit\\Actions\\Trashbin' => $baseDir . '/../lib/Actions/Trashbin.php', 'OCA\\AdminAudit\\Actions\\UserManagement' => $baseDir . '/../lib/Actions/UserManagement.php', 'OCA\\AdminAudit\\Actions\\Versions' => $baseDir . '/../lib/Actions/Versions.php', diff --git a/apps/admin_audit/composer/composer/autoload_static.php b/apps/admin_audit/composer/composer/autoload_static.php index 38518c8a9ba..506e7fad226 100644 --- a/apps/admin_audit/composer/composer/autoload_static.php +++ b/apps/admin_audit/composer/composer/autoload_static.php @@ -30,6 +30,7 @@ class ComposerStaticInitAdminAudit 'OCA\\AdminAudit\\Actions\\GroupManagement' => __DIR__ . '/..' . '/../lib/Actions/GroupManagement.php', 'OCA\\AdminAudit\\Actions\\Security' => __DIR__ . '/..' . '/../lib/Actions/Security.php', 'OCA\\AdminAudit\\Actions\\Sharing' => __DIR__ . '/..' . '/../lib/Actions/Sharing.php', + 'OCA\\AdminAudit\\Actions\\TagManagement' => __DIR__ . '/..' . '/../lib/Actions/TagManagement.php', 'OCA\\AdminAudit\\Actions\\Trashbin' => __DIR__ . '/..' . '/../lib/Actions/Trashbin.php', 'OCA\\AdminAudit\\Actions\\UserManagement' => __DIR__ . '/..' . '/../lib/Actions/UserManagement.php', 'OCA\\AdminAudit\\Actions\\Versions' => __DIR__ . '/..' . '/../lib/Actions/Versions.php', diff --git a/apps/admin_audit/lib/Actions/TagManagement.php b/apps/admin_audit/lib/Actions/TagManagement.php new file mode 100644 index 00000000000..a167017aec3 --- /dev/null +++ b/apps/admin_audit/lib/Actions/TagManagement.php @@ -0,0 +1,27 @@ +log('System tag "%s" (%s, %s) created', + [ + 'name' => $tag->getName(), + 'visbility' => $tag->isUserVisible() ? 'visible' : 'invisible', + 'assignable' => $tag->isUserAssignable() ? 'user assignable' : 'system only', + ], + ['name', 'visibility', 'assignable'] + ); + } +} diff --git a/apps/admin_audit/lib/AppInfo/Application.php b/apps/admin_audit/lib/AppInfo/Application.php index b8b80841539..79c6640e2e2 100644 --- a/apps/admin_audit/lib/AppInfo/Application.php +++ b/apps/admin_audit/lib/AppInfo/Application.php @@ -16,6 +16,7 @@ use OCA\AdminAudit\Actions\Files; use OCA\AdminAudit\Actions\GroupManagement; use OCA\AdminAudit\Actions\Security; use OCA\AdminAudit\Actions\Sharing; +use OCA\AdminAudit\Actions\TagManagement; use OCA\AdminAudit\Actions\Trashbin; use OCA\AdminAudit\Actions\UserManagement; use OCA\AdminAudit\Actions\Versions; @@ -99,6 +100,7 @@ class Application extends App implements IBootstrap { $this->versionsHooks($logger); $this->securityHooks($logger, $eventDispatcher); + $this->tagHooks($logger, $eventDispatcher); } private function userManagementHooks(IAuditLogger $logger, @@ -169,6 +171,13 @@ class Application extends App implements IBootstrap { $appActions->runCommand($event->getArguments()); }); } + private function tagHooks(IAuditLogger $logger, + IEventDispatcher $eventDispatcher): void { + $eventDispatcher->addListener(\OCP\SystemTag\ManagerEvent::EVENT_CREATE, function (\OCP\SystemTag\ManagerEvent $event) use ($logger) { + $tagActions = new TagManagement($logger); + $tagActions->createTag($event->getTag()); + }); + } private function fileHooks(IAuditLogger $logger, IEventDispatcher $eventDispatcher): void {