Share_Backend.php 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Björn Schießle <bjoern@schiessle.org>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. * @author Robin McCorkell <robin@mccorkell.me.uk>
  9. *
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  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, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. // use OCP namespace for all classes that are considered public.
  26. // This means that they should be used by apps instead of the internal ownCloud classes
  27. namespace OCP;
  28. /**
  29. * Interface that apps must implement to share content.
  30. * @since 5.0.0
  31. */
  32. interface Share_Backend {
  33. /**
  34. * Check if this $itemSource exist for the user
  35. * @param string $itemSource
  36. * @param string $uidOwner Owner of the item
  37. * @return boolean|null Source
  38. *
  39. * Return false if the item does not exist for the user
  40. * @since 5.0.0
  41. */
  42. public function isValidSource($itemSource, $uidOwner);
  43. /**
  44. * Get a unique name of the item for the specified user
  45. * @param string $itemSource
  46. * @param string|false $shareWith User the item is being shared with
  47. * @param array|null $exclude List of similar item names already existing as shared items @deprecated since version OC7
  48. * @return string Target name
  49. *
  50. * This function needs to verify that the user does not already have an item with this name.
  51. * If it does generate a new name e.g. name_#
  52. * @since 5.0.0
  53. */
  54. public function generateTarget($itemSource, $shareWith, $exclude = null);
  55. /**
  56. * Converts the shared item sources back into the item in the specified format
  57. * @param array $items Shared items
  58. * @param int $format
  59. * @return array
  60. *
  61. * The items array is a 3-dimensional array with the item_source as the
  62. * first key and the share id as the second key to an array with the share
  63. * info.
  64. *
  65. * The key/value pairs included in the share info depend on the function originally called:
  66. * If called by getItem(s)Shared: id, item_type, item, item_source,
  67. * share_type, share_with, permissions, stime, file_source
  68. *
  69. * If called by getItem(s)SharedWith: id, item_type, item, item_source,
  70. * item_target, share_type, share_with, permissions, stime, file_source,
  71. * file_target
  72. *
  73. * This function allows the backend to control the output of shared items with custom formats.
  74. * It is only called through calls to the public getItem(s)Shared(With) functions.
  75. * @since 5.0.0
  76. */
  77. public function formatItems($items, $format, $parameters = null);
  78. /**
  79. * Check if a given share type is allowd by the back-end
  80. *
  81. * @param int $shareType share type
  82. * @return boolean
  83. *
  84. * The back-end can enable/disable specific share types. Just return true if
  85. * the back-end doesn't provide any specific settings for it and want to allow
  86. * all share types defined by the share API
  87. * @since 8.0.0
  88. */
  89. public function isShareTypeAllowed($shareType);
  90. }