You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ISystemTagManager.php 4.9KB

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