@param string            $user
@param DatabaseInterface $database

@return string
554013
private function formQueryPartForUserName($user, DatabaseInterface $database): string
    {
        $condition = 'oxuser.oxusername = ' . $database->quote($user);

        return $condition;
    }
836517
public function deleteUser($user)
    {

        $sql = sprintf("DELETE FROM {$this->dbTableNamePrefix}" . DataConnector::USER_RESULT_TABLE_NAME . ' ' .
                       'WHERE (user_pk = %d)',
                       $user->getRecordId());
        $ok = mysql_query($sql);

        if ($ok) {
            $user->initialize();
        }

        return $ok;

    }
883260
public function encode(CredentialsHolderInterface $user): string
    {
        return $this->encodePassword($user->getPlainPassword(), $user->getSalt());
    }
1105301
public function getResourceUserPermission(ResourceInterface $resource, UserInterface $user)
    {
        $query = $this->getRepository()->createQueryBuilder('r')
            ->select('r')
            ->where('r.resource_class = :resourceClass AND r.resource_id=:resourceId AND r.user=:user')
            ->setParameter('resourceClass', $resource->getClass())
            ->setParameter('resourceId', $resource->getId())
            ->setParameter('user', $user)
            ->getQuery();

        return $query->getOneOrNullResult();
    }
850730
public function setDatabase(SqlInterface $database)
    {
        $this->database = $database;

        //for each row
        foreach ($this->data as $row) {
            if (!is_object($row) || !method_exists($row, __FUNCTION__)) {
                continue;
            }

            //let the row handle this
            $row->setDatabase($database);
        }

        return $this;
    }
893686
public function connect($server,$user,$password,$database){
		if(empty($this->database_info['server']) || $this->database_info['server']==''){
			$this->database_info['server'] = $server;
		}
		if(empty($this->database_info['user']) || $this->database_info['user']==''){
			$this->database_info['user'] = $user;
		}
		if(empty($this->database_info['pass']) || $this->database_info['pass']==''){
			$this->database_info['pass'] = $password;
		}
		if(empty($this->database_info['database']) || $this->database_info['database']==''){
			$this->database_info['database'] = $database;
		}

		mysql_connect(
		$this->database_info['server'],
		$this->database_info['user'],
		$this->database_info['pass']
		);
		@mysql_select_db($this->database_info['database']) or die("Unable to connect to ".$this->database_info['database']." database.");
	}
959946
public function getCoins(UserInterface $user)
    {
        $accEntityManager = $this->getAccountEntityManager();
        $repository = $accEntityManager->getRepository($this->getGameOptions()->getEntityAccountSkSilk());

        $coins = 0;

        /** @var \GameBackend\Entity\SRO\Account\SkSilk $skSilk */
        $skSilk = $repository->findOneBy(['jid' => $user->getBackendId()]);
        if ($skSilk) {
            $coins = $skSilk->getSilkOwn();
        }

        return $coins;
    }
563682
private function generateTokenForUser(UserInterface $user)
    {
        // if a token was already requested within the request interval time frame
        if (null !== $user->getPasswordResetToken()
            && $this->dateIsInRequestFrame($user->getPasswordResetTokenExpiresAt())) {
            throw new TokenAlreadyRequestedException(self::getRequestInterval());
        }
        $em = $this->getDoctrine()->getManager();

        $user->setPasswordResetToken($this->getToken());
        $expireDateTime = (new \DateTime())->add(self::getResetInterval());
        $user->setPasswordResetTokenExpiresAt($expireDateTime);
        $user->setPasswordResetTokenEmailsSent(0);

        $em->persist($user);
        $em->flush();
    }
473158
public function createToken(UserInterface $user, string $operator = null): TokenInterface
    {
        return $this->getOperator($operator ?? $this->config->defaultOperator())->createToken($user);
    }
655277
protected function getUserName(User $user): string
    {
        $contentInfo = $this->repository->sudo(
            function (Repository $repository) use ($user): ContentInfo {
                return $this->loadService->loadContent($user->id)->contentInfo;
            }
        );

        return $contentInfo->name;
    }
1369074
protected function getUserId(UserInterface $user)
    {
        $class = $this->container->getParameter('tree_house.keystone.model.user.class');
        $meta = $this->getDoctrine()->getManagerForClass($class)->getClassMetadata($class);

        $ids = $meta->getIdentifierValues($user);
        if (sizeof($ids) === 1) {
            return current($ids);
        }

        return $ids;
    }
