Returns 404 Not Found if :user is not following :target. Returns a follow object otherwise.

@param $user
@param $channel

@return mixed
762218
public function userFollowsChannel($user, $channel)
    {
        $response = $this->client->get('kraken/users/' . $user . '/follows/channels/' . $channel);

        return $response->json();
    }
1251388
public function ban(User $user)
    {
        $user->is_blocked = ! $user->is_blocked;
        $user->save();

        if ($user->is_blocked) {
            return $this->notifySuccess('User ' . $user->name . ' blocked!');
        } else {
            return $this->notifySuccess('User ' . $user->name . ' un-blocked!');
        }
    }
92448
public function check($user)
	{
		// Build the request path.
		$path = '/user/following/' . $user;

		$response = $this->client->get($this->fetchUrl($path));

		switch ($response->code)
		{
			case '204' :
				// You are following this user
				return true;
				break;

			case '404' :
				// You are not following this user
				return false;
				break;

			default :
				throw new \UnexpectedValueException('Unexpected response code: ' . $response->code);
				break;
		}
	}
385792
public function userSubscriptionChannel($channel, $user, $token = null)
    {
        return $this->sendRequest('GET', 'users/'.$user.'/subscriptions/'.$channel, $this->getToken($token));
    }
1008408
protected function tryChangeUser($user)
    {
        $changed_user = false;
        // Check user can be changed?
        if ($user && posix_getuid() > 0) {
            // Not root
            throw new \RuntimeException('Only root can change user to spawn the process');
        }

        // Check user if exists?
        if ($user && !($changed_user = posix_getpwnam($user))) {
            throw new \RuntimeException('Can not look up user: ' . $user);
        }

        return $changed_user;
    }
102876
public function userCreate($user)
    {
        $this->dispatchHooks('BeforeUserCreateScope', $user);
        $this->parseEntityFields('user', $user);
        $this->getDriver()->userCreate($user);
        $this->dispatchHooks('AfterUserCreateScope', $user);
        $this->userManager->addUser($user);
        return $user;
    }
891677
public function findGuidedPortfolios(User $user, $executeQuery = true)
    {
        $queryBuilder = $this->createQueryBuilder('p')
            ->join('p.portfolioGuides', 'guides')
            ->andWhere('guides.user = :guide')
            ->setParameter('guide', $user)
        ;

        return $executeQuery ? $queryBuilder->getQuery()->getResult() : $queryBuilder->getQuery();
    }
644680
function getAbsDir($user)
    {
        if (!$this->users[$user]['chroot'])
        {
            $rdir = $this->users[$user]['pwd'];
        }
        else
        {
            $rdir = $this->users[$user]['home'].$this->users[$user]['pwd'];
        }
        return $rdir;
    }
727845
public function hasGuide(User $user)
    {
        $isGuide = false;

        foreach ($this->getPortfolioGuides() as $portfolioGuide) {
            if ($user->getId() === $portfolioGuide->getUser()->getId()) {
                $isGuide = true;
                break;
            }
        }

        return $isGuide;
    }
210240
public function awaitContentHeader($channel)
    {
        if ($this instanceof Async\Client) {
            $deferred = new Deferred();
            $this->addAwaitCallback(function ($frame) use ($deferred, $channel) {
                if ($frame instanceof Protocol\ContentHeaderFrame && $frame->channel === $channel) {
                    $deferred->resolve($frame);
                    return true;
                } elseif ($frame instanceof Protocol\MethodChannelCloseFrame && $frame->channel === $channel) {
                    $this->channelCloseOk($channel)->done(function () use ($frame, $deferred) {
                        $deferred->reject(new ClientException($frame->replyText, $frame->replyCode));
                    });
                    return true;
                } elseif ($frame instanceof Protocol\MethodConnectionCloseFrame) {
                    $this->connectionCloseOk()->done(function () use ($frame, $deferred) {
                        $deferred->reject(new ClientException($frame->replyText, $frame->replyCode));
                    });
                    return true;
                }
                return false;
            });
            return $deferred->promise();
        } else {
            for (;;) {
                while (($frame = $this->getReader()->consumeFrame($this->getReadBuffer())) === null) {
                    $this->feedReadBuffer();
                }
                if ($frame instanceof Protocol\ContentHeaderFrame && $frame->channel === $channel) {
                    return $frame;
                } elseif ($frame instanceof Protocol\MethodChannelCloseFrame && $frame->channel === $channel) {
                    $this->channelCloseOk($channel);
                    throw new ClientException($frame->replyText, $frame->replyCode);
                } elseif ($frame instanceof Protocol\MethodConnectionCloseFrame) {
                    $this->connectionCloseOk();
                    throw new ClientException($frame->replyText, $frame->replyCode);
                } else {
                    $this->enqueue($frame);
                }
            }
        }
        throw new \LogicException('This statement should be never reached.');
    }
26968
protected function verifyUserCanAccessChannel($request, $channel)
    {
        foreach ($this->channels as $pattern => $callback) {
            if (! Str::is(preg_replace('/\{(.*?)\}/', '*', $pattern), $channel)) {
                continue;
            }

            $parameters = $this->extractAuthParameters($pattern, $channel, $callback);

            if ($result = $callback($request->user(), ...$parameters)) {
                return $this->validAuthenticationResponse($request, $result);
            }
        }

        throw new AccessDeniedHttpException;
    }
476560
public function create(User $user)
    {
        /* handle encode */
        $user = $this->encode($user);

        $this->getEm()->persist($user);
        $this->getEm()->flush();

        return $user;
    }
276118
public function getPublisher(User $user)
    {
        foreach ($this->getPublishers() as $publisher) {
            if ($publisher->getUser()->getId() == $user->getId()) {
                return $publisher;
            }
        }

        return null;
    }
188256
protected function sendReactivationEmail(User $user)
    {
        $forum = Podium::getInstance()->podiumConfig->get('name');
        $email = Content::fill(Content::EMAIL_REACTIVATION);
        if ($email !== false) {
            $link = Url::to(['account/activate', 'token' => $user->activation_token], true);
            return Email::queue(
                $user->email,
                str_replace('{forum}', $forum, $email->topic),
                str_replace('{forum}', $forum, str_replace('{link}',
                    Html::a($link, $link), $email->content)),
                !empty($user->id) ? $user->id : null
            );
        }
        return false;
    }
662645
public function channelSubscriptionsUser($channel, $user, $token = null)
    {
        $token = $this->getToken($token);
        $url = 'https://api.twitch.tv/kraken/channels/' . $channel . '/subscriptions/' . $user;

        $request = $this->createRequest('GET', $url, $token);

        $response = $this->client->send($request);

        return $response->json();
    }
330996
protected function getUserLink(User $user = null)
    {
        if (!$user) {
            return '<strong>' . t('Deleted User') . '</strong>';
        }

        $link = $this->getUrlResolver()->resolve(['/dashboard/users/search', $user->getUserID()]);
        $name = h($user->getUserName());
        return "<a href='$link'><strong>$name</strong></a>";
    }
202372
protected function _getCurrentUser($user = null)
    {
        $this->_setCurrentUser($user);

        if (!$this->_currentUserInstance &&
            isset($this->_currentUserViewVar) &&
            !empty($this->viewVars[$this->_currentUserViewVar])
        ) {
            $this->_currentUserInstance = $this->viewVars[$this->_currentUserViewVar];
        }

        return $this->_currentUserInstance;
    }