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.

Sharing.php 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Lukas Reschke <lukas@statuscode.ch>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCA\AdminAudit\Actions;
  25. use OCP\Share;
  26. /**
  27. * Class Sharing logs the sharing actions
  28. *
  29. * @package OCA\AdminAudit\Actions
  30. */
  31. class Sharing extends Action {
  32. /**
  33. * Logs sharing of data
  34. *
  35. * @param array $params
  36. */
  37. public function shared(array $params) {
  38. if($params['shareType'] === Share::SHARE_TYPE_LINK) {
  39. $this->log(
  40. 'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)',
  41. $params,
  42. [
  43. 'itemType',
  44. 'itemTarget',
  45. 'itemSource',
  46. 'permissions',
  47. 'id',
  48. ]
  49. );
  50. } elseif($params['shareType'] === Share::SHARE_TYPE_USER) {
  51. $this->log(
  52. 'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s" (Share ID: %s)',
  53. $params,
  54. [
  55. 'itemType',
  56. 'itemTarget',
  57. 'itemSource',
  58. 'shareWith',
  59. 'permissions',
  60. 'id',
  61. ]
  62. );
  63. } elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) {
  64. $this->log(
  65. 'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s" (Share ID: %s)',
  66. $params,
  67. [
  68. 'itemType',
  69. 'itemTarget',
  70. 'itemSource',
  71. 'shareWith',
  72. 'permissions',
  73. 'id',
  74. ]
  75. );
  76. }
  77. }
  78. /**
  79. * Logs unsharing of data
  80. *
  81. * @param array $params
  82. */
  83. public function unshare(array $params) {
  84. if($params['shareType'] === Share::SHARE_TYPE_LINK) {
  85. $this->log(
  86. 'The %s "%s" with ID "%s" has been unshared (Share ID: %s)',
  87. $params,
  88. [
  89. 'itemType',
  90. 'fileTarget',
  91. 'itemSource',
  92. 'id',
  93. ]
  94. );
  95. } elseif($params['shareType'] === Share::SHARE_TYPE_USER) {
  96. $this->log(
  97. 'The %s "%s" with ID "%s" has been unshared from the user "%s" (Share ID: %s)',
  98. $params,
  99. [
  100. 'itemType',
  101. 'fileTarget',
  102. 'itemSource',
  103. 'shareWith',
  104. 'id',
  105. ]
  106. );
  107. } elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) {
  108. $this->log(
  109. 'The %s "%s" with ID "%s" has been unshared from the group "%s" (Share ID: %s)',
  110. $params,
  111. [
  112. 'itemType',
  113. 'fileTarget',
  114. 'itemSource',
  115. 'shareWith',
  116. 'id',
  117. ]
  118. );
  119. }
  120. }
  121. /**
  122. * Logs the updating of permission changes for shares
  123. *
  124. * @param array $params
  125. */
  126. public function updatePermissions(array $params) {
  127. $this->log(
  128. 'The permissions of the shared %s "%s" with ID "%s" have been changed to "%s"',
  129. $params,
  130. [
  131. 'itemType',
  132. 'path',
  133. 'itemSource',
  134. 'permissions',
  135. ]
  136. );
  137. }
  138. /**
  139. * Logs the password changes for a share
  140. *
  141. * @param array $params
  142. */
  143. public function updatePassword(array $params) {
  144. $this->log(
  145. 'The password of the publicly shared %s "%s" with ID "%s" has been changed',
  146. $params,
  147. [
  148. 'itemType',
  149. 'token',
  150. 'itemSource',
  151. ]
  152. );
  153. }
  154. /**
  155. * Logs the expiration date changes for a share
  156. *
  157. * @param array $params
  158. */
  159. public function updateExpirationDate(array $params) {
  160. $this->log(
  161. 'The expiration date of the publicly shared %s with ID "%s" has been changed to "%s"',
  162. $params,
  163. [
  164. 'itemType',
  165. 'itemSource',
  166. 'date',
  167. ]
  168. );
  169. }
  170. /**
  171. * Logs access of shared files
  172. *
  173. * @param array $params
  174. */
  175. public function shareAccessed(array $params) {
  176. $this->log(
  177. 'The shared %s with the token "%s" by "%s" has been accessed.',
  178. $params,
  179. [
  180. 'itemType',
  181. 'token',
  182. 'uidOwner',
  183. ]
  184. );
  185. }
  186. }