summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-03-05 22:34:46 +0100
committerLukas Reschke <lukas@owncloud.com>2015-03-05 22:36:17 +0100
commit6d5e60bd9b801b2fe8dde2c947aa31b1d2b6ae87 (patch)
treedcaf719cf7115eb4f1fb57efa189d505815990d5
parenta7fc0fc07b42dbd3d88cb73c1b0ab16910a1b828 (diff)
downloadnextcloud-server-6d5e60bd9b801b2fe8dde2c947aa31b1d2b6ae87.tar.gz
nextcloud-server-6d5e60bd9b801b2fe8dde2c947aa31b1d2b6ae87.zip
14719 without public API
-rw-r--r--lib/private/allconfig.php32
-rw-r--r--lib/private/app.php32
-rw-r--r--lib/public/iconfig.php10
-rw-r--r--tests/lib/allconfig.php27
4 files changed, 24 insertions, 77 deletions
diff --git a/lib/private/allconfig.php b/lib/private/allconfig.php
index ff470b3f85a..d729936bc32 100644
--- a/lib/private/allconfig.php
+++ b/lib/private/allconfig.php
@@ -162,38 +162,6 @@ class AllConfig implements \OCP\IConfig {
}
/**
- * Determines the apps that have the set the value for the specified
- * keys
- *
- * @param string $value the value to get the app for
- * @param string $key the key too lookup
- * @return array of app IDs
- */
- public function getAppsForKeyValue($key, $value) {
- // TODO - FIXME
- $this->fixDIInit();
-
- $qb = $this->connection->createQueryBuilder();
- $qb
- ->select('appid')
- ->from('`*PREFIX*appconfig`')
- ->where('configvalue = ?')
- ->andWhere('configkey = ?')
- ->setParameter(0, $value)
- ->setParameter(1, $key)
- ;
- $result = $qb->execute();
-
- $appIDs = [];
- while ($row = $result->fetch()) {
- $appIDs[] = $row['appid'];
- }
-
- sort($appIDs);
- return $appIDs;
- }
-
- /**
* Set a user defined value
*
* @param string $userId the userId of the user that we want to store the value under
diff --git a/lib/private/app.php b/lib/private/app.php
index c12447de752..d3dcf1f8c81 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -330,8 +330,8 @@ class OC_App {
\OC_Hook::emit('OC_App', 'pre_disable', array('app' => $app));
// Convert OCS ID to regular application identifier
- if(is_numeric($app)) {
- $app = \OC::$server->getConfig()->getAppsForKeyValue('ocsid', $app)[0];
+ if(self::getInternalAppIdByOcs($app) !== false) {
+ $app = self::getInternalAppIdByOcs($app);
}
OC_Appconfig::setValue($app, 'enabled', 'no' );
@@ -904,6 +904,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, multi-dimensional array of apps.
* Keys: id, name, type, typename, personid, license, detailpage, preview, changed, description
@@ -928,12 +943,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'] = 0;
- $app1[$i]['active'] = self::isEnabled(\OC::$server->getConfig()->getAppsForKeyValue('ocsid', $app['id'])[0]);
+ $app1[$i]['active'] = ($potentialCleanId !== false) ? self::isEnabled($potentialCleanId) : false;
$app1[$i]['update'] = false;
$app1[$i]['groups'] = false;
$app1[$i]['score'] = $app['score'];
@@ -1086,13 +1102,13 @@ class OC_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 = $config->getAppsForKeyValue('ocsid', $app);
- if(isset($internalAppId[0])) {
- if($appData && version_compare(\OC_App::getAppVersion($internalAppId[0]), $appData['version'], '<')) {
+ $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[0]);
- $app = $internalAppId[0];
+ self::enable($internalAppId);
+ $app = $internalAppId;
}
} else {
$app = self::downloadApp($app);
diff --git a/lib/public/iconfig.php b/lib/public/iconfig.php
index 06638d0891b..96384ce476c 100644
--- a/lib/public/iconfig.php
+++ b/lib/public/iconfig.php
@@ -110,16 +110,6 @@ interface IConfig {
public function deleteAppValues($appName);
/**
- * Determines the apps that have the set the value for the specified
- * keys
- *
- * @param string $value the value to get the app for
- * @param string $key the key too lookup
- * @return array of app IDs
- */
- public function getAppsForKeyValue($key, $value);
-
- /**
* Set a user defined value
*
* @param string $userId the userId of the user that we want to store the value under
diff --git a/tests/lib/allconfig.php b/tests/lib/allconfig.php
index 290e40e8d88..7f8ad5ec221 100644
--- a/tests/lib/allconfig.php
+++ b/tests/lib/allconfig.php
@@ -26,33 +26,6 @@ class TestAllConfig extends \Test\TestCase {
return new \OC\AllConfig($systemConfig, $connection);
}
- // FIXME: Actually an integration test... – Shouldn't be in the unit test at all.
- public function testGetAppsForKeyValue() {
- $config = $this->getConfig();
-
- // preparation - add something to the database
- $data = [
- ['myFirstApp', 'key1', 'value1'],
- ['mySecondApp', 'key1', 'value2'],
- ['mySecondApp', 'key3', 'value2'],
- ['myThirdApp', 'key3', 'value3'],
- ['myThirdApp', 'key3', 'value2'],
- ];
- foreach ($data as $entry) {
- $config->setAppValue($entry[0], $entry[1], $entry[2]);
- }
-
- $this->assertEquals(['mySecondApp'], $config->getAppsForKeyValue('key1', 'value2'));
- $this->assertEquals(['mySecondApp', 'myThirdApp'], $config->getAppsForKeyValue('key3', 'value2'));
- $this->assertEquals([], $config->getAppsForKeyValue('NotExisting', 'NotExistingValue'));
-
- // cleanup
- foreach ($data as $entry) {
- $config->deleteAppValue($entry[0], $entry[1]);
-
- }
- }
-
public function testDeleteUserValue() {
$config = $this->getConfig();