ISystemTagManager.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Vincent Petry <pvince81@owncloud.com>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OCP\SystemTag;
  24. use OCP\IUser;
  25. use OCP\SystemTag\ISystemTag;
  26. /**
  27. * Public interface to access and manage system-wide tags.
  28. *
  29. * @since 9.0.0
  30. */
  31. interface ISystemTagManager {
  32. /**
  33. * Returns the tag objects matching the given tag ids.
  34. *
  35. * @param array|string $tagIds id or array of unique ids of the tag to retrieve
  36. *
  37. * @return \OCP\SystemTag\ISystemTag[] array of system tags with tag id as key
  38. *
  39. * @throws \InvalidArgumentException if at least one given tag ids is invalid (string instead of integer, etc.)
  40. * @throws \OCP\SystemTag\TagNotFoundException if at least one given tag ids did no exist
  41. * The message contains a json_encoded array of the ids that could not be found
  42. *
  43. * @since 9.0.0
  44. */
  45. public function getTagsByIds($tagIds);
  46. /**
  47. * Returns the tag object matching the given attributes.
  48. *
  49. * @param string $tagName tag name
  50. * @param bool $userVisible whether the tag is visible by users
  51. * @param bool $userAssignable whether the tag is assignable by users
  52. *
  53. * @return \OCP\SystemTag\ISystemTag system tag
  54. *
  55. * @throws \OCP\SystemTag\TagNotFoundException if tag does not exist
  56. *
  57. * @since 9.0.0
  58. */
  59. public function getTag($tagName, $userVisible, $userAssignable);
  60. /**
  61. * Creates the tag object using the given attributes.
  62. *
  63. * @param string $tagName tag name
  64. * @param bool $userVisible whether the tag is visible by users
  65. * @param bool $userAssignable whether the tag is assignable by users
  66. *
  67. * @return \OCP\SystemTag\ISystemTag system tag
  68. *
  69. * @throws \OCP\SystemTag\TagAlreadyExistsException if tag already exists
  70. *
  71. * @since 9.0.0
  72. */
  73. public function createTag($tagName, $userVisible, $userAssignable);
  74. /**
  75. * Returns all known tags, optionally filtered by visibility.
  76. *
  77. * @param bool|null $visibilityFilter filter by visibility if non-null
  78. * @param string $nameSearchPattern optional search pattern for the tag name
  79. *
  80. * @return \OCP\SystemTag\ISystemTag[] array of system tags or empty array if none found
  81. *
  82. * @since 9.0.0
  83. */
  84. public function getAllTags($visibilityFilter = null, $nameSearchPattern = null);
  85. /**
  86. * Updates the given tag
  87. *
  88. * @param string $tagId tag id
  89. * @param string $newName the new tag name
  90. * @param bool $userVisible whether the tag is visible by users
  91. * @param bool $userAssignable whether the tag is assignable by users
  92. *
  93. * @throws \OCP\SystemTag\TagNotFoundException if tag with the given id does not exist
  94. * @throws \OCP\SystemTag\TagAlreadyExistsException if there is already another tag
  95. * with the same attributes
  96. *
  97. * @since 9.0.0
  98. */
  99. public function updateTag($tagId, $newName, $userVisible, $userAssignable);
  100. /**
  101. * Delete the given tags from the database and all their relationships.
  102. *
  103. * @param string|array $tagIds array of tag ids
  104. *
  105. * @throws \OCP\SystemTag\TagNotFoundException if at least one tag did not exist
  106. *
  107. * @since 9.0.0
  108. */
  109. public function deleteTags($tagIds);
  110. /**
  111. * Checks whether the given user is allowed to assign/unassign the tag with the
  112. * given id.
  113. *
  114. * @param ISystemTag $tag tag to check permission for
  115. * @param IUser $user user to check permission for
  116. *
  117. * @return true if the user is allowed to assign/unassign the tag, false otherwise
  118. *
  119. * @since 9.1.0
  120. */
  121. public function canUserAssignTag(ISystemTag $tag, IUser $user);
  122. /**
  123. * Checks whether the given user is allowed to see the tag with the given id.
  124. *
  125. * @param ISystemTag $tag tag to check permission for
  126. * @param IUser $user user to check permission for
  127. *
  128. * @return true if the user can see the tag, false otherwise
  129. *
  130. * @since 9.1.0
  131. */
  132. public function canUserSeeTag(ISystemTag $tag, IUser $userId);
  133. /**
  134. * Set groups that can assign a given tag.
  135. *
  136. * @param ISystemTag $tag tag for group assignment
  137. * @param string[] $groupIds group ids of groups that can assign/unassign the tag
  138. *
  139. * @since 9.1.0
  140. */
  141. public function setTagGroups(ISystemTag $tag, $groupIds);
  142. /**
  143. * Get groups that can assign a given tag.
  144. *
  145. * @param ISystemTag $tag tag for group assignment
  146. *
  147. * @return string[] group ids of groups that can assign/unassign the tag
  148. *
  149. * @since 9.1.0
  150. */
  151. public function getTagGroups(ISystemTag $tag);
  152. }