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.

Files.php 2.9KB

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. *
  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. /**
  27. * Class Files logs the actions to files
  28. *
  29. * @package OCA\AdminAudit\Actions
  30. */
  31. class Files extends Action {
  32. /**
  33. * Logs file read actions
  34. *
  35. * @param array $params
  36. */
  37. public function read(array $params) {
  38. $this->log(
  39. 'File accessed: "%s"',
  40. $params,
  41. [
  42. 'path',
  43. ]
  44. );
  45. }
  46. /**
  47. * Logs rename actions of files
  48. *
  49. * @param array $params
  50. */
  51. public function rename(array $params) {
  52. $this->log(
  53. 'File renamed: "%s" to "%s"',
  54. $params,
  55. [
  56. 'oldpath',
  57. 'newpath',
  58. ]
  59. );
  60. }
  61. /**
  62. * Logs creation of files
  63. *
  64. * @param array $params
  65. */
  66. public function create(array $params) {
  67. if ($params['path'] === '/' || $params['path'] === '' || $params['path'] === null) {
  68. return;
  69. }
  70. $this->log(
  71. 'File created: "%s"',
  72. $params,
  73. [
  74. 'path',
  75. ]
  76. );
  77. }
  78. /**
  79. * Logs copying of files
  80. *
  81. * @param array $params
  82. */
  83. public function copy(array $params) {
  84. $this->log(
  85. 'File copied: "%s" to "%s"',
  86. $params,
  87. [
  88. 'oldpath',
  89. 'newpath',
  90. ]
  91. );
  92. }
  93. /**
  94. * Logs writing of files
  95. *
  96. * @param array $params
  97. */
  98. public function write(array $params) {
  99. if ($params['path'] === '/' || $params['path'] === '' || $params['path'] === null) {
  100. return;
  101. }
  102. $this->log(
  103. 'File written to: "%s"',
  104. $params,
  105. [
  106. 'path',
  107. ]
  108. );
  109. }
  110. /**
  111. * Logs update of files
  112. *
  113. * @param array $params
  114. */
  115. public function update(array $params) {
  116. $this->log(
  117. 'File updated: "%s"',
  118. $params,
  119. [
  120. 'path',
  121. ]
  122. );
  123. }
  124. /**
  125. * Logs deletions of files
  126. *
  127. * @param array $params
  128. */
  129. public function delete(array $params) {
  130. $this->log(
  131. 'File deleted: "%s"',
  132. $params,
  133. [
  134. 'path',
  135. ]
  136. );
  137. }
  138. /**
  139. * Logs preview access to a file
  140. *
  141. * @param array $params
  142. */
  143. public function preview(array $params) {
  144. $this->log(
  145. 'Preview accessed: "%s" (width: "%s", height: "%s" crop: "%s", mode: "%s")',
  146. $params,
  147. [
  148. 'path',
  149. 'width',
  150. 'height',
  151. 'crop',
  152. 'mode'
  153. ]
  154. );
  155. }
  156. }