summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorC. Montero Luque <cmonteroluque@users.noreply.github.com>2016-02-09 22:00:24 +0100
committerC. Montero Luque <cmonteroluque@users.noreply.github.com>2016-02-09 22:00:24 +0100
commit962d0c3290fc5b881c579d553373f3facaa3ab3e (patch)
tree90764075266a7708ba5ef899a5bdd4e60cbb03be /apps
parenta39c7591d6b0bfcb323cd14a5c1164576eaf7559 (diff)
parent03d0fb4e3f9734b36e015baa90901b222d03689c (diff)
downloadnextcloud-server-962d0c3290fc5b881c579d553373f3facaa3ab3e.tar.gz
nextcloud-server-962d0c3290fc5b881c579d553373f3facaa3ab3e.zip
Merge pull request #22252 from owncloud/consolidate-user-set-quota
Consolidate getQuota and setQuota methods in User instance
Diffstat (limited to 'apps')
-rw-r--r--apps/files_trashbin/lib/trashbin.php5
-rw-r--r--apps/files_versions/lib/storage.php6
-rw-r--r--apps/provisioning_api/lib/users.php2
-rw-r--r--apps/provisioning_api/tests/userstest.php21
-rw-r--r--apps/user_ldap/lib/user/user.php2
-rw-r--r--apps/user_ldap/tests/user/user.php64
6 files changed, 50 insertions, 50 deletions
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php
index ca3a8b178a2..c91cfe082fd 100644
--- a/apps/files_trashbin/lib/trashbin.php
+++ b/apps/files_trashbin/lib/trashbin.php
@@ -564,11 +564,8 @@ class Trashbin {
$config = \OC::$server->getConfig();
$softQuota = true;
- $quota = $config->getUserValue($user, 'files', 'quota', null);
+ $quota = \OC::$server->getUserManager()->get($user)->getQuota();
$view = new \OC\Files\View('/' . $user);
- if ($quota === null || $quota === 'default') {
- $quota = $config->getAppValue('files', 'default_quota', null);
- }
if ($quota === null || $quota === 'none') {
$quota = \OC\Files\Filesystem::free_space('/');
$softQuota = false;
diff --git a/apps/files_versions/lib/storage.php b/apps/files_versions/lib/storage.php
index 88a4126dabd..47acec1d763 100644
--- a/apps/files_versions/lib/storage.php
+++ b/apps/files_versions/lib/storage.php
@@ -653,11 +653,9 @@ class Storage {
$versionsFileview = new \OC\Files\View('/'.$uid.'/files_versions');
// get available disk space for user
+ $user = \OC::$server->getUserManager()->get($uid);
$softQuota = true;
- $quota = $config->getUserValue($uid, 'files', 'quota', null);
- if ( $quota === null || $quota === 'default') {
- $quota = $config->getAppValue('files', 'default_quota', null);
- }
+ $quota = $user->getQuota();
if ( $quota === null || $quota === 'none' ) {
$quota = \OC\Files\Filesystem::free_space('/');
$softQuota = false;
diff --git a/apps/provisioning_api/lib/users.php b/apps/provisioning_api/lib/users.php
index efb10a50865..c609c7bd849 100644
--- a/apps/provisioning_api/lib/users.php
+++ b/apps/provisioning_api/lib/users.php
@@ -278,7 +278,7 @@ class Users {
$quota = \OCP\Util::humanFileSize($quota);
}
}
- $this->config->setUserValue($targetUserId, 'files', 'quota', $quota);
+ $targetUser->setQuota($quota);
break;
case 'password':
$targetUser->setPassword($parameters['_put']['value']);
diff --git a/apps/provisioning_api/tests/userstest.php b/apps/provisioning_api/tests/userstest.php
index 3ce13181b8d..859bc7228e9 100644
--- a/apps/provisioning_api/tests/userstest.php
+++ b/apps/provisioning_api/tests/userstest.php
@@ -1015,6 +1015,9 @@ class UsersTest extends OriginalTest {
->method('getUID')
->will($this->returnValue('UserToEdit'));
$targetUser = $this->getMock('\OCP\IUser');
+ $targetUser->expects($this->once())
+ ->method('setQuota')
+ ->with('2.9 MB');
$this->userSession
->expects($this->once())
->method('getUser')
@@ -1029,10 +1032,6 @@ class UsersTest extends OriginalTest {
->method('isAdmin')
->with('UserToEdit')
->will($this->returnValue(true));
- $this->config
- ->expects($this->once())
- ->method('setUserValue')
- ->with('UserToEdit', 'files', 'quota', '2.9 MB');
$expected = new \OC_OCS_Result(null, 100);
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => '3042824']]));
@@ -1071,6 +1070,9 @@ class UsersTest extends OriginalTest {
->method('getUID')
->will($this->returnValue('admin'));
$targetUser = $this->getMock('\OCP\IUser');
+ $targetUser->expects($this->once())
+ ->method('setQuota')
+ ->with('2.9 MB');
$this->userSession
->expects($this->once())
->method('getUser')
@@ -1092,10 +1094,6 @@ class UsersTest extends OriginalTest {
->expects($this->once())
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
- $this->config
- ->expects($this->once())
- ->method('setUserValue')
- ->with('UserToEdit', 'files', 'quota', '2.9 MB');
$expected = new \OC_OCS_Result(null, 100);
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => '3042824']]));
@@ -1108,6 +1106,9 @@ class UsersTest extends OriginalTest {
->method('getUID')
->will($this->returnValue('subadmin'));
$targetUser = $this->getMock('\OCP\IUser');
+ $targetUser->expects($this->once())
+ ->method('setQuota')
+ ->with('2.9 MB');
$this->userSession
->expects($this->once())
->method('getUser')
@@ -1129,10 +1130,6 @@ class UsersTest extends OriginalTest {
->expects($this->once())
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
- $this->config
- ->expects($this->once())
- ->method('setUserValue')
- ->with('UserToEdit', 'files', 'quota', '2.9 MB');
$expected = new \OC_OCS_Result(null, 100);
$this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => '3042824']]));
diff --git a/apps/user_ldap/lib/user/user.php b/apps/user_ldap/lib/user/user.php
index 3bc790a6c10..8b70c9e2374 100644
--- a/apps/user_ldap/lib/user/user.php
+++ b/apps/user_ldap/lib/user/user.php
@@ -456,7 +456,7 @@ class User {
}
}
if(!is_null($quota)) {
- $this->config->setUserValue($this->uid, 'files', 'quota', $quota);
+ $user = $this->userManager->get($this->uid)->setQuota($quota);
}
}
diff --git a/apps/user_ldap/tests/user/user.php b/apps/user_ldap/tests/user/user.php
index 046edf58968..ca8d81a4b79 100644
--- a/apps/user_ldap/tests/user/user.php
+++ b/apps/user_ldap/tests/user/user.php
@@ -210,13 +210,15 @@ class Test_User_User extends \Test\TestCase {
$this->equalTo('myquota'))
->will($this->returnValue(array('42 GB')));
- $config->expects($this->once())
- ->method('setUserValue')
- ->with($this->equalTo('alice'),
- $this->equalTo('files'),
- $this->equalTo('quota'),
- $this->equalTo('42 GB'))
- ->will($this->returnValue(true));
+ $user = $this->getMock('\OCP\IUser');
+ $user->expects($this->once())
+ ->method('setQuota')
+ ->with('42 GB');
+
+ $userMgr->expects($this->once())
+ ->method('get')
+ ->with('alice')
+ ->will($this->returnValue($user));
$uid = 'alice';
$dn = 'uid=alice,dc=foo,dc=bar';
@@ -253,13 +255,15 @@ class Test_User_User extends \Test\TestCase {
$this->equalTo('myquota'))
->will($this->returnValue(false));
- $config->expects($this->once())
- ->method('setUserValue')
- ->with($this->equalTo('alice'),
- $this->equalTo('files'),
- $this->equalTo('quota'),
- $this->equalTo('25 GB'))
- ->will($this->returnValue(true));
+ $user = $this->getMock('\OCP\IUser');
+ $user->expects($this->once())
+ ->method('setQuota')
+ ->with('25 GB');
+
+ $userMgr->expects($this->once())
+ ->method('get')
+ ->with('alice')
+ ->will($this->returnValue($user));
$uid = 'alice';
$dn = 'uid=alice,dc=foo,dc=bar';
@@ -296,13 +300,15 @@ class Test_User_User extends \Test\TestCase {
$this->equalTo('myquota'))
->will($this->returnValue(array('27 GB')));
- $config->expects($this->once())
- ->method('setUserValue')
- ->with($this->equalTo('alice'),
- $this->equalTo('files'),
- $this->equalTo('quota'),
- $this->equalTo('27 GB'))
- ->will($this->returnValue(true));
+ $user = $this->getMock('\OCP\IUser');
+ $user->expects($this->once())
+ ->method('setQuota')
+ ->with('27 GB');
+
+ $userMgr->expects($this->once())
+ ->method('get')
+ ->with('alice')
+ ->will($this->returnValue($user));
$uid = 'alice';
$dn = 'uid=alice,dc=foo,dc=bar';
@@ -408,13 +414,15 @@ class Test_User_User extends \Test\TestCase {
$access->expects($this->never())
->method('readAttribute');
- $config->expects($this->once())
- ->method('setUserValue')
- ->with($this->equalTo('alice'),
- $this->equalTo('files'),
- $this->equalTo('quota'),
- $this->equalTo($readQuota))
- ->will($this->returnValue(true));
+ $user = $this->getMock('\OCP\IUser');
+ $user->expects($this->once())
+ ->method('setQuota')
+ ->with($readQuota);
+
+ $userMgr->expects($this->once())
+ ->method('get')
+ ->with('alice')
+ ->will($this->returnValue($user));
$uid = 'alice';
$dn = 'uid=alice,dc=foo,dc=bar';