/** @var IEventDispatcher */
private $dispatcher;
- /** @var bool */
+ /** @var bool|null */
private $enabled;
/** @var Emitter|Manager */
/** @var string */
private $home;
- /** @var int */
+ /** @var int|null */
private $lastLogin;
/** @var \OCP\IConfig */
}
$this->config = $config;
$this->urlGenerator = $urlGenerator;
- $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();
}
* @return int
*/
public function getLastLogin() {
- return $this->lastLogin;
+ if ($this->lastLogin === null) {
+ $this->lastLogin = (int) $this->config->getUserValue($this->uid, 'login', 'lastLogin', 0);
+ }
+ return (int) $this->lastLogin;
}
/**
* updates the timestamp of the most recent login of this user
*/
public function updateLastLoginTimestamp() {
- $firstTimeLogin = ($this->lastLogin === 0);
+ $firstTimeLogin = ($this->getLastLogin() === 0);
$this->lastLogin = time();
$this->config->setUserValue(
$this->uid, 'login', 'lastLogin', $this->lastLogin);
* @return bool
*/
public function isEnabled() {
- return $this->enabled;
+ if ($this->enabled === null) {
+ $enabled = $this->config->getUserValue($this->uid, 'core', 'enabled', 'true');
+ $this->enabled = $enabled === 'true';
+ }
+ return (bool) $this->enabled;
}
/**