You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IAppManager.php 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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 $appId
  47. * @return mixed
  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. * Check if an app is enabled for user
  62. *
  63. * @param string $appId
  64. * @param \OCP\IUser $user (optional) if not defined, the currently loggedin user will be used
  65. * @return bool
  66. * @since 8.0.0
  67. */
  68. public function isEnabledForUser($appId, $user = null);
  69. /**
  70. * Check if an app is enabled in the instance
  71. *
  72. * Notice: This actually checks if the app is enabled and not only if it is installed.
  73. *
  74. * @param string $appId
  75. * @return bool
  76. * @since 8.0.0
  77. */
  78. public function isInstalled($appId);
  79. /**
  80. * Check if an app should be enabled by default
  81. *
  82. * Notice: This actually checks if the app should be enabled by default
  83. * and not if currently installed/enabled
  84. *
  85. * @param string $appId ID of the app
  86. * @since 25.0.0
  87. */
  88. public function isDefaultEnabled(string $appId):bool;
  89. /**
  90. * Load an app, if not already loaded
  91. * @param string $app app id
  92. * @since 27.0.0
  93. */
  94. public function loadApp(string $app): void;
  95. /**
  96. * Check if an app is loaded
  97. * @param string $app app id
  98. * @since 27.0.0
  99. */
  100. public function isAppLoaded(string $app): bool;
  101. /**
  102. * Enable an app for every user
  103. *
  104. * @param string $appId
  105. * @param bool $forceEnable
  106. * @throws AppPathNotFoundException
  107. * @since 8.0.0
  108. */
  109. public function enableApp(string $appId, bool $forceEnable = false): void;
  110. /**
  111. * Whether a list of types contains a protected app type
  112. *
  113. * @param string[] $types
  114. * @return bool
  115. * @since 12.0.0
  116. */
  117. public function hasProtectedAppType($types);
  118. /**
  119. * Enable an app only for specific groups
  120. *
  121. * @param string $appId
  122. * @param \OCP\IGroup[] $groups
  123. * @param bool $forceEnable
  124. * @throws \Exception
  125. * @since 8.0.0
  126. */
  127. public function enableAppForGroups(string $appId, array $groups, bool $forceEnable = false): void;
  128. /**
  129. * Disable an app for every user
  130. *
  131. * @param string $appId
  132. * @param bool $automaticDisabled
  133. * @since 8.0.0
  134. */
  135. public function disableApp($appId, $automaticDisabled = false);
  136. /**
  137. * Get the directory for the given app.
  138. *
  139. * @param string $appId
  140. * @return string
  141. * @since 11.0.0
  142. * @throws AppPathNotFoundException
  143. */
  144. public function getAppPath($appId);
  145. /**
  146. * Get the web path for the given app.
  147. *
  148. * @param string $appId
  149. * @return string
  150. * @since 18.0.0
  151. * @throws AppPathNotFoundException
  152. */
  153. public function getAppWebPath(string $appId): string;
  154. /**
  155. * List all apps enabled for a user
  156. *
  157. * @param \OCP\IUser $user
  158. * @return string[]
  159. * @since 8.1.0
  160. */
  161. public function getEnabledAppsForUser(IUser $user);
  162. /**
  163. * List all installed apps
  164. *
  165. * @return string[]
  166. * @since 8.1.0
  167. */
  168. public function getInstalledApps();
  169. /**
  170. * Clear the cached list of apps when enabling/disabling an app
  171. * @since 8.1.0
  172. */
  173. public function clearAppsCache();
  174. /**
  175. * @param string $appId
  176. * @return boolean
  177. * @since 9.0.0
  178. */
  179. public function isShipped($appId);
  180. /**
  181. * Loads all apps
  182. *
  183. * @param string[] $types
  184. * @return bool
  185. *
  186. * This function walks through the Nextcloud directory and loads all apps
  187. * it can find. A directory contains an app if the file /appinfo/info.xml
  188. * exists.
  189. *
  190. * if $types is set to non-empty array, only apps of those types will be loaded
  191. * @since 27.0.0
  192. */
  193. public function loadApps(array $types = []): bool;
  194. /**
  195. * Check if an app is of a specific type
  196. * @since 27.0.0
  197. */
  198. public function isType(string $app, array $types): bool;
  199. /**
  200. * @return string[]
  201. * @since 9.0.0
  202. */
  203. public function getAlwaysEnabledApps();
  204. /**
  205. * @return string[] app IDs
  206. * @since 25.0.0
  207. */
  208. public function getDefaultEnabledApps(): array;
  209. /**
  210. * @param \OCP\IGroup $group
  211. * @return String[]
  212. * @since 17.0.0
  213. */
  214. public function getEnabledAppsForGroup(IGroup $group): array;
  215. /**
  216. * @param String $appId
  217. * @return string[]
  218. * @since 17.0.0
  219. */
  220. public function getAppRestriction(string $appId): array;
  221. /**
  222. * Returns the id of the user's default app
  223. *
  224. * If `user` is not passed, the currently logged in user will be used
  225. *
  226. * @param ?IUser $user User to query default app for
  227. * @param bool $withFallbacks Include fallback values if no default app was configured manually
  228. *
  229. * @since 25.0.6
  230. * @since 28.0.0 Added optional $withFallbacks parameter
  231. */
  232. public function getDefaultAppForUser(?IUser $user = null, bool $withFallbacks = true): string;
  233. /**
  234. * Get the global default apps with fallbacks
  235. *
  236. * @return string[] The default applications
  237. * @since 28.0.0
  238. */
  239. public function getDefaultApps(): array;
  240. /**
  241. * Set the global default apps with fallbacks
  242. *
  243. * @param string[] $appId
  244. * @throws \InvalidArgumentException If any of the apps is not installed
  245. * @since 28.0.0
  246. */
  247. public function setDefaultApps(array $defaultApps): void;
  248. }