IAppManager.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCP\App;
  8. use OCP\IGroup;
  9. use OCP\IUser;
  10. /**
  11. * Interface IAppManager
  12. *
  13. * @warning This interface shouldn't be included with dependency injection in
  14. * classes used for installing Nextcloud.
  15. *
  16. * @since 8.0.0
  17. */
  18. interface IAppManager {
  19. /**
  20. * @since 30.0.0
  21. */
  22. public const BACKEND_CALDAV = 'caldav';
  23. /**
  24. * Returns the app information from "appinfo/info.xml".
  25. *
  26. * @param string|null $lang
  27. * @return array|null
  28. * @since 14.0.0
  29. */
  30. public function getAppInfo(string $appId, bool $path = false, $lang = null);
  31. /**
  32. * Returns the app information from "appinfo/info.xml".
  33. *
  34. * @param string $appId
  35. * @param bool $useCache
  36. * @return string
  37. * @since 14.0.0
  38. */
  39. public function getAppVersion(string $appId, bool $useCache = true): string;
  40. /**
  41. * Returns the app icon or null if none is found
  42. *
  43. * @param string $appId
  44. * @param bool $dark Enable to request a dark icon variant, default is a white icon
  45. * @return string|null
  46. * @since 29.0.0
  47. */
  48. public function getAppIcon(string $appId, bool $dark = false): ?string;
  49. /**
  50. * Check if an app is enabled for user
  51. *
  52. * @param string $appId
  53. * @param \OCP\IUser|null $user (optional) if not defined, the currently loggedin user will be used
  54. * @return bool
  55. * @since 8.0.0
  56. */
  57. public function isEnabledForUser($appId, $user = null);
  58. /**
  59. * Check if an app is enabled in the instance
  60. *
  61. * Notice: This actually checks if the app is enabled and not only if it is installed.
  62. *
  63. * @param string $appId
  64. * @return bool
  65. * @since 8.0.0
  66. */
  67. public function isInstalled($appId);
  68. /**
  69. * Check if an app should be enabled by default
  70. *
  71. * Notice: This actually checks if the app should be enabled by default
  72. * and not if currently installed/enabled
  73. *
  74. * @param string $appId ID of the app
  75. * @since 25.0.0
  76. */
  77. public function isDefaultEnabled(string $appId):bool;
  78. /**
  79. * Load an app, if not already loaded
  80. * @param string $app app id
  81. * @since 27.0.0
  82. */
  83. public function loadApp(string $app): void;
  84. /**
  85. * Check if an app is loaded
  86. * @param string $app app id
  87. * @since 27.0.0
  88. */
  89. public function isAppLoaded(string $app): bool;
  90. /**
  91. * Enable an app for every user
  92. *
  93. * @param string $appId
  94. * @param bool $forceEnable
  95. * @throws AppPathNotFoundException
  96. * @since 8.0.0
  97. */
  98. public function enableApp(string $appId, bool $forceEnable = false): void;
  99. /**
  100. * Whether a list of types contains a protected app type
  101. *
  102. * @param string[] $types
  103. * @return bool
  104. * @since 12.0.0
  105. */
  106. public function hasProtectedAppType($types);
  107. /**
  108. * Enable an app only for specific groups
  109. *
  110. * @param string $appId
  111. * @param \OCP\IGroup[] $groups
  112. * @param bool $forceEnable
  113. * @throws \Exception
  114. * @since 8.0.0
  115. */
  116. public function enableAppForGroups(string $appId, array $groups, bool $forceEnable = false): void;
  117. /**
  118. * Disable an app for every user
  119. *
  120. * @param string $appId
  121. * @param bool $automaticDisabled
  122. * @since 8.0.0
  123. */
  124. public function disableApp($appId, $automaticDisabled = false);
  125. /**
  126. * Get the directory for the given app.
  127. *
  128. * @since 11.0.0
  129. * @throws AppPathNotFoundException
  130. */
  131. public function getAppPath(string $appId): string;
  132. /**
  133. * Get the web path for the given app.
  134. *
  135. * @param string $appId
  136. * @return string
  137. * @since 18.0.0
  138. * @throws AppPathNotFoundException
  139. */
  140. public function getAppWebPath(string $appId): string;
  141. /**
  142. * List all apps enabled for a user
  143. *
  144. * @param \OCP\IUser $user
  145. * @return string[]
  146. * @since 8.1.0
  147. */
  148. public function getEnabledAppsForUser(IUser $user);
  149. /**
  150. * List all installed apps
  151. *
  152. * @return string[]
  153. * @since 8.1.0
  154. */
  155. public function getInstalledApps();
  156. /**
  157. * Clear the cached list of apps when enabling/disabling an app
  158. * @since 8.1.0
  159. */
  160. public function clearAppsCache();
  161. /**
  162. * @param string $appId
  163. * @return boolean
  164. * @since 9.0.0
  165. */
  166. public function isShipped($appId);
  167. /**
  168. * Loads all apps
  169. *
  170. * @param string[] $types
  171. * @return bool
  172. *
  173. * This function walks through the Nextcloud directory and loads all apps
  174. * it can find. A directory contains an app if the file /appinfo/info.xml
  175. * exists.
  176. *
  177. * if $types is set to non-empty array, only apps of those types will be loaded
  178. * @since 27.0.0
  179. */
  180. public function loadApps(array $types = []): bool;
  181. /**
  182. * Check if an app is of a specific type
  183. * @since 27.0.0
  184. */
  185. public function isType(string $app, array $types): bool;
  186. /**
  187. * @return string[]
  188. * @since 9.0.0
  189. */
  190. public function getAlwaysEnabledApps();
  191. /**
  192. * @return string[] app IDs
  193. * @since 25.0.0
  194. */
  195. public function getDefaultEnabledApps(): array;
  196. /**
  197. * @param \OCP\IGroup $group
  198. * @return String[]
  199. * @since 17.0.0
  200. */
  201. public function getEnabledAppsForGroup(IGroup $group): array;
  202. /**
  203. * @param String $appId
  204. * @return string[]
  205. * @since 17.0.0
  206. */
  207. public function getAppRestriction(string $appId): array;
  208. /**
  209. * Returns the id of the user's default app
  210. *
  211. * If `user` is not passed, the currently logged in user will be used
  212. *
  213. * @param ?IUser $user User to query default app for
  214. * @param bool $withFallbacks Include fallback values if no default app was configured manually
  215. * Before falling back to predefined default apps,
  216. * the user defined app order is considered and the first app would be used as the fallback.
  217. *
  218. * @since 25.0.6
  219. * @since 28.0.0 Added optional $withFallbacks parameter
  220. * @deprecated 31.0.0
  221. * Use @see \OCP\INavigationManager::getDefaultEntryIdForUser() instead
  222. */
  223. public function getDefaultAppForUser(?IUser $user = null, bool $withFallbacks = true): string;
  224. /**
  225. * Get the global default apps with fallbacks
  226. *
  227. * @return string[] The default applications
  228. * @since 28.0.0
  229. * @deprecated 31.0.0
  230. * Use @see \OCP\INavigationManager::getDefaultEntryIds() instead
  231. */
  232. public function getDefaultApps(): array;
  233. /**
  234. * Set the global default apps with fallbacks
  235. *
  236. * @param string[] $appId
  237. * @throws \InvalidArgumentException If any of the apps is not installed
  238. * @since 28.0.0
  239. * @deprecated 31.0.0
  240. * Use @see \OCP\INavigationManager::setDefaultEntryIds() instead
  241. */
  242. public function setDefaultApps(array $defaultApps): void;
  243. /**
  244. * Check whether the given backend is required by at least one app.
  245. *
  246. * @param self::BACKEND_* $backend Name of the backend, one of `self::BACKEND_*`
  247. * @return bool True if at least one app requires the backend
  248. *
  249. * @since 30.0.0
  250. */
  251. public function isBackendRequired(string $backend): bool;
  252. /**
  253. * Clean the appId from forbidden characters
  254. *
  255. * @psalm-taint-escape file
  256. * @psalm-taint-escape include
  257. * @psalm-taint-escape html
  258. * @psalm-taint-escape has_quotes
  259. *
  260. * @since 31.0.0
  261. */
  262. public function cleanAppId(string $app): string;
  263. /**
  264. * Get a list of all apps in the apps folder
  265. *
  266. * @return list<string> an array of app names (string IDs)
  267. * @since 31.0.0
  268. */
  269. public function getAllAppsInAppsFolders(): array;
  270. }