Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ITags.php 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bernhard Reiter <ockham@raz.or.at>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Daniel Kesselberg <mail@danielkesselberg.de>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. * @author Thomas Tanghus <thomas@tanghus.net>
  11. * @author Vincent Petry <vincent@nextcloud.com>
  12. *
  13. * @license AGPL-3.0
  14. *
  15. * This code is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License, version 3,
  17. * as published by the Free Software Foundation.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License, version 3,
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>
  26. *
  27. */
  28. // use OCP namespace for all classes that are considered public.
  29. // This means that they should be used by apps instead of the internal ownCloud classes
  30. namespace OCP;
  31. use OC\Tags;
  32. // FIXME: Where should I put this? Or should it be implemented as a Listener?
  33. \OC_Hook::connect('OC_User', 'post_deleteUser', Tags::class, 'post_deleteUser');
  34. /**
  35. * Class for easily tagging objects by their id
  36. *
  37. * A tag can be e.g. 'Family', 'Work', 'Chore', 'Special Occation' or
  38. * anything else that is either parsed from a vobject or that the user chooses
  39. * to add.
  40. * Tag names are not case-sensitive, but will be saved with the case they
  41. * are entered in. If a user already has a tag 'family' for a type, and
  42. * tries to add a tag named 'Family' it will be silently ignored.
  43. * @since 6.0.0
  44. */
  45. interface ITags {
  46. /**
  47. * @since 19.0.0
  48. */
  49. public const TAG_FAVORITE = '_$!<Favorite>!$_';
  50. /**
  51. * Check if any tags are saved for this type and user.
  52. *
  53. * @return boolean
  54. * @since 6.0.0
  55. */
  56. public function isEmpty();
  57. /**
  58. * Returns an array mapping a given tag's properties to its values:
  59. * ['id' => 0, 'name' = 'Tag', 'owner' = 'User', 'type' => 'tagtype']
  60. *
  61. * @param string $id The ID of the tag that is going to be mapped
  62. * @return array|false
  63. * @since 8.0.0
  64. */
  65. public function getTag($id);
  66. /**
  67. * Get the tags for a specific user.
  68. *
  69. * This returns an array with id/name maps:
  70. * [
  71. * ['id' => 0, 'name' = 'First tag'],
  72. * ['id' => 1, 'name' = 'Second tag'],
  73. * ]
  74. *
  75. * @return array
  76. * @since 6.0.0
  77. */
  78. public function getTags();
  79. /**
  80. * Get a list of tags for the given item ids.
  81. *
  82. * This returns an array with object id / tag names:
  83. * [
  84. * 1 => array('First tag', 'Second tag'),
  85. * 2 => array('Second tag'),
  86. * 3 => array('Second tag', 'Third tag'),
  87. * ]
  88. *
  89. * @param array $objIds item ids
  90. * @return array|boolean with object id as key and an array
  91. * of tag names as value or false if an error occurred
  92. * @since 8.0.0
  93. */
  94. public function getTagsForObjects(array $objIds);
  95. /**
  96. * Get a list of items tagged with $tag.
  97. *
  98. * Throws an exception if the tag could not be found.
  99. *
  100. * @param string|integer $tag Tag id or name.
  101. * @return array|false An array of object ids or false on error.
  102. * @since 6.0.0
  103. */
  104. public function getIdsForTag($tag);
  105. /**
  106. * Checks whether a tag is already saved.
  107. *
  108. * @param string $name The name to check for.
  109. * @return bool
  110. * @since 6.0.0
  111. */
  112. public function hasTag($name);
  113. /**
  114. * Checks whether a tag is saved for the given user,
  115. * disregarding the ones shared with him or her.
  116. *
  117. * @param string $name The tag name to check for.
  118. * @param string $user The user whose tags are to be checked.
  119. * @return bool
  120. * @since 8.0.0
  121. */
  122. public function userHasTag($name, $user);
  123. /**
  124. * Add a new tag.
  125. *
  126. * @param string $name A string with a name of the tag
  127. * @return int|false the id of the added tag or false if it already exists.
  128. * @since 6.0.0
  129. */
  130. public function add($name);
  131. /**
  132. * Rename tag.
  133. *
  134. * @param string|integer $from The name or ID of the existing tag
  135. * @param string $to The new name of the tag.
  136. * @return bool
  137. * @since 6.0.0
  138. */
  139. public function rename($from, $to);
  140. /**
  141. * Add a list of new tags.
  142. *
  143. * @param string[] $names A string with a name or an array of strings containing
  144. * the name(s) of the to add.
  145. * @param bool $sync When true, save the tags
  146. * @param int|null $id int Optional object id to add to this|these tag(s)
  147. * @return bool Returns false on error.
  148. * @since 6.0.0
  149. */
  150. public function addMultiple($names, $sync = false, $id = null);
  151. /**
  152. * Delete tag/object relations from the db
  153. *
  154. * @param array $ids The ids of the objects
  155. * @return boolean Returns false on error.
  156. * @since 6.0.0
  157. */
  158. public function purgeObjects(array $ids);
  159. /**
  160. * Get favorites for an object type
  161. *
  162. * @return array|false An array of object ids.
  163. * @since 6.0.0
  164. */
  165. public function getFavorites();
  166. /**
  167. * Add an object to favorites
  168. *
  169. * @param int $objid The id of the object
  170. * @return boolean
  171. * @since 6.0.0
  172. */
  173. public function addToFavorites($objid);
  174. /**
  175. * Remove an object from favorites
  176. *
  177. * @param int $objid The id of the object
  178. * @return boolean
  179. * @since 6.0.0
  180. */
  181. public function removeFromFavorites($objid);
  182. /**
  183. * Creates a tag/object relation.
  184. *
  185. * @param int $objid The id of the object
  186. * @param string $tag The id or name of the tag
  187. * @return boolean Returns false on database error.
  188. * @since 6.0.0
  189. */
  190. public function tagAs($objid, $tag);
  191. /**
  192. * Delete single tag/object relation from the db
  193. *
  194. * @param int $objid The id of the object
  195. * @param string $tag The id or name of the tag
  196. * @return boolean
  197. * @since 6.0.0
  198. */
  199. public function unTag($objid, $tag);
  200. /**
  201. * Delete tags from the database
  202. *
  203. * @param string[]|integer[] $names An array of tags (names or IDs) to delete
  204. * @return bool Returns false on error
  205. * @since 6.0.0
  206. */
  207. public function delete($names);
  208. }