1
0

GroupManagement.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016 Bjoern Schiessle <bjoern@schiessle.org>
  5. *
  6. * @author Bjoern Schiessle <bjoern@schiessle.org>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Lukas Reschke <lukas@statuscode.ch>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. * @author Roger Szabo <roger.szabo@web.de>
  11. *
  12. * @license GNU AGPL version 3 or any later version
  13. *
  14. * This program is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License as
  16. * published by the Free Software Foundation, either version 3 of the
  17. * License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  26. *
  27. */
  28. namespace OCA\AdminAudit\Actions;
  29. use OCP\IGroup;
  30. use OCP\IUser;
  31. /**
  32. * Class GroupManagement logs all group manager related events
  33. *
  34. * @package OCA\AdminAudit\Actions
  35. */
  36. class GroupManagement extends Action {
  37. /**
  38. * log add user to group event
  39. *
  40. * @param IGroup $group
  41. * @param IUser $user
  42. */
  43. public function addUser(IGroup $group, IUser $user): void {
  44. $this->log('User "%s" added to group "%s"',
  45. [
  46. 'group' => $group->getGID(),
  47. 'user' => $user->getUID()
  48. ],
  49. [
  50. 'user', 'group'
  51. ]
  52. );
  53. }
  54. /**
  55. * log remove user from group event
  56. *
  57. * @param IGroup $group
  58. * @param IUser $user
  59. */
  60. public function removeUser(IGroup $group, IUser $user): void {
  61. $this->log('User "%s" removed from group "%s"',
  62. [
  63. 'group' => $group->getGID(),
  64. 'user' => $user->getUID()
  65. ],
  66. [
  67. 'user', 'group'
  68. ]
  69. );
  70. }
  71. /**
  72. * log create group to group event
  73. *
  74. * @param IGroup $group
  75. */
  76. public function createGroup(IGroup $group): void {
  77. $this->log('Group created: "%s"',
  78. [
  79. 'group' => $group->getGID()
  80. ],
  81. [
  82. 'group'
  83. ]
  84. );
  85. }
  86. /**
  87. * log delete group to group event
  88. *
  89. * @param IGroup $group
  90. */
  91. public function deleteGroup(IGroup $group): void {
  92. $this->log('Group deleted: "%s"',
  93. [
  94. 'group' => $group->getGID()
  95. ],
  96. [
  97. 'group'
  98. ]
  99. );
  100. }
  101. }