summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorThomas Müller <DeepDiver1975@users.noreply.github.com>2016-05-11 11:16:56 +0200
committerThomas Müller <DeepDiver1975@users.noreply.github.com>2016-05-11 11:16:56 +0200
commit9eea0620045979a1ed437749005256bdb223fce4 (patch)
tree357f8fee1424d56c5a77f2683d66c6e507d928ac /lib/private
parenta02c5240073c83c2fe9ce2d064ac9f942d201a26 (diff)
parente2748e4cbfc72e8d8694b5326125a9cf6e7a0985 (diff)
downloadnextcloud-server-9eea0620045979a1ed437749005256bdb223fce4.tar.gz
nextcloud-server-9eea0620045979a1ed437749005256bdb223fce4.zip
Merge pull request #24433 from owncloud/user_psr4
lib/private/user to PSR-4
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/User/Backend.php (renamed from lib/private/user/backend.php)28
-rw-r--r--lib/private/User/Database.php (renamed from lib/private/user/database.php)32
-rw-r--r--lib/private/User/LoginException.php (renamed from lib/private/user/loginexception.php)0
-rw-r--r--lib/private/User/Manager.php (renamed from lib/private/user/manager.php)6
-rw-r--r--lib/private/User/NoUserException.php (renamed from lib/private/user/nouserexception.php)0
-rw-r--r--lib/private/User/Session.php (renamed from lib/private/user/session.php)0
-rw-r--r--lib/private/User/User.php (renamed from lib/private/user/user.php)14
-rw-r--r--lib/private/legacy/user.php2
-rw-r--r--lib/private/legacy/user/backend.php67
-rw-r--r--lib/private/legacy/user/interface.php (renamed from lib/private/user/interface.php)0
10 files changed, 97 insertions, 52 deletions
diff --git a/lib/private/user/backend.php b/lib/private/User/Backend.php
index 2bb1df4d6b3..d5f82dc9621 100644
--- a/lib/private/user/backend.php
+++ b/lib/private/User/Backend.php
@@ -32,37 +32,13 @@
*
*/
-/**
- * error code for functions not provided by the user backend
- * @deprecated Use \OC_User_Backend::NOT_IMPLEMENTED instead
- */
-define('OC_USER_BACKEND_NOT_IMPLEMENTED', -501);
-
-/**
- * actions that user backends can define
- */
-/** @deprecated Use \OC_User_Backend::CREATE_USER instead */
-define('OC_USER_BACKEND_CREATE_USER', 1 << 0);
-/** @deprecated Use \OC_User_Backend::SET_PASSWORD instead */
-define('OC_USER_BACKEND_SET_PASSWORD', 1 << 4);
-/** @deprecated Use \OC_User_Backend::CHECK_PASSWORD instead */
-define('OC_USER_BACKEND_CHECK_PASSWORD', 1 << 8);
-/** @deprecated Use \OC_User_Backend::GET_HOME instead */
-define('OC_USER_BACKEND_GET_HOME', 1 << 12);
-/** @deprecated Use \OC_User_Backend::GET_DISPLAYNAME instead */
-define('OC_USER_BACKEND_GET_DISPLAYNAME', 1 << 16);
-/** @deprecated Use \OC_User_Backend::SET_DISPLAYNAME instead */
-define('OC_USER_BACKEND_SET_DISPLAYNAME', 1 << 20);
-/** @deprecated Use \OC_User_Backend::PROVIDE_AVATAR instead */
-define('OC_USER_BACKEND_PROVIDE_AVATAR', 1 << 24);
-/** @deprecated Use \OC_User_Backend::COUNT_USERS instead */
-define('OC_USER_BACKEND_COUNT_USERS', 1 << 28);
+namespace OC\User;
/**
* Abstract base class for user management. Provides methods for querying backend
* capabilities.
*/
-abstract class OC_User_Backend implements \OCP\UserInterface {
+abstract class Backend implements \OCP\UserInterface {
/**
* error code for functions not provided by the user backend
*/
diff --git a/lib/private/user/database.php b/lib/private/User/Database.php
index fd273055ae1..7a4b58e6f40 100644
--- a/lib/private/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/user/loginexception.php b/lib/private/User/LoginException.php
index 84426f7f5da..84426f7f5da 100644
--- a/lib/private/user/loginexception.php
+++ b/lib/private/User/LoginException.php
diff --git a/lib/private/user/manager.php b/lib/private/User/Manager.php
index 37a3e5ba134..a9d9425e24d 100644
--- a/lib/private/user/manager.php
+++ b/lib/private/User/Manager.php
@@ -186,7 +186,7 @@ class Manager extends PublicEmitter implements IUserManager {
$password = str_replace("\0", '', $password);
foreach ($this->backends as $backend) {
- if ($backend->implementsActions(\OC_User_Backend::CHECK_PASSWORD)) {
+ if ($backend->implementsActions(\OC\User\Backend::CHECK_PASSWORD)) {
$uid = $backend->checkPassword($loginName, $password);
if ($uid !== false) {
return $this->getUserObject($uid, $backend);
@@ -290,7 +290,7 @@ class Manager extends PublicEmitter implements IUserManager {
$this->emit('\OC\User', 'preCreateUser', array($uid, $password));
foreach ($this->backends as $backend) {
- if ($backend->implementsActions(\OC_User_Backend::CREATE_USER)) {
+ if ($backend->implementsActions(\OC\User\Backend::CREATE_USER)) {
$backend->createUser($uid, $password);
$user = $this->getUserObject($uid, $backend);
$this->emit('\OC\User', 'postCreateUser', array($user, $password));
@@ -308,7 +308,7 @@ class Manager extends PublicEmitter implements IUserManager {
public function countUsers() {
$userCountStatistics = array();
foreach ($this->backends as $backend) {
- if ($backend->implementsActions(\OC_User_Backend::COUNT_USERS)) {
+ if ($backend->implementsActions(\OC\User\Backend::COUNT_USERS)) {
$backendUsers = $backend->countUsers();
if($backendUsers !== false) {
if($backend instanceof IUserBackend) {
diff --git a/lib/private/user/nouserexception.php b/lib/private/User/NoUserException.php
index afd5c729fcf..afd5c729fcf 100644
--- a/lib/private/user/nouserexception.php
+++ b/lib/private/User/NoUserException.php
diff --git a/lib/private/user/session.php b/lib/private/User/Session.php
index c7f8a6920de..c7f8a6920de 100644
--- a/lib/private/user/session.php
+++ b/lib/private/User/Session.php
diff --git a/lib/private/user/user.php b/lib/private/User/User.php
index 36680436769..66ecbd18534 100644
--- a/lib/private/user/user.php
+++ b/lib/private/User/User.php
@@ -110,7 +110,7 @@ class User implements IUser {
public function getDisplayName() {
if (!isset($this->displayName)) {
$displayName = '';
- if ($this->backend and $this->backend->implementsActions(\OC_User_Backend::GET_DISPLAYNAME)) {
+ if ($this->backend and $this->backend->implementsActions(\OC\User\Backend::GET_DISPLAYNAME)) {
// get display name and strip whitespace from the beginning and end of it
$backendDisplayName = $this->backend->getDisplayName($this->uid);
if (is_string($backendDisplayName)) {
@@ -135,7 +135,7 @@ class User implements IUser {
*/
public function setDisplayName($displayName) {
$displayName = trim($displayName);
- if ($this->backend->implementsActions(\OC_User_Backend::SET_DISPLAYNAME) && !empty($displayName)) {
+ if ($this->backend->implementsActions(\OC\User\Backend::SET_DISPLAYNAME) && !empty($displayName)) {
$result = $this->backend->setDisplayName($this->uid, $displayName);
if ($result) {
$this->displayName = $displayName;
@@ -230,7 +230,7 @@ class User implements IUser {
if ($this->emitter) {
$this->emitter->emit('\OC\User', 'preSetPassword', array($this, $password, $recoveryPassword));
}
- if ($this->backend->implementsActions(\OC_User_Backend::SET_PASSWORD)) {
+ if ($this->backend->implementsActions(\OC\User\Backend::SET_PASSWORD)) {
$result = $this->backend->setPassword($this->uid, $password);
if ($this->emitter) {
$this->emitter->emit('\OC\User', 'postSetPassword', array($this, $password, $recoveryPassword));
@@ -248,7 +248,7 @@ class User implements IUser {
*/
public function getHome() {
if (!$this->home) {
- if ($this->backend->implementsActions(\OC_User_Backend::GET_HOME) and $home = $this->backend->getHome($this->uid)) {
+ if ($this->backend->implementsActions(\OC\User\Backend::GET_HOME) and $home = $this->backend->getHome($this->uid)) {
$this->home = $home;
} elseif ($this->config) {
$this->home = $this->config->getSystemValue('datadirectory') . '/' . $this->uid;
@@ -277,7 +277,7 @@ class User implements IUser {
* @return bool
*/
public function canChangeAvatar() {
- if ($this->backend->implementsActions(\OC_User_Backend::PROVIDE_AVATAR)) {
+ if ($this->backend->implementsActions(\OC\User\Backend::PROVIDE_AVATAR)) {
return $this->backend->canChangeAvatar($this->uid);
}
return true;
@@ -289,7 +289,7 @@ class User implements IUser {
* @return bool
*/
public function canChangePassword() {
- return $this->backend->implementsActions(\OC_User_Backend::SET_PASSWORD);
+ return $this->backend->implementsActions(\OC\User\Backend::SET_PASSWORD);
}
/**
@@ -301,7 +301,7 @@ class User implements IUser {
if ($this->config->getSystemValue('allow_user_to_change_display_name') === false) {
return false;
}
- return $this->backend->implementsActions(\OC_User_Backend::SET_DISPLAYNAME);
+ return $this->backend->implementsActions(\OC\User\Backend::SET_DISPLAYNAME);
}
/**
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/lib/private/legacy/user/backend.php b/lib/private/legacy/user/backend.php
new file mode 100644
index 00000000000..42c7b9aa126
--- /dev/null
+++ b/lib/private/legacy/user/backend.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * @author Aldo "xoen" Giambelluca <xoen@xoen.org>
+ * @author Bart Visscher <bartv@thisnet.nl>
+ * @author Björn Schießle <schiessle@owncloud.com>
+ * @author Dominik Schmidt <dev@dominik-schmidt.de>
+ * @author Georg Ehrke <georg@owncloud.com>
+ * @author Jakob Sack <mail@jakobsack.de>
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ * @author Jörn Friedrich Dreyer <jfd@butonic.de>
+ * @author Lukas Reschke <lukas@owncloud.com>
+ * @author Morris Jobke <hey@morrisjobke.de>
+ * @author Robin Appelman <icewind@owncloud.com>
+ * @author Sam Tuke <mail@samtuke.com>
+ * @author Thomas Müller <thomas.mueller@tmit.eu>
+ * @author Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+/**
+ * error code for functions not provided by the user backend
+ * @deprecated Use \OC_User_Backend::NOT_IMPLEMENTED instead
+ */
+define('OC_USER_BACKEND_NOT_IMPLEMENTED', -501);
+
+/**
+ * actions that user backends can define
+ */
+/** @deprecated Use \OC_User_Backend::CREATE_USER instead */
+define('OC_USER_BACKEND_CREATE_USER', 1 << 0);
+/** @deprecated Use \OC_User_Backend::SET_PASSWORD instead */
+define('OC_USER_BACKEND_SET_PASSWORD', 1 << 4);
+/** @deprecated Use \OC_User_Backend::CHECK_PASSWORD instead */
+define('OC_USER_BACKEND_CHECK_PASSWORD', 1 << 8);
+/** @deprecated Use \OC_User_Backend::GET_HOME instead */
+define('OC_USER_BACKEND_GET_HOME', 1 << 12);
+/** @deprecated Use \OC_User_Backend::GET_DISPLAYNAME instead */
+define('OC_USER_BACKEND_GET_DISPLAYNAME', 1 << 16);
+/** @deprecated Use \OC_User_Backend::SET_DISPLAYNAME instead */
+define('OC_USER_BACKEND_SET_DISPLAYNAME', 1 << 20);
+/** @deprecated Use \OC_User_Backend::PROVIDE_AVATAR instead */
+define('OC_USER_BACKEND_PROVIDE_AVATAR', 1 << 24);
+/** @deprecated Use \OC_User_Backend::COUNT_USERS instead */
+define('OC_USER_BACKEND_COUNT_USERS', 1 << 28);
+
+/**
+ * Abstract base class for user management. Provides methods for querying backend
+ * capabilities.
+ */
+abstract class OC_User_Backend extends \OC\User\Backend implements \OCP\UserInterface {
+
+}
diff --git a/lib/private/user/interface.php b/lib/private/legacy/user/interface.php
index d2868a79c2c..d2868a79c2c 100644
--- a/lib/private/user/interface.php
+++ b/lib/private/legacy/user/interface.php