IAppManager.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Daniel Rudolf <github.com@daniel-rudolf.de>
  6. * @author Greta Doci <gretadoci@gmail.com>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Julius Haertl <jus@bitgrid.net>
  9. * @author Julius Härtl <jus@bitgrid.net>
  10. * @author Lukas Reschke <lukas@statuscode.ch>
  11. * @author Morris Jobke <hey@morrisjobke.de>
  12. * @author Robin Appelman <robin@icewind.nl>
  13. * @author Roeland Jago Douma <roeland@famdouma.nl>
  14. * @author Thomas Müller <thomas.mueller@tmit.eu>
  15. *
  16. * @license AGPL-3.0
  17. *
  18. * This code is free software: you can redistribute it and/or modify
  19. * it under the terms of the GNU Affero General Public License, version 3,
  20. * as published by the Free Software Foundation.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU Affero General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU Affero General Public License, version 3,
  28. * along with this program. If not, see <http://www.gnu.org/licenses/>
  29. *
  30. */
  31. namespace OCP\App;
  32. use OCP\IGroup;
  33. use OCP\IUser;
  34. /**
  35. * Interface IAppManager
  36. *
  37. * @warning This interface shouldn't be included with dependency injection in
  38. * classes used for installing Nextcloud.
  39. *
  40. * @since 8.0.0
  41. */
  42. interface IAppManager {
  43. /**
  44. * Returns the app information from "appinfo/info.xml".
  45. *
  46. * @param string|null $lang
  47. * @return array|null
  48. * @since 14.0.0
  49. */
  50. public function getAppInfo(string $appId, bool $path = false, $lang = null);
  51. /**
  52. * Returns the app information from "appinfo/info.xml".
  53. *
  54. * @param string $appId
  55. * @param bool $useCache
  56. * @return string
  57. * @since 14.0.0
  58. */
  59. public function getAppVersion(string $appId, bool $useCache = true): string;
  60. /**
  61. * Returns the app icon or null if none is found
  62. *
  63. * @param string $appId
  64. * @param bool $dark Enable to request a dark icon variant, default is a white icon
  65. * @return string|null
  66. * @since 29.0.0
  67. */
  68. public function getAppIcon(string $appId, bool $dark = false): string|null;
  69. /**
  70. * Check if an app is enabled for user
  71. *
  72. * @param string $appId
  73. * @param \OCP\IUser|null $user (optional) if not defined, the currently loggedin user will be used
  74. * @return bool
  75. * @since 8.0.0
  76. */
  77. public function isEnabledForUser($appId, $user = null);
  78. /**
  79. * Check if an app is enabled in the instance
  80. *
  81. * Notice: This actually checks if the app is enabled and not only if it is installed.
  82. *
  83. * @param string $appId
  84. * @return bool
  85. * @since 8.0.0
  86. */
  87. public function isInstalled($appId);
  88. /**
  89. * Check if an app should be enabled by default
  90. *
  91. * Notice: This actually checks if the app should be enabled by default
  92. * and not if currently installed/enabled
  93. *
  94. * @param string $appId ID of the app
  95. * @since 25.0.0
  96. */
  97. public function isDefaultEnabled(string $appId):bool;
  98. /**
  99. * Load an app, if not already loaded
  100. * @param string $app app id
  101. * @since 27.0.0
  102. */
  103. public function loadApp(string $app): void;
  104. /**
  105. * Check if an app is loaded
  106. * @param string $app app id
  107. * @since 27.0.0
  108. */
  109. public function isAppLoaded(string $app): bool;
  110. /**
  111. * Enable an app for every user
  112. *
  113. * @param string $appId
  114. * @param bool $forceEnable
  115. * @throws AppPathNotFoundException
  116. * @since 8.0.0
  117. */
  118. public function enableApp(string $appId, bool $forceEnable = false): void;
  119. /**
  120. * Whether a list of types contains a protected app type
  121. *
  122. * @param string[] $types
  123. * @return bool
  124. * @since 12.0.0
  125. */
  126. public function hasProtectedAppType($types);
  127. /**
  128. * Enable an app only for specific groups
  129. *
  130. * @param string $appId
  131. * @param \OCP\IGroup[] $groups
  132. * @param bool $forceEnable
  133. * @throws \Exception
  134. * @since 8.0.0
  135. */
  136. public function enableAppForGroups(string $appId, array $groups, bool $forceEnable = false): void;
  137. /**
  138. * Disable an app for every user
  139. *
  140. * @param string $appId
  141. * @param bool $automaticDisabled
  142. * @since 8.0.0
  143. */
  144. public function disableApp($appId, $automaticDisabled = false);
  145. /**
  146. * Get the directory for the given app.
  147. *
  148. * @param string $appId
  149. * @return string
  150. * @since 11.0.0
  151. * @throws AppPathNotFoundException
  152. */
  153. public function getAppPath($appId);
  154. /**
  155. * Get the web path for the given app.
  156. *
  157. * @param string $appId
  158. * @return string
  159. * @since 18.0.0
  160. * @throws AppPathNotFoundException
  161. */
  162. public function getAppWebPath(string $appId): string;
  163. /**
  164. * List all apps enabled for a user
  165. *
  166. * @param \OCP\IUser $user
  167. * @return string[]
  168. * @since 8.1.0
  169. */
  170. public function getEnabledAppsForUser(IUser $user);
  171. /**
  172. * List all installed apps
  173. *
  174. * @return string[]
  175. * @since 8.1.0
  176. */
  177. public function getInstalledApps();
  178. /**
  179. * Clear the cached list of apps when enabling/disabling an app
  180. * @since 8.1.0
  181. */
  182. public function clearAppsCache();
  183. /**
  184. * @param string $appId
  185. * @return boolean
  186. * @since 9.0.0
  187. */
  188. public function isShipped($appId);
  189. /**
  190. * Loads all apps
  191. *
  192. * @param string[] $types
  193. * @return bool
  194. *
  195. * This function walks through the Nextcloud directory and loads all apps
  196. * it can find. A directory contains an app if the file /appinfo/info.xml
  197. * exists.
  198. *
  199. * if $types is set to non-empty array, only apps of those types will be loaded
  200. * @since 27.0.0
  201. */
  202. public function loadApps(array $types = []): bool;
  203. /**
  204. * Check if an app is of a specific type
  205. * @since 27.0.0
  206. */
  207. public function isType(string $app, array $types): bool;
  208. /**
  209. * @return string[]
  210. * @since 9.0.0
  211. */
  212. public function getAlwaysEnabledApps();
  213. /**
  214. * @return string[] app IDs
  215. * @since 25.0.0
  216. */
  217. public function getDefaultEnabledApps(): array;
  218. /**
  219. * @param \OCP\IGroup $group
  220. * @return String[]
  221. * @since 17.0.0
  222. */
  223. public function getEnabledAppsForGroup(IGroup $group): array;
  224. /**
  225. * @param String $appId
  226. * @return string[]
  227. * @since 17.0.0
  228. */
  229. public function getAppRestriction(string $appId): array;
  230. /**
  231. * Returns the id of the user's default app
  232. *
  233. * If `user` is not passed, the currently logged in user will be used
  234. *
  235. * @param ?IUser $user User to query default app for
  236. * @param bool $withFallbacks Include fallback values if no default app was configured manually
  237. * Before falling back to predefined default apps,
  238. * the user defined app order is considered and the first app would be used as the fallback.
  239. *
  240. * @since 25.0.6
  241. * @since 28.0.0 Added optional $withFallbacks parameter
  242. */
  243. public function getDefaultAppForUser(?IUser $user = null, bool $withFallbacks = true): string;
  244. /**
  245. * Get the global default apps with fallbacks
  246. *
  247. * @return string[] The default applications
  248. * @since 28.0.0
  249. */
  250. public function getDefaultApps(): array;
  251. /**
  252. * Set the global default apps with fallbacks
  253. *
  254. * @param string[] $appId
  255. * @throws \InvalidArgumentException If any of the apps is not installed
  256. * @since 28.0.0
  257. */
  258. public function setDefaultApps(array $defaultApps): void;
  259. }