Remove group restrictions when those are not allowed anymore

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-01-04 10:40:14 +01:00
parent a75cfb601e
commit ec4b0d1e84
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
3 changed files with 32 additions and 0 deletions

View File

@ -220,6 +220,21 @@ class AppManager implements IAppManager {
$this->clearAppsCache(); $this->clearAppsCache();
} }
/**
* Whether a list of types contains a protected app type
*
* @param string[] $types
* @return bool
*/
public function hasProtectedAppType($types) {
if (empty($types)) {
return false;
}
$protectedTypes = array_intersect($this->protectedAppTypes, $types);
return !empty($protectedTypes);
}
/** /**
* Enable an app only for specific groups * Enable an app only for specific groups
* *

View File

@ -273,9 +273,17 @@ class OC_App {
$appTypes = implode(',', $appData['types']); $appTypes = implode(',', $appData['types']);
} else { } else {
$appTypes = ''; $appTypes = '';
$appData['types'] = [];
} }
\OC::$server->getAppConfig()->setValue($app, 'types', $appTypes); \OC::$server->getAppConfig()->setValue($app, 'types', $appTypes);
if (\OC::$server->getAppManager()->hasProtectedAppType($appData['types'])) {
$enabled = \OC::$server->getAppConfig()->getValue($app, 'enabled', 'yes');
if ($enabled !== 'yes' && $enabled !== 'no') {
\OC::$server->getAppConfig()->setValue($app, 'enabled', 'yes');
}
}
} }
/** /**

View File

@ -61,6 +61,15 @@ interface IAppManager {
*/ */
public function enableApp($appId); public function enableApp($appId);
/**
* Whether a list of types contains a protected app type
*
* @param string[] $types
* @return bool
* @since 12.0.0
*/
public function hasProtectedAppType($types);
/** /**
* Enable an app only for specific groups * Enable an app only for specific groups
* *