ISystemTagManager.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. /**
  26. * Public interface to access and manage system-wide tags.
  27. *
  28. * @since 9.0.0
  29. */
  30. interface ISystemTagManager {
  31. /**
  32. * Returns the tag objects matching the given tag ids.
  33. *
  34. * @param array|string $tagIds id or array of unique ids of the tag to retrieve
  35. *
  36. * @return \OCP\SystemTag\ISystemTag[] array of system tags with tag id as key
  37. *
  38. * @throws \InvalidArgumentException if at least one given tag ids is invalid (string instead of integer, etc.)
  39. * @throws \OCP\SystemTag\TagNotFoundException if at least one given tag ids did no exist
  40. * The message contains a json_encoded array of the ids that could not be found
  41. *
  42. * @since 9.0.0
  43. */
  44. public function getTagsByIds($tagIds);
  45. /**
  46. * Returns the tag object matching the given attributes.
  47. *
  48. * @param string $tagName tag name
  49. * @param bool $userVisible whether the tag is visible by users
  50. * @param bool $userAssignable whether the tag is assignable by users
  51. *
  52. * @return \OCP\SystemTag\ISystemTag system tag
  53. *
  54. * @throws \OCP\SystemTag\TagNotFoundException if tag does not exist
  55. *
  56. * @since 9.0.0
  57. */
  58. public function getTag($tagName, $userVisible, $userAssignable);
  59. /**
  60. * Creates the tag object using the given attributes.
  61. *
  62. * @param string $tagName tag name
  63. * @param bool $userVisible whether the tag is visible by users
  64. * @param bool $userAssignable whether the tag is assignable by users
  65. *
  66. * @return \OCP\SystemTag\ISystemTag system tag
  67. *
  68. * @throws \OCP\SystemTag\TagAlreadyExistsException if tag already exists
  69. *
  70. * @since 9.0.0
  71. */
  72. public function createTag($tagName, $userVisible, $userAssignable);
  73. /**
  74. * Returns all known tags, optionally filtered by visibility.
  75. *
  76. * @param bool|null $visibilityFilter filter by visibility if non-null
  77. * @param string $nameSearchPattern optional search pattern for the tag name
  78. *
  79. * @return \OCP\SystemTag\ISystemTag[] array of system tags or empty array if none found
  80. *
  81. * @since 9.0.0
  82. */
  83. public function getAllTags($visibilityFilter = null, $nameSearchPattern = null);
  84. /**
  85. * Updates the given tag
  86. *
  87. * @param string $tagId tag id
  88. * @param string $newName the new tag name
  89. * @param bool $userVisible whether the tag is visible by users
  90. * @param bool $userAssignable whether the tag is assignable by users
  91. *
  92. * @throws \OCP\SystemTag\TagNotFoundException if tag with the given id does not exist
  93. * @throws \OCP\SystemTag\TagAlreadyExistsException if there is already another tag
  94. * with the same attributes
  95. *
  96. * @since 9.0.0
  97. */
  98. public function updateTag($tagId, $newName, $userVisible, $userAssignable);
  99. /**
  100. * Delete the given tags from the database and all their relationships.
  101. *
  102. * @param string|array $tagIds array of tag ids
  103. *
  104. * @throws \OCP\SystemTag\TagNotFoundException if at least one tag did not exist
  105. *
  106. * @since 9.0.0
  107. */
  108. public function deleteTags($tagIds);
  109. /**
  110. * Checks whether the given user is allowed to assign/unassign the tag with the
  111. * given id.
  112. *
  113. * @param ISystemTag $tag tag to check permission for
  114. * @param IUser $user user to check permission for
  115. *
  116. * @return true if the user is allowed to assign/unassign the tag, false otherwise
  117. *
  118. * @since 9.1.0
  119. */
  120. public function canUserAssignTag(ISystemTag $tag, IUser $user);
  121. /**
  122. * Checks whether the given user is allowed to see the tag with the given id.
  123. *
  124. * @param ISystemTag $tag tag to check permission for
  125. * @param IUser $user user to check permission for
  126. *
  127. * @return true if the user can see the tag, false otherwise
  128. *
  129. * @since 9.1.0
  130. */
  131. public function canUserSeeTag(ISystemTag $tag, IUser $userId);
  132. /**
  133. * Set groups that can assign a given tag.
  134. *
  135. * @param ISystemTag $tag tag for group assignment
  136. * @param string[] $groupIds group ids of groups that can assign/unassign the tag
  137. *
  138. * @since 9.1.0
  139. */
  140. public function setTagGroups(ISystemTag $tag, $groupIds);
  141. /**
  142. * Get groups that can assign a given tag.
  143. *
  144. * @param ISystemTag $tag tag for group assignment
  145. *
  146. * @return string[] group ids of groups that can assign/unassign the tag
  147. *
  148. * @since 9.1.0
  149. */
  150. public function getTagGroups(ISystemTag $tag);
  151. }