Skip to content
Snippets Groups Projects
Commit 0c8021e9 authored by Thomas Müller's avatar Thomas Müller
Browse files

Merge pull request #21832 from owncloud/reduce-user-object-issues

Always set up a config object within the user object
parents 55e55dd9 5fe55de6
No related branches found
No related tags found
No related merge requests found
......@@ -80,16 +80,14 @@ class User implements IUser {
$this->uid = $uid;
$this->backend = $backend;
$this->emitter = $emitter;
if(is_null($config)) {
$config = \OC::$server->getConfig();
}
$this->config = $config;
$this->urlGenerator = $urlGenerator;
if ($this->config) {
$enabled = $this->config->getUserValue($uid, 'core', 'enabled', 'true');
$this->enabled = ($enabled === 'true');
$this->lastLogin = $this->config->getUserValue($uid, 'login', 'lastLogin', 0);
} else {
$this->enabled = true;
$this->lastLogin = \OC::$server->getConfig()->getUserValue($uid, 'login', 'lastLogin', 0);
}
$enabled = $this->config->getUserValue($uid, 'core', 'enabled', 'true');
$this->enabled = ($enabled === 'true');
$this->lastLogin = $this->config->getUserValue($uid, 'login', 'lastLogin', 0);
if (is_null($this->urlGenerator)) {
$this->urlGenerator = \OC::$server->getURLGenerator();
}
......@@ -300,11 +298,10 @@ class User implements IUser {
* @return bool
*/
public function canChangeDisplayName() {
if ($this->config and $this->config->getSystemValue('allow_user_to_change_display_name') === false) {
if ($this->config->getSystemValue('allow_user_to_change_display_name') === false) {
return false;
} else {
return $this->backend->implementsActions(\OC_User_Backend::SET_DISPLAYNAME);
}
return $this->backend->implementsActions(\OC_User_Backend::SET_DISPLAYNAME);
}
/**
......@@ -323,10 +320,8 @@ class User implements IUser {
*/
public function setEnabled($enabled) {
$this->enabled = $enabled;
if ($this->config) {
$enabled = ($enabled) ? 'true' : 'false';
$this->config->setUserValue($this->uid, 'core', 'enabled', $enabled);
}
$enabled = ($enabled) ? 'true' : 'false';
$this->config->setUserValue($this->uid, 'core', 'enabled', $enabled);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment