1
0

Share_Backend.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. // use OCP namespace for all classes that are considered public.
  8. // This means that they should be used by apps instead of the internal Nextcloud classes
  9. namespace OCP;
  10. /**
  11. * Interface that apps must implement to share content.
  12. * @since 5.0.0
  13. */
  14. interface Share_Backend {
  15. /**
  16. * Check if this $itemSource exist for the user
  17. * @param string $itemSource
  18. * @param string $uidOwner Owner of the item
  19. * @return boolean|null Source
  20. *
  21. * Return false if the item does not exist for the user
  22. * @since 5.0.0
  23. */
  24. public function isValidSource($itemSource, $uidOwner);
  25. /**
  26. * Get a unique name of the item for the specified user
  27. * @param string $itemSource
  28. * @param string|false $shareWith User the item is being shared with
  29. * @param array|null $exclude List of similar item names already existing as shared items @deprecated since version OC7
  30. * @return string Target name
  31. *
  32. * This function needs to verify that the user does not already have an item with this name.
  33. * If it does generate a new name e.g. name_#
  34. * @since 5.0.0
  35. */
  36. public function generateTarget($itemSource, $shareWith, $exclude = null);
  37. /**
  38. * Converts the shared item sources back into the item in the specified format
  39. * @param array $items Shared items
  40. * @param int $format
  41. * @return array
  42. *
  43. * The items array is a 3-dimensional array with the item_source as the
  44. * first key and the share id as the second key to an array with the share
  45. * info.
  46. *
  47. * The key/value pairs included in the share info depend on the function originally called:
  48. * If called by getItem(s)Shared: id, item_type, item, item_source,
  49. * share_type, share_with, permissions, stime, file_source
  50. *
  51. * If called by getItem(s)SharedWith: id, item_type, item, item_source,
  52. * item_target, share_type, share_with, permissions, stime, file_source,
  53. * file_target
  54. *
  55. * This function allows the backend to control the output of shared items with custom formats.
  56. * It is only called through calls to the public getItem(s)Shared(With) functions.
  57. * @since 5.0.0
  58. */
  59. public function formatItems($items, $format, $parameters = null);
  60. /**
  61. * Check if a given share type is allowed by the back-end
  62. *
  63. * @param int $shareType share type
  64. * @return boolean
  65. *
  66. * The back-end can enable/disable specific share types. Just return true if
  67. * the back-end doesn't provide any specific settings for it and want to allow
  68. * all share types defined by the share API
  69. * @since 8.0.0
  70. */
  71. public function isShareTypeAllowed($shareType);
  72. }