@param string $userEmail

@return \Google_Client
421407
private function createGoogleBatchClient(string $userEmail)
    {
        if (array_key_exists($userEmail, $this->googleBatchClients)) {
            return $this->googleBatchClients[$userEmail];
        }

        $googleClient = new \Google_Client();
        $googleClient->setScopes(static::SCOPES);
        $googleClient->setAuthConfig($this->configFileLocation);
        $googleClient->setSubject($userEmail);
        $googleClient->setUseBatch(true);

        $this->googleBatchClients[$userEmail] = $googleClient;

        return $googleClient;
    }
255834
protected function createRequest($client, $userId, $request, array $scopes)
    {
        return (new ServerRequest)->withParsedBody(
            ['grant_type' => 'password',
            'client_id' => $client->id,
            'client_secret' => $client->secret,
            'username' => $request->get('email'),
            'password' => $request->get('password'),
            'user_id' => $userId,
            'scope' => implode(' ', $scopes)]
        );
    }
610675
public function subscribe(string $email, string $name = '')
    {
        $userList = $this->filter(new IsUserEmail($email))->limit(1)->all();

        $user = $userList[0] ?? new User([
                'email'        => $email,
                'name'         => $name,
                'guid'         => Guid::Generate(),
                'isSubscriber' => 1,
            ]);

        if ((new IsUserSubscriber())->isSatisfiedBy($user)) {
            return null;
        }

        if ($user->id) {
            return $this->update($user->id, ['isSubscriber' => 1]);

        }

        return $this->create($user);
    }
538851
public function findUserByUsernameOrEmail($username, $email)
    {
        $dql = '
            SELECT u
            FROM Claroline\CoreBundle\Entity\User u
            WHERE u.username = :username
            OR u.email = :email
            AND u.isRemoved = false
        ';

        $query = $this->_em->createQuery($dql);
        $query->setParameter('username', $username);
        $query->setParameter('email', $email);

        return $query->getResult();
    }
228206
public static function invite(UserId $anId, UserEmail $anEmail, array $userRoles)
    {
        $user = new static($anId, $anEmail, $userRoles);
        $user->invitationToken = new UserToken();
        $user->publish(
            new UserInvited(
                $user->id(),
                $user->email(),
                $user->invitationToken()
            )
        );

        return $user;
    }
412852
protected function loadSyliusUser($userType, $email)
    {
        if (empty($email)) {
            return null;
        }

        /** @var \Sylius\Component\User\Repository\UserRepositoryInterface $userRepository */
        $userRepository = $this->getContainer()->get(
            sprintf('sylius.repository.%s_user', $userType)
        );

        return $userRepository->findOneByEmail($email);
    }
468841
public function getGoogleBatchServiceGmailForUserId(string $userId)
    {
        $email = $this->directory->resolvePrimaryEmailFromUserId($userId);
        if (array_key_exists($email, $this->googleBatchServiceGmails)) {
            return $this->googleBatchServiceGmails[$email];
        }

        $googleServiceGmail = new \Google_Service_Gmail($this->serviceAccount->getGoogleBatchClientForEmail($email));
        $this->googleBatchServiceGmails[$email] = $googleServiceGmail;

        return $googleServiceGmail;
    }
1288006
public function getUserByEmail($userEmail)
    {
        Piwik::checkUserHasSuperUserAccess();
        $this->checkUserEmailExists($userEmail);

        $user = $this->model->getUserByEmail($userEmail);

        $user = $this->userFilter->filterUser($user);
        $user = $this->enrichUser($user);

        return $user;
    }
1039007
protected function parseEmailClient($userAgent, $referer = null)
    {
        $result = array(
            'family' => 'Other',
            'major'  => null,
            'minor'  => null,
            'patch'  => null,
        );

        if (!isset($this->regexes['email_client_parsers'])) {
            return $result;
        }

        foreach ($this->regexes['email_client_parsers'] as $expression) {
            if (preg_match('/'.str_replace('/','\/',str_replace('\/','/', $expression['regex'])).'/i', $userAgent, $matches)) {
                if (!isset($matches[1])) { $matches[1] = 'Other'; }
                if (!isset($matches[2])) { $matches[2] = null; }
                if (!isset($matches[3])) { $matches[3] = null; }
                if (!isset($matches[4])) { $matches[4] = null; }
                if (!isset($matches[5])) { $matches[5] = null; }

                $result['family'] = isset($expression['family_replacement']) ? str_replace('$1', $matches[1], $expression['family_replacement']) : $matches[1];
                $result['major']  = isset($expression['major_replacement']) ? $expression['major_replacement'] : $matches[2];
                $result['minor']  = isset($expression['minor_replacement']) ? $expression['minor_replacement'] : $matches[3];
                $result['patch']  = isset($expression['patch_replacement']) ? $expression['patch_replacement'] : $matches[4];
                $result['type']   = isset($expression['type_replacement']) ? $expression['type_replacement'] : $matches[5];

                goto referer;
            }
        }

        referer:

        if ($result['family'] == 'Other' && null !== $referer) {
            foreach ($this->regexes['email_client_parsers'] as $emailClientRegexe) {
                if (preg_match('/'.str_replace('/','\/',str_replace('\/','/', $emailClientRegexe['regex'])).'/i', $referer, $emailClientRefererMatches)) {
                    if (!isset($emailClientRefererMatches[1])) { $emailClientRefererMatches[1] = 'Other'; }
                    if (!isset($emailClientRefererMatches[2])) { $emailClientRefererMatches[2] = null; }

                    $result['family'] = isset($emailClientRegexe['family_replacement']) ? str_replace('$1', $emailClientRefererMatches[1], $emailClientRegexe['family_replacement']) : $emailClientRefererMatches[1];
                    $result['type']   = isset($emailClientRegexe['type_replacement']) ? $emailClientRegexe['type_replacement'] : $emailClientRefererMatches[2];

                    return $result;
                }
            }
        }

        return $result;
    }
