diff options
-rw-r--r-- | lib/base.php | 2 | ||||
-rw-r--r-- | lib/private/User/Database.php (renamed from lib/private/legacy/user/database.php) | 32 | ||||
-rw-r--r-- | lib/private/legacy/user.php | 2 | ||||
-rw-r--r-- | tests/lib/user/database.php | 2 | ||||
-rw-r--r-- | tests/lib/user/user.php | 8 | ||||
-rw-r--r-- | tests/settings/controller/userscontrollertest.php | 4 |
6 files changed, 26 insertions, 24 deletions
diff --git a/lib/base.php b/lib/base.php index badbe3cd1f8..0ea8a117e98 100644 --- a/lib/base.php +++ b/lib/base.php @@ -619,7 +619,7 @@ class OC { self::$server->getSession()->set('user_id', ''); } - OC_User::useBackend(new OC_User_Database()); + OC_User::useBackend(new \OC\User\Database()); OC_Group::useBackend(new OC_Group_Database()); // Subscribe to the hook diff --git a/lib/private/legacy/user/database.php b/lib/private/User/Database.php index fd273055ae1..ac8b2f96e53 100644 --- a/lib/private/legacy/user/database.php +++ b/lib/private/User/Database.php @@ -48,12 +48,14 @@ * */ +namespace OC\User; + use OC\Cache\CappedMemoryCache; /** * Class for user management in a SQL Database (e.g. MySQL, SQLite) */ -class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend { +class Database extends \OC_User_Backend implements \OCP\IUserBackend { /** @var CappedMemoryCache */ private $cache; @@ -75,7 +77,7 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend { */ public function createUser($uid, $password) { if (!$this->userExists($uid)) { - $query = OC_DB::prepare('INSERT INTO `*PREFIX*users` ( `uid`, `password` ) VALUES( ?, ? )'); + $query = \OC_DB::prepare('INSERT INTO `*PREFIX*users` ( `uid`, `password` ) VALUES( ?, ? )'); $result = $query->execute(array($uid, \OC::$server->getHasher()->hash($password))); return $result ? true : false; @@ -93,7 +95,7 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend { */ public function deleteUser($uid) { // Delete user-group-relation - $query = OC_DB::prepare('DELETE FROM `*PREFIX*users` WHERE `uid` = ?'); + $query = \OC_DB::prepare('DELETE FROM `*PREFIX*users` WHERE `uid` = ?'); $result = $query->execute(array($uid)); if (isset($this->cache[$uid])) { @@ -113,7 +115,7 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend { */ public function setPassword($uid, $password) { if ($this->userExists($uid)) { - $query = OC_DB::prepare('UPDATE `*PREFIX*users` SET `password` = ? WHERE `uid` = ?'); + $query = \OC_DB::prepare('UPDATE `*PREFIX*users` SET `password` = ? WHERE `uid` = ?'); $result = $query->execute(array(\OC::$server->getHasher()->hash($password), $uid)); return $result ? true : false; @@ -132,7 +134,7 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend { */ public function setDisplayName($uid, $displayName) { if ($this->userExists($uid)) { - $query = OC_DB::prepare('UPDATE `*PREFIX*users` SET `displayname` = ? WHERE LOWER(`uid`) = LOWER(?)'); + $query = \OC_DB::prepare('UPDATE `*PREFIX*users` SET `displayname` = ? WHERE LOWER(`uid`) = LOWER(?)'); $query->execute(array($displayName, $uid)); $this->cache[$uid]['displayname'] = $displayName; @@ -171,7 +173,7 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend { } $displayNames = array(); - $query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`' + $query = \OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`' . $searchLike .' ORDER BY `uid` ASC', $limit, $offset); $result = $query->execute($parameters); while ($row = $result->fetchRow()) { @@ -191,7 +193,7 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend { * returns the user id or false */ public function checkPassword($uid, $password) { - $query = OC_DB::prepare('SELECT `uid`, `password` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)'); + $query = \OC_DB::prepare('SELECT `uid`, `password` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)'); $result = $query->execute(array($uid)); $row = $result->fetchRow(); @@ -217,11 +219,11 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend { */ private function loadUser($uid) { if (empty($this->cache[$uid])) { - $query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)'); + $query = \OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)'); $result = $query->execute(array($uid)); if ($result === false) { - \OCP\Util::writeLog('core', OC_DB::getErrorMessage(), \OCP\Util::ERROR); + \OCP\Util::writeLog('core', \OC_DB::getErrorMessage(), \OCP\Util::ERROR); return false; } @@ -250,7 +252,7 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend { $searchLike = ' WHERE LOWER(`uid`) LIKE LOWER(?)'; } - $query = OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users`' . $searchLike . ' ORDER BY `uid` ASC', $limit, $offset); + $query = \OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users`' . $searchLike . ' ORDER BY `uid` ASC', $limit, $offset); $result = $query->execute($parameters); $users = array(); while ($row = $result->fetchRow()) { @@ -276,7 +278,7 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend { */ public function getHome($uid) { if ($this->userExists($uid)) { - return \OC::$server->getConfig()->getSystemValue("datadirectory", OC::$SERVERROOT . "/data") . '/' . $uid; + return \OC::$server->getConfig()->getSystemValue("datadirectory", \OC::$SERVERROOT . "/data") . '/' . $uid; } return false; @@ -295,10 +297,10 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend { * @return int|bool */ public function countUsers() { - $query = OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users`'); + $query = \OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users`'); $result = $query->execute(); if ($result === false) { - \OCP\Util::writeLog('core', OC_DB::getErrorMessage(), \OCP\Util::ERROR); + \OCP\Util::writeLog('core', \OC_DB::getErrorMessage(), \OCP\Util::ERROR); return false; } return $result->fetchOne(); @@ -333,8 +335,8 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend { $backends = \OC::$server->getUserManager()->getBackends(); foreach ($backends as $backend) { - if ($backend instanceof \OC_User_Database) { - /** @var \OC_User_Database $backend */ + if ($backend instanceof \OC\User\Database) { + /** @var \OC\User\Database $backend */ $uid = $backend->loginName2UserName($param['uid']); if ($uid !== false) { $param['uid'] = $uid; diff --git a/lib/private/legacy/user.php b/lib/private/legacy/user.php index f0e829bbe33..7855b5e7059 100644 --- a/lib/private/legacy/user.php +++ b/lib/private/legacy/user.php @@ -94,7 +94,7 @@ class OC_User { case 'mysql': case 'sqlite': \OCP\Util::writeLog('core', 'Adding user backend ' . $backend . '.', \OCP\Util::DEBUG); - self::$_usedBackends[$backend] = new OC_User_Database(); + self::$_usedBackends[$backend] = new \OC\User\Database(); \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); break; case 'dummy': diff --git a/tests/lib/user/database.php b/tests/lib/user/database.php index ba44d333a8c..0dea037ad78 100644 --- a/tests/lib/user/database.php +++ b/tests/lib/user/database.php @@ -37,7 +37,7 @@ class Test_User_Database extends Test_User_Backend { protected function setUp() { parent::setUp(); - $this->backend=new OC_User_Database(); + $this->backend=new \OC\User\Database(); } protected function tearDown() { diff --git a/tests/lib/user/user.php b/tests/lib/user/user.php index a8d688d9c88..acb557ccd91 100644 --- a/tests/lib/user/user.php +++ b/tests/lib/user/user.php @@ -225,7 +225,7 @@ class User extends \Test\TestCase { public function testGetBackendClassName() { $user = new \OC\User\User('foo', new \Test\Util\User\Dummy()); $this->assertEquals('Dummy', $user->getBackendClassName()); - $user = new \OC\User\User('foo', new \OC_User_Database()); + $user = new \OC\User\User('foo', new \OC\User\Database()); $this->assertEquals('Database', $user->getBackendClassName()); } @@ -328,7 +328,7 @@ class User extends \Test\TestCase { /** * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Database'); + $backend = $this->getMock('\OC\User\Database'); $backend->expects($this->any()) ->method('implementsActions') @@ -357,7 +357,7 @@ class User extends \Test\TestCase { /** * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Database'); + $backend = $this->getMock('\OC\User\Database'); $backend->expects($this->any()) ->method('implementsActions') @@ -378,7 +378,7 @@ class User extends \Test\TestCase { /** * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend */ - $backend = $this->getMock('\OC_User_Database'); + $backend = $this->getMock('\OC\User\Database'); $backend->expects($this->any()) ->method('implementsActions') diff --git a/tests/settings/controller/userscontrollertest.php b/tests/settings/controller/userscontrollertest.php index 6f07f34ba8d..2a2b53d8ff8 100644 --- a/tests/settings/controller/userscontrollertest.php +++ b/tests/settings/controller/userscontrollertest.php @@ -668,7 +668,7 @@ class UsersControllerTest extends \Test\TestCase { $this->container['UserManager'] ->expects($this->once()) ->method('getBackends') - ->will($this->returnValue([new \Test\Util\User\Dummy(), new \OC_User_Database()])); + ->will($this->returnValue([new \Test\Util\User\Dummy(), new \OC\User\Database()])); $this->container['UserManager'] ->expects($this->once()) ->method('clearBackends'); @@ -716,7 +716,7 @@ class UsersControllerTest extends \Test\TestCase { $this->container['UserManager'] ->expects($this->once()) ->method('getBackends') - ->will($this->returnValue([new \Test\Util\User\Dummy(), new \OC_User_Database()])); + ->will($this->returnValue([new \Test\Util\User\Dummy(), new \OC\User\Database()])); $this->container['UserManager'] ->expects($this->once()) ->method('search') |