IAppManager.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. * Enable an app for every user
  91. *
  92. * @param string $appId
  93. * @param bool $forceEnable
  94. * @throws AppPathNotFoundException
  95. * @since 8.0.0
  96. */
  97. public function enableApp(string $appId, bool $forceEnable = false): void;
  98. /**
  99. * Whether a list of types contains a protected app type
  100. *
  101. * @param string[] $types
  102. * @return bool
  103. * @since 12.0.0
  104. */
  105. public function hasProtectedAppType($types);
  106. /**
  107. * Enable an app only for specific groups
  108. *
  109. * @param string $appId
  110. * @param \OCP\IGroup[] $groups
  111. * @param bool $forceEnable
  112. * @throws \Exception
  113. * @since 8.0.0
  114. */
  115. public function enableAppForGroups(string $appId, array $groups, bool $forceEnable = false): void;
  116. /**
  117. * Disable an app for every user
  118. *
  119. * @param string $appId
  120. * @param bool $automaticDisabled
  121. * @since 8.0.0
  122. */
  123. public function disableApp($appId, $automaticDisabled = false);
  124. /**
  125. * Get the directory for the given app.
  126. *
  127. * @param string $appId
  128. * @return string
  129. * @since 11.0.0
  130. * @throws AppPathNotFoundException
  131. */
  132. public function getAppPath($appId);
  133. /**
  134. * Get the web path for the given app.
  135. *
  136. * @param string $appId
  137. * @return string
  138. * @since 18.0.0
  139. * @throws AppPathNotFoundException
  140. */
  141. public function getAppWebPath(string $appId): string;
  142. /**
  143. * List all apps enabled for a user
  144. *
  145. * @param \OCP\IUser $user
  146. * @return string[]
  147. * @since 8.1.0
  148. */
  149. public function getEnabledAppsForUser(IUser $user);
  150. /**
  151. * List all installed apps
  152. *
  153. * @return string[]
  154. * @since 8.1.0
  155. */
  156. public function getInstalledApps();
  157. /**
  158. * Clear the cached list of apps when enabling/disabling an app
  159. * @since 8.1.0
  160. */
  161. public function clearAppsCache();
  162. /**
  163. * @param string $appId
  164. * @return boolean
  165. * @since 9.0.0
  166. */
  167. public function isShipped($appId);
  168. /**
  169. * @return string[]
  170. * @since 9.0.0
  171. */
  172. public function getAlwaysEnabledApps();
  173. /**
  174. * @return string[] app IDs
  175. * @since 25.0.0
  176. */
  177. public function getDefaultEnabledApps(): array;
  178. /**
  179. * @param \OCP\IGroup $group
  180. * @return String[]
  181. * @since 17.0.0
  182. */
  183. public function getEnabledAppsForGroup(IGroup $group): array;
  184. /**
  185. * @param String $appId
  186. * @return string[]
  187. * @since 17.0.0
  188. */
  189. public function getAppRestriction(string $appId): array;
  190. /**
  191. * Returns the id of the user's default app
  192. *
  193. * If `user` is not passed, the currently logged in user will be used
  194. *
  195. * @since 25.0.6
  196. */
  197. public function getDefaultAppForUser(?IUser $user = null): string;
  198. }