Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2014-12-04 18:48:07 +0300
committerMorris Jobke <hey@morrisjobke.de>2014-12-09 00:42:37 +0300
commit0d4f0ab87182cf2cb588bd3285fe41b46f26ee4d (patch)
tree68ee815c2f06e4f6ef049d56f65fdbf2cf8c4d18 /apps
parent2d5fc9c1a6beec15f04277ccf1408b17f04631e9 (diff)
reduce OC_Preferences, OC_Config and \OCP\Config usage
* files_encryption * files_versions * files_trashbin * tests * status.php * core * server container
Diffstat (limited to 'apps')
-rw-r--r--apps/files_encryption/hooks/hooks.php2
-rw-r--r--apps/files_encryption/lib/util.php20
-rwxr-xr-xapps/files_encryption/tests/util.php4
-rw-r--r--apps/files_trashbin/lib/trashbin.php6
-rw-r--r--apps/files_versions/lib/storage.php7
5 files changed, 27 insertions, 12 deletions
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index a6b7555b376..f26eefa30e2 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -502,7 +502,7 @@ class Hooks {
public static function preDisable($params) {
if ($params['app'] === 'files_encryption') {
- \OC_Preferences::deleteAppFromAllUsers('files_encryption');
+ \OC::$server->getConfig()->deleteAppFromAllUsers('files_encryption');
$session = new \OCA\Encryption\Session(new \OC\Files\View('/'));
$session->setInitialized(\OCA\Encryption\Session::NOT_INITIALIZED);
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 42a7e20c87f..2b4a50d6e2b 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -225,7 +225,7 @@ class Util {
*/
public function recoveryEnabledForUser() {
- $recoveryMode = \OC_Preferences::getValue($this->userId, 'files_encryption', 'recovery_enabled', '0');
+ $recoveryMode = \OC::$server->getConfig()->getUserValue($this->userId, 'files_encryption', 'recovery_enabled', '0');
return ($recoveryMode === '1') ? true : false;
@@ -239,7 +239,12 @@ class Util {
public function setRecoveryForUser($enabled) {
$value = $enabled ? '1' : '0';
- return \OC_Preferences::setValue($this->userId, 'files_encryption', 'recovery_enabled', $value);
+ try {
+ \OC::$server->getConfig()->setUserValue($this->userId, 'files_encryption', 'recovery_enabled', $value);
+ return true;
+ } catch(\OCP\PreConditionNotMetException $e) {
+ return false;
+ }
}
@@ -1102,7 +1107,12 @@ class Util {
// convert to string if preCondition is set
$preCondition = ($preCondition === null) ? null : (string)$preCondition;
- return \OC_Preferences::setValue($this->userId, 'files_encryption', 'migration_status', (string)$status, $preCondition);
+ try {
+ \OC::$server->getConfig()->setUserValue($this->userId, 'files_encryption', 'migration_status', (string)$status, $preCondition);
+ return true;
+ } catch(\OCP\PreConditionNotMetException $e) {
+ return false;
+ }
}
@@ -1154,9 +1164,9 @@ class Util {
$migrationStatus = false;
if (\OCP\User::userExists($this->userId)) {
- $migrationStatus = \OC_Preferences::getValue($this->userId, 'files_encryption', 'migration_status');
+ $migrationStatus = \OC::$server->getConfig()->getUserValue($this->userId, 'files_encryption', 'migration_status', null);
if ($migrationStatus === null) {
- \OC_Preferences::setValue($this->userId, 'files_encryption', 'migration_status', (string)self::MIGRATION_OPEN);
+ \OC::$server->getConfig()->setUserValue($this->userId, 'files_encryption', 'migration_status', (string)self::MIGRATION_OPEN);
$migrationStatus = self::MIGRATION_OPEN;
}
}
diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php
index 8d9aba423cd..2d58db2128c 100755
--- a/apps/files_encryption/tests/util.php
+++ b/apps/files_encryption/tests/util.php
@@ -617,7 +617,9 @@ class Test_Encryption_Util extends \OCA\Files_Encryption\Tests\TestCase {
* @return boolean
*/
private function setMigrationStatus($status, $user) {
- return \OC_Preferences::setValue($user, 'files_encryption', 'migration_status', (string)$status);
+ \OC::$server->getConfig()->setUserValue($user, 'files_encryption', 'migration_status', (string)$status);
+ // the update will definitely be executed -> return value is always true
+ return true;
}
}
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php
index 661fc271dfc..b9d7a4aa6cf 100644
--- a/apps/files_trashbin/lib/trashbin.php
+++ b/apps/files_trashbin/lib/trashbin.php
@@ -621,11 +621,13 @@ class Trashbin {
* @return int available free space for trash bin
*/
private static function calculateFreeSpace($trashbinSize, $user) {
+ $config = \OC::$server->getConfig();
+
$softQuota = true;
- $quota = \OC_Preferences::getValue($user, 'files', 'quota');
+ $quota = $config->getUserValue($user, 'files', 'quota', null);
$view = new \OC\Files\View('/' . $user);
if ($quota === null || $quota === 'default') {
- $quota = \OC::$server->getAppConfig()->getValue('files', 'default_quota');
+ $quota = $config->getAppValue('files', 'default_quota', null);
}
if ($quota === null || $quota === 'none') {
$quota = \OC\Files\Filesystem::free_space('/');
diff --git a/apps/files_versions/lib/storage.php b/apps/files_versions/lib/storage.php
index 82e0ecc3e2f..3d30ada863a 100644
--- a/apps/files_versions/lib/storage.php
+++ b/apps/files_versions/lib/storage.php
@@ -479,15 +479,16 @@ class Storage {
* Erase a file's versions which exceed the set quota
*/
private static function expire($filename, $versionsSize = null, $offset = 0) {
- if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
+ $config = \OC::$server->getConfig();
+ if($config->getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
list($uid, $filename) = self::getUidAndFilename($filename);
$versionsFileview = new \OC\Files\View('/'.$uid.'/files_versions');
// get available disk space for user
$softQuota = true;
- $quota = \OC_Preferences::getValue($uid, 'files', 'quota');
+ $quota = $config->getUserValue($uid, 'files', 'quota', null);
if ( $quota === null || $quota === 'default') {
- $quota = \OC::$server->getAppConfig()->getValue('files', 'default_quota');
+ $quota = $config->getAppValue('files', 'default_quota', null);
}
if ( $quota === null || $quota === 'none' ) {
$quota = \OC\Files\Filesystem::free_space('/');