You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UserManagement.php 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
  4. *
  5. * @author Bjoern Schiessle <bjoern@schiessle.org>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Lukas Reschke <lukas@statuscode.ch>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OCA\AdminAudit\Actions;
  26. use OCP\IUser;
  27. /**
  28. * Class UserManagement logs all user management related actions.
  29. *
  30. * @package OCA\AdminAudit\Actions
  31. */
  32. class UserManagement extends Action {
  33. /**
  34. * Log creation of users
  35. *
  36. * @param array $params
  37. */
  38. public function create(array $params) {
  39. $this->log(
  40. 'User created: "%s"',
  41. $params,
  42. [
  43. 'uid',
  44. ]
  45. );
  46. }
  47. /**
  48. * Log deletion of users
  49. *
  50. * @param array $params
  51. */
  52. public function delete(array $params) {
  53. $this->log(
  54. 'User deleted: "%s"',
  55. $params,
  56. [
  57. 'uid',
  58. ]
  59. );
  60. }
  61. /**
  62. * Log enabling of users
  63. *
  64. * @param array $params
  65. */
  66. public function change(array $params) {
  67. if ($params['feature'] === 'enabled') {
  68. $this->log(
  69. $params['value'] === 'true' ? 'User enabled: "%s"' : 'User disabled: "%s"',
  70. ['user' => $params['user']->getUID()],
  71. [
  72. 'user',
  73. ]
  74. );
  75. }
  76. }
  77. /**
  78. * Logs changing of the user scope
  79. *
  80. * @param IUser $user
  81. */
  82. public function setPassword(IUser $user) {
  83. if($user->getBackendClassName() === 'Database') {
  84. $this->log(
  85. 'Password of user "%s" has been changed',
  86. [
  87. 'user' => $user->getUID(),
  88. ],
  89. [
  90. 'user',
  91. ]
  92. );
  93. }
  94. }
  95. }