share_backend.php 3.4 KB

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