Unnecessary fully qualified names

This commit is contained in:
Jörn Friedrich Dreyer 2016-08-11 09:52:02 +02:00 committed by Roeland Jago Douma
parent 241fc286c7
commit d2a16c4dc8
No known key found for this signature in database
GPG key ID: 1E152838F164D13B
4 changed files with 25 additions and 17 deletions

View file

@ -22,11 +22,13 @@
namespace OC\User; namespace OC\User;
use \OCP\UserInterface;
/** /**
* Abstract base class for user management. Provides methods for querying backend * Abstract base class for user management. Provides methods for querying backend
* capabilities. * capabilities.
*/ */
abstract class Backend implements \OCP\UserInterface { abstract class Backend implements UserInterface {
/** /**
* error code for functions not provided by the user backend * error code for functions not provided by the user backend
*/ */

View file

@ -55,15 +55,19 @@ namespace OC\User;
use OC\Cache\CappedMemoryCache; use OC\Cache\CappedMemoryCache;
use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\GenericEvent; use Symfony\Component\EventDispatcher\GenericEvent;
use OCP\IUserBackend;
use OCP\Util;
/** /**
* Class for user management in a SQL Database (e.g. MySQL, SQLite) * Class for user management in a SQL Database (e.g. MySQL, SQLite)
*/ */
class Database extends \OC\User\Backend implements \OCP\IUserBackend { class Database extends Backend implements IUserBackend {
/** @var CappedMemoryCache */ /** @var CappedMemoryCache */
private $cache; private $cache;
/** @var EventDispatcher */ /** @var EventDispatcher */
private $eventDispatcher; private $eventDispatcher;
/** /**
* OC_User_Database constructor. * OC_User_Database constructor.
*/ */
@ -233,7 +237,7 @@ class Database extends \OC\User\Backend implements \OCP\IUserBackend {
$result = $query->execute(array($uid)); $result = $query->execute(array($uid));
if ($result === false) { if ($result === false) {
\OCP\Util::writeLog('core', \OC_DB::getErrorMessage(), \OCP\Util::ERROR); Util::writeLog('core', \OC_DB::getErrorMessage(), Util::ERROR);
return false; return false;
} }
@ -310,7 +314,7 @@ class Database extends \OC\User\Backend implements \OCP\IUserBackend {
$query = \OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users`'); $query = \OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users`');
$result = $query->execute(); $result = $query->execute();
if ($result === false) { if ($result === false) {
\OCP\Util::writeLog('core', \OC_DB::getErrorMessage(), \OCP\Util::ERROR); Util::writeLog('core', \OC_DB::getErrorMessage(), Util::ERROR);
return false; return false;
} }
return $result->fetchOne(); return $result->fetchOne();
@ -345,7 +349,7 @@ class Database extends \OC\User\Backend implements \OCP\IUserBackend {
$backends = \OC::$server->getUserManager()->getBackends(); $backends = \OC::$server->getUserManager()->getBackends();
foreach ($backends as $backend) { foreach ($backends as $backend) {
if ($backend instanceof \OC\User\Database) { if ($backend instanceof Database) {
/** @var \OC\User\Database $backend */ /** @var \OC\User\Database $backend */
$uid = $backend->loginName2UserName($param['uid']); $uid = $backend->loginName2UserName($param['uid']);
if ($uid !== false) { if ($uid !== false) {

View file

@ -187,7 +187,7 @@ class Manager extends PublicEmitter implements IUserManager {
$password = str_replace("\0", '', $password); $password = str_replace("\0", '', $password);
foreach ($this->backends as $backend) { foreach ($this->backends as $backend) {
if ($backend->implementsActions(\OC\User\Backend::CHECK_PASSWORD)) { if ($backend->implementsActions(Backend::CHECK_PASSWORD)) {
$uid = $backend->checkPassword($loginName, $password); $uid = $backend->checkPassword($loginName, $password);
if ($uid !== false) { if ($uid !== false) {
return $this->getUserObject($uid, $backend); return $this->getUserObject($uid, $backend);
@ -291,7 +291,7 @@ class Manager extends PublicEmitter implements IUserManager {
$this->emit('\OC\User', 'preCreateUser', array($uid, $password)); $this->emit('\OC\User', 'preCreateUser', array($uid, $password));
foreach ($this->backends as $backend) { foreach ($this->backends as $backend) {
if ($backend->implementsActions(\OC\User\Backend::CREATE_USER)) { if ($backend->implementsActions(Backend::CREATE_USER)) {
$backend->createUser($uid, $password); $backend->createUser($uid, $password);
$user = $this->getUserObject($uid, $backend); $user = $this->getUserObject($uid, $backend);
$this->emit('\OC\User', 'postCreateUser', array($user, $password)); $this->emit('\OC\User', 'postCreateUser', array($user, $password));
@ -309,7 +309,7 @@ class Manager extends PublicEmitter implements IUserManager {
public function countUsers() { public function countUsers() {
$userCountStatistics = array(); $userCountStatistics = array();
foreach ($this->backends as $backend) { foreach ($this->backends as $backend) {
if ($backend->implementsActions(\OC\User\Backend::COUNT_USERS)) { if ($backend->implementsActions(Backend::COUNT_USERS)) {
$backendUsers = $backend->countUsers(); $backendUsers = $backend->countUsers();
if($backendUsers !== false) { if($backendUsers !== false) {
if($backend instanceof IUserBackend) { if($backend instanceof IUserBackend) {

View file

@ -30,6 +30,7 @@
namespace OC\User; namespace OC\User;
use OC\Files\Cache\Storage;
use OC\Hooks\Emitter; use OC\Hooks\Emitter;
use OC_Helper; use OC_Helper;
use OCP\IAvatarManager; use OCP\IAvatarManager;
@ -38,6 +39,7 @@ use OCP\IURLGenerator;
use OCP\IUser; use OCP\IUser;
use OCP\IConfig; use OCP\IConfig;
use OCP\UserInterface; use OCP\UserInterface;
use \OCP\IUserBackend;
class User implements IUser { class User implements IUser {
/** @var string $uid */ /** @var string $uid */
@ -111,7 +113,7 @@ class User implements IUser {
public function getDisplayName() { public function getDisplayName() {
if (!isset($this->displayName)) { if (!isset($this->displayName)) {
$displayName = ''; $displayName = '';
if ($this->backend and $this->backend->implementsActions(\OC\User\Backend::GET_DISPLAYNAME)) { if ($this->backend and $this->backend->implementsActions(Backend::GET_DISPLAYNAME)) {
// get display name and strip whitespace from the beginning and end of it // get display name and strip whitespace from the beginning and end of it
$backendDisplayName = $this->backend->getDisplayName($this->uid); $backendDisplayName = $this->backend->getDisplayName($this->uid);
if (is_string($backendDisplayName)) { if (is_string($backendDisplayName)) {
@ -136,7 +138,7 @@ class User implements IUser {
*/ */
public function setDisplayName($displayName) { public function setDisplayName($displayName) {
$displayName = trim($displayName); $displayName = trim($displayName);
if ($this->backend->implementsActions(\OC\User\Backend::SET_DISPLAYNAME) && !empty($displayName)) { if ($this->backend->implementsActions(Backend::SET_DISPLAYNAME) && !empty($displayName)) {
$result = $this->backend->setDisplayName($this->uid, $displayName); $result = $this->backend->setDisplayName($this->uid, $displayName);
if ($result) { if ($result) {
$this->displayName = $displayName; $this->displayName = $displayName;
@ -208,7 +210,7 @@ class User implements IUser {
\OC_Helper::rmdirr(\OC_User::getHome($this->uid)); \OC_Helper::rmdirr(\OC_User::getHome($this->uid));
// Delete the users entry in the storage table // Delete the users entry in the storage table
\OC\Files\Cache\Storage::remove('home::' . $this->uid); Storage::remove('home::' . $this->uid);
\OC::$server->getCommentsManager()->deleteReferencesOfActor('users', $this->uid); \OC::$server->getCommentsManager()->deleteReferencesOfActor('users', $this->uid);
\OC::$server->getCommentsManager()->deleteReadMarksFromUser($this); \OC::$server->getCommentsManager()->deleteReadMarksFromUser($this);
@ -231,7 +233,7 @@ class User implements IUser {
if ($this->emitter) { if ($this->emitter) {
$this->emitter->emit('\OC\User', 'preSetPassword', array($this, $password, $recoveryPassword)); $this->emitter->emit('\OC\User', 'preSetPassword', array($this, $password, $recoveryPassword));
} }
if ($this->backend->implementsActions(\OC\User\Backend::SET_PASSWORD)) { if ($this->backend->implementsActions(Backend::SET_PASSWORD)) {
$result = $this->backend->setPassword($this->uid, $password); $result = $this->backend->setPassword($this->uid, $password);
if ($this->emitter) { if ($this->emitter) {
$this->emitter->emit('\OC\User', 'postSetPassword', array($this, $password, $recoveryPassword)); $this->emitter->emit('\OC\User', 'postSetPassword', array($this, $password, $recoveryPassword));
@ -249,7 +251,7 @@ class User implements IUser {
*/ */
public function getHome() { public function getHome() {
if (!$this->home) { if (!$this->home) {
if ($this->backend->implementsActions(\OC\User\Backend::GET_HOME) and $home = $this->backend->getHome($this->uid)) { if ($this->backend->implementsActions(Backend::GET_HOME) and $home = $this->backend->getHome($this->uid)) {
$this->home = $home; $this->home = $home;
} elseif ($this->config) { } elseif ($this->config) {
$this->home = $this->config->getSystemValue('datadirectory') . '/' . $this->uid; $this->home = $this->config->getSystemValue('datadirectory') . '/' . $this->uid;
@ -266,7 +268,7 @@ class User implements IUser {
* @return string * @return string
*/ */
public function getBackendClassName() { public function getBackendClassName() {
if($this->backend instanceof \OCP\IUserBackend) { if($this->backend instanceof IUserBackend) {
return $this->backend->getBackendName(); return $this->backend->getBackendName();
} }
return get_class($this->backend); return get_class($this->backend);
@ -278,7 +280,7 @@ class User implements IUser {
* @return bool * @return bool
*/ */
public function canChangeAvatar() { public function canChangeAvatar() {
if ($this->backend->implementsActions(\OC\User\Backend::PROVIDE_AVATAR)) { if ($this->backend->implementsActions(Backend::PROVIDE_AVATAR)) {
return $this->backend->canChangeAvatar($this->uid); return $this->backend->canChangeAvatar($this->uid);
} }
return true; return true;
@ -290,7 +292,7 @@ class User implements IUser {
* @return bool * @return bool
*/ */
public function canChangePassword() { public function canChangePassword() {
return $this->backend->implementsActions(\OC\User\Backend::SET_PASSWORD); return $this->backend->implementsActions(Backend::SET_PASSWORD);
} }
/** /**
@ -302,7 +304,7 @@ class User implements IUser {
if ($this->config->getSystemValue('allow_user_to_change_display_name') === false) { if ($this->config->getSystemValue('allow_user_to_change_display_name') === false) {
return false; return false;
} }
return $this->backend->implementsActions(\OC\User\Backend::SET_DISPLAYNAME); return $this->backend->implementsActions(Backend::SET_DISPLAYNAME);
} }
/** /**