summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-08-20 11:50:01 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-08-20 11:50:01 +0200
commit06d8edd9637f59f914ec7f3d7f6846f3cbe88eaf (patch)
tree49833fd9a8a80255b7ae2d91291e5371a047870b /lib
parent2fe070ca37c76bc118c0fe360b9c7008bf01e52b (diff)
parenta2674b2b303c6b2a5935638af04f0e4a61afae24 (diff)
downloadnextcloud-server-06d8edd9637f59f914ec7f3d7f6846f3cbe88eaf.tar.gz
nextcloud-server-06d8edd9637f59f914ec7f3d7f6846f3cbe88eaf.zip
Merge pull request #17434 from owncloud/update-showappnameonappupdate
Display app names in update page for app updates
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php57
-rw-r--r--lib/private/app/appmanager.php69
2 files changed, 105 insertions, 21 deletions
diff --git a/lib/base.php b/lib/base.php
index c0f3e50142e..42e1d7f8586 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -346,27 +346,7 @@ class OC {
if (\OCP\Util::needUpgrade()) {
$systemConfig = \OC::$server->getSystemConfig();
if ($showTemplate && !$systemConfig->getValue('maintenance', false)) {
- $version = OC_Util::getVersion();
- $oldTheme = $systemConfig->getValue('theme');
- $systemConfig->setValue('theme', '');
- OC_Util::addScript('config'); // needed for web root
- OC_Util::addScript('update');
- $tmpl = new OC_Template('', 'update.admin', 'guest');
- $tmpl->assign('version', OC_Util::getVersionString());
-
- // get third party apps
- $apps = OC_App::getEnabledApps();
- $incompatibleApps = array();
- foreach ($apps as $appId) {
- $info = OC_App::getAppInfo($appId);
- if(!OC_App::isAppCompatible($version, $info)) {
- $incompatibleApps[] = $info;
- }
- }
- $tmpl->assign('appList', $incompatibleApps);
- $tmpl->assign('productName', 'ownCloud'); // for now
- $tmpl->assign('oldTheme', $oldTheme);
- $tmpl->printPage();
+ self::printUpgradePage();
exit();
} else {
return true;
@@ -375,6 +355,41 @@ class OC {
return false;
}
+ /**
+ * Prints the upgrade page
+ */
+ private static function printUpgradePage() {
+ $systemConfig = \OC::$server->getSystemConfig();
+ $oldTheme = $systemConfig->getValue('theme');
+ $systemConfig->setValue('theme', '');
+ \OCP\Util::addScript('config'); // needed for web root
+ \OCP\Util::addScript('update');
+
+ // check whether this is a core update or apps update
+ $installedVersion = $systemConfig->getValue('version', '0.0.0');
+ $currentVersion = implode('.', OC_Util::getVersion());
+
+ $appManager = \OC::$server->getAppManager();
+
+ $tmpl = new OC_Template('', 'update.admin', 'guest');
+ $tmpl->assign('version', OC_Util::getVersionString());
+
+ // if not a core upgrade, then it's apps upgrade
+ if (version_compare($currentVersion, $installedVersion, '=')) {
+ $tmpl->assign('isAppsOnlyUpgrade', true);
+ } else {
+ $tmpl->assign('isAppsOnlyUpgrade', false);
+ }
+
+ // get third party apps
+ $ocVersion = OC_Util::getVersion();
+ $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion));
+ $tmpl->assign('incompatibleAppsList', $appManager->getIncompatibleApps($ocVersion));
+ $tmpl->assign('productName', 'ownCloud'); // for now
+ $tmpl->assign('oldTheme', $oldTheme);
+ $tmpl->printPage();
+ }
+
public static function initTemplateEngine() {
// Add the stuff we need always
// following logic will import all vendor libraries that are
diff --git a/lib/private/app/appmanager.php b/lib/private/app/appmanager.php
index 7a61cd53c59..75b1c0a7865 100644
--- a/lib/private/app/appmanager.php
+++ b/lib/private/app/appmanager.php
@@ -209,4 +209,73 @@ class AppManager implements IAppManager {
$settingsMemCache = $this->memCacheFactory->create('settings');
$settingsMemCache->clear('listApps');
}
+
+ /**
+ * Returns a list of apps that need upgrade
+ *
+ * @param array $version ownCloud version as array of version components
+ * @return array list of app info from apps that need an upgrade
+ *
+ * @internal
+ */
+ public function getAppsNeedingUpgrade($ocVersion) {
+ $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, '>')
+ && \OC_App::isAppCompatible($ocVersion, $appInfo)
+ ) {
+ $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 ownCloud 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;
+ }
+
}