share_backend.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. */
  30. interface Share_Backend {
  31. /**
  32. * Check if this $itemSource exist for the user
  33. * @param string $itemSource
  34. * @param string $uidOwner Owner of the item
  35. * @return boolean|null Source
  36. *
  37. * Return false if the item does not exist for the user
  38. */
  39. public function isValidSource($itemSource, $uidOwner);
  40. /**
  41. * Get a unique name of the item for the specified user
  42. * @param string $itemSource
  43. * @param string|false $shareWith User the item is being shared with
  44. * @param array|null $exclude List of similar item names already existing as shared items @deprecated since version OC7
  45. * @return string Target name
  46. *
  47. * This function needs to verify that the user does not already have an item with this name.
  48. * If it does generate a new name e.g. name_#
  49. */
  50. public function generateTarget($itemSource, $shareWith, $exclude = null);
  51. /**
  52. * Converts the shared item sources back into the item in the specified format
  53. * @param array $items Shared items
  54. * @param int $format
  55. * @return array
  56. *
  57. * The items array is a 3-dimensional array with the item_source as the
  58. * first key and the share id as the second key to an array with the share
  59. * info.
  60. *
  61. * The key/value pairs included in the share info depend on the function originally called:
  62. * If called by getItem(s)Shared: id, item_type, item, item_source,
  63. * share_type, share_with, permissions, stime, file_source
  64. *
  65. * If called by getItem(s)SharedWith: id, item_type, item, item_source,
  66. * item_target, share_type, share_with, permissions, stime, file_source,
  67. * file_target
  68. *
  69. * This function allows the backend to control the output of shared items with custom formats.
  70. * It is only called through calls to the public getItem(s)Shared(With) functions.
  71. */
  72. public function formatItems($items, $format, $parameters = null);
  73. /**
  74. * Check if a given share type is allowd by the back-end
  75. *
  76. * @param int $shareType share type
  77. * @return boolean
  78. *
  79. * The back-end can enable/disable specific share types. Just return true if
  80. * the back-end doesn't provide any specific settings for it and want to allow
  81. * all share types defined by the share API
  82. */
  83. public function isShareTypeAllowed($shareType);
  84. }