_record = $record; } public function getDbRecord() { if (!$this->_record) { $this->_record = User::finder()->findByLogin($this->Name); } return $this->_record; } public function createUser($username) { $dbUser = User::finder()->findByLogin($username); if (!$dbUser) { return NULL; } $user = new DbUser($this->Manager); $user->setDbRecord($dbUser); $user->Name = $dbUser->Login; if ($dbUser->IsAdmin) { $user->Roles = 'Admin'; } $user->IsGuest = FALSE; return $user; } public function validateUser($login, $password) { $user = User::finder()->findByLogin($login); $dbPassword = $user ? $user->Password : ''; if (UserFacade::getInstance()->verifyPassword($password, $dbPassword) && $user) { $user->LastLogin = date('Y-m-d H:i:s'); $user->save(); return TRUE; } else { return FALSE; } } public function __call($name, $args) { $match = []; if (preg_match('/^getIs(.+)$/', $name, $match)) { return $this->isInRole($match[1]); } throw new Exception('Unimplemented CustomDbUser method'); } } ?>