diff options
author | Lukas Reschke <lukas@owncloud.com> | 2015-03-06 18:52:12 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2015-03-06 18:52:12 +0100 |
commit | 60c507cd4ece1c01a0f59095192ff2f9ea81a0d5 (patch) | |
tree | 539db63780306162fc9bce0b386345eb80b59174 /lib | |
parent | a77a6f3b481080f01fb49b94416a43ef0d2f1785 (diff) | |
parent | d5a8225c0e818b95cf06a4afcdb07d4cf5ecf08b (diff) | |
download | nextcloud-server-60c507cd4ece1c01a0f59095192ff2f9ea81a0d5.tar.gz nextcloud-server-60c507cd4ece1c01a0f59095192ff2f9ea81a0d5.zip |
Merge pull request #14722 from owncloud/master-14711
Fix totally broken AppStore code...
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/app.php | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/lib/private/app.php b/lib/private/app.php index e39165695cf..9ae4ae30d74 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -303,6 +303,11 @@ class OC_App { * @throws Exception */ public static function disable($app) { + // Convert OCS ID to regular application identifier + if(self::getInternalAppIdByOcs($app) !== false) { + $app = self::getInternalAppIdByOcs($app); + } + if($app === 'files') { throw new \Exception("files can't be disabled."); } @@ -879,6 +884,21 @@ class OC_App { } /** + * Returns the internal app ID or false + * @param string $ocsID + * @return string|false + */ + protected static function getInternalAppIdByOcs($ocsID) { + if(is_numeric($ocsID)) { + $idArray = \OC::$server->getAppConfig()->getValues(false, 'ocsid'); + if(array_search($ocsID, $idArray)) { + return array_search($ocsID, $idArray); + } + } + return false; + } + + /** * get a list of all apps on apps.owncloud.com * * @return array|false multi-dimensional array of apps. @@ -904,11 +924,13 @@ class OC_App { $i = 0; $l = \OC::$server->getL10N('core'); foreach ($remoteApps as $app) { + $potentialCleanId = self::getInternalAppIdByOcs($app['id']); // enhance app info (for example the description) $app1[$i] = OC_App::parseAppInfo($app); $app1[$i]['author'] = $app['personid']; $app1[$i]['ocs_id'] = $app['id']; - $app1[$i]['internal'] = $app1[$i]['active'] = 0; + $app1[$i]['internal'] = 0; + $app1[$i]['active'] = ($potentialCleanId !== false) ? self::isEnabled($potentialCleanId) : false; $app1[$i]['update'] = false; $app1[$i]['groups'] = false; $app1[$i]['score'] = $app['score']; @@ -1059,7 +1081,20 @@ class OC_App { $app = OC_Installer::installShippedApp($app); } } else { - $app = self::downloadApp($app); + // Maybe the app is already installed - compare the version in this + // case and use the local already installed one. + // FIXME: This is a horrible hack. I feel sad. The god of code cleanness may forgive me. + $internalAppId = self::getInternalAppIdByOcs($app); + if($internalAppId !== false) { + if($appData && version_compare(\OC_App::getAppVersion($internalAppId), $appData['version'], '<')) { + $app = self::downloadApp($app); + } else { + self::enable($internalAppId); + $app = $internalAppId; + } + } else { + $app = self::downloadApp($app); + } } if ($app !== false) { |