diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-03-09 19:09:22 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-09 19:09:22 -0600 |
commit | c38f87e799c93942c79dfe972b74fa3c2860793d (patch) | |
tree | 1f9cd5133b1e1868bceeec5f43ee6b4ea74fb1fe /apps | |
parent | 8904fb1cf3ececa210e4835fd2c0758530db3249 (diff) | |
parent | a5ba1f78033b3ebe69c771fb33c1217a60494728 (diff) | |
download | nextcloud-server-c38f87e799c93942c79dfe972b74fa3c2860793d.tar.gz nextcloud-server-c38f87e799c93942c79dfe972b74fa3c2860793d.zip |
Merge pull request #3690 from nextcloud/cleanup-legacy-groups-class
Remove legacy class OC_Group and OC_User
Diffstat (limited to 'apps')
-rw-r--r-- | apps/federatedfilesharing/tests/TestCase.php | 18 | ||||
-rw-r--r-- | apps/files_sharing/tests/TestCase.php | 25 | ||||
-rw-r--r-- | apps/user_ldap/appinfo/app.php | 2 | ||||
-rw-r--r-- | apps/user_ldap/lib/Access.php | 4 | ||||
-rw-r--r-- | apps/user_ldap/tests/User_LDAPTest.php | 2 |
5 files changed, 33 insertions, 18 deletions
diff --git a/apps/federatedfilesharing/tests/TestCase.php b/apps/federatedfilesharing/tests/TestCase.php index 7ccf76bbbc6..b31772e4e9e 100644 --- a/apps/federatedfilesharing/tests/TestCase.php +++ b/apps/federatedfilesharing/tests/TestCase.php @@ -42,7 +42,7 @@ abstract class TestCase extends \Test\TestCase { // reset backend \OC_User::clearBackends(); - \OC_Group::clearBackends(); + \OC::$server->getGroupManager()->clearBackends(); // create users $backend = new \Test\Util\User\Dummy(); @@ -76,8 +76,8 @@ abstract class TestCase extends \Test\TestCase { // reset backend \OC_User::clearBackends(); \OC_User::useBackend('database'); - \OC_Group::clearBackends(); - \OC_Group::useBackend(new Database()); + \OC::$server->getGroupManager()->clearBackends(); + \OC::$server->getGroupManager()->addBackend(new Database()); parent::tearDownAfterClass(); } @@ -94,9 +94,15 @@ abstract class TestCase extends \Test\TestCase { } if ($create) { - \OC::$server->getUserManager()->createUser($user, $password); - \OC_Group::createGroup('group'); - \OC_Group::addToGroup($user, 'group'); + $userManager = \OC::$server->getUserManager(); + $groupManager = \OC::$server->getGroupManager(); + + $userObject = $userManager->createUser($user, $password); + $group = $groupManager->createGroup('group'); + + if ($group and $userObject) { + $group->addUser($userObject); + } } self::resetStorage(); diff --git a/apps/files_sharing/tests/TestCase.php b/apps/files_sharing/tests/TestCase.php index a9163a086bf..3b1ccb71a94 100644 --- a/apps/files_sharing/tests/TestCase.php +++ b/apps/files_sharing/tests/TestCase.php @@ -75,7 +75,7 @@ abstract class TestCase extends \Test\TestCase { // reset backend \OC_User::clearBackends(); - \OC_Group::clearBackends(); + \OC::$server->getGroupManager()->clearBackends(); // clear share hooks \OC_Hook::clear('OCP\\Share'); @@ -103,7 +103,7 @@ abstract class TestCase extends \Test\TestCase { $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER3, 'group2'); $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER4, 'group3'); $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_GROUP1); - \OC_Group::useBackend($groupBackend); + \OC::$server->getGroupManager()->addBackend($groupBackend); } protected function setUp() { @@ -136,7 +136,10 @@ abstract class TestCase extends \Test\TestCase { if ($user !== null) { $user->delete(); } // delete group - \OC_Group::deleteGroup(self::TEST_FILES_SHARING_API_GROUP1); + $group = \OC::$server->getGroupManager()->get(self::TEST_FILES_SHARING_API_GROUP1); + if ($group) { + $group->delete(); + } \OC_Util::tearDownFS(); \OC_User::setUserId(''); @@ -145,8 +148,8 @@ abstract class TestCase extends \Test\TestCase { // reset backend \OC_User::clearBackends(); \OC_User::useBackend('database'); - \OC_Group::clearBackends(); - \OC_Group::useBackend(new \OC\Group\Database()); + \OC::$server->getGroupManager()->clearBackends(); + \OC::$server->getGroupManager()->addBackend(new \OC\Group\Database()); parent::tearDownAfterClass(); } @@ -163,9 +166,15 @@ abstract class TestCase extends \Test\TestCase { } if ($create) { - \OC::$server->getUserManager()->createUser($user, $password); - \OC_Group::createGroup('group'); - \OC_Group::addToGroup($user, 'group'); + $userManager = \OC::$server->getUserManager(); + $groupManager = \OC::$server->getGroupManager(); + + $userObject = $userManager->createUser($user, $password); + $group = $groupManager->createGroup('group'); + + if ($group and $userObject) { + $group->addUser($userObject); + } } self::resetStorage(); diff --git a/apps/user_ldap/appinfo/app.php b/apps/user_ldap/appinfo/app.php index 995b1226649..6f930ea39f0 100644 --- a/apps/user_ldap/appinfo/app.php +++ b/apps/user_ldap/appinfo/app.php @@ -58,7 +58,7 @@ if(count($configPrefixes) === 1) { if(count($configPrefixes) > 0) { // register user backend OC_User::useBackend($userBackend); - OC_Group::useBackend($groupBackend); + \OC::$server->getGroupManager()->addBackend($groupBackend); } \OCP\Util::connectHook( diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php index cc0446ae523..ff95d96ebdb 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -570,7 +570,7 @@ class Access extends LDAPUtility implements IUserTools { $originalTTL = $this->connection->ldapCacheTTL; $this->connection->setConfiguration(array('ldapCacheTTL' => 0)); if(($isUser && !\OCP\User::userExists($intName)) - || (!$isUser && !\OC_Group::groupExists($intName))) { + || (!$isUser && !\OC::$server->getGroupManager()->groupExists($intName))) { if($mapper->map($fdn, $intName, $uuid)) { $this->connection->setConfiguration(array('ldapCacheTTL' => $originalTTL)); return $intName; @@ -737,7 +737,7 @@ class Access extends LDAPUtility implements IUserTools { // Check to be really sure it is unique // while loop is just a precaution. If a name is not generated within // 20 attempts, something else is very wrong. Avoids infinite loop. - if(!\OC_Group::groupExists($altName)) { + if(!\OC::$server->getGroupManager()->groupExists($altName)) { return $altName; } $altName = $name . '_' . ($lastNo + $attempts); diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php index 606eff4e7a7..f1a23f9a6c8 100644 --- a/apps/user_ldap/tests/User_LDAPTest.php +++ b/apps/user_ldap/tests/User_LDAPTest.php @@ -64,7 +64,7 @@ class User_LDAPTest extends TestCase { parent::setUp(); \OC_User::clearBackends(); - \OC_Group::clearBackends(); + \OC::$server->getGroupManager()->clearBackends(); } /** |