GroupManagement.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\AdminAudit\Actions;
  8. use OCP\IGroup;
  9. use OCP\IUser;
  10. /**
  11. * Class GroupManagement logs all group manager related events
  12. *
  13. * @package OCA\AdminAudit\Actions
  14. */
  15. class GroupManagement extends Action {
  16. /**
  17. * log add user to group event
  18. *
  19. * @param IGroup $group
  20. * @param IUser $user
  21. */
  22. public function addUser(IGroup $group, IUser $user): void {
  23. $this->log('User "%s" added to group "%s"',
  24. [
  25. 'group' => $group->getGID(),
  26. 'user' => $user->getUID()
  27. ],
  28. [
  29. 'user', 'group'
  30. ]
  31. );
  32. }
  33. /**
  34. * log remove user from group event
  35. *
  36. * @param IGroup $group
  37. * @param IUser $user
  38. */
  39. public function removeUser(IGroup $group, IUser $user): void {
  40. $this->log('User "%s" removed from group "%s"',
  41. [
  42. 'group' => $group->getGID(),
  43. 'user' => $user->getUID()
  44. ],
  45. [
  46. 'user', 'group'
  47. ]
  48. );
  49. }
  50. /**
  51. * log create group to group event
  52. *
  53. * @param IGroup $group
  54. */
  55. public function createGroup(IGroup $group): void {
  56. $this->log('Group created: "%s"',
  57. [
  58. 'group' => $group->getGID()
  59. ],
  60. [
  61. 'group'
  62. ]
  63. );
  64. }
  65. /**
  66. * log delete group to group event
  67. *
  68. * @param IGroup $group
  69. */
  70. public function deleteGroup(IGroup $group): void {
  71. $this->log('Group deleted: "%s"',
  72. [
  73. 'group' => $group->getGID()
  74. ],
  75. [
  76. 'group'
  77. ]
  78. );
  79. }
  80. }