1
0

Share.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bart Visscher <bartv@thisnet.nl>
  6. * @author Björn Schießle <bjoern@schiessle.org>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Robin McCorkell <robin@mccorkell.me.uk>
  11. * @author Thomas Müller <thomas.mueller@tmit.eu>
  12. *
  13. * @license AGPL-3.0
  14. *
  15. * This code is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License, version 3,
  17. * as published by the Free Software Foundation.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License, version 3,
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>
  26. *
  27. */
  28. /**
  29. * Public interface of ownCloud for apps to use.
  30. * Share Class
  31. *
  32. */
  33. // use OCP namespace for all classes that are considered public.
  34. // This means that they should be used by apps instead of the internal ownCloud classes
  35. namespace OCP;
  36. /**
  37. * This class provides the ability for apps to share their content between users.
  38. * Apps must create a backend class that implements OCP\Share_Backend and register it with this class.
  39. *
  40. * It provides the following hooks:
  41. * - post_shared
  42. * @since 5.0.0
  43. */
  44. class Share extends \OC\Share\Constants {
  45. /**
  46. * Get the item of item type shared with a given user by source
  47. * @param string $itemType
  48. * @param string $itemSource
  49. * @param string $user User to whom the item was shared
  50. * @param string $owner Owner of the share
  51. * @return array Return list of items with file_target, permissions and expiration
  52. * @since 6.0.0 - parameter $owner was added in 8.0.0
  53. */
  54. public static function getItemSharedWithUser($itemType, $itemSource, $user, $owner = null) {
  55. return \OC\Share\Share::getItemSharedWithUser($itemType, $itemSource, $user, $owner);
  56. }
  57. /**
  58. * Get the item of item type shared with the current user by source
  59. * @param string $itemType
  60. * @param string $itemSource
  61. * @param int $format (optional) Format type must be defined by the backend
  62. * @param mixed $parameters
  63. * @param bool $includeCollections
  64. * @return array
  65. * @since 5.0.0
  66. */
  67. public static function getItemSharedWithBySource($itemType, $itemSource, $format = self::FORMAT_NONE,
  68. $parameters = null, $includeCollections = false) {
  69. return \OC\Share\Share::getItemSharedWithBySource($itemType, $itemSource, $format, $parameters, $includeCollections);
  70. }
  71. /**
  72. * Based on the given token the share information will be returned - password protected shares will be verified
  73. * @param string $token
  74. * @param bool $checkPasswordProtection
  75. * @return array|bool false will be returned in case the token is unknown or unauthorized
  76. * @since 5.0.0 - parameter $checkPasswordProtection was added in 7.0.0
  77. */
  78. public static function getShareByToken($token, $checkPasswordProtection = true) {
  79. return \OC\Share\Share::getShareByToken($token, $checkPasswordProtection);
  80. }
  81. /**
  82. * resolves reshares down to the last real share
  83. * @param array $linkItem
  84. * @return array file owner
  85. * @since 6.0.0
  86. */
  87. public static function resolveReShare($linkItem) {
  88. return \OC\Share\Share::resolveReShare($linkItem);
  89. }
  90. /**
  91. * Get the shared items of item type owned by the current user
  92. * @param string $itemType
  93. * @param int $format (optional) Format type must be defined by the backend
  94. * @param mixed $parameters
  95. * @param int $limit Number of items to return (optional) Returns all by default
  96. * @param bool $includeCollections
  97. * @return mixed Return depends on format
  98. * @since 5.0.0
  99. */
  100. public static function getItemsShared($itemType, $format = self::FORMAT_NONE, $parameters = null,
  101. $limit = -1, $includeCollections = false) {
  102. return \OC\Share\Share::getItemsShared($itemType, $format, $parameters, $limit, $includeCollections);
  103. }
  104. /**
  105. * Get the shared item of item type owned by the current user
  106. * @param string $itemType
  107. * @param string $itemSource
  108. * @param int $format (optional) Format type must be defined by the backend
  109. * @param mixed $parameters
  110. * @param bool $includeCollections
  111. * @return mixed Return depends on format
  112. * @since 5.0.0
  113. */
  114. public static function getItemShared($itemType, $itemSource, $format = self::FORMAT_NONE,
  115. $parameters = null, $includeCollections = false) {
  116. return \OC\Share\Share::getItemShared($itemType, $itemSource, $format, $parameters, $includeCollections);
  117. }
  118. /**
  119. * sent status if users got informed by mail about share
  120. * @param string $itemType
  121. * @param string $itemSource
  122. * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
  123. * @param string $recipient with whom was the item shared
  124. * @param bool $status
  125. * @since 6.0.0 - parameter $originIsSource was added in 8.0.0
  126. */
  127. public static function setSendMailStatus($itemType, $itemSource, $shareType, $recipient, $status) {
  128. return \OC\Share\Share::setSendMailStatus($itemType, $itemSource, $shareType, $recipient, $status);
  129. }
  130. }