675648
public function format($user)
    {
        $id = null;
        $name = '';
        $userInfo = null;
        if (isset($user) && $user) {
            if (is_int($user) || (is_string($user) && is_numeric($user))) {
                $user = \User::getByUserID($user);
            }
            try {
                if ($user instanceof ConcreteUser && $user->getUserID() && $user->isRegistered()) {
                    $id = (int) $user->getUserID();
                    $name = $user->getUserName();
                } elseif ($user instanceof UserInfo && $user->getUserID()) {
                    $id = (int) $user->getUserID();
                    $name = $user->getUserName();
                    $userInfo = $user;
                } elseif ($user instanceof ConcreteUserEntity && $user->getUserID()) {
                    $id = (int) $user->getUserID();
                    $name = $user->getUserName();
                }
            } catch (EntityNotFoundException $x) {
                $id = null;
            }
        }
        if ($id === null) {
            $result = '<i class="comtra-user comtra-user-removed">' . t('removed user') . '</i>';
        } elseif ($id == USER_SUPER_ID) {
            $result = '<i class="comtra-user comtra-user-system">' . t('system') . '</i>';
        } else {
            $profileURL = null;
            if ($userInfo === null) {
                $userInfo = $this->app->make(UserInfoRepository::class)->getByID($id);
            }
            if ($userInfo !== null) {
                $profileURL = $userInfo->getUserPublicProfileUrl();
            }
            if ($profileURL === null) {
                $result = '<span';
            } else {
                $result = '<a href="' . h((string) $profileURL) . '"';
            }
            $result .= ' class="comtra-user comtra-user-found">' . h($name);
            if ($profileURL === null) {
                $result .= '</span>';
            } else {
                $result .= '</a>';
            }
        }

        return $result;
    }
602755
public function completed(UserInterface $user)
    {
        $queryBuilder = $this->createQueryBuilder('a');

        $queryBuilder
            ->where('a.user = :user')
            ->andWhere('a.completed = :completed');

        $queryBuilder
            ->setParameters([
                'user' => $user,
                'completed' => true
            ]);

        try
        {
            return $queryBuilder->getQuery()->getSingleResult();
        }
        catch (NoResultException $e)
        {
            return false;
        }
    }
742039
protected function config($host, $database, $user, $password)
    {
        //if(Config::get("database.host")=="" && Config::get("database.username")=="" && Config::get("database.password")=="" && Config::get("database.database")=="") throw new DatabaseArgumentsException();
        return [
            'host'     => $this->setLocal($host ? $host : Config::get('database.host')),
            'database' => $database ? $database : Config::get('database.database'),
            'user'     => $user ? $user : Config::get('database.username'),
            'password' => $password ? $password : Config::get('database.password'),
        ];
    }
236328
public function getEntry4User(UserInterface $user)
    {
        $query = $this->createQueryBuilder('p')
            ->select('p')
            ->where('p.usn = :usn')
            ->setParameter('usn', $user->getBackendId())
            ->getQuery();

        $result = null;
        try {
            $result = $query->getOneOrNullResult();
        } catch (\Exception $e) {

        }

        return $result;
    }
63717
public function loadUser($user)
    {

        $ok = false;
        if (!empty($user->getRecordId())) {
            $sql = sprintf('SELECT user_pk, resource_link_pk, lti_user_id, lti_result_sourcedid, created, updated ' .
                           "FROM {$this->dbTableNamePrefix}" . DataConnector::USER_RESULT_TABLE_NAME . ' ' .
                           'WHERE (user_pk = %d)',
            $user->getRecordId());
        } else {
            $sql = sprintf('SELECT user_pk, resource_link_pk, lti_user_id, lti_result_sourcedid, created, updated ' .
                           "FROM {$this->dbTableNamePrefix}" . DataConnector::USER_RESULT_TABLE_NAME . ' ' .
                           'WHERE (resource_link_pk = %d) AND (lti_user_id = %s)',
                           $user->getResourceLink()->getRecordId(),
                           DataConnector::quoted($user->getId(ToolProvider\ToolProvider::ID_SCOPE_ID_ONLY)));
        }
        $rsUser = mysql_query($sql);
        if ($rsUser) {
            $row = mysql_fetch_object($rsUser);
            if ($row) {
                $user->setRecordId(intval($row->user_pk));
                $user->setResourceLinkId(intval($row->resource_link_pk));
                $user->ltiUserId = $row->lti_user_id;
                $user->ltiResultSourcedId = $row->lti_result_sourcedid;
                $user->created = strtotime($row->created);
                $user->updated = strtotime($row->updated);
                $ok = true;
            }
        }

        return $ok;

    }
428215
public function findDraft($user)
    {
        if ($user instanceof UserInterface) {
            $user = $user->getId();
        }

        return $this->findOneDraftBy(['user' => $user]);
    }