IManager.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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. * @param string $app The app where this event is associated with
  70. * @param string $subject A short description of the event
  71. * @param array $subjectParams Array with parameters that are filled in the subject
  72. * @param string $message A longer description of the event
  73. * @param array $messageParams Array with parameters that are filled in the message
  74. * @param string $file The file including path where this event is associated with
  75. * @param string $link A link where this event is associated with
  76. * @param string $affectedUser Recipient of the activity
  77. * @param string $type Type of the notification
  78. * @param int $priority Priority of the notification
  79. * @since 6.0.0
  80. * @deprecated 8.2.0 Grab an IEvent from generateEvent() instead and use the publish() method
  81. */
  82. public function publishActivity($app, $subject, $subjectParams, $message, $messageParams, $file, $link, $affectedUser, $type, $priority);
  83. /**
  84. * In order to improve lazy loading a closure can be registered which will be called in case
  85. * activity consumers are actually requested
  86. *
  87. * $callable has to return an instance of \OCP\Activity\IConsumer
  88. *
  89. * @param \Closure $callable
  90. * @return void
  91. * @since 6.0.0
  92. */
  93. public function registerConsumer(\Closure $callable);
  94. /**
  95. * In order to improve lazy loading a closure can be registered which will be called in case
  96. * activity consumers are actually requested
  97. *
  98. * $callable has to return an instance of \OCP\Activity\IExtension
  99. *
  100. * @param \Closure $callable
  101. * @return void
  102. * @since 8.0.0
  103. */
  104. public function registerExtension(\Closure $callable);
  105. /**
  106. * @param string $filter Class must implement OCA\Activity\IFilter
  107. * @return void
  108. * @since 11.0.0
  109. */
  110. public function registerFilter($filter);
  111. /**
  112. * @return IFilter[]
  113. * @since 11.0.0
  114. */
  115. public function getFilters();
  116. /**
  117. * @param string $id
  118. * @return IFilter
  119. * @throws \InvalidArgumentException when the filter was not found
  120. * @since 11.0.0
  121. */
  122. public function getFilterById($id);
  123. /**
  124. * @param string $setting Class must implement OCA\Activity\ISetting
  125. * @return void
  126. * @since 11.0.0
  127. */
  128. public function registerSetting($setting);
  129. /**
  130. * @return ISetting[]
  131. * @since 11.0.0
  132. */
  133. public function getSettings();
  134. /**
  135. * @param string $provider Class must implement OCA\Activity\IProvider
  136. * @return void
  137. * @since 11.0.0
  138. */
  139. public function registerProvider($provider);
  140. /**
  141. * @return IProvider[]
  142. * @since 11.0.0
  143. */
  144. public function getProviders();
  145. /**
  146. * @param string $id
  147. * @return ISetting
  148. * @throws \InvalidArgumentException when the setting was not found
  149. * @since 11.0.0
  150. */
  151. public function getSettingById($id);
  152. /**
  153. * Will return additional notification types as specified by other apps
  154. *
  155. * @param string $languageCode
  156. * @return array Array "stringID of the type" => "translated string description for the setting"
  157. * or Array "stringID of the type" => [
  158. * 'desc' => "translated string description for the setting"
  159. * 'methods' => [\OCP\Activity\IExtension::METHOD_*],
  160. * ]
  161. * @since 8.0.0 - 8.2.0: Added support to allow limiting notifications to certain methods
  162. * @deprecated 11.0.0 - Use getSettings() instead
  163. */
  164. public function getNotificationTypes($languageCode);
  165. /**
  166. * @param string $method
  167. * @return array
  168. * @since 8.0.0
  169. * @deprecated 11.0.0 - Use getSettings()->isDefaulEnabled<method>() instead
  170. */
  171. public function getDefaultTypes($method);
  172. /**
  173. * @param string $type
  174. * @return string
  175. * @since 8.0.0
  176. */
  177. public function getTypeIcon($type);
  178. /**
  179. * @param string $type
  180. * @param int $id
  181. * @since 8.2.0
  182. */
  183. public function setFormattingObject($type, $id);
  184. /**
  185. * @return bool
  186. * @since 8.2.0
  187. */
  188. public function isFormattingFilteredObject();
  189. /**
  190. * @param bool $status Set to true, when parsing events should not use SVG icons
  191. * @since 12.0.1
  192. */
  193. public function setRequirePNG($status);
  194. /**
  195. * @return bool
  196. * @since 12.0.1
  197. */
  198. public function getRequirePNG();
  199. /**
  200. * @param string $app
  201. * @param string $text
  202. * @param array $params
  203. * @param boolean $stripPath
  204. * @param boolean $highlightParams
  205. * @param string $languageCode
  206. * @return string|false
  207. * @since 8.0.0
  208. */
  209. public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode);
  210. /**
  211. * @param string $app
  212. * @param string $text
  213. * @return array|false
  214. * @since 8.0.0
  215. */
  216. public function getSpecialParameterList($app, $text);
  217. /**
  218. * @param array $activity
  219. * @return integer|false
  220. * @since 8.0.0
  221. */
  222. public function getGroupParameter($activity);
  223. /**
  224. * Set the user we need to use
  225. *
  226. * @param string|null $currentUserId
  227. * @throws \UnexpectedValueException If the user is invalid
  228. * @since 9.0.1
  229. */
  230. public function setCurrentUserId($currentUserId);
  231. /**
  232. * Get the user we need to use
  233. *
  234. * Either the user is logged in, or we try to get it from the token
  235. *
  236. * @return string
  237. * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
  238. * @since 8.1.0
  239. */
  240. public function getCurrentUserId();
  241. /**
  242. * @return array
  243. * @since 8.0.0
  244. * @deprecated 11.0.0 - Use getFilters() instead
  245. */
  246. public function getNavigation();
  247. /**
  248. * @param string $filterValue
  249. * @return boolean
  250. * @since 8.0.0
  251. * @deprecated 11.0.0 - Use getFilterById() instead
  252. */
  253. public function isFilterValid($filterValue);
  254. /**
  255. * @param array $types
  256. * @param string $filter
  257. * @return array
  258. * @since 8.0.0
  259. * @deprecated 11.0.0 - Use getFilterById()->filterTypes() instead
  260. */
  261. public function filterNotificationTypes($types, $filter);
  262. /**
  263. * @param string $filter
  264. * @return array
  265. * @since 8.0.0
  266. * @deprecated 11.0.0 - Use getFilterById() instead
  267. */
  268. public function getQueryForFilter($filter);
  269. }