355344
public function getUser($email)
    {
        $user = $this->userMapper->findByEmail($email);

        if (!$user) {
            return false;
        }

        return $user;
    }
733053
public function convertInviteEmails($email, $user_id)
	{
		// @FIXME: Should wrap this up in a nice transaction to handle partial failures and
		// race conditions.

		if (empty($email) || empty($user_id))
		{
			return false;
		}

		$db = \App::get('db');

		$sql = 'SELECT gidNumber FROM `#__xgroups_inviteemails` WHERE email=' . $db->quote($email) . ';';

		$db->setQuery($sql);

		$result = $db->loadColumn();

		if ($result === false)
		{
			return false;
		}

		if (empty($result))
		{
			return true;
		}

		foreach ($result as $r)
		{
			$values .= "($r,$user_id),";
			$gids   .= "$r,";
		}

		$values = rtrim($values, ',');
		$gids = rtrim($gids, ',');

		$sql = 'INSERT INTO `#__xgroups_invitees` (gidNumber,uidNumber) VALUES ' . $values . ';';

		$db->setQuery($sql);

		$result = $db->query();

		if (!$result)
		{
			return false;
		}

		$sql = 'DELETE FROM `#__xgroups_inviteemails` WHERE email=' . $db->quote($email) . ' AND gidNumber IN (' . $gids . ');';

		$db->setQuery($sql);

		$result = $db->query();

		if (!$result)
		{
			return false;
		}

		return true;
	}
449315
public function getUserByEMail(string $email)
    {
        $retval = null;

        if (strlen($email) > 0) {
            $nb_user = CNabuUser::findByEMail($this, $email);
            if ($nb_user instanceof CNabuUser && $nb_user->validateCustomer($this)) {
                $nb_user->setCustomer($this);
                $retval = $nb_user;
            }
        }

        return $retval;
    }
323927
public function trash(string $userId, string $emailId): ?\Google_Service_Gmail_Message
    {
        if ($this->get($userId, $emailId)) {
            return null;
        }

        return $this->googleServices->getGoogleServiceGmailForUserId($userId)->users_messages->trash($userId, $emailId);
    }
1091015
public function getUserLoginFromUserEmail($userEmail)
    {
        Piwik::checkUserIsNotAnonymous();
        Piwik::checkUserHasSomeAdminAccess();

        $this->checkUserEmailExists($userEmail);

        $user = $this->model->getUserByEmail($userEmail);

        // any user with some admin access is allowed to find any user by email, no need to filter by access here

        return $user['login'];
    }
1127564
public function getGoogleServiceGmailForUserId(string $userId)
    {
        $email = $this->directory->resolvePrimaryEmailFromUserId($userId);
        if (array_key_exists($email, $this->googleServiceGmails)) {
            return $this->googleServiceGmails[$email];
        }

        $googleServiceGmail = new \Google_Service_Gmail($this->serviceAccount->getGoogleClientForEmail($email));
        $this->googleServiceGmails[$email] = $googleServiceGmail;

        return $googleServiceGmail;
    }
207591
public function setEmail($email): User
    {
        if ($this->email !== $email) {
            $this->email = $email;

            DB::table('user')
                ->where('user_id', '=', $this->user_id)
                ->update([
                    'email' => $email,
                ]);
        }

        return $this;
    }
868308
public static function setClient($input=null)
    {
        // New or encapsulate
        self::$client = ($input instanceof Google_client) ? $input : new Google_Client();

        // While new and there has the config
        if (is_array($input)) {
            
            foreach ($input as $key => $value) {
                // ex. 'authConfig' => setAuthConfig()
                $method = "set" . ucfirst($key);
                // Config method check
                if (!method_exists(self::$client, $method)) {
                    throw new Exception("setClient() Config Key: `{$key}` is invalid referred to Google_Client->{$method}()", 500);
                }
                // Call set method by Google_Client
                call_user_func([self::$client, $method], $value);
            }
        }

        return new self;
    }