Files.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
  5. *
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Lukas Reschke <lukas@statuscode.ch>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. *
  10. * @license GNU AGPL version 3 or any later version
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License as
  14. * published by the Free Software Foundation, either version 3 of the
  15. * License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. *
  25. */
  26. namespace OCA\AdminAudit\Actions;
  27. /**
  28. * Class Files logs the actions to files
  29. *
  30. * @package OCA\AdminAudit\Actions
  31. */
  32. class Files extends Action {
  33. /**
  34. * Logs file read actions
  35. *
  36. * @param array $params
  37. */
  38. public function read(array $params): void {
  39. $this->log(
  40. 'File accessed: "%s"',
  41. $params,
  42. [
  43. 'path',
  44. ]
  45. );
  46. }
  47. /**
  48. * Logs rename actions of files
  49. *
  50. * @param array $params
  51. */
  52. public function rename(array $params): void {
  53. $this->log(
  54. 'File renamed: "%s" to "%s"',
  55. $params,
  56. [
  57. 'oldpath',
  58. 'newpath',
  59. ]
  60. );
  61. }
  62. /**
  63. * Logs creation of files
  64. *
  65. * @param array $params
  66. */
  67. public function create(array $params): void {
  68. if ($params['path'] === '/' || $params['path'] === '' || $params['path'] === null) {
  69. return;
  70. }
  71. $this->log(
  72. 'File created: "%s"',
  73. $params,
  74. [
  75. 'path',
  76. ]
  77. );
  78. }
  79. /**
  80. * Logs copying of files
  81. *
  82. * @param array $params
  83. */
  84. public function copy(array $params): void {
  85. $this->log(
  86. 'File copied: "%s" to "%s"',
  87. $params,
  88. [
  89. 'oldpath',
  90. 'newpath',
  91. ]
  92. );
  93. }
  94. /**
  95. * Logs writing of files
  96. *
  97. * @param array $params
  98. */
  99. public function write(array $params): void {
  100. if ($params['path'] === '/' || $params['path'] === '' || $params['path'] === null) {
  101. return;
  102. }
  103. $this->log(
  104. 'File written to: "%s"',
  105. $params,
  106. [
  107. 'path',
  108. ]
  109. );
  110. }
  111. /**
  112. * Logs update of files
  113. *
  114. * @param array $params
  115. */
  116. public function update(array $params): void {
  117. $this->log(
  118. 'File updated: "%s"',
  119. $params,
  120. [
  121. 'path',
  122. ]
  123. );
  124. }
  125. /**
  126. * Logs deletions of files
  127. *
  128. * @param array $params
  129. */
  130. public function delete(array $params): void {
  131. $this->log(
  132. 'File deleted: "%s"',
  133. $params,
  134. [
  135. 'path',
  136. ]
  137. );
  138. }
  139. /**
  140. * Logs preview access to a file
  141. *
  142. * @param array $params
  143. */
  144. public function preview(array $params): void {
  145. $this->log(
  146. 'Preview accessed: "%s" (width: "%s", height: "%s" crop: "%s", mode: "%s")',
  147. $params,
  148. [
  149. 'path',
  150. 'width',
  151. 'height',
  152. 'crop',
  153. 'mode'
  154. ]
  155. );
  156. }
  157. }