summaryrefslogtreecommitdiffstats
path: root/lib/private/app/appmanager.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/app/appmanager.php')
-rw-r--r--lib/private/app/appmanager.php67
1 files changed, 67 insertions, 0 deletions
diff --git a/lib/private/app/appmanager.php b/lib/private/app/appmanager.php
index 7a61cd53c59..86674aa047c 100644
--- a/lib/private/app/appmanager.php
+++ b/lib/private/app/appmanager.php
@@ -209,4 +209,71 @@ class AppManager implements IAppManager {
$settingsMemCache = $this->memCacheFactory->create('settings');
$settingsMemCache->clear('listApps');
}
+
+ /**
+ * Returns a list of apps that need upgrade
+ *
+ * @return array list of app info from apps that need an upgrade
+ *
+ * @internal
+ */
+ public function getAppsNeedingUpgrade() {
+ $appsToUpgrade = [];
+ $apps = $this->getInstalledApps();
+ foreach ($apps as $appId) {
+ $appInfo = $this->getAppInfo($appId);
+ $appDbVersion = $this->appConfig->getValue($appId, 'installed_version');
+ if ($appDbVersion
+ && isset($appInfo['version'])
+ && version_compare($appInfo['version'], $appDbVersion, '>')
+ ) {
+ $appsToUpgrade[] = $appInfo;
+ }
+ }
+
+ return $appsToUpgrade;
+ }
+
+ /**
+ * Returns the app information from "appinfo/info.xml".
+ *
+ * If no version was present in "appinfo/info.xml", reads it
+ * from the external "appinfo/version" file instead.
+ *
+ * @param string $appId app id
+ *
+ * @return array app iinfo
+ *
+ * @internal
+ */
+ public function getAppInfo($appId) {
+ $appInfo = \OC_App::getAppInfo($appId);
+ if (!isset($appInfo['version'])) {
+ // read version from separate file
+ $appInfo['version'] = \OC_App::getAppVersion($appId);
+ }
+ return $appInfo;
+ }
+
+ /**
+ * Returns a list of apps incompatible with the given version
+ *
+ * @param array $version version as array of version components
+ *
+ * @return array list of app info from incompatible apps
+ *
+ * @internal
+ */
+ public function getIncompatibleApps($version) {
+ $apps = $this->getInstalledApps();
+ $incompatibleApps = array();
+ foreach ($apps as $appId) {
+ $info = $this->getAppInfo($appId);
+ if (!\OC_App::isAppCompatible($version, $info)) {
+ $incompatibleApps[] = $info;
+ }
+ }
+ return $incompatibleApps;
+ }
+
}