IManager.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wurst <christoph@owncloud.com>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Thomas Müller <thomas.mueller@tmit.eu>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. /**
  27. * Public interface of ownCloud for apps to use.
  28. * Activity/IManager interface
  29. */
  30. // use OCP namespace for all classes that are considered public.
  31. // This means that they should be used by apps instead of the internal ownCloud classes
  32. namespace OCP\Activity;
  33. /**
  34. * Interface IManager
  35. *
  36. * @package OCP\Activity
  37. * @since 6.0.0
  38. */
  39. interface IManager {
  40. /**
  41. * Generates a new IEvent object
  42. *
  43. * Make sure to call at least the following methods before sending it to the
  44. * app with via the publish() method:
  45. * - setApp()
  46. * - setType()
  47. * - setAffectedUser()
  48. * - setSubject()
  49. *
  50. * @return IEvent
  51. * @since 8.2.0
  52. */
  53. public function generateEvent();
  54. /**
  55. * Publish an event to the activity consumers
  56. *
  57. * Make sure to call at least the following methods before sending an Event:
  58. * - setApp()
  59. * - setType()
  60. * - setAffectedUser()
  61. * - setSubject()
  62. *
  63. * @param IEvent $event
  64. * @throws \BadMethodCallException if required values have not been set
  65. * @since 8.2.0
  66. */
  67. public function publish(IEvent $event);
  68. /**
  69. * In order to improve lazy loading a closure can be registered which will be called in case
  70. * activity consumers are actually requested
  71. *
  72. * $callable has to return an instance of \OCP\Activity\IConsumer
  73. *
  74. * @param \Closure $callable
  75. * @return void
  76. * @since 6.0.0
  77. */
  78. public function registerConsumer(\Closure $callable);
  79. /**
  80. * In order to improve lazy loading a closure can be registered which will be called in case
  81. * activity consumers are actually requested
  82. *
  83. * $callable has to return an instance of \OCP\Activity\IExtension
  84. *
  85. * @param \Closure $callable
  86. * @return void
  87. * @since 8.0.0
  88. */
  89. public function registerExtension(\Closure $callable);
  90. /**
  91. * @param string $filter Class must implement OCA\Activity\IFilter
  92. * @return void
  93. * @since 11.0.0
  94. */
  95. public function registerFilter($filter);
  96. /**
  97. * @return IFilter[]
  98. * @since 11.0.0
  99. */
  100. public function getFilters();
  101. /**
  102. * @param string $id
  103. * @return IFilter
  104. * @throws \InvalidArgumentException when the filter was not found
  105. * @since 11.0.0
  106. */
  107. public function getFilterById($id);
  108. /**
  109. * @param string $setting Class must implement OCA\Activity\ISetting
  110. * @return void
  111. * @since 11.0.0
  112. */
  113. public function registerSetting($setting);
  114. /**
  115. * @return ISetting[]
  116. * @since 11.0.0
  117. */
  118. public function getSettings();
  119. /**
  120. * @param string $provider Class must implement OCA\Activity\IProvider
  121. * @return void
  122. * @since 11.0.0
  123. */
  124. public function registerProvider($provider);
  125. /**
  126. * @return IProvider[]
  127. * @since 11.0.0
  128. */
  129. public function getProviders();
  130. /**
  131. * @param string $id
  132. * @return ISetting
  133. * @throws \InvalidArgumentException when the setting was not found
  134. * @since 11.0.0
  135. */
  136. public function getSettingById($id);
  137. /**
  138. * Will return additional notification types as specified by other apps
  139. *
  140. * @param string $languageCode
  141. * @return array Array "stringID of the type" => "translated string description for the setting"
  142. * or Array "stringID of the type" => [
  143. * 'desc' => "translated string description for the setting"
  144. * 'methods' => [\OCP\Activity\IExtension::METHOD_*],
  145. * ]
  146. * @since 8.0.0 - 8.2.0: Added support to allow limiting notifications to certain methods
  147. * @deprecated 11.0.0 - Use getSettings() instead
  148. */
  149. public function getNotificationTypes($languageCode);
  150. /**
  151. * @param string $method
  152. * @return array
  153. * @since 8.0.0
  154. * @deprecated 11.0.0 - Use getSettings()->isDefaulEnabled<method>() instead
  155. */
  156. public function getDefaultTypes($method);
  157. /**
  158. * @param string $type
  159. * @return string
  160. * @since 8.0.0
  161. */
  162. public function getTypeIcon($type);
  163. /**
  164. * @param string $type
  165. * @param int $id
  166. * @since 8.2.0
  167. */
  168. public function setFormattingObject($type, $id);
  169. /**
  170. * @return bool
  171. * @since 8.2.0
  172. */
  173. public function isFormattingFilteredObject();
  174. /**
  175. * @param bool $status Set to true, when parsing events should not use SVG icons
  176. * @since 12.0.1
  177. */
  178. public function setRequirePNG($status);
  179. /**
  180. * @return bool
  181. * @since 12.0.1
  182. */
  183. public function getRequirePNG();
  184. /**
  185. * @param string $app
  186. * @param string $text
  187. * @param array $params
  188. * @param boolean $stripPath
  189. * @param boolean $highlightParams
  190. * @param string $languageCode
  191. * @return string|false
  192. * @since 8.0.0
  193. */
  194. public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode);
  195. /**
  196. * @param string $app
  197. * @param string $text
  198. * @return array|false
  199. * @since 8.0.0
  200. */
  201. public function getSpecialParameterList($app, $text);
  202. /**
  203. * @param array $activity
  204. * @return integer|false
  205. * @since 8.0.0
  206. */
  207. public function getGroupParameter($activity);
  208. /**
  209. * Set the user we need to use
  210. *
  211. * @param string|null $currentUserId
  212. * @throws \UnexpectedValueException If the user is invalid
  213. * @since 9.0.1
  214. */
  215. public function setCurrentUserId($currentUserId);
  216. /**
  217. * Get the user we need to use
  218. *
  219. * Either the user is logged in, or we try to get it from the token
  220. *
  221. * @return string
  222. * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
  223. * @since 8.1.0
  224. */
  225. public function getCurrentUserId();
  226. /**
  227. * @return array
  228. * @since 8.0.0
  229. * @deprecated 11.0.0 - Use getFilters() instead
  230. */
  231. public function getNavigation();
  232. /**
  233. * @param string $filterValue
  234. * @return boolean
  235. * @since 8.0.0
  236. * @deprecated 11.0.0 - Use getFilterById() instead
  237. */
  238. public function isFilterValid($filterValue);
  239. /**
  240. * @param array $types
  241. * @param string $filter
  242. * @return array
  243. * @since 8.0.0
  244. * @deprecated 11.0.0 - Use getFilterById()->filterTypes() instead
  245. */
  246. public function filterNotificationTypes($types, $filter);
  247. /**
  248. * @param string $filter
  249. * @return array
  250. * @since 8.0.0
  251. * @deprecated 11.0.0 - Use getFilterById() instead
  252. */
  253. public function getQueryForFilter($filter);
  254. }