@@ -28,7 +28,6 @@ |
||
| 28 | 28 | use \OC_App; |
| 29 | 29 | use OCP\App\AppPathNotFoundException; |
| 30 | 30 | use OCP\App\IAppManager; |
| 31 | -use OCP\AppFramework\Http; |
|
| 32 | 31 | use OCP\AppFramework\Http\DataResponse; |
| 33 | 32 | use OCP\AppFramework\OCS\OCSException; |
| 34 | 33 | use OCP\AppFramework\OCSController; |
@@ -35,91 +35,91 @@ |
||
| 35 | 35 | use OCP\IRequest; |
| 36 | 36 | |
| 37 | 37 | class AppsController extends OCSController { |
| 38 | - /** @var \OCP\App\IAppManager */ |
|
| 39 | - private $appManager; |
|
| 38 | + /** @var \OCP\App\IAppManager */ |
|
| 39 | + private $appManager; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @param string $appName |
|
| 43 | - * @param IRequest $request |
|
| 44 | - * @param IAppManager $appManager |
|
| 45 | - */ |
|
| 46 | - public function __construct( |
|
| 47 | - $appName, |
|
| 48 | - IRequest $request, |
|
| 49 | - IAppManager $appManager |
|
| 50 | - ) { |
|
| 51 | - parent::__construct($appName, $request); |
|
| 41 | + /** |
|
| 42 | + * @param string $appName |
|
| 43 | + * @param IRequest $request |
|
| 44 | + * @param IAppManager $appManager |
|
| 45 | + */ |
|
| 46 | + public function __construct( |
|
| 47 | + $appName, |
|
| 48 | + IRequest $request, |
|
| 49 | + IAppManager $appManager |
|
| 50 | + ) { |
|
| 51 | + parent::__construct($appName, $request); |
|
| 52 | 52 | |
| 53 | - $this->appManager = $appManager; |
|
| 54 | - } |
|
| 53 | + $this->appManager = $appManager; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @param string $filter |
|
| 58 | - * @return DataResponse |
|
| 59 | - * @throws OCSException |
|
| 60 | - */ |
|
| 61 | - public function getApps($filter = null) { |
|
| 62 | - $apps = (new OC_App())->listAllApps(); |
|
| 63 | - $list = []; |
|
| 64 | - foreach($apps as $app) { |
|
| 65 | - $list[] = $app['id']; |
|
| 66 | - } |
|
| 67 | - if($filter){ |
|
| 68 | - switch($filter){ |
|
| 69 | - case 'enabled': |
|
| 70 | - return new DataResponse(['apps' => \OC_App::getEnabledApps()]); |
|
| 71 | - break; |
|
| 72 | - case 'disabled': |
|
| 73 | - $enabled = OC_App::getEnabledApps(); |
|
| 74 | - return new DataResponse(['apps' => array_diff($list, $enabled)]); |
|
| 75 | - break; |
|
| 76 | - default: |
|
| 77 | - // Invalid filter variable |
|
| 78 | - throw new OCSException('', 101); |
|
| 79 | - } |
|
| 56 | + /** |
|
| 57 | + * @param string $filter |
|
| 58 | + * @return DataResponse |
|
| 59 | + * @throws OCSException |
|
| 60 | + */ |
|
| 61 | + public function getApps($filter = null) { |
|
| 62 | + $apps = (new OC_App())->listAllApps(); |
|
| 63 | + $list = []; |
|
| 64 | + foreach($apps as $app) { |
|
| 65 | + $list[] = $app['id']; |
|
| 66 | + } |
|
| 67 | + if($filter){ |
|
| 68 | + switch($filter){ |
|
| 69 | + case 'enabled': |
|
| 70 | + return new DataResponse(['apps' => \OC_App::getEnabledApps()]); |
|
| 71 | + break; |
|
| 72 | + case 'disabled': |
|
| 73 | + $enabled = OC_App::getEnabledApps(); |
|
| 74 | + return new DataResponse(['apps' => array_diff($list, $enabled)]); |
|
| 75 | + break; |
|
| 76 | + default: |
|
| 77 | + // Invalid filter variable |
|
| 78 | + throw new OCSException('', 101); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - } else { |
|
| 82 | - return new DataResponse(['apps' => $list]); |
|
| 83 | - } |
|
| 84 | - } |
|
| 81 | + } else { |
|
| 82 | + return new DataResponse(['apps' => $list]); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * @param string $app |
|
| 88 | - * @return DataResponse |
|
| 89 | - * @throws OCSException |
|
| 90 | - */ |
|
| 91 | - public function getAppInfo($app) { |
|
| 92 | - $info = \OCP\App::getAppInfo($app); |
|
| 93 | - if(!is_null($info)) { |
|
| 94 | - return new DataResponse(OC_App::getAppInfo($app)); |
|
| 95 | - } else { |
|
| 96 | - throw new OCSException('The request app was not found', \OCP\API::RESPOND_NOT_FOUND); |
|
| 97 | - } |
|
| 98 | - } |
|
| 86 | + /** |
|
| 87 | + * @param string $app |
|
| 88 | + * @return DataResponse |
|
| 89 | + * @throws OCSException |
|
| 90 | + */ |
|
| 91 | + public function getAppInfo($app) { |
|
| 92 | + $info = \OCP\App::getAppInfo($app); |
|
| 93 | + if(!is_null($info)) { |
|
| 94 | + return new DataResponse(OC_App::getAppInfo($app)); |
|
| 95 | + } else { |
|
| 96 | + throw new OCSException('The request app was not found', \OCP\API::RESPOND_NOT_FOUND); |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * @PasswordConfirmationRequired |
|
| 102 | - * @param string $app |
|
| 103 | - * @return DataResponse |
|
| 104 | - * @throws OCSException |
|
| 105 | - */ |
|
| 106 | - public function enable($app) { |
|
| 107 | - try { |
|
| 108 | - $this->appManager->enableApp($app); |
|
| 109 | - } catch (AppPathNotFoundException $e) { |
|
| 110 | - throw new OCSException('The request app was not found', \OCP\API::RESPOND_NOT_FOUND); |
|
| 111 | - } |
|
| 112 | - return new DataResponse(); |
|
| 113 | - } |
|
| 100 | + /** |
|
| 101 | + * @PasswordConfirmationRequired |
|
| 102 | + * @param string $app |
|
| 103 | + * @return DataResponse |
|
| 104 | + * @throws OCSException |
|
| 105 | + */ |
|
| 106 | + public function enable($app) { |
|
| 107 | + try { |
|
| 108 | + $this->appManager->enableApp($app); |
|
| 109 | + } catch (AppPathNotFoundException $e) { |
|
| 110 | + throw new OCSException('The request app was not found', \OCP\API::RESPOND_NOT_FOUND); |
|
| 111 | + } |
|
| 112 | + return new DataResponse(); |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * @PasswordConfirmationRequired |
|
| 117 | - * @param string $app |
|
| 118 | - * @return DataResponse |
|
| 119 | - */ |
|
| 120 | - public function disable($app) { |
|
| 121 | - $this->appManager->disableApp($app); |
|
| 122 | - return new DataResponse(); |
|
| 123 | - } |
|
| 115 | + /** |
|
| 116 | + * @PasswordConfirmationRequired |
|
| 117 | + * @param string $app |
|
| 118 | + * @return DataResponse |
|
| 119 | + */ |
|
| 120 | + public function disable($app) { |
|
| 121 | + $this->appManager->disableApp($app); |
|
| 122 | + return new DataResponse(); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | 125 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | /** |
| 122 | 122 | * List all installed apps |
| 123 | 123 | * |
| 124 | - * @return string[] |
|
| 124 | + * @return integer[] |
|
| 125 | 125 | */ |
| 126 | 126 | public function getInstalledApps() { |
| 127 | 127 | return array_keys($this->getInstalledAppsValues()); |
@@ -382,6 +382,9 @@ discard block |
||
| 382 | 382 | return in_array($appId, $this->shippedApps, true); |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | + /** |
|
| 386 | + * @param string $appId |
|
| 387 | + */ |
|
| 385 | 388 | private function isAlwaysEnabled($appId) { |
| 386 | 389 | $alwaysEnabled = $this->getAlwaysEnabledApps(); |
| 387 | 390 | return in_array($appId, $alwaysEnabled, true); |
@@ -43,367 +43,367 @@ |
||
| 43 | 43 | |
| 44 | 44 | class AppManager implements IAppManager { |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Apps with these types can not be enabled for certain groups only |
|
| 48 | - * @var string[] |
|
| 49 | - */ |
|
| 50 | - protected $protectedAppTypes = [ |
|
| 51 | - 'filesystem', |
|
| 52 | - 'prelogin', |
|
| 53 | - 'authentication', |
|
| 54 | - 'logging', |
|
| 55 | - 'prevent_group_restriction', |
|
| 56 | - ]; |
|
| 57 | - |
|
| 58 | - /** @var IUserSession */ |
|
| 59 | - private $userSession; |
|
| 60 | - |
|
| 61 | - /** @var IAppConfig */ |
|
| 62 | - private $appConfig; |
|
| 63 | - |
|
| 64 | - /** @var IGroupManager */ |
|
| 65 | - private $groupManager; |
|
| 66 | - |
|
| 67 | - /** @var ICacheFactory */ |
|
| 68 | - private $memCacheFactory; |
|
| 69 | - |
|
| 70 | - /** @var EventDispatcherInterface */ |
|
| 71 | - private $dispatcher; |
|
| 72 | - |
|
| 73 | - /** @var string[] $appId => $enabled */ |
|
| 74 | - private $installedAppsCache; |
|
| 75 | - |
|
| 76 | - /** @var string[] */ |
|
| 77 | - private $shippedApps; |
|
| 78 | - |
|
| 79 | - /** @var string[] */ |
|
| 80 | - private $alwaysEnabled; |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * @param IUserSession $userSession |
|
| 84 | - * @param IAppConfig $appConfig |
|
| 85 | - * @param IGroupManager $groupManager |
|
| 86 | - * @param ICacheFactory $memCacheFactory |
|
| 87 | - * @param EventDispatcherInterface $dispatcher |
|
| 88 | - */ |
|
| 89 | - public function __construct(IUserSession $userSession, |
|
| 90 | - IAppConfig $appConfig, |
|
| 91 | - IGroupManager $groupManager, |
|
| 92 | - ICacheFactory $memCacheFactory, |
|
| 93 | - EventDispatcherInterface $dispatcher) { |
|
| 94 | - $this->userSession = $userSession; |
|
| 95 | - $this->appConfig = $appConfig; |
|
| 96 | - $this->groupManager = $groupManager; |
|
| 97 | - $this->memCacheFactory = $memCacheFactory; |
|
| 98 | - $this->dispatcher = $dispatcher; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * @return string[] $appId => $enabled |
|
| 103 | - */ |
|
| 104 | - private function getInstalledAppsValues() { |
|
| 105 | - if (!$this->installedAppsCache) { |
|
| 106 | - $values = $this->appConfig->getValues(false, 'enabled'); |
|
| 107 | - |
|
| 108 | - $alwaysEnabledApps = $this->getAlwaysEnabledApps(); |
|
| 109 | - foreach($alwaysEnabledApps as $appId) { |
|
| 110 | - $values[$appId] = 'yes'; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $this->installedAppsCache = array_filter($values, function ($value) { |
|
| 114 | - return $value !== 'no'; |
|
| 115 | - }); |
|
| 116 | - ksort($this->installedAppsCache); |
|
| 117 | - } |
|
| 118 | - return $this->installedAppsCache; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * List all installed apps |
|
| 123 | - * |
|
| 124 | - * @return string[] |
|
| 125 | - */ |
|
| 126 | - public function getInstalledApps() { |
|
| 127 | - return array_keys($this->getInstalledAppsValues()); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * List all apps enabled for a user |
|
| 132 | - * |
|
| 133 | - * @param \OCP\IUser $user |
|
| 134 | - * @return string[] |
|
| 135 | - */ |
|
| 136 | - public function getEnabledAppsForUser(IUser $user) { |
|
| 137 | - $apps = $this->getInstalledAppsValues(); |
|
| 138 | - $appsForUser = array_filter($apps, function ($enabled) use ($user) { |
|
| 139 | - return $this->checkAppForUser($enabled, $user); |
|
| 140 | - }); |
|
| 141 | - return array_keys($appsForUser); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * Check if an app is enabled for user |
|
| 146 | - * |
|
| 147 | - * @param string $appId |
|
| 148 | - * @param \OCP\IUser $user (optional) if not defined, the currently logged in user will be used |
|
| 149 | - * @return bool |
|
| 150 | - */ |
|
| 151 | - public function isEnabledForUser($appId, $user = null) { |
|
| 152 | - if ($this->isAlwaysEnabled($appId)) { |
|
| 153 | - return true; |
|
| 154 | - } |
|
| 155 | - if ($user === null) { |
|
| 156 | - $user = $this->userSession->getUser(); |
|
| 157 | - } |
|
| 158 | - $installedApps = $this->getInstalledAppsValues(); |
|
| 159 | - if (isset($installedApps[$appId])) { |
|
| 160 | - return $this->checkAppForUser($installedApps[$appId], $user); |
|
| 161 | - } else { |
|
| 162 | - return false; |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * @param string $enabled |
|
| 168 | - * @param IUser $user |
|
| 169 | - * @return bool |
|
| 170 | - */ |
|
| 171 | - private function checkAppForUser($enabled, $user) { |
|
| 172 | - if ($enabled === 'yes') { |
|
| 173 | - return true; |
|
| 174 | - } elseif ($user === null) { |
|
| 175 | - return false; |
|
| 176 | - } else { |
|
| 177 | - if(empty($enabled)){ |
|
| 178 | - return false; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - $groupIds = json_decode($enabled); |
|
| 182 | - |
|
| 183 | - if (!is_array($groupIds)) { |
|
| 184 | - $jsonError = json_last_error(); |
|
| 185 | - \OC::$server->getLogger()->warning('AppManger::checkAppForUser - can\'t decode group IDs: ' . print_r($enabled, true) . ' - json error code: ' . $jsonError, ['app' => 'lib']); |
|
| 186 | - return false; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - $userGroups = $this->groupManager->getUserGroupIds($user); |
|
| 190 | - foreach ($userGroups as $groupId) { |
|
| 191 | - if (in_array($groupId, $groupIds, true)) { |
|
| 192 | - return true; |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - return false; |
|
| 196 | - } |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * Check if an app is installed in the instance |
|
| 201 | - * |
|
| 202 | - * @param string $appId |
|
| 203 | - * @return bool |
|
| 204 | - */ |
|
| 205 | - public function isInstalled($appId) { |
|
| 206 | - $installedApps = $this->getInstalledAppsValues(); |
|
| 207 | - return isset($installedApps[$appId]); |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * Enable an app for every user |
|
| 212 | - * |
|
| 213 | - * @param string $appId |
|
| 214 | - * @throws AppPathNotFoundException |
|
| 215 | - */ |
|
| 216 | - public function enableApp($appId) { |
|
| 217 | - // Check if app exists |
|
| 218 | - $this->getAppPath($appId); |
|
| 219 | - |
|
| 220 | - $this->installedAppsCache[$appId] = 'yes'; |
|
| 221 | - $this->appConfig->setValue($appId, 'enabled', 'yes'); |
|
| 222 | - $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent( |
|
| 223 | - ManagerEvent::EVENT_APP_ENABLE, $appId |
|
| 224 | - )); |
|
| 225 | - $this->clearAppsCache(); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - /** |
|
| 229 | - * Whether a list of types contains a protected app type |
|
| 230 | - * |
|
| 231 | - * @param string[] $types |
|
| 232 | - * @return bool |
|
| 233 | - */ |
|
| 234 | - public function hasProtectedAppType($types) { |
|
| 235 | - if (empty($types)) { |
|
| 236 | - return false; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - $protectedTypes = array_intersect($this->protectedAppTypes, $types); |
|
| 240 | - return !empty($protectedTypes); |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * Enable an app only for specific groups |
|
| 245 | - * |
|
| 246 | - * @param string $appId |
|
| 247 | - * @param \OCP\IGroup[] $groups |
|
| 248 | - * @throws \Exception if app can't be enabled for groups |
|
| 249 | - */ |
|
| 250 | - public function enableAppForGroups($appId, $groups) { |
|
| 251 | - $info = $this->getAppInfo($appId); |
|
| 252 | - if (!empty($info['types'])) { |
|
| 253 | - $protectedTypes = array_intersect($this->protectedAppTypes, $info['types']); |
|
| 254 | - if (!empty($protectedTypes)) { |
|
| 255 | - throw new \Exception("$appId can't be enabled for groups."); |
|
| 256 | - } |
|
| 257 | - } |
|
| 258 | - |
|
| 259 | - $groupIds = array_map(function ($group) { |
|
| 260 | - /** @var \OCP\IGroup $group */ |
|
| 261 | - return $group->getGID(); |
|
| 262 | - }, $groups); |
|
| 263 | - $this->installedAppsCache[$appId] = json_encode($groupIds); |
|
| 264 | - $this->appConfig->setValue($appId, 'enabled', json_encode($groupIds)); |
|
| 265 | - $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, new ManagerEvent( |
|
| 266 | - ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, $appId, $groups |
|
| 267 | - )); |
|
| 268 | - $this->clearAppsCache(); |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - /** |
|
| 272 | - * Disable an app for every user |
|
| 273 | - * |
|
| 274 | - * @param string $appId |
|
| 275 | - * @throws \Exception if app can't be disabled |
|
| 276 | - */ |
|
| 277 | - public function disableApp($appId) { |
|
| 278 | - if ($this->isAlwaysEnabled($appId)) { |
|
| 279 | - throw new \Exception("$appId can't be disabled."); |
|
| 280 | - } |
|
| 281 | - unset($this->installedAppsCache[$appId]); |
|
| 282 | - $this->appConfig->setValue($appId, 'enabled', 'no'); |
|
| 283 | - $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_DISABLE, new ManagerEvent( |
|
| 284 | - ManagerEvent::EVENT_APP_DISABLE, $appId |
|
| 285 | - )); |
|
| 286 | - $this->clearAppsCache(); |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - /** |
|
| 290 | - * Get the directory for the given app. |
|
| 291 | - * |
|
| 292 | - * @param string $appId |
|
| 293 | - * @return string |
|
| 294 | - * @throws AppPathNotFoundException if app folder can't be found |
|
| 295 | - */ |
|
| 296 | - public function getAppPath($appId) { |
|
| 297 | - $appPath = \OC_App::getAppPath($appId); |
|
| 298 | - if($appPath === false) { |
|
| 299 | - throw new AppPathNotFoundException('Could not find path for ' . $appId); |
|
| 300 | - } |
|
| 301 | - return $appPath; |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * Clear the cached list of apps when enabling/disabling an app |
|
| 306 | - */ |
|
| 307 | - public function clearAppsCache() { |
|
| 308 | - $settingsMemCache = $this->memCacheFactory->create('settings'); |
|
| 309 | - $settingsMemCache->clear('listApps'); |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - /** |
|
| 313 | - * Returns a list of apps that need upgrade |
|
| 314 | - * |
|
| 315 | - * @param string $version Nextcloud version as array of version components |
|
| 316 | - * @return array list of app info from apps that need an upgrade |
|
| 317 | - * |
|
| 318 | - * @internal |
|
| 319 | - */ |
|
| 320 | - public function getAppsNeedingUpgrade($version) { |
|
| 321 | - $appsToUpgrade = []; |
|
| 322 | - $apps = $this->getInstalledApps(); |
|
| 323 | - foreach ($apps as $appId) { |
|
| 324 | - $appInfo = $this->getAppInfo($appId); |
|
| 325 | - $appDbVersion = $this->appConfig->getValue($appId, 'installed_version'); |
|
| 326 | - if ($appDbVersion |
|
| 327 | - && isset($appInfo['version']) |
|
| 328 | - && version_compare($appInfo['version'], $appDbVersion, '>') |
|
| 329 | - && \OC_App::isAppCompatible($version, $appInfo) |
|
| 330 | - ) { |
|
| 331 | - $appsToUpgrade[] = $appInfo; |
|
| 332 | - } |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - return $appsToUpgrade; |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - /** |
|
| 339 | - * Returns the app information from "appinfo/info.xml". |
|
| 340 | - * |
|
| 341 | - * @param string $appId app id |
|
| 342 | - * |
|
| 343 | - * @return array app info |
|
| 344 | - * |
|
| 345 | - * @internal |
|
| 346 | - */ |
|
| 347 | - public function getAppInfo($appId) { |
|
| 348 | - $appInfo = \OC_App::getAppInfo($appId); |
|
| 349 | - if (!isset($appInfo['version'])) { |
|
| 350 | - // read version from separate file |
|
| 351 | - $appInfo['version'] = \OC_App::getAppVersion($appId); |
|
| 352 | - } |
|
| 353 | - return $appInfo; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * Returns a list of apps incompatible with the given version |
|
| 358 | - * |
|
| 359 | - * @param string $version Nextcloud version as array of version components |
|
| 360 | - * |
|
| 361 | - * @return array list of app info from incompatible apps |
|
| 362 | - * |
|
| 363 | - * @internal |
|
| 364 | - */ |
|
| 365 | - public function getIncompatibleApps($version) { |
|
| 366 | - $apps = $this->getInstalledApps(); |
|
| 367 | - $incompatibleApps = array(); |
|
| 368 | - foreach ($apps as $appId) { |
|
| 369 | - $info = $this->getAppInfo($appId); |
|
| 370 | - if (!\OC_App::isAppCompatible($version, $info)) { |
|
| 371 | - $incompatibleApps[] = $info; |
|
| 372 | - } |
|
| 373 | - } |
|
| 374 | - return $incompatibleApps; |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - /** |
|
| 378 | - * @inheritdoc |
|
| 379 | - */ |
|
| 380 | - public function isShipped($appId) { |
|
| 381 | - $this->loadShippedJson(); |
|
| 382 | - return in_array($appId, $this->shippedApps, true); |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - private function isAlwaysEnabled($appId) { |
|
| 386 | - $alwaysEnabled = $this->getAlwaysEnabledApps(); |
|
| 387 | - return in_array($appId, $alwaysEnabled, true); |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - private function loadShippedJson() { |
|
| 391 | - if ($this->shippedApps === null) { |
|
| 392 | - $shippedJson = \OC::$SERVERROOT . '/core/shipped.json'; |
|
| 393 | - if (!file_exists($shippedJson)) { |
|
| 394 | - throw new \Exception("File not found: $shippedJson"); |
|
| 395 | - } |
|
| 396 | - $content = json_decode(file_get_contents($shippedJson), true); |
|
| 397 | - $this->shippedApps = $content['shippedApps']; |
|
| 398 | - $this->alwaysEnabled = $content['alwaysEnabled']; |
|
| 399 | - } |
|
| 400 | - } |
|
| 401 | - |
|
| 402 | - /** |
|
| 403 | - * @inheritdoc |
|
| 404 | - */ |
|
| 405 | - public function getAlwaysEnabledApps() { |
|
| 406 | - $this->loadShippedJson(); |
|
| 407 | - return $this->alwaysEnabled; |
|
| 408 | - } |
|
| 46 | + /** |
|
| 47 | + * Apps with these types can not be enabled for certain groups only |
|
| 48 | + * @var string[] |
|
| 49 | + */ |
|
| 50 | + protected $protectedAppTypes = [ |
|
| 51 | + 'filesystem', |
|
| 52 | + 'prelogin', |
|
| 53 | + 'authentication', |
|
| 54 | + 'logging', |
|
| 55 | + 'prevent_group_restriction', |
|
| 56 | + ]; |
|
| 57 | + |
|
| 58 | + /** @var IUserSession */ |
|
| 59 | + private $userSession; |
|
| 60 | + |
|
| 61 | + /** @var IAppConfig */ |
|
| 62 | + private $appConfig; |
|
| 63 | + |
|
| 64 | + /** @var IGroupManager */ |
|
| 65 | + private $groupManager; |
|
| 66 | + |
|
| 67 | + /** @var ICacheFactory */ |
|
| 68 | + private $memCacheFactory; |
|
| 69 | + |
|
| 70 | + /** @var EventDispatcherInterface */ |
|
| 71 | + private $dispatcher; |
|
| 72 | + |
|
| 73 | + /** @var string[] $appId => $enabled */ |
|
| 74 | + private $installedAppsCache; |
|
| 75 | + |
|
| 76 | + /** @var string[] */ |
|
| 77 | + private $shippedApps; |
|
| 78 | + |
|
| 79 | + /** @var string[] */ |
|
| 80 | + private $alwaysEnabled; |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * @param IUserSession $userSession |
|
| 84 | + * @param IAppConfig $appConfig |
|
| 85 | + * @param IGroupManager $groupManager |
|
| 86 | + * @param ICacheFactory $memCacheFactory |
|
| 87 | + * @param EventDispatcherInterface $dispatcher |
|
| 88 | + */ |
|
| 89 | + public function __construct(IUserSession $userSession, |
|
| 90 | + IAppConfig $appConfig, |
|
| 91 | + IGroupManager $groupManager, |
|
| 92 | + ICacheFactory $memCacheFactory, |
|
| 93 | + EventDispatcherInterface $dispatcher) { |
|
| 94 | + $this->userSession = $userSession; |
|
| 95 | + $this->appConfig = $appConfig; |
|
| 96 | + $this->groupManager = $groupManager; |
|
| 97 | + $this->memCacheFactory = $memCacheFactory; |
|
| 98 | + $this->dispatcher = $dispatcher; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * @return string[] $appId => $enabled |
|
| 103 | + */ |
|
| 104 | + private function getInstalledAppsValues() { |
|
| 105 | + if (!$this->installedAppsCache) { |
|
| 106 | + $values = $this->appConfig->getValues(false, 'enabled'); |
|
| 107 | + |
|
| 108 | + $alwaysEnabledApps = $this->getAlwaysEnabledApps(); |
|
| 109 | + foreach($alwaysEnabledApps as $appId) { |
|
| 110 | + $values[$appId] = 'yes'; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $this->installedAppsCache = array_filter($values, function ($value) { |
|
| 114 | + return $value !== 'no'; |
|
| 115 | + }); |
|
| 116 | + ksort($this->installedAppsCache); |
|
| 117 | + } |
|
| 118 | + return $this->installedAppsCache; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * List all installed apps |
|
| 123 | + * |
|
| 124 | + * @return string[] |
|
| 125 | + */ |
|
| 126 | + public function getInstalledApps() { |
|
| 127 | + return array_keys($this->getInstalledAppsValues()); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * List all apps enabled for a user |
|
| 132 | + * |
|
| 133 | + * @param \OCP\IUser $user |
|
| 134 | + * @return string[] |
|
| 135 | + */ |
|
| 136 | + public function getEnabledAppsForUser(IUser $user) { |
|
| 137 | + $apps = $this->getInstalledAppsValues(); |
|
| 138 | + $appsForUser = array_filter($apps, function ($enabled) use ($user) { |
|
| 139 | + return $this->checkAppForUser($enabled, $user); |
|
| 140 | + }); |
|
| 141 | + return array_keys($appsForUser); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * Check if an app is enabled for user |
|
| 146 | + * |
|
| 147 | + * @param string $appId |
|
| 148 | + * @param \OCP\IUser $user (optional) if not defined, the currently logged in user will be used |
|
| 149 | + * @return bool |
|
| 150 | + */ |
|
| 151 | + public function isEnabledForUser($appId, $user = null) { |
|
| 152 | + if ($this->isAlwaysEnabled($appId)) { |
|
| 153 | + return true; |
|
| 154 | + } |
|
| 155 | + if ($user === null) { |
|
| 156 | + $user = $this->userSession->getUser(); |
|
| 157 | + } |
|
| 158 | + $installedApps = $this->getInstalledAppsValues(); |
|
| 159 | + if (isset($installedApps[$appId])) { |
|
| 160 | + return $this->checkAppForUser($installedApps[$appId], $user); |
|
| 161 | + } else { |
|
| 162 | + return false; |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * @param string $enabled |
|
| 168 | + * @param IUser $user |
|
| 169 | + * @return bool |
|
| 170 | + */ |
|
| 171 | + private function checkAppForUser($enabled, $user) { |
|
| 172 | + if ($enabled === 'yes') { |
|
| 173 | + return true; |
|
| 174 | + } elseif ($user === null) { |
|
| 175 | + return false; |
|
| 176 | + } else { |
|
| 177 | + if(empty($enabled)){ |
|
| 178 | + return false; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + $groupIds = json_decode($enabled); |
|
| 182 | + |
|
| 183 | + if (!is_array($groupIds)) { |
|
| 184 | + $jsonError = json_last_error(); |
|
| 185 | + \OC::$server->getLogger()->warning('AppManger::checkAppForUser - can\'t decode group IDs: ' . print_r($enabled, true) . ' - json error code: ' . $jsonError, ['app' => 'lib']); |
|
| 186 | + return false; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + $userGroups = $this->groupManager->getUserGroupIds($user); |
|
| 190 | + foreach ($userGroups as $groupId) { |
|
| 191 | + if (in_array($groupId, $groupIds, true)) { |
|
| 192 | + return true; |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + return false; |
|
| 196 | + } |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * Check if an app is installed in the instance |
|
| 201 | + * |
|
| 202 | + * @param string $appId |
|
| 203 | + * @return bool |
|
| 204 | + */ |
|
| 205 | + public function isInstalled($appId) { |
|
| 206 | + $installedApps = $this->getInstalledAppsValues(); |
|
| 207 | + return isset($installedApps[$appId]); |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * Enable an app for every user |
|
| 212 | + * |
|
| 213 | + * @param string $appId |
|
| 214 | + * @throws AppPathNotFoundException |
|
| 215 | + */ |
|
| 216 | + public function enableApp($appId) { |
|
| 217 | + // Check if app exists |
|
| 218 | + $this->getAppPath($appId); |
|
| 219 | + |
|
| 220 | + $this->installedAppsCache[$appId] = 'yes'; |
|
| 221 | + $this->appConfig->setValue($appId, 'enabled', 'yes'); |
|
| 222 | + $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent( |
|
| 223 | + ManagerEvent::EVENT_APP_ENABLE, $appId |
|
| 224 | + )); |
|
| 225 | + $this->clearAppsCache(); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + /** |
|
| 229 | + * Whether a list of types contains a protected app type |
|
| 230 | + * |
|
| 231 | + * @param string[] $types |
|
| 232 | + * @return bool |
|
| 233 | + */ |
|
| 234 | + public function hasProtectedAppType($types) { |
|
| 235 | + if (empty($types)) { |
|
| 236 | + return false; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + $protectedTypes = array_intersect($this->protectedAppTypes, $types); |
|
| 240 | + return !empty($protectedTypes); |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * Enable an app only for specific groups |
|
| 245 | + * |
|
| 246 | + * @param string $appId |
|
| 247 | + * @param \OCP\IGroup[] $groups |
|
| 248 | + * @throws \Exception if app can't be enabled for groups |
|
| 249 | + */ |
|
| 250 | + public function enableAppForGroups($appId, $groups) { |
|
| 251 | + $info = $this->getAppInfo($appId); |
|
| 252 | + if (!empty($info['types'])) { |
|
| 253 | + $protectedTypes = array_intersect($this->protectedAppTypes, $info['types']); |
|
| 254 | + if (!empty($protectedTypes)) { |
|
| 255 | + throw new \Exception("$appId can't be enabled for groups."); |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + $groupIds = array_map(function ($group) { |
|
| 260 | + /** @var \OCP\IGroup $group */ |
|
| 261 | + return $group->getGID(); |
|
| 262 | + }, $groups); |
|
| 263 | + $this->installedAppsCache[$appId] = json_encode($groupIds); |
|
| 264 | + $this->appConfig->setValue($appId, 'enabled', json_encode($groupIds)); |
|
| 265 | + $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, new ManagerEvent( |
|
| 266 | + ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, $appId, $groups |
|
| 267 | + )); |
|
| 268 | + $this->clearAppsCache(); |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + /** |
|
| 272 | + * Disable an app for every user |
|
| 273 | + * |
|
| 274 | + * @param string $appId |
|
| 275 | + * @throws \Exception if app can't be disabled |
|
| 276 | + */ |
|
| 277 | + public function disableApp($appId) { |
|
| 278 | + if ($this->isAlwaysEnabled($appId)) { |
|
| 279 | + throw new \Exception("$appId can't be disabled."); |
|
| 280 | + } |
|
| 281 | + unset($this->installedAppsCache[$appId]); |
|
| 282 | + $this->appConfig->setValue($appId, 'enabled', 'no'); |
|
| 283 | + $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_DISABLE, new ManagerEvent( |
|
| 284 | + ManagerEvent::EVENT_APP_DISABLE, $appId |
|
| 285 | + )); |
|
| 286 | + $this->clearAppsCache(); |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + /** |
|
| 290 | + * Get the directory for the given app. |
|
| 291 | + * |
|
| 292 | + * @param string $appId |
|
| 293 | + * @return string |
|
| 294 | + * @throws AppPathNotFoundException if app folder can't be found |
|
| 295 | + */ |
|
| 296 | + public function getAppPath($appId) { |
|
| 297 | + $appPath = \OC_App::getAppPath($appId); |
|
| 298 | + if($appPath === false) { |
|
| 299 | + throw new AppPathNotFoundException('Could not find path for ' . $appId); |
|
| 300 | + } |
|
| 301 | + return $appPath; |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * Clear the cached list of apps when enabling/disabling an app |
|
| 306 | + */ |
|
| 307 | + public function clearAppsCache() { |
|
| 308 | + $settingsMemCache = $this->memCacheFactory->create('settings'); |
|
| 309 | + $settingsMemCache->clear('listApps'); |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * Returns a list of apps that need upgrade |
|
| 314 | + * |
|
| 315 | + * @param string $version Nextcloud version as array of version components |
|
| 316 | + * @return array list of app info from apps that need an upgrade |
|
| 317 | + * |
|
| 318 | + * @internal |
|
| 319 | + */ |
|
| 320 | + public function getAppsNeedingUpgrade($version) { |
|
| 321 | + $appsToUpgrade = []; |
|
| 322 | + $apps = $this->getInstalledApps(); |
|
| 323 | + foreach ($apps as $appId) { |
|
| 324 | + $appInfo = $this->getAppInfo($appId); |
|
| 325 | + $appDbVersion = $this->appConfig->getValue($appId, 'installed_version'); |
|
| 326 | + if ($appDbVersion |
|
| 327 | + && isset($appInfo['version']) |
|
| 328 | + && version_compare($appInfo['version'], $appDbVersion, '>') |
|
| 329 | + && \OC_App::isAppCompatible($version, $appInfo) |
|
| 330 | + ) { |
|
| 331 | + $appsToUpgrade[] = $appInfo; |
|
| 332 | + } |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + return $appsToUpgrade; |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + /** |
|
| 339 | + * Returns the app information from "appinfo/info.xml". |
|
| 340 | + * |
|
| 341 | + * @param string $appId app id |
|
| 342 | + * |
|
| 343 | + * @return array app info |
|
| 344 | + * |
|
| 345 | + * @internal |
|
| 346 | + */ |
|
| 347 | + public function getAppInfo($appId) { |
|
| 348 | + $appInfo = \OC_App::getAppInfo($appId); |
|
| 349 | + if (!isset($appInfo['version'])) { |
|
| 350 | + // read version from separate file |
|
| 351 | + $appInfo['version'] = \OC_App::getAppVersion($appId); |
|
| 352 | + } |
|
| 353 | + return $appInfo; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * Returns a list of apps incompatible with the given version |
|
| 358 | + * |
|
| 359 | + * @param string $version Nextcloud version as array of version components |
|
| 360 | + * |
|
| 361 | + * @return array list of app info from incompatible apps |
|
| 362 | + * |
|
| 363 | + * @internal |
|
| 364 | + */ |
|
| 365 | + public function getIncompatibleApps($version) { |
|
| 366 | + $apps = $this->getInstalledApps(); |
|
| 367 | + $incompatibleApps = array(); |
|
| 368 | + foreach ($apps as $appId) { |
|
| 369 | + $info = $this->getAppInfo($appId); |
|
| 370 | + if (!\OC_App::isAppCompatible($version, $info)) { |
|
| 371 | + $incompatibleApps[] = $info; |
|
| 372 | + } |
|
| 373 | + } |
|
| 374 | + return $incompatibleApps; |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + /** |
|
| 378 | + * @inheritdoc |
|
| 379 | + */ |
|
| 380 | + public function isShipped($appId) { |
|
| 381 | + $this->loadShippedJson(); |
|
| 382 | + return in_array($appId, $this->shippedApps, true); |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + private function isAlwaysEnabled($appId) { |
|
| 386 | + $alwaysEnabled = $this->getAlwaysEnabledApps(); |
|
| 387 | + return in_array($appId, $alwaysEnabled, true); |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + private function loadShippedJson() { |
|
| 391 | + if ($this->shippedApps === null) { |
|
| 392 | + $shippedJson = \OC::$SERVERROOT . '/core/shipped.json'; |
|
| 393 | + if (!file_exists($shippedJson)) { |
|
| 394 | + throw new \Exception("File not found: $shippedJson"); |
|
| 395 | + } |
|
| 396 | + $content = json_decode(file_get_contents($shippedJson), true); |
|
| 397 | + $this->shippedApps = $content['shippedApps']; |
|
| 398 | + $this->alwaysEnabled = $content['alwaysEnabled']; |
|
| 399 | + } |
|
| 400 | + } |
|
| 401 | + |
|
| 402 | + /** |
|
| 403 | + * @inheritdoc |
|
| 404 | + */ |
|
| 405 | + public function getAlwaysEnabledApps() { |
|
| 406 | + $this->loadShippedJson(); |
|
| 407 | + return $this->alwaysEnabled; |
|
| 408 | + } |
|
| 409 | 409 | } |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | $values = $this->appConfig->getValues(false, 'enabled'); |
| 107 | 107 | |
| 108 | 108 | $alwaysEnabledApps = $this->getAlwaysEnabledApps(); |
| 109 | - foreach($alwaysEnabledApps as $appId) { |
|
| 109 | + foreach ($alwaysEnabledApps as $appId) { |
|
| 110 | 110 | $values[$appId] = 'yes'; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - $this->installedAppsCache = array_filter($values, function ($value) { |
|
| 113 | + $this->installedAppsCache = array_filter($values, function($value) { |
|
| 114 | 114 | return $value !== 'no'; |
| 115 | 115 | }); |
| 116 | 116 | ksort($this->installedAppsCache); |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | public function getEnabledAppsForUser(IUser $user) { |
| 137 | 137 | $apps = $this->getInstalledAppsValues(); |
| 138 | - $appsForUser = array_filter($apps, function ($enabled) use ($user) { |
|
| 138 | + $appsForUser = array_filter($apps, function($enabled) use ($user) { |
|
| 139 | 139 | return $this->checkAppForUser($enabled, $user); |
| 140 | 140 | }); |
| 141 | 141 | return array_keys($appsForUser); |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | } elseif ($user === null) { |
| 175 | 175 | return false; |
| 176 | 176 | } else { |
| 177 | - if(empty($enabled)){ |
|
| 177 | + if (empty($enabled)) { |
|
| 178 | 178 | return false; |
| 179 | 179 | } |
| 180 | 180 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | if (!is_array($groupIds)) { |
| 184 | 184 | $jsonError = json_last_error(); |
| 185 | - \OC::$server->getLogger()->warning('AppManger::checkAppForUser - can\'t decode group IDs: ' . print_r($enabled, true) . ' - json error code: ' . $jsonError, ['app' => 'lib']); |
|
| 185 | + \OC::$server->getLogger()->warning('AppManger::checkAppForUser - can\'t decode group IDs: '.print_r($enabled, true).' - json error code: '.$jsonError, ['app' => 'lib']); |
|
| 186 | 186 | return false; |
| 187 | 187 | } |
| 188 | 188 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - $groupIds = array_map(function ($group) { |
|
| 259 | + $groupIds = array_map(function($group) { |
|
| 260 | 260 | /** @var \OCP\IGroup $group */ |
| 261 | 261 | return $group->getGID(); |
| 262 | 262 | }, $groups); |
@@ -295,8 +295,8 @@ discard block |
||
| 295 | 295 | */ |
| 296 | 296 | public function getAppPath($appId) { |
| 297 | 297 | $appPath = \OC_App::getAppPath($appId); |
| 298 | - if($appPath === false) { |
|
| 299 | - throw new AppPathNotFoundException('Could not find path for ' . $appId); |
|
| 298 | + if ($appPath === false) { |
|
| 299 | + throw new AppPathNotFoundException('Could not find path for '.$appId); |
|
| 300 | 300 | } |
| 301 | 301 | return $appPath; |
| 302 | 302 | } |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | |
| 390 | 390 | private function loadShippedJson() { |
| 391 | 391 | if ($this->shippedApps === null) { |
| 392 | - $shippedJson = \OC::$SERVERROOT . '/core/shipped.json'; |
|
| 392 | + $shippedJson = \OC::$SERVERROOT.'/core/shipped.json'; |
|
| 393 | 393 | if (!file_exists($shippedJson)) { |
| 394 | 394 | throw new \Exception("File not found: $shippedJson"); |
| 395 | 395 | } |
@@ -34,103 +34,103 @@ |
||
| 34 | 34 | * @since 8.0.0 |
| 35 | 35 | */ |
| 36 | 36 | interface IAppManager { |
| 37 | - /** |
|
| 38 | - * Check if an app is enabled for user |
|
| 39 | - * |
|
| 40 | - * @param string $appId |
|
| 41 | - * @param \OCP\IUser $user (optional) if not defined, the currently loggedin user will be used |
|
| 42 | - * @return bool |
|
| 43 | - * @since 8.0.0 |
|
| 44 | - */ |
|
| 45 | - public function isEnabledForUser($appId, $user = null); |
|
| 37 | + /** |
|
| 38 | + * Check if an app is enabled for user |
|
| 39 | + * |
|
| 40 | + * @param string $appId |
|
| 41 | + * @param \OCP\IUser $user (optional) if not defined, the currently loggedin user will be used |
|
| 42 | + * @return bool |
|
| 43 | + * @since 8.0.0 |
|
| 44 | + */ |
|
| 45 | + public function isEnabledForUser($appId, $user = null); |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Check if an app is installed in the instance |
|
| 49 | - * |
|
| 50 | - * @param string $appId |
|
| 51 | - * @return bool |
|
| 52 | - * @since 8.0.0 |
|
| 53 | - */ |
|
| 54 | - public function isInstalled($appId); |
|
| 47 | + /** |
|
| 48 | + * Check if an app is installed in the instance |
|
| 49 | + * |
|
| 50 | + * @param string $appId |
|
| 51 | + * @return bool |
|
| 52 | + * @since 8.0.0 |
|
| 53 | + */ |
|
| 54 | + public function isInstalled($appId); |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Enable an app for every user |
|
| 58 | - * |
|
| 59 | - * @param string $appId |
|
| 60 | - * @throws AppPathNotFoundException |
|
| 61 | - * @since 8.0.0 |
|
| 62 | - */ |
|
| 63 | - public function enableApp($appId); |
|
| 56 | + /** |
|
| 57 | + * Enable an app for every user |
|
| 58 | + * |
|
| 59 | + * @param string $appId |
|
| 60 | + * @throws AppPathNotFoundException |
|
| 61 | + * @since 8.0.0 |
|
| 62 | + */ |
|
| 63 | + public function enableApp($appId); |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Whether a list of types contains a protected app type |
|
| 67 | - * |
|
| 68 | - * @param string[] $types |
|
| 69 | - * @return bool |
|
| 70 | - * @since 12.0.0 |
|
| 71 | - */ |
|
| 72 | - public function hasProtectedAppType($types); |
|
| 65 | + /** |
|
| 66 | + * Whether a list of types contains a protected app type |
|
| 67 | + * |
|
| 68 | + * @param string[] $types |
|
| 69 | + * @return bool |
|
| 70 | + * @since 12.0.0 |
|
| 71 | + */ |
|
| 72 | + public function hasProtectedAppType($types); |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Enable an app only for specific groups |
|
| 76 | - * |
|
| 77 | - * @param string $appId |
|
| 78 | - * @param \OCP\IGroup[] $groups |
|
| 79 | - * @since 8.0.0 |
|
| 80 | - */ |
|
| 81 | - public function enableAppForGroups($appId, $groups); |
|
| 74 | + /** |
|
| 75 | + * Enable an app only for specific groups |
|
| 76 | + * |
|
| 77 | + * @param string $appId |
|
| 78 | + * @param \OCP\IGroup[] $groups |
|
| 79 | + * @since 8.0.0 |
|
| 80 | + */ |
|
| 81 | + public function enableAppForGroups($appId, $groups); |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Disable an app for every user |
|
| 85 | - * |
|
| 86 | - * @param string $appId |
|
| 87 | - * @since 8.0.0 |
|
| 88 | - */ |
|
| 89 | - public function disableApp($appId); |
|
| 83 | + /** |
|
| 84 | + * Disable an app for every user |
|
| 85 | + * |
|
| 86 | + * @param string $appId |
|
| 87 | + * @since 8.0.0 |
|
| 88 | + */ |
|
| 89 | + public function disableApp($appId); |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Get the directory for the given app. |
|
| 93 | - * |
|
| 94 | - * @param string $appId |
|
| 95 | - * @return string |
|
| 96 | - * @since 11.0.0 |
|
| 97 | - * @throws AppPathNotFoundException |
|
| 98 | - */ |
|
| 99 | - public function getAppPath($appId); |
|
| 91 | + /** |
|
| 92 | + * Get the directory for the given app. |
|
| 93 | + * |
|
| 94 | + * @param string $appId |
|
| 95 | + * @return string |
|
| 96 | + * @since 11.0.0 |
|
| 97 | + * @throws AppPathNotFoundException |
|
| 98 | + */ |
|
| 99 | + public function getAppPath($appId); |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * List all apps enabled for a user |
|
| 103 | - * |
|
| 104 | - * @param \OCP\IUser $user |
|
| 105 | - * @return string[] |
|
| 106 | - * @since 8.1.0 |
|
| 107 | - */ |
|
| 108 | - public function getEnabledAppsForUser(IUser $user); |
|
| 101 | + /** |
|
| 102 | + * List all apps enabled for a user |
|
| 103 | + * |
|
| 104 | + * @param \OCP\IUser $user |
|
| 105 | + * @return string[] |
|
| 106 | + * @since 8.1.0 |
|
| 107 | + */ |
|
| 108 | + public function getEnabledAppsForUser(IUser $user); |
|
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * List all installed apps |
|
| 112 | - * |
|
| 113 | - * @return string[] |
|
| 114 | - * @since 8.1.0 |
|
| 115 | - */ |
|
| 116 | - public function getInstalledApps(); |
|
| 110 | + /** |
|
| 111 | + * List all installed apps |
|
| 112 | + * |
|
| 113 | + * @return string[] |
|
| 114 | + * @since 8.1.0 |
|
| 115 | + */ |
|
| 116 | + public function getInstalledApps(); |
|
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Clear the cached list of apps when enabling/disabling an app |
|
| 120 | - * @since 8.1.0 |
|
| 121 | - */ |
|
| 122 | - public function clearAppsCache(); |
|
| 118 | + /** |
|
| 119 | + * Clear the cached list of apps when enabling/disabling an app |
|
| 120 | + * @since 8.1.0 |
|
| 121 | + */ |
|
| 122 | + public function clearAppsCache(); |
|
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * @param string $appId |
|
| 126 | - * @return boolean |
|
| 127 | - * @since 9.0.0 |
|
| 128 | - */ |
|
| 129 | - public function isShipped($appId); |
|
| 124 | + /** |
|
| 125 | + * @param string $appId |
|
| 126 | + * @return boolean |
|
| 127 | + * @since 9.0.0 |
|
| 128 | + */ |
|
| 129 | + public function isShipped($appId); |
|
| 130 | 130 | |
| 131 | - /** |
|
| 132 | - * @return string[] |
|
| 133 | - * @since 9.0.0 |
|
| 134 | - */ |
|
| 135 | - public function getAlwaysEnabledApps(); |
|
| 131 | + /** |
|
| 132 | + * @return string[] |
|
| 133 | + * @since 9.0.0 |
|
| 134 | + */ |
|
| 135 | + public function getAlwaysEnabledApps(); |
|
| 136 | 136 | } |