Share_Backend.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. // use OCP namespace for all classes that are considered public.
  27. // This means that they should be used by apps instead of the internal ownCloud classes
  28. namespace OCP;
  29. /**
  30. * Interface that apps must implement to share content.
  31. * @since 5.0.0
  32. */
  33. interface Share_Backend {
  34. /**
  35. * Check if this $itemSource exist for the user
  36. * @param string $itemSource
  37. * @param string $uidOwner Owner of the item
  38. * @return boolean|null Source
  39. *
  40. * Return false if the item does not exist for the user
  41. * @since 5.0.0
  42. */
  43. public function isValidSource($itemSource, $uidOwner);
  44. /**
  45. * Get a unique name of the item for the specified user
  46. * @param string $itemSource
  47. * @param string|false $shareWith User the item is being shared with
  48. * @param array|null $exclude List of similar item names already existing as shared items @deprecated since version OC7
  49. * @return string Target name
  50. *
  51. * This function needs to verify that the user does not already have an item with this name.
  52. * If it does generate a new name e.g. name_#
  53. * @since 5.0.0
  54. */
  55. public function generateTarget($itemSource, $shareWith, $exclude = null);
  56. /**
  57. * Converts the shared item sources back into the item in the specified format
  58. * @param array $items Shared items
  59. * @param int $format
  60. * @return array
  61. *
  62. * The items array is a 3-dimensional array with the item_source as the
  63. * first key and the share id as the second key to an array with the share
  64. * info.
  65. *
  66. * The key/value pairs included in the share info depend on the function originally called:
  67. * If called by getItem(s)Shared: id, item_type, item, item_source,
  68. * share_type, share_with, permissions, stime, file_source
  69. *
  70. * If called by getItem(s)SharedWith: id, item_type, item, item_source,
  71. * item_target, share_type, share_with, permissions, stime, file_source,
  72. * file_target
  73. *
  74. * This function allows the backend to control the output of shared items with custom formats.
  75. * It is only called through calls to the public getItem(s)Shared(With) functions.
  76. * @since 5.0.0
  77. */
  78. public function formatItems($items, $format, $parameters = null);
  79. /**
  80. * Check if a given share type is allowd by the back-end
  81. *
  82. * @param int $shareType share type
  83. * @return boolean
  84. *
  85. * The back-end can enable/disable specific share types. Just return true if
  86. * the back-end doesn't provide any specific settings for it and want to allow
  87. * all share types defined by the share API
  88. * @since 8.0.0
  89. */
  90. public function isShareTypeAllowed($shareType);
  91. }