1
0

Share.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. * Get the shared items of item type owned by the current user
  83. * @param string $itemType
  84. * @param int $format (optional) Format type must be defined by the backend
  85. * @param mixed $parameters
  86. * @param int $limit Number of items to return (optional) Returns all by default
  87. * @param bool $includeCollections
  88. * @return mixed Return depends on format
  89. * @since 5.0.0
  90. */
  91. public static function getItemsShared($itemType, $format = self::FORMAT_NONE, $parameters = null,
  92. $limit = -1, $includeCollections = false) {
  93. return \OC\Share\Share::getItemsShared($itemType, $format, $parameters, $limit, $includeCollections);
  94. }
  95. /**
  96. * Get the shared item of item type owned by the current user
  97. * @param string $itemType
  98. * @param string $itemSource
  99. * @param int $format (optional) Format type must be defined by the backend
  100. * @param mixed $parameters
  101. * @param bool $includeCollections
  102. * @return mixed Return depends on format
  103. * @since 5.0.0
  104. */
  105. public static function getItemShared($itemType, $itemSource, $format = self::FORMAT_NONE,
  106. $parameters = null, $includeCollections = false) {
  107. return \OC\Share\Share::getItemShared($itemType, $itemSource, $format, $parameters, $includeCollections);
  108. }
  109. /**
  110. * sent status if users got informed by mail about share
  111. * @param string $itemType
  112. * @param string $itemSource
  113. * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
  114. * @param string $recipient with whom was the item shared
  115. * @param bool $status
  116. * @since 6.0.0 - parameter $originIsSource was added in 8.0.0
  117. */
  118. public static function setSendMailStatus($itemType, $itemSource, $shareType, $recipient, $status) {
  119. return \OC\Share\Share::setSendMailStatus($itemType, $itemSource, $shareType, $recipient, $status);
  120. }
  121. }