IManager.php 7.5 KB

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