Some more code fixes
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
5cf6fc7e8d
commit
6d30b35ed7
|
@ -55,18 +55,21 @@ class AppManager implements IAppManager {
|
||||||
'prevent_group_restriction',
|
'prevent_group_restriction',
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var \OCP\IUserSession */
|
/** @var IUserSession */
|
||||||
private $userSession;
|
private $userSession;
|
||||||
|
|
||||||
/** @var \OCP\IAppConfig */
|
/** @var IAppConfig */
|
||||||
private $appConfig;
|
private $appConfig;
|
||||||
|
|
||||||
/** @var \OCP\IGroupManager */
|
/** @var IGroupManager */
|
||||||
private $groupManager;
|
private $groupManager;
|
||||||
|
|
||||||
/** @var \OCP\ICacheFactory */
|
/** @var ICacheFactory */
|
||||||
private $memCacheFactory;
|
private $memCacheFactory;
|
||||||
|
|
||||||
|
/** @var EventDispatcherInterface */
|
||||||
|
private $dispatcher;
|
||||||
|
|
||||||
/** @var string[] $appId => $enabled */
|
/** @var string[] $appId => $enabled */
|
||||||
private $installedAppsCache;
|
private $installedAppsCache;
|
||||||
|
|
||||||
|
@ -76,14 +79,12 @@ class AppManager implements IAppManager {
|
||||||
/** @var string[] */
|
/** @var string[] */
|
||||||
private $alwaysEnabled;
|
private $alwaysEnabled;
|
||||||
|
|
||||||
/** @var EventDispatcherInterface */
|
|
||||||
private $dispatcher;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \OCP\IUserSession $userSession
|
* @param IUserSession $userSession
|
||||||
* @param \OCP\IAppConfig $appConfig
|
* @param IAppConfig $appConfig
|
||||||
* @param \OCP\IGroupManager $groupManager
|
* @param IGroupManager $groupManager
|
||||||
* @param \OCP\ICacheFactory $memCacheFactory
|
* @param ICacheFactory $memCacheFactory
|
||||||
|
* @param EventDispatcherInterface $dispatcher
|
||||||
*/
|
*/
|
||||||
public function __construct(IUserSession $userSession,
|
public function __construct(IUserSession $userSession,
|
||||||
IAppConfig $appConfig,
|
IAppConfig $appConfig,
|
||||||
|
@ -151,7 +152,7 @@ class AppManager implements IAppManager {
|
||||||
if ($this->isAlwaysEnabled($appId)) {
|
if ($this->isAlwaysEnabled($appId)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (is_null($user)) {
|
if ($user === null) {
|
||||||
$user = $this->userSession->getUser();
|
$user = $this->userSession->getUser();
|
||||||
}
|
}
|
||||||
$installedApps = $this->getInstalledAppsValues();
|
$installedApps = $this->getInstalledAppsValues();
|
||||||
|
@ -170,7 +171,7 @@ class AppManager implements IAppManager {
|
||||||
private function checkAppForUser($enabled, $user) {
|
private function checkAppForUser($enabled, $user) {
|
||||||
if ($enabled === 'yes') {
|
if ($enabled === 'yes') {
|
||||||
return true;
|
return true;
|
||||||
} elseif (is_null($user)) {
|
} elseif ($user === null) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if(empty($enabled)){
|
if(empty($enabled)){
|
||||||
|
@ -187,7 +188,7 @@ class AppManager implements IAppManager {
|
||||||
|
|
||||||
$userGroups = $this->groupManager->getUserGroupIds($user);
|
$userGroups = $this->groupManager->getUserGroupIds($user);
|
||||||
foreach ($userGroups as $groupId) {
|
foreach ($userGroups as $groupId) {
|
||||||
if (array_search($groupId, $groupIds) !== false) {
|
if (in_array($groupId, $groupIds, true)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -311,12 +312,12 @@ class AppManager implements IAppManager {
|
||||||
/**
|
/**
|
||||||
* Returns a list of apps that need upgrade
|
* Returns a list of apps that need upgrade
|
||||||
*
|
*
|
||||||
* @param array $version ownCloud version as array of version components
|
* @param string $version Nextcloud version as array of version components
|
||||||
* @return array list of app info from apps that need an upgrade
|
* @return array list of app info from apps that need an upgrade
|
||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public function getAppsNeedingUpgrade($ocVersion) {
|
public function getAppsNeedingUpgrade($version) {
|
||||||
$appsToUpgrade = [];
|
$appsToUpgrade = [];
|
||||||
$apps = $this->getInstalledApps();
|
$apps = $this->getInstalledApps();
|
||||||
foreach ($apps as $appId) {
|
foreach ($apps as $appId) {
|
||||||
|
@ -325,7 +326,7 @@ class AppManager implements IAppManager {
|
||||||
if ($appDbVersion
|
if ($appDbVersion
|
||||||
&& isset($appInfo['version'])
|
&& isset($appInfo['version'])
|
||||||
&& version_compare($appInfo['version'], $appDbVersion, '>')
|
&& version_compare($appInfo['version'], $appDbVersion, '>')
|
||||||
&& \OC_App::isAppCompatible($ocVersion, $appInfo)
|
&& \OC_App::isAppCompatible($version, $appInfo)
|
||||||
) {
|
) {
|
||||||
$appsToUpgrade[] = $appInfo;
|
$appsToUpgrade[] = $appInfo;
|
||||||
}
|
}
|
||||||
|
@ -355,7 +356,7 @@ class AppManager implements IAppManager {
|
||||||
/**
|
/**
|
||||||
* Returns a list of apps incompatible with the given version
|
* Returns a list of apps incompatible with the given version
|
||||||
*
|
*
|
||||||
* @param array $version ownCloud version as array of version components
|
* @param string $version Nextcloud version as array of version components
|
||||||
*
|
*
|
||||||
* @return array list of app info from incompatible apps
|
* @return array list of app info from incompatible apps
|
||||||
*
|
*
|
||||||
|
@ -378,16 +379,16 @@ class AppManager implements IAppManager {
|
||||||
*/
|
*/
|
||||||
public function isShipped($appId) {
|
public function isShipped($appId) {
|
||||||
$this->loadShippedJson();
|
$this->loadShippedJson();
|
||||||
return in_array($appId, $this->shippedApps);
|
return in_array($appId, $this->shippedApps, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isAlwaysEnabled($appId) {
|
private function isAlwaysEnabled($appId) {
|
||||||
$alwaysEnabled = $this->getAlwaysEnabledApps();
|
$alwaysEnabled = $this->getAlwaysEnabledApps();
|
||||||
return in_array($appId, $alwaysEnabled);
|
return in_array($appId, $alwaysEnabled, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadShippedJson() {
|
private function loadShippedJson() {
|
||||||
if (is_null($this->shippedApps)) {
|
if ($this->shippedApps === null) {
|
||||||
$shippedJson = \OC::$SERVERROOT . '/core/shipped.json';
|
$shippedJson = \OC::$SERVERROOT . '/core/shipped.json';
|
||||||
if (!file_exists($shippedJson)) {
|
if (!file_exists($shippedJson)) {
|
||||||
throw new \Exception("File not found: $shippedJson");
|
throw new \Exception("File not found: $shippedJson");
|
||||||
|
|
Loading…
Reference in New Issue