Sharing.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. use OCP\Share;
  27. /**
  28. * Class Sharing logs the sharing actions
  29. *
  30. * @package OCA\AdminAudit\Actions
  31. */
  32. class Sharing extends Action {
  33. /**
  34. * Logs sharing of data
  35. *
  36. * @param array $params
  37. */
  38. public function shared(array $params) {
  39. if($params['shareType'] === Share::SHARE_TYPE_LINK) {
  40. $this->log(
  41. 'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)',
  42. $params,
  43. [
  44. 'itemType',
  45. 'itemTarget',
  46. 'itemSource',
  47. 'permissions',
  48. 'id',
  49. ]
  50. );
  51. } elseif($params['shareType'] === Share::SHARE_TYPE_USER) {
  52. $this->log(
  53. 'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s" (Share ID: %s)',
  54. $params,
  55. [
  56. 'itemType',
  57. 'itemTarget',
  58. 'itemSource',
  59. 'shareWith',
  60. 'permissions',
  61. 'id',
  62. ]
  63. );
  64. } elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) {
  65. $this->log(
  66. 'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s" (Share ID: %s)',
  67. $params,
  68. [
  69. 'itemType',
  70. 'itemTarget',
  71. 'itemSource',
  72. 'shareWith',
  73. 'permissions',
  74. 'id',
  75. ]
  76. );
  77. } elseif($params['shareType'] === Share::SHARE_TYPE_ROOM) {
  78. $this->log(
  79. 'The %s "%s" with ID "%s" has been shared to the room "%s" with permissions "%s" (Share ID: %s)',
  80. $params,
  81. [
  82. 'itemType',
  83. 'itemTarget',
  84. 'itemSource',
  85. 'shareWith',
  86. 'permissions',
  87. 'id',
  88. ]
  89. );
  90. }
  91. }
  92. /**
  93. * Logs unsharing of data
  94. *
  95. * @param array $params
  96. */
  97. public function unshare(array $params) {
  98. if($params['shareType'] === Share::SHARE_TYPE_LINK) {
  99. $this->log(
  100. 'The %s "%s" with ID "%s" has been unshared (Share ID: %s)',
  101. $params,
  102. [
  103. 'itemType',
  104. 'fileTarget',
  105. 'itemSource',
  106. 'id',
  107. ]
  108. );
  109. } elseif($params['shareType'] === Share::SHARE_TYPE_USER) {
  110. $this->log(
  111. 'The %s "%s" with ID "%s" has been unshared from the user "%s" (Share ID: %s)',
  112. $params,
  113. [
  114. 'itemType',
  115. 'fileTarget',
  116. 'itemSource',
  117. 'shareWith',
  118. 'id',
  119. ]
  120. );
  121. } elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) {
  122. $this->log(
  123. 'The %s "%s" with ID "%s" has been unshared from the group "%s" (Share ID: %s)',
  124. $params,
  125. [
  126. 'itemType',
  127. 'fileTarget',
  128. 'itemSource',
  129. 'shareWith',
  130. 'id',
  131. ]
  132. );
  133. } elseif($params['shareType'] === Share::SHARE_TYPE_ROOM) {
  134. $this->log(
  135. 'The %s "%s" with ID "%s" has been unshared from the room "%s" (Share ID: %s)',
  136. $params,
  137. [
  138. 'itemType',
  139. 'fileTarget',
  140. 'itemSource',
  141. 'shareWith',
  142. 'id',
  143. ]
  144. );
  145. }
  146. }
  147. /**
  148. * Logs the updating of permission changes for shares
  149. *
  150. * @param array $params
  151. */
  152. public function updatePermissions(array $params) {
  153. $this->log(
  154. 'The permissions of the shared %s "%s" with ID "%s" have been changed to "%s"',
  155. $params,
  156. [
  157. 'itemType',
  158. 'path',
  159. 'itemSource',
  160. 'permissions',
  161. ]
  162. );
  163. }
  164. /**
  165. * Logs the password changes for a share
  166. *
  167. * @param array $params
  168. */
  169. public function updatePassword(array $params) {
  170. $this->log(
  171. 'The password of the publicly shared %s "%s" with ID "%s" has been changed',
  172. $params,
  173. [
  174. 'itemType',
  175. 'token',
  176. 'itemSource',
  177. ]
  178. );
  179. }
  180. /**
  181. * Logs the expiration date changes for a share
  182. *
  183. * @param array $params
  184. */
  185. public function updateExpirationDate(array $params) {
  186. $this->log(
  187. 'The expiration date of the publicly shared %s with ID "%s" has been changed to "%s"',
  188. $params,
  189. [
  190. 'itemType',
  191. 'itemSource',
  192. 'date',
  193. ]
  194. );
  195. }
  196. /**
  197. * Logs access of shared files
  198. *
  199. * @param array $params
  200. */
  201. public function shareAccessed(array $params) {
  202. $this->log(
  203. 'The shared %s with the token "%s" by "%s" has been accessed.',
  204. $params,
  205. [
  206. 'itemType',
  207. 'token',
  208. 'uidOwner',
  209. ]
  210. );
  211. }
  212. }